Afaik,在gcc中,您可以设置-m32
标志以使其将linux源编译为32位可执行文件。我对Makefile没有广泛的了解,但是您可以对其进行调整。
编辑:
我想在这里从stackoverflow添加一个问题,其中告诉它设置cflags:
export CFLAGS=-m32
在Torvalds的github帐户中的linux存储库中,我发现主makefile的以下部分可能对您有用,因为它告诉您可以通过设置环境变量来设置目标体系结构。阅读注释,当前,这些行来自此文件,介于174-196行之间:
# Cross compiling and selecting different set of gcc/bin-utils
# ---------------------------------------------------------------------------
#
# When performing cross compilation for other architectures ARCH shall be set
# to the target architecture. (See arch/* for the possibilities).
# ARCH can be set during invocation of make:
# make ARCH=ia64
# Another way is to have ARCH set in the environment.
# The default ARCH is the host where make is executed.
# CROSS_COMPILE specify the prefix used for all executables used
# during compilation. Only gcc and related bin-utils executables
# are prefixed with $(CROSS_COMPILE).
# CROSS_COMPILE can be set on the command line
# make CROSS_COMPILE=ia64-linux-
# Alternatively CROSS_COMPILE can be set in the environment.
# A third alternative is to store a setting in .config so that plain
# "make" in the configured kernel build directory always uses that.
# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
export KBUILD_BUILDHOST := $(SUBARCH)
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
# ...
# There are more architecture related stuff beyond this line