diff --git a/Makefile b/Makefile index 6234742..4e95726 100644 --- a/Makefile +++ b/Makefile @@ -56,8 +56,8 @@ 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' 2>/dev/null | cut -f 1 | sed -e 's/-gcc/-/'),$(CROSS_DEFAULT)) -CROSS_CC ?= $(CROSS_COMPILE)gcc +CROSS_COMPILE ?= $(or $(shell ./find-arm-gcc.sh),$(CROSS_DEFAULT)) +CROSS_CC := $(CROSS_COMPILE)gcc DESTDIR ?= PREFIX ?= /usr/local diff --git a/find-arm-gcc.sh b/find-arm-gcc.sh new file mode 100755 index 0000000..ae7bf4b --- /dev/null +++ b/find-arm-gcc.sh @@ -0,0 +1,13 @@ +# +# Try to locate suitable ARM cross compilers available via $PATH +# If any are found, this function will output them as a TAB-delimited list +# +scan_path () { +IFS=":" +for path in $PATH; do + find "$path" -maxdepth 1 -executable -name 'arm*-gcc' -printf '%f\t' 2>/dev/null +done +} + +# Use only the first field from result, and convert it to a toolchain prefix +scan_path | cut -f 1 | sed -e 's/-gcc/-/' diff --git a/thunks/Makefile b/thunks/Makefile index 8161179..9ba6635 100644 --- a/thunks/Makefile +++ b/thunks/Makefile @@ -17,8 +17,7 @@ all: $(SPL_THUNK) $(THUNKS) FORCE: # If not specified explicitly: try to guess a suitable ARM toolchain prefix -PATH_DIRS := $(shell echo $$PATH | sed -e 's/:/ /g') -CROSS_COMPILE ?= $(shell find $(PATH_DIRS) -executable -name 'arm*-gcc' -printf '%f\t' | cut -f 1 | sed -e 's/-gcc/-/') +CROSS_COMPILE ?= $(shell ../find-arm-gcc.sh) AS := $(CROSS_COMPILE)as OBJDUMP := $(CROSS_COMPILE)objdump