From 98092929fca2033abb7e47a301cb4e8e0d439194 Mon Sep 17 00:00:00 2001 From: midipix Date: Nov 23 2017 20:43:28 +0000 Subject: build system: added --cchost support. --- diff --git a/Makefile.in b/Makefile.in index bae3699..b825744 100644 --- a/Makefile.in +++ b/Makefile.in @@ -8,6 +8,7 @@ AVOID_VERSION = @avoid_version@ BUILD = @build@ HOST = @host@ +CCHOST = @cchost@ TARGET = @target@ ARCH = @arch@ COMPILER = @compiler@ @@ -231,6 +232,9 @@ dirs.tag: mkdir -p lib touch dirs.tag +cchost: + $(PROJECT_DIR)/sysinfo/host/host.sh --compiler="$(CC)" --cflags="$(CFLAGS)" + host.tag: Makefile $(PROJECT_DIR)/sysinfo/host/host.sh --compiler="$(CC)" --cflags="$(CFLAGS)" touch host.tag @@ -283,6 +287,7 @@ clean: clean-implib .display-env: @echo BUILD:' '$(BUILD) @echo HOST:' '$(HOST) + @echo CCHOST:' '$(CCHOST) @echo TARGET:' '$(TARGET) @echo ARCH:' '$(ARCH) @echo COMPILER:' '$(COMPILER) @@ -409,8 +414,8 @@ clean: clean-implib @echo $(CFLAGS) -.PHONY: all install shared static app \ - package-app \ +.PHONY: cchost package-app \ + all install shared static app \ shared-objs shared-lib \ shared-soname shared-solink \ package-shared-soname package-shared-solink \ diff --git a/config.project b/config.project index cd8e822..969857e 100644 --- a/config.project +++ b/config.project @@ -8,6 +8,7 @@ mb_avoid_version=no # build mb_default_build= mb_default_host= +mb_default_cchost= mb_default_target= mb_default_arch= mb_default_compiler= diff --git a/config.usage b/config.usage index ffc327c..d93852d 100644 --- a/config.usage +++ b/config.usage @@ -34,6 +34,7 @@ supported switches: --build --host + --cchost --target --arch --compiler @@ -94,6 +95,7 @@ supported variables: BUILD HOST + CCHOST TARGET ARCH COMPILER diff --git a/configure b/configure index dbe5e08..c7bb6ff 100755 --- a/configure +++ b/configure @@ -66,6 +66,7 @@ init_vars() # build mb_build=$BUILD mb_host=$HOST + mb_cchost=$CCHOST mb_target=$TARGET mb_arch=$ARCH mb_compiler=$COMPILER @@ -198,6 +199,7 @@ common_defaults() # build [ -z "$mb_build" ] && mb_build=$mb_default_build [ -z "$mb_host" ] && mb_host=$mb_default_host + [ -z "$mb_cchost" ] && mb_cchost=$mb_default_cchost [ -z "$mb_target" ] && mb_target=$mb_default_target [ -z "$mb_arch" ] && mb_arch=$mb_default_arch [ -z "$mb_compiler" ] && mb_compiler=$mb_default_compiler @@ -514,7 +516,21 @@ config_copy() -e 's^@disable_frontend@^'"$mb_disable_frontend"'^g' \ -e 's^@disable_static@^'"$mb_disable_static"'^g' \ -e 's^@disable_shared@^'"$mb_disable_shared"'^g' \ - $mb_project_dir/Makefile.in > $mb_pwd/Makefile + $mb_project_dir/Makefile.in > $mb_pwd/Makefile.tmp || exit 2 + + if [ -z "$mb_cchost" ]; then + if [ "$mb_host" = 'native' ]; then + mb_cchost=`make -s -f $mb_pwd/Makefile.tmp cchost` + else + mb_cchost=$mb_host + fi + fi + + sed -e 's^@cchost@^'"$mb_cchost"'^g' $mb_pwd/Makefile.tmp \ + > $mb_pwd/Makefile.host || exit 2 + + rm $mb_pwd/Makefile.tmp || exit 2 + mv $mb_pwd/Makefile.host $mb_pwd/Makefile || exit 2 } @@ -645,6 +661,9 @@ for arg ; do --host=*) mb_host=${arg#*=} ;; + --cchost=*) + mb_cchost=${arg#*=} + ;; --target=*) mb_target=${arg#*=} ;; diff --git a/sysinfo/host/host.sh b/sysinfo/host/host.sh index b3975ae..686edca 100755 --- a/sysinfo/host/host.sh +++ b/sysinfo/host/host.sh @@ -15,7 +15,7 @@ host_test() exit 2 fi - $mb_compiler -dM -E - < /dev/null > /dev/null && return 0 + $mb_compiler $mb_cflags -dumpmachine && return 0 error_msg "config error: invalid compiler." exit 2