start net offlinejoin composeodj
[gd/samba/.git] / wscript
diff --git a/wscript b/wscript
index f928b16a298ab54243d8113bdd0b2a2936f1c54e..d8220b350959f8e47c3ce72f66f3e3cd1399c71a 100644 (file)
--- a/wscript
+++ b/wscript
@@ -141,11 +141,21 @@ def configure(conf):
         conf.env.DEVELOPER = True
         # if we are in a git tree without a pre-commit hook, install a
         # simple default.
-        pre_commit_hook = os.path.join(Context.g_module.top, '.git/hooks/pre-commit')
-        if (os.path.isdir(os.path.dirname(pre_commit_hook)) and
-            not os.path.exists(pre_commit_hook)):
-            shutil.copy(os.path.join(Context.g_module.top, 'script/git-hooks/pre-commit-hook'),
-                        pre_commit_hook)
+        # we need git for 'waf dist'
+        githooksdir = None
+        conf.find_program('git', var='GIT')
+        if 'GIT' in conf.env:
+            githooksdir = conf.CHECK_COMMAND('%s rev-parse --git-path hooks' % conf.env.GIT[0],
+                               msg='Finding githooks directory',
+                               define=None,
+                               on_target=False)
+        if githooksdir and os.path.isdir(githooksdir):
+            pre_commit_hook = os.path.join(githooksdir, 'pre-commit')
+            if not os.path.exists(pre_commit_hook):
+                Logs.info("Installing script/git-hooks/pre-commit-hook as %s" %
+                          pre_commit_hook)
+                shutil.copy(os.path.join(Context.g_module.top, 'script/git-hooks/pre-commit-hook'),
+                            pre_commit_hook)
 
     conf.ADD_EXTRA_INCLUDES('#include/public #source4 #lib #source4/lib #source4/include #include #lib/replace')
 
@@ -380,6 +390,34 @@ def configure(conf):
                          msg="Checking compiler for full RELRO support"):
             conf.env['ENABLE_RELRO'] = True
 
+    #
+    # FreeBSD is broken. It doesn't include 'extern char **environ'
+    # in any shared library, but statically inside crt0.o.
+    #
+    # If we're running on a FreeBSD with the GNU linker ld we
+    # can get around this by explicitly telling the linker to
+    # ignore 'environ' as an unresolved symbol in a shared library.
+    #
+    # However, the clang linker ld.lld-XX is broken in that it
+    # doesn't have that option.
+    #
+    # First try to see if have '-Wl,--ignore-unresolved-symbol,environ'
+    # and just use that if so.
+    #
+    # If not, we have to use '-Wl,--allow-shlib-undefined' instead
+    # and remove all instances of '-Wl,-no-undefined'.
+
+    if sys.platform.startswith('freebsd'):
+        # Do we have Wl,--ignore-unresolved-symbol,environ ?
+        flag_added = conf.ADD_LDFLAGS('-Wl,--ignore-unresolved-symbol,environ', testflags=True)
+        if not flag_added:
+            # No, fall back to -Wl,--allow-shlib-undefined.
+            conf.ADD_LDFLAGS('-Wl,--allow-shlib-undefined', testflags=True)
+            # Remove any uses of '-Wl,-no-undefined'
+            conf.env['EXTRA_LDFLAGS'] = list(filter(('-Wl,-no-undefined').__ne__, conf.env['EXTRA_LDFLAGS']))
+            # And make sure we don't try and remove it again when 'allow_undefined_symbols=true'
+            conf.env.undefined_ldflags = []
+
     conf.SAMBA_CONFIG_H('include/config.h')
 
 def etags(ctx):