kconfig CROSS_COMPILE option
PATCH 1/1 kconfig CROSS_COMPILE option
This adds CROSS_COMPILE as a kconfig string so you can store it in .config. Then you can use plain "make" in the configured kernel build directory to do the right cross compilation without setting the command-line or environment variable every time.
With this, you can set up different build directories for different kernel configurations, whether native or cross-builds, and then use the simple:
make -C /build/dir M=module-source-dir
idiom to build modules for any given target kernel, indicating which one by nothing but the build directory chosen.
I tried a version that defaults the string with env="CROSS_COMPILE" so that in a "make oldconfig" with CROSS_COMPILE in the environment you can just hit return to store the way you're building it. But the kconfig prompt for strings doesn't give you any way to say you want an empty string instead of the default, so I punted that.
--- Makefile | 4 +++- init/Kconfig | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletions(-)
Makefile +3 -1
@@ -177,11 +177,13 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ # 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 ?= +CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) # Architecture as present in compile.h UTS_MACHINE := $(ARCH)
init/Kconfig +8 -0
@@ -76,6 +76,14 @@ config INIT_ENV_ARG_LIMIT variables passed to init from the kernel command line. +config CROSS_COMPILE + string "Cross-compiler tool prefix" + help + Same as running 'make CROSS_COMPILE=prefix-' but stored for + default make runs in this kernel build directory. You don't + need to set this unless you want the configured kernel build + directory to select the cross-compiler automatically. + config LOCALVERSION string "Local version - append to kernel release" help
Hi!
Quoted 11 lines
This adds
CROSS_COMPILEas a kconfig string so you can store it in .config. Then you can use plain "make" in the configured kernel build directory to do the right cross compilation without setting the command-line or environment variable every time.With this, you can set up different build directories for different kernel configurations, whether native or cross-builds, and then use the simple:
make -C /build/dir M=module-source-dir
idiom to build modules for any given target kernel, indicating which one by nothing but the build directory chosen.
Quoted 5 lines
I tried a version that defaults the string with env="CROSS_COMPILE" so that in a "make oldconfig" with
CROSS_COMPILEin the environment you can just hit return to store the way you're building it. But the kconfig prompt for strings doesn't give you any way to say you want an empty string instead of the default, so I punted that.
Yes that would be very nice. Editing Makefile every time I crosscomppile for arm sucks.
But... do we need an option for subarch, too? And will Kconfig system handle that?
Pavel
Quoted 14 lines
# Alternatively
CROSS_COMPILEcan be set in the environment.Makefile +3
-1+# 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 ?= +CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%) # Architecture as present in compile.h UTS_MACHINE := $(ARCH)init/Kconfig +0
-0
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 2 lines
Yes that would be very nice. Editing
Makefileevery time I crosscomppile for arm sucks.
The other trick I can recommend is to write a GNUmakefile containing:
ARCH=foo
CROSS_COMPILE=foo-linux-
include Makefile
(GNU make reads GNUmakefile in preference to Makefile.)
But this manual hackery is still not nearly as nice as the automagic way.
Quoted 2 lines
But... do we need an option for subarch, too? And will
Kconfigsystem handle that?
I'm not sure I follow exactly what your concern is. I am mostly familiar with doing x86 and powerpc builds. For both of those, the kernel config sets whether it's the 32-bit or 64-bit world.
Thanks,
Roland
Quoted 8 lines · Roland McGrath
Quoted 2 lines
Yes that would be very nice. Editing
Makefileevery time I crosscomppile for arm sucks.The other trick I can recommend is to write a GNUmakefile containing:
ARCH=foo
CROSS_COMPILE=foo-linux-
includeMakefile
Hehe, thanks.
Quoted 9 lines
(GNU make reads GNUmakefile in preference to
Makefile.)
But this manual hackery is still not nearly as nice as the automagic way.Quoted 2 lines
But... do we need an option for subarch, too? And will
Kconfigsystem handle that?I'm not sure I follow exactly what your concern is. I am mostly familiar with doing x86 and powerpc builds. For both of those, the kernel config sets whether it's the 32-bit or 64-bit world.
Well, my concern is that your patch allows me to set $CROSS_COMPILE, but I need to set $ARCH too, to get useful result. So I can't actually see how to use your patch.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 8 lines · Roland McGrath
Quoted 2 lines
Yes that would be very nice. Editing
Makefileevery time I crosscomppile for arm sucks.The other trick I can recommend is to write a GNUmakefile containing:
ARCH=foo
CROSS_COMPILE=foo-linux-
includeMakefile
Woow, that's shorter than mine :-)
--------------------------------------------------------------------------------
MAKEARGS = ARCH=powerpc CROSS_COMPILE=ppu- CC="ppu-gcc43 -m32 -mcpu=440"
MAKEFLAGS += --no-print-directory
.PHONY: all $(MAKECMDGOALS)
all := $(filter-out all Makefile,$(MAKECMDGOALS))
all:
$(MAKE) $(MAKEARGS) $(all) -f Makefile
Makefile:;
$(all) %/: all
@:
--------------------------------------------------------------------------------
Note that in this example I also have to override CC, as (1) ppu-gcc is gcc version 4.1.1, i.e. too old and (2) ppu-gcc43 defaults to -m64 and -mcpu=cell.
Quoted 2 lines
(GNU make reads GNUmakefile in preference to
Makefile.)
But this manual hackery is still not nearly as nice as the automagic way.
Indeed, putting everything in .config would be more convenient.
With kind regards,
Geert Uytterhoeven
Software Architect
Techsoft Centre
Technology and Software Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium
Phone: +32 (0)2 700 8453 Fax: +32 (0)2 700 8622 E-mail: [email protected] Internet: http://www.sony-europe.com/
A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis · BIC GEBABEBB · IBAN BE41293037680010