From 3d6603e340d6d461832f0aa204b04343d34af3d4 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Wed, 29 Apr 2020 16:30:40 -0400 Subject: [PATCH 1/5] depends: Propagate well-known vars into depends For example, doing: make CC=clang CXX=clang++ Should now propagate these settings down to depends packages --- depends/hosts/default.mk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/depends/hosts/default.mk b/depends/hosts/default.mk index 144e5f88b78..258619a9d05 100644 --- a/depends/hosts/default.mk +++ b/depends/hosts/default.mk @@ -13,9 +13,18 @@ default_host_OTOOL = $(host_toolchain)otool default_host_NM = $(host_toolchain)nm define add_host_tool_func +ifneq ($(filter $(origin $1),undefined default),) +# Do not consider the well-known var $1 if it is undefined or is taking a value +# that is predefined by "make" (e.g. the make variable "CC" has a predefined +# value of "cc") $(host_os)_$1?=$$(default_host_$1) $(host_arch)_$(host_os)_$1?=$$($(host_os)_$1) $(host_arch)_$(host_os)_$(release_type)_$1?=$$($(host_os)_$1) +else +$(host_os)_$1=$(or $($1),$($(host_os)_$1),$(default_host_$1)) +$(host_arch)_$(host_os)_$1=$(or $($1),$($(host_arch)_$(host_os)_$1),$$($(host_os)_$1)) +$(host_arch)_$(host_os)_$(release_type)_$1=$(or $($1),$($(host_arch)_$(host_os)_$(release_type)_$1),$$($(host_os)_$1)) +endif host_$1=$$($(host_arch)_$(host_os)_$1) endef From 2d4e48081382a58033ed5c3734a4ad810b56a963 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Wed, 29 Apr 2020 16:32:20 -0400 Subject: [PATCH 2/5] depends: boost: Specify toolset to bootstrap.sh b2 will pickup our user-config.jam just fine, however, bootstrap.sh has its own toolset autodetect mechanism, which doesn't GAF about our user-config.jam --- depends/packages/boost.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 970c81041ea..6605c1c6ca5 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -33,7 +33,7 @@ define $(package)_preprocess_cmds endef define $(package)_config_cmds - ./bootstrap.sh --without-icu --with-libraries=$($(package)_config_libraries) + ./bootstrap.sh --without-icu --with-libraries=$($(package)_config_libraries) --with-toolset=$($(package)_toolset_$(host_os)) endef define $(package)_build_cmds From 1ce74bcde341bbab538937544a0e4b4abccdc050 Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Fri, 22 May 2020 17:00:53 -0400 Subject: [PATCH 3/5] depends: boost: Split target-os from toolset Previously, we specified the target-os in the toolset (and sometimes used the wrong command line flags), now we have a clear separation, which is favored by ./bootstrap.sh and ./b2. This means that all supported OSes will specify the correct target-os= and toolset= on the command line. --- depends/packages/boost.mk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 6605c1c6ca5..f7fd28c0ea2 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -9,9 +9,9 @@ $(package)_config_opts_release=variant=release $(package)_config_opts_debug=variant=debug $(package)_config_opts=--layout=tagged --build-type=complete --user-config=user-config.jam $(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1 -$(package)_config_opts_linux=threadapi=pthread runtime-link=shared -$(package)_config_opts_darwin=--toolset=clang-darwin runtime-link=shared -$(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static +$(package)_config_opts_linux=target-os=linux threadapi=pthread runtime-link=shared +$(package)_config_opts_darwin=target-os=darwin runtime-link=shared +$(package)_config_opts_mingw32=target-os=windows binary-format=pe threadapi=win32 runtime-link=static $(package)_config_opts_x86_64_mingw32=address-model=64 $(package)_config_opts_i686_mingw32=address-model=32 $(package)_config_opts_i686_linux=address-model=32 architecture=x86 @@ -20,8 +20,8 @@ $(package)_config_opts_aarch64_android=address-model=64 $(package)_config_opts_x86_64_android=address-model=64 $(package)_config_opts_armv7a_android=address-model=32 $(package)_toolset_$(host_os)=gcc +$(package)_toolset_darwin=clang $(package)_archiver_$(host_os)=$($(package)_ar) -$(package)_toolset_darwin=clang-darwin $(package)_config_libraries=filesystem,system,thread,test $(package)_cxxflags=-std=c++11 -fvisibility=hidden $(package)_cxxflags_linux=-fPIC @@ -37,9 +37,9 @@ define $(package)_config_cmds endef define $(package)_build_cmds - ./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) stage + ./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) toolset=$($(package)_toolset_$(host_os)) stage endef define $(package)_stage_cmds - ./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) install + ./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) toolset=$($(package)_toolset_$(host_os)) install endef From 0a33803f1c42c938cc7c6c5291ef1f9a1dfb491b Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Fri, 22 May 2020 17:03:46 -0400 Subject: [PATCH 4/5] depends: boost: Use clang toolset if clang in CXX --- depends/packages/boost.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index f7fd28c0ea2..3a7e605b4fa 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -21,6 +21,9 @@ $(package)_config_opts_x86_64_android=address-model=64 $(package)_config_opts_armv7a_android=address-model=32 $(package)_toolset_$(host_os)=gcc $(package)_toolset_darwin=clang +ifneq (,$(findstring clang,$($(package)_cxx))) + $(package)_toolset_$(host_os)=clang +endif $(package)_archiver_$(host_os)=$($(package)_ar) $(package)_config_libraries=filesystem,system,thread,test $(package)_cxxflags=-std=c++11 -fvisibility=hidden From f0d7ed10b48a6303d8b0cb6f2fc6b8652945bffb Mon Sep 17 00:00:00 2001 From: Carl Dong Date: Wed, 27 May 2020 17:03:46 -0400 Subject: [PATCH 5/5] depends: Propagate only specific CLI variables to sub-makes We want to supply well-known vars to ./configure scripts to do with as they please. However, we do _not_ want to override these well-known vars at make-time as certain build systems expect a self-mangled version of these well-known vars. For example, freetype and bdb will prepend `libtool --mode=compile' to CC and CXX, which, if we override CC on the command line at make-time, will break the build. --- depends/Makefile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/depends/Makefile b/depends/Makefile index 5ad82bb56a9..3d0784cb6b7 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -4,6 +4,30 @@ print-%: @echo $* = $($*) +# When invoking a sub-make, keep only the command line variable definitions +# matching the pattern in the filter function. +# +# e.g. invoking: +# $ make A=1 C=1 print-MAKEOVERRIDES print-MAKEFLAGS +# +# with the following in the Makefile: +# MAKEOVERRIDES := $(filter A=% B=%,$(MAKEOVERRIDES)) +# +# will print: +# MAKEOVERRIDES = A=1 +# MAKEFLAGS = -- A=1 +# +# this is because as the GNU make manual says: +# The command line variable definitions really appear in the variable +# MAKEOVERRIDES, and MAKEFLAGS contains a reference to this variable. +# +# and since the GNU make manual also says: +# variables defined on the command line are passed to the sub-make through +# MAKEFLAGS +# +# this means that sub-makes will be invoked as if: +# $(MAKE) A=1 blah blah +MAKEOVERRIDES := $(filter V=%,$(MAKEOVERRIDES)) SOURCES_PATH ?= $(BASEDIR)/sources WORK_PATH = $(BASEDIR)/work BASE_CACHE ?= $(BASEDIR)/built