thirdparty:waf: New files for waf 1.9.10
[sfrench/samba-autobuild/.git] / third_party / waf / waflib / Tools / gxx.py
1 #! /usr/bin/env python
2 # encoding: utf-8
3 # WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
4
5 #!/usr/bin/env python
6 # encoding: utf-8
7 # Thomas Nagy, 2006-2016 (ita)
8 # Ralf Habacker, 2006 (rh)
9 # Yinon Ehrlich, 2009
10
11 """
12 g++/llvm detection.
13 """
14
15 from waflib.Tools import ccroot, ar
16 from waflib.Configure import conf
17
18 @conf
19 def find_gxx(conf):
20         """
21         Finds the program g++, and if present, try to detect its version number
22         """
23         cxx = conf.find_program(['g++', 'c++'], var='CXX')
24         conf.get_cc_version(cxx, gcc=True)
25         conf.env.CXX_NAME = 'gcc'
26
27 @conf
28 def gxx_common_flags(conf):
29         """
30         Common flags for g++ on nearly all platforms
31         """
32         v = conf.env
33
34         v.CXX_SRC_F           = []
35         v.CXX_TGT_F           = ['-c', '-o']
36
37         if not v.LINK_CXX:
38                 v.LINK_CXX = v.CXX
39
40         v.CXXLNK_SRC_F        = []
41         v.CXXLNK_TGT_F        = ['-o']
42         v.CPPPATH_ST          = '-I%s'
43         v.DEFINES_ST          = '-D%s'
44
45         v.LIB_ST              = '-l%s' # template for adding libs
46         v.LIBPATH_ST          = '-L%s' # template for adding libpaths
47         v.STLIB_ST            = '-l%s'
48         v.STLIBPATH_ST        = '-L%s'
49         v.RPATH_ST            = '-Wl,-rpath,%s'
50
51         v.SONAME_ST           = '-Wl,-h,%s'
52         v.SHLIB_MARKER        = '-Wl,-Bdynamic'
53         v.STLIB_MARKER        = '-Wl,-Bstatic'
54
55         v.cxxprogram_PATTERN  = '%s'
56
57         v.CXXFLAGS_cxxshlib   = ['-fPIC']
58         v.LINKFLAGS_cxxshlib  = ['-shared']
59         v.cxxshlib_PATTERN    = 'lib%s.so'
60
61         v.LINKFLAGS_cxxstlib  = ['-Wl,-Bstatic']
62         v.cxxstlib_PATTERN    = 'lib%s.a'
63
64         v.LINKFLAGS_MACBUNDLE = ['-bundle', '-undefined', 'dynamic_lookup']
65         v.CXXFLAGS_MACBUNDLE  = ['-fPIC']
66         v.macbundle_PATTERN   = '%s.bundle'
67
68 @conf
69 def gxx_modifier_win32(conf):
70         """Configuration flags for executing gcc on Windows"""
71         v = conf.env
72         v.cxxprogram_PATTERN  = '%s.exe'
73
74         v.cxxshlib_PATTERN    = '%s.dll'
75         v.implib_PATTERN      = 'lib%s.dll.a'
76         v.IMPLIB_ST           = '-Wl,--out-implib,%s'
77
78         v.CXXFLAGS_cxxshlib   = []
79
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'])
84
85 @conf
86 def gxx_modifier_cygwin(conf):
87         """Configuration flags for executing g++ on Cygwin"""
88         gxx_modifier_win32(conf)
89         v = conf.env
90         v.cxxshlib_PATTERN    = 'cyg%s.dll'
91         v.append_value('LINKFLAGS_cxxshlib', ['-Wl,--enable-auto-image-base'])
92         v.CXXFLAGS_cxxshlib   = []
93
94 @conf
95 def gxx_modifier_darwin(conf):
96         """Configuration flags for executing g++ on MacOS"""
97         v = conf.env
98         v.CXXFLAGS_cxxshlib   = ['-fPIC']
99         v.LINKFLAGS_cxxshlib  = ['-dynamiclib']
100         v.cxxshlib_PATTERN    = 'lib%s.dylib'
101         v.FRAMEWORKPATH_ST    = '-F%s'
102         v.FRAMEWORK_ST        = ['-framework']
103         v.ARCH_ST             = ['-arch']
104
105         v.LINKFLAGS_cxxstlib  = []
106
107         v.SHLIB_MARKER        = []
108         v.STLIB_MARKER        = []
109         v.SONAME_ST           = []
110
111 @conf
112 def gxx_modifier_aix(conf):
113         """Configuration flags for executing g++ on AIX"""
114         v = conf.env
115         v.LINKFLAGS_cxxprogram= ['-Wl,-brtl']
116
117         v.LINKFLAGS_cxxshlib  = ['-shared', '-Wl,-brtl,-bexpfull']
118         v.SHLIB_MARKER        = []
119
120 @conf
121 def gxx_modifier_hpux(conf):
122         v = conf.env
123         v.SHLIB_MARKER        = []
124         v.STLIB_MARKER        = []
125         v.CFLAGS_cxxshlib     = ['-fPIC','-DPIC']
126         v.cxxshlib_PATTERN    = 'lib%s.sl'
127
128 @conf
129 def gxx_modifier_openbsd(conf):
130         conf.env.SONAME_ST = []
131
132 @conf
133 def gcc_modifier_osf1V(conf):
134         v = conf.env
135         v.SHLIB_MARKER        = []
136         v.STLIB_MARKER        = []
137         v.SONAME_ST           = []
138
139 @conf
140 def gxx_modifier_platform(conf):
141         """Execute platform-specific functions based on *gxx_modifier_+NAME*"""
142         # * set configurations specific for a platform.
143         # * the destination platform is detected automatically by looking at the macros the compiler predefines,
144         #   and if it's not recognised, it fallbacks to sys.platform.
145         gxx_modifier_func = getattr(conf, 'gxx_modifier_' + conf.env.DEST_OS, None)
146         if gxx_modifier_func:
147                 gxx_modifier_func()
148
149 def configure(conf):
150         """
151         Configuration for g++
152         """
153         conf.find_gxx()
154         conf.find_ar()
155         conf.gxx_common_flags()
156         conf.gxx_modifier_platform()
157         conf.cxx_load_tools()
158         conf.cxx_add_flags()
159         conf.link_add_flags()