3
# Thomas Nagy, 2006 (ita)
4
# Ralf Habacker, 2006 (rh)
6
import os, sys, pproc, Object
8
import Utils, Action, Params, checks, Configure
17
elif 'CC' in os.environ:
19
if not cc: cc = conf.find_program('cc', var='CC')
22
#TODO: Has anyone a better ida to check if this is a sun cc?
23
ret = os.popen("%s -flags" %cc).close()
25
conf.check_message('suncc', '', not ret)
26
return 0 #at least gcc exit with error
27
conf.check_tool('checks')
29
# load the cc builders
32
# sun cc requires ar for static libs
33
if not conf.check_tool('ar'):
34
Utils.error('suncc needs ar - not found')
50
v['CC_TGT_F'] = '-c -o '
51
v['CPPPATH_ST'] = '-I%s' # template for adding include paths
54
v['LINK_CC'] = v['CC']
58
v['CCLNK_TGT_F'] = '-o '
60
v['LIB_ST'] = '-l%s' # template for adding libs
61
v['LIBPATH_ST'] = '-L%s' # template for adding libpaths
62
v['STATICLIB_ST'] = '-l%s'
63
v['STATICLIBPATH_ST'] = '-L%s'
64
v['_LIBDIRFLAGS'] = ''
66
v['CCDEFINES_ST'] = '-D%s'
70
v['LINKFLAGS_OPTIMIZED'] = ['-s']
71
v['LINKFLAGS_RELEASE'] = ['-s']
72
v['LINKFLAGS_DEBUG'] = ['-g']
73
v['LINKFLAGS_ULTRADEBUG'] = ['-g3']
75
v['SHLIB_MARKER'] = '-Bdynamic'
76
v['STATICLIB_MARKER'] = '-Bstatic'
79
v['shlib_CCFLAGS'] = ['-Kpic', '-DPIC']
80
v['shlib_LINKFLAGS'] = ['-G']
81
v['shlib_obj_ext'] = ['.o']
82
v['shlib_PREFIX'] = 'lib'
83
v['shlib_SUFFIX'] = '.so'
85
# plugins. We handle them exactly as shlibs
86
# everywhere except on osx, where we do bundles
87
v['plugin_CCFLAGS'] = v['shlib_CCFLAGS']
88
v['plugin_LINKFLAGS'] = v['shlib_LINKFLAGS']
89
v['plugin_obj_ext'] = v['shlib_obj_ext']
90
v['plugin_PREFIX'] = v['shlib_PREFIX']
91
v['plugin_SUFFIX'] = v['shlib_SUFFIX']
94
v['staticlib_LINKFLAGS'] = ['-Bstatic']
95
v['staticlib_obj_ext'] = ['.o']
96
v['staticlib_PREFIX'] = 'lib'
97
v['staticlib_SUFFIX'] = '.a'
100
v['program_obj_ext'] = ['.o']
101
v['program_SUFFIX'] = ''
103
#test if the compiler could build a prog
104
test = Configure.check_data()
105
test.code = 'int main() {return 0;}\n'
108
test.force_compiler="cc"
109
ret = conf.run_check(test, "program")
110
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.force_compiler="cc"
120
ret = conf.run_check(lib_obj)
121
conf.check_message('compiler could create', 'shared libs', not (ret is False))
125
#test if the compiler could build a staiclib
126
lib_obj = Configure.check_data()
127
lib_obj.code = "int k = 3;\n"
129
lib_obj.build_type = "staticlib"
130
lib_obj.force_compiler="cc"
131
ret = conf.run_check(lib_obj)
132
conf.check_message('compiler could create', 'static libs', not (ret is False))
136
# compiler debug levels
137
v['CCFLAGS'] = ['-O']
138
if conf.check_flags('-O2'):
139
v['CCFLAGS_OPTIMIZED'] = ['-O2']
140
v['CCFLAGS_RELEASE'] = ['-O2']
141
if conf.check_flags('-g -DDEBUG'):
142
v['CCFLAGS_DEBUG'] = ['-g', '-DDEBUG']
143
if conf.check_flags('-g3 -O0 -DDEBUG'):
144
v['CCFLAGS_ULTRADEBUG'] = ['-g3', '-O0', '-DDEBUG']
146
# see the option below
148
v['CCFLAGS'] = v['CCFLAGS_'+Params.g_options.debug_level.upper()]
149
except AttributeError:
153
def addflags(orig, dest=None):
154
if not dest: dest=orig
155
try: conf.env[dest] = ron[orig]
156
except KeyError: pass
157
addflags('CCFLAGS', 'CFLAGS')
159
addflags('LINKFLAGS')
161
if not v['DESTDIR']: v['DESTDIR']=''
163
v['program_INST_VAR'] = 'PREFIX'
164
v['program_INST_DIR'] = 'bin'
165
v['shlib_INST_VAR'] = 'PREFIX'
166
v['shlib_INST_DIR'] = 'lib'
167
v['staticlib_INST_VAR'] = 'PREFIX'
168
v['staticlib_INST_DIR'] = 'lib'
172
def set_options(opt):
174
opt.add_option('-d', '--debug-level',
177
help = 'Specify the debug level, does nothing if CFLAGS is set in the environment. [Allowed Values: ultradebug, debug, release, optimized]',
178
dest = 'debug_level')
179
except optparse.OptionConflictError:
180
# the g++ tool might have added that option already