3 # Thomas Nagy, 2006-2008 (ita)
4 # Ralf Habacker, 2006 (rh)
8 import Configure
, Options
, Utils
10 from Configure
import conftest
14 cc
= conf
.find_program(['gcc', 'cc'], var
='CC', mandatory
=True)
15 cc
= conf
.cmd_to_list(cc
)
16 ccroot
.get_cc_version(conf
, cc
, gcc
=True)
17 conf
.env
.CC_NAME
= 'gcc'
21 def gcc_common_flags(conf
):
24 # CPPFLAGS CCDEFINES _CCINCFLAGS _CCDEFFLAGS
26 v
['CCFLAGS_DEBUG'] = ['-g']
28 v
['CCFLAGS_RELEASE'] = ['-O2']
31 v
['CC_TGT_F'] = ['-c', '-o', ''] # shell hack for -MD
32 v
['CPPPATH_ST'] = '-I%s' # template for adding include paths
35 if not v
['LINK_CC']: v
['LINK_CC'] = v
['CC']
37 v
['CCLNK_TGT_F'] = ['-o', ''] # shell hack for -MD
39 v
['LIB_ST'] = '-l%s' # template for adding libs
40 v
['LIBPATH_ST'] = '-L%s' # template for adding libpaths
41 v
['STATICLIB_ST'] = '-l%s'
42 v
['STATICLIBPATH_ST'] = '-L%s'
43 v
['RPATH_ST'] = '-Wl,-rpath,%s'
44 v
['CCDEFINES_ST'] = '-D%s'
46 v
['SONAME_ST'] = '-Wl,-h,%s'
47 v
['SHLIB_MARKER'] = '-Wl,-Bdynamic'
48 v
['STATICLIB_MARKER'] = '-Wl,-Bstatic'
49 v
['FULLSTATIC_MARKER'] = '-static'
52 v
['program_PATTERN'] = '%s'
55 v
['shlib_CCFLAGS'] = ['-fPIC', '-DPIC'] # avoid using -DPIC, -fPIC aleady defines the __PIC__ macro
56 v
['shlib_LINKFLAGS'] = ['-shared']
57 v
['shlib_PATTERN'] = 'lib%s.so'
60 v
['staticlib_LINKFLAGS'] = ['-Wl,-Bstatic']
61 v
['staticlib_PATTERN'] = 'lib%s.a'
64 v
['LINKFLAGS_MACBUNDLE'] = ['-bundle', '-undefined', 'dynamic_lookup']
65 v
['CCFLAGS_MACBUNDLE'] = ['-fPIC']
66 v
['macbundle_PATTERN'] = '%s.bundle'
69 def gcc_modifier_win32(conf
):
71 v
['program_PATTERN'] = '%s.exe'
73 v
['shlib_PATTERN'] = '%s.dll'
74 v
['implib_PATTERN'] = 'lib%s.dll.a'
75 v
['IMPLIB_ST'] = '-Wl,--out-implib,%s'
77 dest_arch
= v
['DEST_CPU']
78 v
['shlib_CCFLAGS'] = ['-DPIC']
80 v
.append_value('shlib_CCFLAGS', '-DDLL_EXPORT') # TODO adding nonstandard defines like this DLL_EXPORT is not a good idea
82 # Auto-import is enabled by default even without this option,
83 # but enabling it explicitly has the nice effect of suppressing the rather boring, debug-level messages
84 # that the linker emits otherwise.
85 v
.append_value('LINKFLAGS', '-Wl,--enable-auto-import')
88 def gcc_modifier_cygwin(conf
):
89 gcc_modifier_win32(conf
)
91 v
['shlib_PATTERN'] = 'cyg%s.dll'
92 v
.append_value('shlib_LINKFLAGS', '-Wl,--enable-auto-image-base')
95 def gcc_modifier_darwin(conf
):
97 v
['shlib_CCFLAGS'] = ['-fPIC', '-compatibility_version', '1', '-current_version', '1']
98 v
['shlib_LINKFLAGS'] = ['-dynamiclib']
99 v
['shlib_PATTERN'] = 'lib%s.dylib'
101 v
['staticlib_LINKFLAGS'] = []
103 v
['SHLIB_MARKER'] = ''
104 v
['STATICLIB_MARKER'] = ''
108 def gcc_modifier_aix(conf
):
110 v
['program_LINKFLAGS'] = ['-Wl,-brtl']
112 v
['shlib_LINKFLAGS'] = ['-shared','-Wl,-brtl,-bexpfull']
114 v
['SHLIB_MARKER'] = ''
117 def gcc_modifier_platform(conf
):
118 # * set configurations specific for a platform.
119 # * the destination platform is detected automatically by looking at the macros the compiler predefines,
120 # and if it's not recognised, it fallbacks to sys.platform.
121 dest_os
= conf
.env
['DEST_OS'] or Utils
.unversioned_sys_platform()
122 gcc_modifier_func
= globals().get('gcc_modifier_' + dest_os
)
123 if gcc_modifier_func
:
124 gcc_modifier_func(conf
)
130 conf
.gcc_common_flags()
131 conf
.gcc_modifier_platform()
134 conf
.link_add_flags()