build: set shared libraries flags correctly on mac os X
authorMatthieu Patou <mat@matws.net>
Sat, 30 Oct 2010 12:50:33 +0000 (16:50 +0400)
committerMatthieu Patou <mat@samba.org>
Sat, 30 Oct 2010 13:45:18 +0000 (13:45 +0000)
buildtools/wafsamba/samba_conftests.py
buildtools/wafsamba/wscript
source4/wscript

index 8a57d20baa54b9c2f43297630d152e661c1e1ab3..49cd4ff17c7a6748efe0d60f424f269f9b795c9f 100644 (file)
@@ -93,6 +93,27 @@ def find_config_dir(conf):
         conf.fatal('cannot use the configuration test folder %r' % dir)
     return dir
 
+@conf
+def CHECK_SHLIB_W_PYTHON(conf, msg):
+    '''check if we need -undefined dynamic_lookup'''
+
+    dir = find_config_dir(conf)
+
+    env = conf.env
+
+    snip = '''
+#include <Python.h>
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+
+static PyObject *ldb_module = NULL;
+int foo(int v) {
+    extern char **environ;
+    environ[0] = 1;
+    ldb_module = PyImport_ImportModule("ldb");
+    return v * 2;
+}'''
+    return conf.check(features='cc cshlib',uselib='PYEMBED',fragment=snip,msg=msg)
 
 # this one is quite complex, and should probably be broken up
 # into several parts. I'd quite like to create a set of CHECK_COMPOUND()
index 49f1cf460496f182c42b52b21d94db6a66d39d04..90aeb45582c5f3895156d9c12fa65844835f5181 100644 (file)
@@ -275,8 +275,6 @@ def configure(conf):
     else:
         conf.ADD_CFLAGS('-fPIC', testflags=True)
 
-    if sys.platform == 'darwin':
-        conf.ADD_LDFLAGS('-fno-common', testflags=True)
     conf.CHECK_INLINE()
 
     # check for pkgconfig
index 45d147f8e55f3baaacc90a3db43a683e050395bf..333079d48b00c1c348a4775b90ba22d4c46d6562 100644 (file)
@@ -86,6 +86,11 @@ def configure(conf):
     conf.check_python_version((2,4,2))
     conf.check_python_headers(mandatory=True)
 
+    if not conf.env['HAVE_ENVIRON_DECL']:
+        if not conf.CHECK_SHLIB_W_PYTHON("Checking if -single_module is not needed"):
+            conf.env.append_value('shlib_LINKFLAGS', ['-single_module'])
+        if not conf.CHECK_SHLIB_W_PYTHON("Checking if -undefined dynamic_lookup is not need"):
+            conf.env.append_value('shlib_LINKFLAGS', ['-undefined', 'dynamic_lookup'])
     if int(conf.env['PYTHON_VERSION'][0]) >= 3:
         raise Utils.WafError('Python version 3.x is not supported by Samba yet')