Skip to contentSkip to conversation

out-of-tree builds: preserve ARCH and CROSS_COMPILE settings

PATCH New Ralph Siemsen 1 participant 1 message Feb 7, 2005 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 out-of-tree builds: preserve ARCH and CROSS_COMPILE settings

[I am not subscribed, please CC: any replies]

When you build the 2.6 kernel outside of its source directory, using the O= option like so:

	make -C linux-2.6.10 O=../builddir

this conveniently produces a top-level Makefile in "builddir" which can be used to update/clean/rebuild the tree with a simple "make". It also uses the ".config" file from "builddir", which makes it very convenient for managing multiple builds for different target systems.

However if you are cross-compiling, you must also set ARCH and CROSS_COMPILE variables as appropriate. Unfortunately these settings are not recorded in the generated Makefile in "builddir", so one cannot simply do "make" anymore.

The attached patch fixes the script that generates the Makefile, so as to pass ARCH and CROSS_COMPILE settings, only when they are defined. Otherwise behaviour is exactly as it was before.

Since the contents of "builddir" are specific to ARCH and CROSS_COMPILER I see no reason why the values should not become fixed in "builddir".

scripts/mkmakefile +4 -2
diff -u mkmakefile
@@ -9,6 +9,8 @@
 # $3 - version
 # $4 - patchlevel
 
+test "$ARCH" != "" && ARCH="ARCH=$ARCH"
+test "$CROSS_COMPILE" != "" && CROSS="CROSS_COMPILE=$CROSS_COMPILE"
 
 cat << EOF
 # Automatically generated by $0: don't edit
@@ -22,10 +24,10 @@
 MAKEFLAGS += --no-print-directory
 
 all:
-	\$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT)
+	\$(MAKE) $ARCH $CROSS -C \$(KERNELSRC) O=\$(KERNELOUTPUT)
 
 %::
-	\$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
+	\$(MAKE) $ARCH $CROSS -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
 
 EOF