FreeBSD: Use driver.h relay include.
[jack2.git] / waflib / Tools / gxx.py
blob22c5d26f2a4d310cdd8f9b130348d1f7822f49a2
1 #!/usr/bin/env python
2 # encoding: utf-8
3 # Thomas Nagy, 2006-2018 (ita)
4 # Ralf Habacker, 2006 (rh)
5 # Yinon Ehrlich, 2009
7 """
8 g++/llvm detection.
9 """
11 from waflib.Tools import ccroot, ar
12 from waflib.Configure import conf
14 @conf
15 def find_gxx(conf):
16 """
17 Finds the program g++, and if present, try to detect its version number
18 """
19 cxx = conf.find_program(['g++', 'c++'], var='CXX')
20 conf.get_cc_version(cxx, gcc=True)
21 conf.env.CXX_NAME = 'gcc'
23 @conf
24 def gxx_common_flags(conf):
25 """
26 Common flags for g++ on nearly all platforms
27 """
28 v = conf.env
30 v.CXX_SRC_F = []
31 v.CXX_TGT_F = ['-c', '-o']
33 if not v.LINK_CXX:
34 v.LINK_CXX = v.CXX
36 v.CXXLNK_SRC_F = []
37 v.CXXLNK_TGT_F = ['-o']
38 v.CPPPATH_ST = '-I%s'
39 v.DEFINES_ST = '-D%s'
41 v.LIB_ST = '-l%s' # template for adding libs
42 v.LIBPATH_ST = '-L%s' # template for adding libpaths
43 v.STLIB_ST = '-l%s'
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'
64 @conf
65 def gxx_modifier_win32(conf):
66 """Configuration flags for executing gcc on Windows"""
67 v = conf.env
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'])
81 @conf
82 def gxx_modifier_cygwin(conf):
83 """Configuration flags for executing g++ on Cygwin"""
84 gxx_modifier_win32(conf)
85 v = conf.env
86 v.cxxshlib_PATTERN = 'cyg%s.dll'
87 v.append_value('LINKFLAGS_cxxshlib', ['-Wl,--enable-auto-image-base'])
88 v.CXXFLAGS_cxxshlib = []
90 @conf
91 def gxx_modifier_darwin(conf):
92 """Configuration flags for executing g++ on MacOS"""
93 v = conf.env
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']
99 v.ARCH_ST = ['-arch']
101 v.LINKFLAGS_cxxstlib = []
103 v.SHLIB_MARKER = []
104 v.STLIB_MARKER = []
105 v.SONAME_ST = []
107 @conf
108 def gxx_modifier_aix(conf):
109 """Configuration flags for executing g++ on AIX"""
110 v = conf.env
111 v.LINKFLAGS_cxxprogram= ['-Wl,-brtl']
113 v.LINKFLAGS_cxxshlib = ['-shared', '-Wl,-brtl,-bexpfull']
114 v.SHLIB_MARKER = []
116 @conf
117 def gxx_modifier_hpux(conf):
118 v = conf.env
119 v.SHLIB_MARKER = []
120 v.STLIB_MARKER = []
121 v.CFLAGS_cxxshlib = ['-fPIC','-DPIC']
122 v.cxxshlib_PATTERN = 'lib%s.sl'
124 @conf
125 def gxx_modifier_openbsd(conf):
126 conf.env.SONAME_ST = []
128 @conf
129 def gcc_modifier_osf1V(conf):
130 v = conf.env
131 v.SHLIB_MARKER = []
132 v.STLIB_MARKER = []
133 v.SONAME_ST = []
135 @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:
143 gxx_modifier_func()
145 def configure(conf):
147 Configuration for g++
149 conf.find_gxx()
150 conf.find_ar()
151 conf.gxx_common_flags()
152 conf.gxx_modifier_platform()
153 conf.cxx_load_tools()
154 conf.cxx_add_flags()
155 conf.link_add_flags()
156 conf.check_gcc_o_space('cxx')