3
# Thomas Nagy, 2006 (ita)
4
# Ralf Habacker, 2006 (rh)
8
import Utils, Action, Params, checks, Configure
13
# tool detection and initial setup
14
# is called when a configure process is started,
15
# the values are cached for further build processes
20
elif 'CXX' in os.environ:
21
cxx = os.environ['CXX']
22
if not cxx: cxx = conf.find_program('CC', var='CXX')
24
conf.check_message('sunc++', '', False)
26
conf.check_tool('checks')
30
# load the cpp builders
31
conf.check_tool('cpp')
33
# g++ requires ar for static libs
34
if not conf.check_tool('ar'):
35
Utils.error('sunc++ needs ar - not found')
43
v['CXXDEFINES'] = [] # command-line defines
45
v['_CXXINCFLAGS'] = []
46
v['_CXXDEFFLAGS'] = []
49
v['CXX_TGT_F'] = '-c -o '
51
v['CPPPATH_ST'] = '-I%s' # template for adding include paths
55
v['LINK_CXX'] = v['CXX']
58
v['CPPLNK_TGT_F'] = '-o '
59
v['CPPLNK_SRC_F'] = ''
61
v['LIB_ST'] = '-l%s' # template for adding libs
62
v['LIBPATH_ST'] = '-L%s' # template for adding libpaths
63
v['STATICLIB_ST'] = '-l%s'
64
v['STATICLIBPATH_ST'] = '-L%s'
65
v['CXXDEFINES_ST'] = '-D%s'
66
v['_LIBDIRFLAGS'] = ''
69
v['SHLIB_MARKER'] = '-Bdynamic'
70
v['STATICLIB_MARKER'] = '-Bstatic'
74
v['LINKFLAGS_OPTIMIZED'] = ['-s']
75
v['LINKFLAGS_RELEASE'] = ['-s']
76
v['LINKFLAGS_DEBUG'] = ['-g']
77
v['LINKFLAGS_ULTRADEBUG'] = ['-g3']
80
v['shlib_CXXFLAGS'] = ['-Kpic', '-DPIC']
81
v['shlib_LINKFLAGS'] = ['-G']
82
v['shlib_obj_ext'] = ['.o']
83
v['shlib_PREFIX'] = 'lib'
84
v['shlib_SUFFIX'] = '.so'
86
# plugins. We handle them exactly as shlibs
87
# everywhere except on osx, where we do bundles
88
v['plugin_CCCFLAGS'] = v['shlib_CCFLAGS']
89
v['plugin_LINKFLAGS'] = v['shlib_LINKFLAGS']
90
v['plugin_obj_ext'] = v['shlib_obj_ext']
91
v['plugin_PREFIX'] = v['shlib_PREFIX']
92
v['plugin_SUFFIX'] = v['shlib_SUFFIX']
95
v['staticlib_LINKFLAGS'] = ['-Bstatic']
96
v['staticlib_obj_ext'] = ['.o']
97
v['staticlib_PREFIX'] = 'lib'
98
v['staticlib_SUFFIX'] = '.a'
101
v['program_obj_ext'] = ['.o']
102
v['program_SUFFIX'] = ''
104
#test if the compiler could build a prog
105
test = Configure.check_data()
106
test.code = 'int main() {return 0;}\n'
109
test.force_compiler = "cpp"
110
ret = conf.run_check(test)
111
conf.check_message('compiler could create', 'programs', not (ret is False))
114
#test if the compiler could build a shlib
115
lib_obj = Configure.check_data()
116
lib_obj.code = "int k = 3;\n"
118
lib_obj.build_type = "shlib"
119
lib_obj.orce_compiler = "cpp"
120
ret = conf.run_check(lib_obj)
121
conf.check_message('compiler could create', 'shared libs', not (ret is False))
124
#test if the compiler could build a staiclib
125
lib_obj = Configure.check_data()
126
lib_obj.code = "int k = 3;\n"
128
lib_obj.build_type = "staticlib"
129
lib_obj.orce_compiler = "cpp"
130
ret = conf.run_check(lib_obj)
131
conf.check_message('compiler could create', 'static libs', not (ret is False))
135
# compiler debug levels
137
if conf.check_flags('-O2'):
138
v['CXXFLAGS_OPTIMIZED'] = ['-O2']
139
v['CXXFLAGS_RELEASE'] = ['-O2']
140
if conf.check_flags('-g -DDEBUG'):
141
v['CXXFLAGS_DEBUG'] = ['-g', '-DDEBUG']
142
if conf.check_flags('-g3 -O0 -DDEBUG'):
143
v['CXXFLAGS_ULTRADEBUG'] = ['-g3', '-O0', '-DDEBUG']
145
# see the option below
147
v['CXXFLAGS'] = v['CXXFLAGS_'+Params.g_options.debug_level.upper()]
148
except AttributeError:
152
def addflags(orig, dest=None):
153
if not dest: dest=orig
154
try: conf.env[dest] = ron[orig]
155
except KeyError: pass
158
addflags('LINKFLAGS')
160
if not v['DESTDIR']: v['DESTDIR']=''
162
v['program_INST_VAR'] = 'PREFIX'
163
v['program_INST_DIR'] = 'bin'
164
v['shlib_INST_VAR'] = 'PREFIX'
165
v['shlib_INST_DIR'] = 'lib'
166
v['staticlib_INST_VAR'] = 'PREFIX'
167
v['staticlib_INST_DIR'] = 'lib'
171
def set_options(opt):
173
opt.add_option('-d', '--debug-level',
176
help = 'Specify the debug level, does nothing if CXXFLAGS is set in the environment. [Allowed Values: ultradebug, debug, release, optimized]',
177
dest = 'debug_level')
178
except optparse.OptionConflictError:
179
# the gcc tool might have added that option already