Skip to content

Commit

Permalink
powerpc/Makefile: Auto detect cross compiler
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Michael Ellerman committed Dec 7, 2023
1 parent 22f17b0 commit 402928b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions arch/powerpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 402928b

Please sign in to comment.