diff options
author | Yuichiro NAITO <[email protected]> | 2018-11-17 17:23:53 +0900 |
---|---|---|
committer | Bradley Sepos <[email protected]> | 2018-11-26 17:59:40 -0500 |
commit | 9e71ecc64729fa852e270e7f0b46827897603c74 (patch) | |
tree | 111c0779d0d686f8cfcd88d2eafae43a0ea44eaa | |
parent | da1f90d8427d444386b269a3ae21a7420e9d81cb (diff) |
build: Respect CC environment variable on FreeBSD.
Fixes #1674.
We use the compiler that CC environment variable indicates.
If CC is ommited, use gcc or clang which is installed.
If gcc is chosen, we need to add `-Wl,-rpath` option to make runtime linker
linking gcc's runtime libraries from installed path. For example, gcc7's
runtime libraries are installed in `/usr/local/lib/gcc7` by default.
And we also need to link libc++ first to make libc++ initializer is called
on runtime.
-rw-r--r-- | gtk/module.rules | 2 | ||||
-rw-r--r-- | make/configure.py | 7 | ||||
-rw-r--r-- | make/include/gcc.defs | 4 | ||||
-rw-r--r-- | make/variant/freebsd.defs | 4 |
4 files changed, 14 insertions, 3 deletions
diff --git a/gtk/module.rules b/gtk/module.rules index eaebdb3f5..09d99b466 100644 --- a/gtk/module.rules +++ b/gtk/module.rules @@ -17,6 +17,8 @@ $(GTK.CONFIGURE.stamp): $(GTK.src/)configure.ac $(GTK.src/)src/Makefile.am set -e; cd $(GTK.build/); $(call fn.ABSOLUTE,$(GTK.src/))configure \ $(GTK.CONFIGURE.extra) \ PKG_CONFIG_PATH=$(BUILD/)contrib/lib/pkgconfig:$(PKG_CONFIG_PATH) \ + CC="$(GCC.gcc)" \ + CXX="$(GCC.gxx)" \ CFLAGS="$(call fn.ARGS,GTK.GCC,.g .O *D ?extra)" \ LDFLAGS="$(call fn.ARGS,GTK.GCC,?strip .g .O ?extra.exe)" \ PYTHON="$(PYTHON.exe)" \ diff --git a/make/configure.py b/make/configure.py index 9697fffa5..6f58a78e2 100644 --- a/make/configure.py +++ b/make/configure.py @@ -1512,7 +1512,12 @@ try: class Tools: ar = ToolProbe( 'AR.exe', 'ar', abort=True ) cp = ToolProbe( 'CP.exe', 'cp', abort=True ) - gcc = ToolProbe( 'GCC.gcc', 'gcc', IfHost( 'clang', '*-*-freebsd*' ), IfHost( 'gcc-4', '*-*-cygwin*' )) + gcc_tools = ['GCC.gcc', + IfHost( os.environ.get('CC', None), '*-*-freebsd*' ), + 'gcc', + IfHost( 'clang', '*-*-freebsd*' ), + IfHost( 'gcc-4', '*-*-cygwin*' )] + gcc = ToolProbe(*filter(None, gcc_tools)) if host.match( '*-*-darwin*' ): gmake = ToolProbe( 'GMAKE.exe', 'make', 'gmake', abort=True ) diff --git a/make/include/gcc.defs b/make/include/gcc.defs index adb86ad46..83b26aafa 100644 --- a/make/include/gcc.defs +++ b/make/include/gcc.defs @@ -1,5 +1,5 @@ GCC.gcc = gcc -GCC.gxx = $(dir $(GCC.gcc))$(subst clang,clang++,$(subst gcc,g++,$(notdir $(GCC.gcc)))) +GCC.gxx = $(dir $(GCC.gcc))$(subst cc,c++,$(subst clang,clang++,$(subst gcc,g++,$(notdir $(GCC.gcc))))) GCC.strip = $$(if $$(filter none,$$(GCC.g)),1) GCC.dylib = 1 @@ -91,7 +91,7 @@ GCC.args.extra.exe++ = $(LDFLAGS) define import.GCC $(1).GCC.gcc = $$(GCC.gcc) - $(1).GCC.gxx = $$(dir $$($(1).GCC.gcc))$$(subst clang,clang++,$$(subst gcc,g++,$$(notdir $$($(1).GCC.gcc)))) + $(1).GCC.gxx = $$(dir $$($(1).GCC.gcc))$$(subst cc,c++,$$(subst clang,clang++,$$(subst gcc,g++,$$(notdir $$($(1).GCC.gcc))))) $(1).GCC.pipe = $$(GCC.pipe) $(1).GCC.c_std = $$(GCC.c_std) diff --git a/make/variant/freebsd.defs b/make/variant/freebsd.defs index d8a7245f8..e0855b51a 100644 --- a/make/variant/freebsd.defs +++ b/make/variant/freebsd.defs @@ -14,3 +14,7 @@ GCC.args.g.none = -g0 GCC.args.g.min = -g1 GCC.args.g.std = -g2 GCC.args.g.max = -g3 + +GCC.MAJOR_VERSION = $(shell $(GCC.gcc) -dumpversion | cut -f 1 -d .) +GCC.LDFLAGS = -lc++ -Wl,-rpath=$(LOCALBASE)/lib/gcc$(GCC.MAJOR_VERSION) +LDFLAGS += $(if $(findstring gcc, $(GCC.gcc)), $(GCC.LDFLAGS), ) |