3
# Thomas Nagy, 2006 (ita)
4
# Ralf Habacker, 2006 (rh)
8
import Configure, Options, Utils
10
from Configure import conftest
14
cxx = conf.find_program(['g++', 'c++'], var='CXX', mandatory=True)
15
cxx = conf.cmd_to_list(cxx)
16
ccroot.get_cc_version(conf, cxx, gcc=True)
17
conf.env.CXX_NAME = 'gcc'
21
def gxx_common_flags(conf):
24
# CPPFLAGS CXXDEFINES _CXXINCFLAGS _CXXDEFFLAGS
25
v['CXXFLAGS_DEBUG'] = ['-g']
26
v['CXXFLAGS_RELEASE'] = ['-O2']
29
v['CXX_TGT_F'] = ['-c', '-o', ''] # shell hack for -MD
30
v['CPPPATH_ST'] = '-I%s' # template for adding include paths
33
if not v['LINK_CXX']: v['LINK_CXX'] = v['CXX']
34
v['CXXLNK_SRC_F'] = ''
35
v['CXXLNK_TGT_F'] = ['-o', ''] # shell hack for -MD
37
v['LIB_ST'] = '-l%s' # template for adding libs
38
v['LIBPATH_ST'] = '-L%s' # template for adding libpaths
39
v['STATICLIB_ST'] = '-l%s'
40
v['STATICLIBPATH_ST'] = '-L%s'
41
v['RPATH_ST'] = '-Wl,-rpath,%s'
42
v['CXXDEFINES_ST'] = '-D%s'
44
v['SONAME_ST'] = '-Wl,-h,%s'
45
v['SHLIB_MARKER'] = '-Wl,-Bdynamic'
46
v['STATICLIB_MARKER'] = '-Wl,-Bstatic'
47
v['FULLSTATIC_MARKER'] = '-static'
50
v['program_PATTERN'] = '%s'
53
v['shlib_CXXFLAGS'] = ['-fPIC', '-DPIC'] # avoid using -DPIC, -fPIC aleady defines the __PIC__ macro
54
v['shlib_LINKFLAGS'] = ['-shared']
55
v['shlib_PATTERN'] = 'lib%s.so'
58
v['staticlib_LINKFLAGS'] = ['-Wl,-Bstatic']
59
v['staticlib_PATTERN'] = 'lib%s.a'
62
v['LINKFLAGS_MACBUNDLE'] = ['-bundle', '-undefined', 'dynamic_lookup']
63
v['CCFLAGS_MACBUNDLE'] = ['-fPIC']
64
v['macbundle_PATTERN'] = '%s.bundle'
67
def gxx_modifier_win32(conf):
69
v['program_PATTERN'] = '%s.exe'
71
v['shlib_PATTERN'] = '%s.dll'
72
v['implib_PATTERN'] = 'lib%s.dll.a'
73
v['IMPLIB_ST'] = '-Wl,--out-implib,%s'
75
dest_arch = v['DEST_CPU']
76
v['shlib_CXXFLAGS'] = []
78
v.append_value('shlib_CXXFLAGS', '-DDLL_EXPORT') # TODO adding nonstandard defines like this DLL_EXPORT is not a good idea
80
# Auto-import is enabled by default even without this option,
81
# but enabling it explicitly has the nice effect of suppressing the rather boring, debug-level messages
82
# that the linker emits otherwise.
83
v.append_value('LINKFLAGS', '-Wl,--enable-auto-import')
86
def gxx_modifier_cygwin(conf):
87
gxx_modifier_win32(conf)
89
v['shlib_PATTERN'] = 'cyg%s.dll'
90
v.append_value('shlib_LINKFLAGS', '-Wl,--enable-auto-image-base')
93
def gxx_modifier_darwin(conf):
95
v['shlib_CXXFLAGS'] = ['-fPIC', '-compatibility_version', '1', '-current_version', '1']
96
v['shlib_LINKFLAGS'] = ['-dynamiclib']
97
v['shlib_PATTERN'] = 'lib%s.dylib'
99
v['staticlib_LINKFLAGS'] = []
101
v['SHLIB_MARKER'] = ''
102
v['STATICLIB_MARKER'] = ''
106
def gxx_modifier_aix(conf):
108
v['program_LINKFLAGS'] = ['-Wl,-brtl']
110
v['shlib_LINKFLAGS'] = ['-shared', '-Wl,-brtl,-bexpfull']
112
v['SHLIB_MARKER'] = ''
115
def gxx_modifier_platform(conf):
116
# * set configurations specific for a platform.
117
# * the destination platform is detected automatically by looking at the macros the compiler predefines,
118
# and if it's not recognised, it fallbacks to sys.platform.
119
dest_os = conf.env['DEST_OS'] or Utils.unversioned_sys_platform()
120
gxx_modifier_func = globals().get('gxx_modifier_' + dest_os)
121
if gxx_modifier_func:
122
gxx_modifier_func(conf)
128
conf.gxx_common_flags()
129
conf.gxx_modifier_platform()
130
conf.cxx_load_tools()
132
conf.link_add_flags()