Makefile: Improve auto-detection of ARM cross compiler

Try an 'educated guess' for a suitable toolchain if no explicit
CROSS_COMPILE was set (but still default to "arm-none-eabi-").

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
This commit is contained in:
Bernhard Nortmann 2017-01-26 00:35:36 +01:00
parent e125a9da47
commit ce583ece03
2 changed files with 8 additions and 4 deletions

View File

@ -52,9 +52,12 @@ MISC_TOOLS = phoenix_info sunxi-nand-image-builder
# Note: To use this target, set/adjust CROSS_COMPILE and MKSUNXIBOOT if needed
BINFILES = jtag-loop.sunxi fel-sdboot.sunxi uart0-helloworld-sdboot.sunxi
CROSS_COMPILE ?= arm-none-eabi-
CROSS_CC ?= $(CROSS_COMPILE)gcc
MKSUNXIBOOT ?= mksunxiboot
PATH_DIRS := $(shell echo $$PATH | sed -e 's/:/ /g')
# Try to guess a suitable default ARM cross toolchain
CROSS_DEFAULT := arm-none-eabi-
CROSS_COMPILE ?= $(or $(shell find $(PATH_DIRS) -executable -name 'arm*-gcc' -printf '%f\t' | cut -f 1 | sed -e 's/-gcc/-/'),$(CROSS_DEFAULT))
CROSS_CC ?= $(CROSS_COMPILE)gcc
DESTDIR ?=
PREFIX ?= /usr/local

View File

@ -112,8 +112,9 @@ and our default target (when simply using `make`).
* `make target-tools`
builds tools that are intended for the target (Allwinner SoC), using a
cross-compiler. The toolchain prefix *CROSS_COMPILE* defaults to `arm-none-eabi-`,
adjust it if needed.
cross-compiler. The Makefile will try to auto-detect a suitable toolchain
prefix, and falls back to `arm-none-eabi-` otherwise.
If needed, you may override this by explicitly setting *CROSS_COMPILE*.
<br>_Hint:_ When compiling 'natively' on the target platform you may
simply use an empty toolchain prefix here (`make target-tools CROSS_COMPILE=`
or `make all CROSS_COMPILE=`).