allow the user to provide project-wide compilation and link flags

This commit is contained in:
Mathieu Lacage
2006-10-03 08:17:05 +02:00
parent 77b66f56e1
commit 3d64c8d0b6
2 changed files with 13 additions and 3 deletions

6
BUILD
View File

@@ -23,6 +23,12 @@ setup environment variables to point to the right libraries.
the default build output is terse. To get a more verbose
output, you need to set the 'verbose' variable to 'y'.
Example: scons verbose=y
- cflags: flags for the C compiler.
Example: scons cflags="-O3 -ffast-math"
- cxxflags: flags for the C++ compiler.
Example: scons cxxflags="-O3 -ffast-math"
- ldflags: flags for the linker:
Example: scons ldflags="-L/foo -L/bar"
2) Targets
----------

View File

@@ -304,22 +304,26 @@ class Ns3:
self.gen_mod_config (env)
cc = env['CC']
cxx = env.subst (env['CXX'])
common_flags = ARGUMENTS.get('cflags', '').split (' ')
cxxflags = ARGUMENTS.get('cxxflags', '').split (' ')
ldflags = ARGUMENTS.get('ldflags', '').split (' ')
if cc == 'cl' and cxx == 'cl':
env = Environment (tools = ['mingw'])
cc = env['CC']
cxx = env.subst (env['CXX'])
if cc == 'gcc' and cxx == 'g++':
common_flags = ['-g3', '-Wall', '-Werror']
common_flags.extend (['-g3', '-Wall', '-Werror'])
debug_flags = []
opti_flags = ['-O3']
elif cc == 'cl' and cxx == 'cl':
env = Environment (ENV = os.environ)
common_flags = []
debug_flags = ['-W1', '-GX', '-EHsc', '-D_DEBUG', '/MDd']
opti_flags = ['-O2', '-EHsc', '-DNDEBUG', '/MD']
env.Append (CCFLAGS=common_flags,
CPPDEFINES=['RUN_SELF_TESTS'],
TARFLAGS='-c -z')
TARFLAGS='-c -z',
CPPFLAGS=cxxflags,
LINKFLAGS=ldflags)
verbose = ARGUMENTS.get('verbose', 'n')
if verbose == 'n':
env['PRINT_CMD_LINE_FUNC'] = print_cmd_line