3 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
7 # Thomas Nagy, 2006-2018 (ita)
8 # Ralf Habacker, 2006 (rh)
15 from waflib.Tools import ccroot, ar
16 from waflib.Configure import conf
21 Find the program gcc, and if present, try to detect its version number
23 cc = conf.find_program(['gcc', 'cc'], var='CC')
24 conf.get_cc_version(cc, gcc=True)
25 conf.env.CC_NAME = 'gcc'
28 def gcc_common_flags(conf):
30 Common flags for gcc on nearly all platforms
35 v.CC_TGT_F = ['-c', '-o']
41 v.CCLNK_TGT_F = ['-o']
45 v.LIB_ST = '-l%s' # template for adding libs
46 v.LIBPATH_ST = '-L%s' # template for adding libpaths
48 v.STLIBPATH_ST = '-L%s'
49 v.RPATH_ST = '-Wl,-rpath,%s'
51 v.SONAME_ST = '-Wl,-h,%s'
52 v.SHLIB_MARKER = '-Wl,-Bdynamic'
53 v.STLIB_MARKER = '-Wl,-Bstatic'
55 v.cprogram_PATTERN = '%s'
57 v.CFLAGS_cshlib = ['-fPIC']
58 v.LINKFLAGS_cshlib = ['-shared']
59 v.cshlib_PATTERN = 'lib%s.so'
61 v.LINKFLAGS_cstlib = ['-Wl,-Bstatic']
62 v.cstlib_PATTERN = 'lib%s.a'
64 v.LINKFLAGS_MACBUNDLE = ['-bundle', '-undefined', 'dynamic_lookup']
65 v.CFLAGS_MACBUNDLE = ['-fPIC']
66 v.macbundle_PATTERN = '%s.bundle'
69 def gcc_modifier_win32(conf):
70 """Configuration flags for executing gcc on Windows"""
72 v.cprogram_PATTERN = '%s.exe'
74 v.cshlib_PATTERN = '%s.dll'
75 v.implib_PATTERN = '%s.dll.a'
76 v.IMPLIB_ST = '-Wl,--out-implib,%s'
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 gcc_modifier_cygwin(conf):
87 """Configuration flags for executing gcc on Cygwin"""
88 gcc_modifier_win32(conf)
90 v.cshlib_PATTERN = 'cyg%s.dll'
91 v.append_value('LINKFLAGS_cshlib', ['-Wl,--enable-auto-image-base'])
95 def gcc_modifier_darwin(conf):
96 """Configuration flags for executing gcc on MacOS"""
98 v.CFLAGS_cshlib = ['-fPIC']
99 v.LINKFLAGS_cshlib = ['-dynamiclib']
100 v.cshlib_PATTERN = 'lib%s.dylib'
101 v.FRAMEWORKPATH_ST = '-F%s'
102 v.FRAMEWORK_ST = ['-framework']
103 v.ARCH_ST = ['-arch']
105 v.LINKFLAGS_cstlib = []
112 def gcc_modifier_aix(conf):
113 """Configuration flags for executing gcc on AIX"""
115 v.LINKFLAGS_cprogram = ['-Wl,-brtl']
116 v.LINKFLAGS_cshlib = ['-shared','-Wl,-brtl,-bexpfull']
120 def gcc_modifier_hpux(conf):
124 v.CFLAGS_cshlib = ['-fPIC','-DPIC']
125 v.cshlib_PATTERN = 'lib%s.sl'
128 def gcc_modifier_openbsd(conf):
129 conf.env.SONAME_ST = []
132 def gcc_modifier_osf1V(conf):
139 def gcc_modifier_platform(conf):
140 """Execute platform-specific functions based on *gcc_modifier_+NAME*"""
141 # * set configurations specific for a platform.
142 # * the destination platform is detected automatically by looking at the macros the compiler predefines,
143 # and if it's not recognised, it fallbacks to sys.platform.
144 gcc_modifier_func = getattr(conf, 'gcc_modifier_' + conf.env.DEST_OS, None)
145 if gcc_modifier_func:
150 Configuration for gcc
154 conf.gcc_common_flags()
155 conf.gcc_modifier_platform()
158 conf.link_add_flags()
159 conf.check_gcc_o_space()