enable static builds, even when python is enabled
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 22 Apr 2009 17:22:41 +0200
changeset 4395 489abe44ed7e
parent 4394 dced016d5f49
child 4396 7d096e399d77
enable static builds, even when python is enabled
bindings/python/wscript
src/wscript
wscript
--- a/bindings/python/wscript	Wed Apr 22 13:59:10 2009 +0200
+++ b/bindings/python/wscript	Wed Apr 22 17:22:41 2009 +0200
@@ -445,6 +445,10 @@
         pymod.target = 'ns3/_ns3'
         pymod.name = 'ns3module'
         pymod.uselib_local = "ns3"
+        if pymod.env['ENABLE_STATIC_NS3']:
+            pymod.env.append_value('LINKFLAGS', '-Wl,--whole-archive,-Bstatic')
+            pymod.env.append_value('LINKFLAGS', '-lns3')
+            pymod.env.append_value('LINKFLAGS', '-Wl,-Bdynamic,--no-whole-archive')
 
         defines = list(pymod.env['CXXDEFINES'])
         defines.extend(['NS_DEPRECATED=', 'NS3_DEPRECATED_H'])
--- a/src/wscript	Wed Apr 22 13:59:10 2009 +0200
+++ b/src/wscript	Wed Apr 22 17:22:41 2009 +0200
@@ -74,6 +74,14 @@
     module.module_deps = list(dependencies)
     if not module.env['ENABLE_STATIC_NS3']:
         module.env.append_value('CXXFLAGS', module.env['shlib_CXXFLAGS'])
+    elif module.env['CXX_NAME'] == 'gcc' and \
+            os.uname()[4] == 'x86_64' and \
+            module.env['ENABLE_PYTHON_BINDINGS']:
+        # enable that flag for static builds only on x86-64 platforms
+        # when gcc is present and only when we want python bindings
+        # (it's more efficient to not use this option if we can avoid it)
+        module.env.append_value('CXXFLAGS', '-mcmodel=large')
+        
     module.env.append_value('CXXDEFINES', "NS3_MODULE_COMPILATION")
     return module
 
--- a/wscript	Wed Apr 22 13:59:10 2009 +0200
+++ b/wscript	Wed Apr 22 17:22:41 2009 +0200
@@ -291,7 +291,6 @@
     conf.find_program('valgrind', var='VALGRIND')
 
     if Options.options.enable_static and \
-            not conf.env['ENABLE_PYTHON_BINDINGS'] and \
             env['PLATFORM'].startswith('linux'):
         conf.env['ENABLE_STATIC_NS3'] = Options.options.enable_static