diff --git a/BUILD b/BUILD index eda3e038c..d8373f57e 100644 --- a/BUILD +++ b/BUILD @@ -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 ---------- diff --git a/build.py b/build.py index 6bc40ec50..21a056275 100644 --- a/build.py +++ b/build.py @@ -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