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.
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)" \
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 )
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
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)
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), )