waf-1.6: Mac OSX and other fixes
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Tue, 13 Sep 2011 13:47:17 +0100
changeset 7494 d93f5e8e0a59
parent 7493 3bbefa91e694
child 7495 d87f20fd2421
waf-1.6: Mac OSX and other fixes
bindings/python/wscript
src/core/model/int64x64-128.h
src/emu/wscript
src/openflow/wscript
src/tap-bridge/wscript
src/visualizer/wscript
src/wscript
wscript
--- a/bindings/python/wscript	Mon Sep 12 19:19:00 2011 +0100
+++ b/bindings/python/wscript	Tue Sep 13 13:47:17 2011 +0100
@@ -14,6 +14,8 @@
 import Build
 import Utils
 
+from waflib.Errors import WafError
+
 ## https://launchpad.net/pybindgen/
 REQUIRED_PYBINDGEN_VERSION = (0, 15, 0, 795)
 REQUIRED_PYGCCXML_VERSION = (0, 9, 5)
@@ -52,10 +54,6 @@
                    help=("Don't build Python bindings."),
                    action="store_true", default=False,
                    dest='python_disable')
-    opt.add_option('--python-scan',
-                   help=("Rescan Python bindings.  Needs working GCCXML / pygccxml environment."),
-                   action="store_true", default=False,
-                   dest='python_scan')
     opt.add_option('--apiscan',
                    help=("EXPERIMENTAL: Rescan the API for the indicated module(s), for Python bindings.  "
                          "Needs working GCCXML / pygccxml environment.  "
@@ -103,6 +101,21 @@
         conf.report_optional_feature("python", "Python Bindings", False, str(ex))
         return
 
+    # stupid Mac OSX Python wants to build extensions as "universal
+    # binaries", i386, x86_64, and ppc, but this way the type
+    # __uint128_t is not available.  We need to disable the multiarch
+    # crap by removing the -arch parameters.
+    for flags_var in ["CFLAGS_PYEXT", "CFLAGS_PYEMBED", "CXXFLAGS_PYEMBED",
+                      "CXXFLAGS_PYEXT", "LINKFLAGS_PYEMBED", "LINKFLAGS_PYEXT"]:
+        flags = conf.env[flags_var]
+        i = 0
+        while i < len(flags):
+            if flags[i] == '-arch':
+                del flags[i]
+                del flags[i]
+                continue
+            i += 1
+        conf.env[flags_var] = flags
 
     if 0:
         # alternative code to computing PYTHONDIR, that is more correct than the one in waf 1.5.16
@@ -261,7 +274,10 @@
     
 
     ## Check gccxml version
-    gccxml = conf.find_program('gccxml', var='GCCXML')
+    try:
+        gccxml = conf.find_program('gccxml', var='GCCXML')
+    except WafError:
+        gccxml = None
     if not gccxml:
         Logs.warn("gccxml missing; automatic scanning of API definitions will not be possible")
         conf.report_optional_feature("pygccxml", "Python API Scanning Support", False,
--- a/src/core/model/int64x64-128.h	Mon Sep 12 19:19:00 2011 +0100
+++ b/src/core/model/int64x64-128.h	Tue Sep 13 13:47:17 2011 +0100
@@ -6,7 +6,7 @@
 #include <stdint.h>
 #include <math.h>
 
-#if defined(HAVE___UINT128_T)and !defined(HAVE_UINT128_T)
+#if defined(HAVE___UINT128_T) && !defined(HAVE_UINT128_T)
 typedef __uint128_t uint128_t;
 typedef __int128_t int128_t;
 #endif
--- a/src/emu/wscript	Mon Sep 12 19:19:00 2011 +0100
+++ b/src/emu/wscript	Tue Sep 13 13:47:17 2011 +0100
@@ -4,7 +4,7 @@
 
 def configure(conf):
     if conf.env['ENABLE_THREADING']:
-        conf.env['ENABLE_EMU'] = conf.check(header_name='netpacket/packet.h',
+        conf.env['ENABLE_EMU'] = conf.check_nonfatal(header_name='netpacket/packet.h',
                                             define_name='HAVE_PACKET_H')
         conf.report_optional_feature("EmuNetDevice", "Emulated Net Device",
                                      conf.env['ENABLE_EMU'],
--- a/src/openflow/wscript	Mon Sep 12 19:19:00 2011 +0100
+++ b/src/openflow/wscript	Tue Sep 13 13:47:17 2011 +0100
@@ -2,6 +2,7 @@
 
 import os
 import Options
+from waflib.Errors import WafError
 
 def options(opt):
     opt.add_option('--with-openflow',
@@ -10,17 +11,20 @@
     opt.tool_options('boost', tooldir=["waf-tools"])
 
 def configure(conf):
-    conf.check_tool('boost')
-    conf.env['BOOST'] = conf.check_boost(lib = 'signals filesystem',
-                                         kind = 'STATIC_BOTH',
-                                         score_version = (-1000, 1000),
-                                         tag_minscore = 1000)
-    if not conf.env['BOOST']:
+    try:
+        conf.check_tool('boost')
         conf.env['BOOST'] = conf.check_boost(lib = 'signals filesystem',
-                                            kind = 'STATIC_BOTH',
-                                            score_version = (-1000, 1000),
-                                            tag_minscore = 1000,
-                                            libpath="/usr/lib64")
+                                             kind = 'STATIC_BOTH',
+                                             score_version = (-1000, 1000),
+                                             tag_minscore = 1000)
+        if not conf.env['BOOST']:
+            conf.env['BOOST'] = conf.check_boost(lib = 'signals filesystem',
+                                                kind = 'STATIC_BOTH',
+                                                score_version = (-1000, 1000),
+                                                tag_minscore = 1000,
+                                                libpath="/usr/lib64")
+    except WafError:
+        conf.env['BOOST'] = False
 
     if not conf.env['BOOST']:
 	conf.report_optional_feature("openflow", "NS-3 OpenFlow Integration", False,
--- a/src/tap-bridge/wscript	Mon Sep 12 19:19:00 2011 +0100
+++ b/src/tap-bridge/wscript	Tue Sep 13 13:47:17 2011 +0100
@@ -4,7 +4,7 @@
 
 def configure(conf):
     if conf.env['ENABLE_THREADING']:
-        conf.env['ENABLE_TAP'] = conf.check(header_name='linux/if_tun.h',
+        conf.env['ENABLE_TAP'] = conf.check_nonfatal(header_name='linux/if_tun.h',
                                             define_name='HAVE_IF_TUN_H')
         conf.report_optional_feature("TapBridge", "Tap Bridge",
                                      conf.env['ENABLE_TAP'],
--- a/src/visualizer/wscript	Mon Sep 12 19:19:00 2011 +0100
+++ b/src/visualizer/wscript	Tue Sep 13 13:47:17 2011 +0100
@@ -36,8 +36,8 @@
         return
 
     module.features.append('pyembed')
-    module.env.append_value('CXXFLAGS', module.env['shlib_CXXFLAGS'])
-    module.includes = '.'
+    #module.env.append_value('CXXFLAGS', module.env['shlib_CXXFLAGS'])
+    #module.includes = '.'
 
     module.source.extend([
         'model/pyviz.cc',
--- a/src/wscript	Mon Sep 12 19:19:00 2011 +0100
+++ b/src/wscript	Tue Sep 13 13:47:17 2011 +0100
@@ -308,14 +308,14 @@
                 #mod = mod.split("--lib")[0]
                 pymod.env.append_value('LINKFLAGS', '-l' + mod)
             pymod.env.append_value('LINKFLAGS', '-Wl,-Bdynamic,--no-whole-archive')
-    defines = list(pymod.env['CXXDEFINES'])
+    defines = list(pymod.env['DEFINES'])
     defines.extend(['NS_DEPRECATED=', 'NS3_DEPRECATED_H'])
     if Options.platform == 'win32':
         try:
             defines.remove('_DEBUG') # causes undefined symbols on win32
         except ValueError:
             pass
-    pymod.env['CXXDEFINES'] = defines
+    pymod.env['DEFINES'] = defines
     pymod.includes = '# bindings'
     pymod.install_path = '${PYTHONDIR}/ns'
     return pymod
--- a/wscript	Mon Sep 12 19:19:00 2011 +0100
+++ b/wscript	Tue Sep 13 13:47:17 2011 +0100
@@ -24,6 +24,8 @@
 import Configure
 import Scripting
 
+from waflib.Errors import WafError
+
 from utils import read_config_file
 
 # By default, all modules will be enabled, examples will be disabled,
@@ -286,8 +288,8 @@
         env.append_value('LINKFLAGS', '-fprofile-arcs')
 
     if Options.options.build_profile == 'debug':
-        env.append_value('CXXDEFINES', 'NS3_ASSERT_ENABLE')
-        env.append_value('CXXDEFINES', 'NS3_LOG_ENABLE')
+        env.append_value('DEFINES', 'NS3_ASSERT_ENABLE')
+        env.append_value('DEFINES', 'NS3_LOG_ENABLE')
 
     env['PLATFORM'] = sys.platform
 
@@ -467,12 +469,10 @@
                                  conf.env['ENABLE_GSL'],
                                  "GSL not found")
     if have_gsl:
-        conf.env.append_value('CXXDEFINES', "ENABLE_GSL")
-        conf.env.append_value('CCDEFINES', "ENABLE_GSL")
+        conf.env.append_value('DEFINES', "ENABLE_GSL")
 
     # for compiling C code, copy over the CXX* flags
     conf.env.append_value('CCFLAGS', conf.env['CXXFLAGS'])
-    conf.env.append_value('CCDEFINES', conf.env['CXXDEFINES'])
 
     def add_gcc_flag(flag):
         if env['COMPILER_CXX'] == 'g++' and 'CXXFLAGS' not in os.environ:
@@ -486,7 +486,10 @@
     add_gcc_flag('-fstrict-aliasing')
     add_gcc_flag('-Wstrict-aliasing')
 
-    conf.find_program('doxygen', var='DOXYGEN')
+    try:
+        conf.find_program('doxygen', var='DOXYGEN')
+    except WafError:
+        pass
 
     # append user defined flags after all our ones
     for (confvar, envvar) in [['CCFLAGS', 'CCFLAGS_EXTRA'],