allow CROSS or MUSL_DIR to be set on the command line so that an external cross compiler can be used (issue #162)

This commit is contained in:
Trammell hudson 2018-03-16 12:59:24 -04:00
parent 114d17bab6
commit 7f30b22b82
No known key found for this signature in database
GPG Key ID: 687A5005935B1533
2 changed files with 35 additions and 6 deletions

View File

@ -73,15 +73,16 @@ $(shell mkdir -p "$(initrd_lib_dir)" "$(initrd_bin_dir)")
SHELL := /bin/bash SHELL := /bin/bash
.SHELLFLAGS := -o pipefail -c .SHELLFLAGS := -o pipefail -c
# If musl-libc is being used in the initrd, set the heads_cc # Include the musl-cross module early so that $(CROSS) will
# variable to point to it. # be defined prior to any other module.
include modules/musl-cross
musl_dep := musl musl_dep := musl
heads_cc := $(INSTALL)/bin/musl-gcc \ heads_cc := $(INSTALL)/bin/musl-gcc \
-fdebug-prefix-map=$(pwd)=heads \ -fdebug-prefix-map=$(pwd)=heads \
-gno-record-gcc-switches \ -gno-record-gcc-switches \
-D__MUSL__ \ -D__MUSL__ \
CROSS := $(build)/../crossgcc/x86_64-linux-musl/bin/x86_64-musl-linux-
CROSS_TOOLS_NOCC := \ CROSS_TOOLS_NOCC := \
AR="$(CROSS)ar" \ AR="$(CROSS)ar" \
LD="$(CROSS)ld" \ LD="$(CROSS)ld" \

View File

@ -1,14 +1,42 @@
modules-y += musl-cross ifeq "$(MUSL_CROSS_ONCE)" ""
MUSL_CROSS_ONCE := 1
# Allow the path to the musl-cross directory to be passed on
# the environment so that the full path doens't need to be spelled out
ifneq "$(MUSL_DIR)" ""
CROSS := $(MUSL_DIR)/crossgcc/x86_64-linux-musl/bin/x86_64-linux-musl-
endif
ifneq "$(CROSS)" ""
# check that $(CROSS)gcc exists or else things just won't work
ifneq "y" "$(shell [ -x '$(CROSS)gcc' ] && echo y)"
$(error $(CROSS)gcc does not exist - can not build
endif
# The cross compiler has already been built, so the musl-cross target
# is a NOP.
musl-cross.intermediate:
else
# Force a full build of the cross compiler
modules-y += musl-cross
musl-cross_version := git musl-cross_version := git
musl-cross_dir := musl-cross-$(musl-cross_version) musl-cross_dir := musl-cross-$(musl-cross_version)
musl-cross_repo := https://github.com/GregorR/musl-cross musl-cross_repo := https://github.com/GregorR/musl-cross
musl-cross_output := ../../crossgcc/x86_64-linux-musl/bin/x86_64-linux-musl-gcc
musl-cross_configure := \ musl-cross_configure := \
/bin/echo -e > Makefile \ /bin/echo -e > Makefile \
'$(musl-cross_output):\n\tCC_BASE_PREFIX="$(pwd)/crossgcc" ./build.sh' '$(musl-cross_output):\n\tCC_BASE_PREFIX="$(pwd)/crossgcc" ./build.sh'
CROSS := $(build)/../crossgcc/x86_64-linux-musl/bin/x86_64-musl-linux-
musl-cross_output := $(CROSS)gcc
endif
musl-cross_target := musl-cross_target :=
endif