3 # Thomas Nagy, 2006-2018 (ita)
4 # Ralf Habacker, 2006 (rh)
11 from waflib
.Tools
import ccroot
, ar
12 from waflib
.Configure
import conf
17 Finds the program g++, and if present, try to detect its version number
19 cxx
= conf
.find_program(['g++', 'c++'], var
='CXX')
20 conf
.get_cc_version(cxx
, gcc
=True)
21 conf
.env
.CXX_NAME
= 'gcc'
24 def gxx_common_flags(conf
):
26 Common flags for g++ on nearly all platforms
31 v
.CXX_TGT_F
= ['-c', '-o']
37 v
.CXXLNK_TGT_F
= ['-o']
41 v
.LIB_ST
= '-l%s' # template for adding libs
42 v
.LIBPATH_ST
= '-L%s' # template for adding libpaths
44 v
.STLIBPATH_ST
= '-L%s'
45 v
.RPATH_ST
= '-Wl,-rpath,%s'
47 v
.SONAME_ST
= '-Wl,-h,%s'
48 v
.SHLIB_MARKER
= '-Wl,-Bdynamic'
49 v
.STLIB_MARKER
= '-Wl,-Bstatic'
51 v
.cxxprogram_PATTERN
= '%s'
53 v
.CXXFLAGS_cxxshlib
= ['-fPIC']
54 v
.LINKFLAGS_cxxshlib
= ['-shared']
55 v
.cxxshlib_PATTERN
= 'lib%s.so'
57 v
.LINKFLAGS_cxxstlib
= ['-Wl,-Bstatic']
58 v
.cxxstlib_PATTERN
= 'lib%s.a'
60 v
.LINKFLAGS_MACBUNDLE
= ['-bundle', '-undefined', 'dynamic_lookup']
61 v
.CXXFLAGS_MACBUNDLE
= ['-fPIC']
62 v
.macbundle_PATTERN
= '%s.bundle'
65 def gxx_modifier_win32(conf
):
66 """Configuration flags for executing gcc on Windows"""
68 v
.cxxprogram_PATTERN
= '%s.exe'
70 v
.cxxshlib_PATTERN
= '%s.dll'
71 v
.implib_PATTERN
= '%s.dll.a'
72 v
.IMPLIB_ST
= '-Wl,--out-implib,%s'
74 v
.CXXFLAGS_cxxshlib
= []
76 # Auto-import is enabled by default even without this option,
77 # but enabling it explicitly has the nice effect of suppressing the rather boring, debug-level messages
78 # that the linker emits otherwise.
79 v
.append_value('LINKFLAGS', ['-Wl,--enable-auto-import'])
82 def gxx_modifier_cygwin(conf
):
83 """Configuration flags for executing g++ on Cygwin"""
84 gxx_modifier_win32(conf
)
86 v
.cxxshlib_PATTERN
= 'cyg%s.dll'
87 v
.append_value('LINKFLAGS_cxxshlib', ['-Wl,--enable-auto-image-base'])
88 v
.CXXFLAGS_cxxshlib
= []
91 def gxx_modifier_darwin(conf
):
92 """Configuration flags for executing g++ on MacOS"""
94 v
.CXXFLAGS_cxxshlib
= ['-fPIC']
95 v
.LINKFLAGS_cxxshlib
= ['-dynamiclib']
96 v
.cxxshlib_PATTERN
= 'lib%s.dylib'
97 v
.FRAMEWORKPATH_ST
= '-F%s'
98 v
.FRAMEWORK_ST
= ['-framework']
101 v
.LINKFLAGS_cxxstlib
= []
108 def gxx_modifier_aix(conf
):
109 """Configuration flags for executing g++ on AIX"""
111 v
.LINKFLAGS_cxxprogram
= ['-Wl,-brtl']
113 v
.LINKFLAGS_cxxshlib
= ['-shared', '-Wl,-brtl,-bexpfull']
117 def gxx_modifier_hpux(conf
):
121 v
.CFLAGS_cxxshlib
= ['-fPIC','-DPIC']
122 v
.cxxshlib_PATTERN
= 'lib%s.sl'
125 def gxx_modifier_openbsd(conf
):
126 conf
.env
.SONAME_ST
= []
129 def gcc_modifier_osf1V(conf
):
136 def gxx_modifier_platform(conf
):
137 """Execute platform-specific functions based on *gxx_modifier_+NAME*"""
138 # * set configurations specific for a platform.
139 # * the destination platform is detected automatically by looking at the macros the compiler predefines,
140 # and if it's not recognised, it fallbacks to sys.platform.
141 gxx_modifier_func
= getattr(conf
, 'gxx_modifier_' + conf
.env
.DEST_OS
, None)
142 if gxx_modifier_func
:
147 Configuration for g++
151 conf
.gxx_common_flags()
152 conf
.gxx_modifier_platform()
153 conf
.cxx_load_tools()
155 conf
.link_add_flags()
156 conf
.check_gcc_o_space('cxx')