diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2023-12-06 22:55:48 +1100 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2023-12-07 23:34:38 +1100 |
commit | 402928b58ec62b42b11992a7b51ff2f56ed65a18 (patch) | |
tree | ae72d9cdf7a074f81e639be49b215bc24325602f /arch/powerpc/Makefile | |
parent | 22f17b02f88b48c01d3ac38d40d2b0b695ab2d10 (diff) | |
download | lwn-402928b58ec62b42b11992a7b51ff2f56ed65a18.tar.gz lwn-402928b58ec62b42b11992a7b51ff2f56ed65a18.zip |
powerpc/Makefile: Auto detect cross compiler
If no cross compiler is specified, try to auto detect one.
Look for various combinations, matching:
powerpc(64(le)?)?(-unknown)?-linux(-gnu)?-
There are more possibilities, but the above is known to find a compiler
on Fedora and Ubuntu (which use linux-gnu-), and also detects the
kernel.org cross compilers (which use linux-).
This allows cross compiling with simply:
# Ubuntu
$ sudo apt install gcc-powerpc-linux-gnu
# Fedora
$ sudo dnf install gcc-powerpc64-linux-gnu
$ make ARCH=powerpc defconfig
$ make ARCH=powerpc -j 4
Inspired by arch/parisc/Makefile.
Acked-by: Segher Boessenkool <segher@kernel.crashing.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231206115548.1466874-4-mpe@ellerman.id.au
Diffstat (limited to 'arch/powerpc/Makefile')
-rw-r--r-- | arch/powerpc/Makefile | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 48c06f5a0dc1..051247027da0 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -10,6 +10,17 @@ # Rewritten by Cort Dougan and Paul Mackerras # +ifdef cross_compiling + ifeq ($(CROSS_COMPILE),) + # Auto detect cross compiler prefix. + # Look for: (powerpc(64(le)?)?)(-unknown)?-linux(-gnu)?- + CC_ARCHES := powerpc powerpc64 powerpc64le + CC_SUFFIXES := linux linux-gnu unknown-linux-gnu + CROSS_COMPILE := $(call cc-cross-prefix, $(foreach a,$(CC_ARCHES), \ + $(foreach s,$(CC_SUFFIXES),$(a)-$(s)-))) + endif +endif + HAS_BIARCH := $(call cc-option-yn, -m32) # Set default 32 bits cross compilers for vdso and boot wrapper |