[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu Jan 8 18:03:04 MST 2015


The branch, master has been updated
       via  115eb94 wafadmin: backported the openbsd fixes from waf 1.7
       via  9f2979a wafsamba: remove commented out code.
       via  ffff95d Revert "waf: added suncc_wrap"
       via  d7bd51a wafsamba: generate an empty.c file if a SAMBA_{LIBRARY,SUBSYSTEM} doesn't have any source files
       via  a6bda1f wafsamba: flags from enviroment are put before our own internal versions
       via  707dc16 wafsamba: filter out standard library paths from RPATH and LIBPATH
       via  dc808a4 wafsamba: fix ordering problems with lib-provided and internal RPATHs
       via  d744c7c wafsamba: make it possible to specify ADDITIONAL_{CFLAGS,LDFLAGS} as env var to ./configure
       via  46fdd62 wafsamba: improve -fvisibility=hidden, we should check it together this WERROR_CFLAGS
       via  52eb885 wafsamba: let CURRENT_CFLAGS() use bld.env.VISIBILITY_CFLAGS
       via  4683fc0 wafsamba: move -fvisibility=hidden checks from lib/replace to wafsamba
       via  208be32 wafsamba: move '-fstack-protector' checks from lib/replace to wafsamba
       via  0f4ce41 wafsamba: move WERROR_CFLAGS checks from lib/replace to wafsamba
       via  7a3dc66 wafsamba: move compiler / cflags related stuff from lib/replace to wafsamba
       via  ab4b988 wafsamba: let TO_LIST(mylist) return a copy of mylist
       via  56e2384 vfs_fruit: mmap under FreeBSD needs PROT_READ
      from  87c1765 lib/util: Avoid collision which alread defined consumer DEBUG macro.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 115eb94215f4d9c73d05606de2ad978f6b48d07f
Author: Thomas Nagy <tnagy2pow10 at gmail.com>
Date:   Tue Sep 17 00:00:40 2013 +0200

    wafadmin: backported the openbsd fixes from waf 1.7
    
    This is a backport from waf 1.5...
    
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Jan  9 02:02:07 CET 2015 on sn-devel-104

commit 9f2979a1a42f4714bdc49d09e4b5094333409834
Author: Michael Adam <obnox at samba.org>
Date:   Mon Dec 22 11:30:21 2014 +0100

    wafsamba: remove commented out code.
    
    This code has only ever been there as commented out...
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit ffff95d421e3ca7fa31ec668a2e8fc7fdaee05df
Author: Michael Adam <obnox at samba.org>
Date:   Mon Dec 22 11:27:40 2014 +0100

    Revert "waf: added suncc_wrap"
    
    This reverts commit 65743f932b511db009655847e77288c95c0aa525.
    
    Conflicts:
    	buildtools/wafsamba/samba_optimisation.py
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit d7bd51a79d0784d3db809c0c5e82193f79799dc3
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Dec 19 13:10:30 2014 +0100

    wafsamba: generate an empty.c file if a SAMBA_{LIBRARY,SUBSYSTEM} doesn't have any source files
    
    This is better than passing '-' as filename to the compiler/linker.
    This replaces commit 65743f932b511db009655847e77288c95c0aa525.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=9334
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10315
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit a6bda1f2bc85779feb9680bc74821da5ccd401c5
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Dec 19 09:05:33 2014 +0100

    wafsamba: flags from enviroment are put before our own internal versions
    
    Ensure user provided CPPFLAGS and LDFLAGS are put *behind* our
    internally computed compiler and linker flags.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10877
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>

commit 707dc16987c982b75c83cd5b06d4373c23e777e0
Author: Michael Adam <obnox at samba.org>
Date:   Thu Dec 18 21:36:07 2014 +0100

    wafsamba: filter out standard library paths from RPATH and LIBPATH
    
    We should avoid passing them explicitly to the compiler/linker.
    
    We ask the compiler with the '-print-search-dirs' argument
    or fallback to [ '/usr/lib', '/usr/lib64' ].
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dc808a466ef835535a3d4bb87f19316eeff1c567
Author: Michael Adam <obnox at samba.org>
Date:   Thu Dec 18 18:09:15 2014 +0100

    wafsamba: fix ordering problems with lib-provided and internal RPATHs
    
    When a library or system (like cups) provides an RPATH,
    e.g. with -Wl,-R or -Wl,-rpath, this was added by waf
    to the LINKFLAGS, wich was later prepended to our RPATH.
    But if the path by chance contains an older version of
    one of our internal libraries like talloc, this would lead
    to linking the too old talloc into our binaries.
    
    This has been observed on, e.g., FreeBSD, but it is a general
    problem.
    
    This patch fixes the problem by specially parsing the RPATH
    linker options from the pkg-config(, cups-config, ....) output
    and putting the paths into the RPATH_<lib> container, which
    is then later correctly appended to our internal RPATH.
    
    This is a better fix than commit 64f5e24100a764ec198cab9a8d2c43fa86e7027c
    as it touches wafsamba only. 64f5e24100a764ec198cab9a8d2c43fa86e7027c
    is already in waf 1.5 upstream, but has some possible bugs,
    e.g. it doesn't handle -Wl,-R, (with ',' at the end)
    or some combinations where the path is given via an additional
    -Wl,/path argument.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=10548
    
    Pair-Programmed-With: Stefan Metzmacher <metze at samba.org>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d744c7c080d81121b84a592a95761e03c2a1090c
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Jan 7 11:13:04 2015 +0100

    wafsamba: make it possible to specify ADDITIONAL_{CFLAGS,LDFLAGS} as env var to ./configure
    
    CFLAGS and LDFLAGS are also used during the configure checks and might impact
    their results.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 46fdd6221e9c64b459e0d05e6d02d89deb8dafb5
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Jan 7 09:16:57 2015 +0100

    wafsamba: improve -fvisibility=hidden, we should check it together this WERROR_CFLAGS
    
    GCC ignores -fvisibility=hidden with a warning instead of failing
    om some platforms (e.g. Solaris).
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11031
    
    Based on a patch from Tom Schulz <schulz at adi.com>.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 52eb8854ff8535577c9282f8e4133875fbb0ed33
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Jan 7 09:58:38 2015 +0100

    wafsamba: let CURRENT_CFLAGS() use bld.env.VISIBILITY_CFLAGS
    
    This is better than a hardcoded value in multiple places.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 4683fc0f1dc5af3bcf81edaebfbd6c8d3b38df9e
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Jan 7 09:56:56 2015 +0100

    wafsamba: move -fvisibility=hidden checks from lib/replace to wafsamba
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 208be32c6a9b275c507fb5e3334b832a3cb9578a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Jan 7 09:54:43 2015 +0100

    wafsamba: move '-fstack-protector' checks from lib/replace to wafsamba
    
    This moves the check to the end of the configure run,
    which means we no longer use this on configure checks,
    but only for the real build.
    
    This behavior is similar than our developer cflags.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 0f4ce418ae1410a294aa6e629beea68c6a16aff8
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Jan 7 09:52:53 2015 +0100

    wafsamba: move WERROR_CFLAGS checks from lib/replace to wafsamba
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 7a3dc668528f398458851aca5d27ff789414343a
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Jan 7 09:48:38 2015 +0100

    wafsamba: move compiler / cflags related stuff from lib/replace to wafsamba
    
    We should have this just in one central place.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit ab4b988ba2ba85ec2bfb01d7711d6870b3e0f710
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Jan 7 09:41:02 2015 +0100

    wafsamba: let TO_LIST(mylist) return a copy of mylist
    
    In most cases we have TO_LIST(mystring) which returns an independent
    list.
    
    newlist = TO_LIST(mylist) returned just a reference to mylist.
    Which means newlist.append("end") would also modify mylist.
    
    TO_LIST() should always return an independent list.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 56e2384dfe29fd8f16b9d0cf7264f9bb8ed38966
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jan 8 17:14:37 2015 +0100

    vfs_fruit: mmap under FreeBSD needs PROT_READ
    
    We memmove, which does read
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Böhme <rb at sernet.de>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 buildtools/wafadmin/Tools/ccroot.py       |  18 +++--
 buildtools/wafadmin/Tools/gcc.py          |   4 ++
 buildtools/wafadmin/Tools/gxx.py          |   4 ++
 buildtools/wafsamba/samba_autoconf.py     |  19 ++++-
 buildtools/wafsamba/samba_conftests.py    |  82 ++++++++++++++++++++++
 buildtools/wafsamba/samba_optimisation.py | 113 ++++++++++++++++++------------
 buildtools/wafsamba/samba_utils.py        |   3 +-
 buildtools/wafsamba/wafsamba.py           |  29 ++++++--
 buildtools/wafsamba/wscript               |  43 ++++++++++++
 lib/replace/wscript                       |  45 ------------
 source3/modules/vfs_fruit.c               |   2 +-
 11 files changed, 256 insertions(+), 106 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildtools/wafadmin/Tools/ccroot.py b/buildtools/wafadmin/Tools/ccroot.py
index 264bdc7..d59cf26 100644
--- a/buildtools/wafadmin/Tools/ccroot.py
+++ b/buildtools/wafadmin/Tools/ccroot.py
@@ -177,10 +177,14 @@ def get_target_name(self):
 
 	dir, name = os.path.split(self.target)
 
-	if self.env.DEST_BINFMT == 'pe' and getattr(self, 'vnum', None) and 'cshlib' in self.features:
-		# include the version in the dll file name,
-		# the import lib file name stays unversionned.
-		name = name + '-' + self.vnum.split('.')[0]
+	if 'cshlib' in self.features and getattr(self, 'vnum', None):
+		nums = self.vnum.split('.')
+		if self.env.DEST_BINFMT == 'pe':
+			# include the version in the dll file name,
+			# the import lib file name stays unversionned.
+			name = name + '-' + nums[0]
+		elif self.env.DEST_OS == 'openbsd':
+			pattern = '%s.%s.%s' % (pattern, nums[0], nums[1])
 
 	return os.path.join(dir, pattern % name)
 
@@ -598,14 +602,16 @@ def apply_vnum(self):
 	if not path: return
 
 	if self.env.DEST_OS == 'openbsd':
-		bld.install_as(path + os.sep + name2, node, env=self.env, chmod=self.link_task.chmod)
+		libname = self.link_task.outputs[0].name
+		bld.install_as('%s%s%s' % (path, os.sep, libname), node, env=self.env)
 	else:
 		bld.install_as(path + os.sep + name3, node, env=self.env)
 		bld.symlink_as(path + os.sep + name2, name3)
 		bld.symlink_as(path + os.sep + libname, name3)
 
 	# the following task is just to enable execution from the build dir :-/
-	self.create_task('vnum', node, [node.parent.find_or_declare(name2), node.parent.find_or_declare(name3)])
+	if self.env.DEST_OS != 'openbsd':
+		self.create_task('vnum', node, [node.parent.find_or_declare(name2), node.parent.find_or_declare(name3)])
 
 def exec_vnum_link(self):
 	for x in self.outputs:
diff --git a/buildtools/wafadmin/Tools/gcc.py b/buildtools/wafadmin/Tools/gcc.py
index 420b44f..a6be0b2 100644
--- a/buildtools/wafadmin/Tools/gcc.py
+++ b/buildtools/wafadmin/Tools/gcc.py
@@ -114,6 +114,10 @@ def gcc_modifier_aix(conf):
 	v['SHLIB_MARKER']        = ''
 
 @conftest
+def gcc_modifier_openbsd(conf):
+	conf.env['SONAME_ST'] = []
+
+ at conftest
 def gcc_modifier_platform(conf):
 	# * set configurations specific for a platform.
 	# * the destination platform is detected automatically by looking at the macros the compiler predefines,
diff --git a/buildtools/wafadmin/Tools/gxx.py b/buildtools/wafadmin/Tools/gxx.py
index 8f4a0bf..4984122 100644
--- a/buildtools/wafadmin/Tools/gxx.py
+++ b/buildtools/wafadmin/Tools/gxx.py
@@ -112,6 +112,10 @@ def gxx_modifier_aix(conf):
 	v['SHLIB_MARKER']        = ''
 
 @conftest
+def gxx_modifier_openbsd(conf):
+	conf.env['SONAME_ST'] = []
+
+ at conftest
 def gxx_modifier_platform(conf):
 	# * set configurations specific for a platform.
 	# * the destination platform is detected automatically by looking at the macros the compiler predefines,
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index 9e50ee5..8d84a5e 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -646,6 +646,10 @@ def SAMBA_CONFIG_H(conf, path=None):
     if not IN_LAUNCH_DIR(conf):
         return
 
+    if conf.CHECK_CFLAGS(['-fstack-protector']) and conf.CHECK_LDFLAGS(['-fstack-protector']):
+        conf.ADD_CFLAGS('-fstack-protector')
+        conf.ADD_LDFLAGS('-fstack-protector')
+
     if Options.options.debug:
         conf.ADD_CFLAGS('-g', testflags=True)
 
@@ -699,6 +703,19 @@ int main(void) {
     if Options.options.pedantic:
         conf.ADD_CFLAGS('-W', testflags=True)
 
+
+    # Let people pass an additional ADDITIONAL_{CFLAGS,LDFLAGS}
+    # environment variables which are only used the for final build.
+    #
+    # The CFLAGS and LDFLAGS environment variables are also
+    # used for the configure checks which might impact their results.
+    conf.add_os_flags('ADDITIONAL_CFLAGS')
+    if conf.env.ADDITIONAL_CFLAGS and conf.CHECK_CFLAGS(conf.env['ADDITIONAL_CFLAGS']):
+        conf.env['EXTRA_CFLAGS'].extend(conf.env['ADDITIONAL_CFLAGS'])
+    conf.add_os_flags('ADDITIONAL_LDFLAGS')
+    if conf.env.ADDITIONAL_LDFLAGS and conf.CHECK_LDFLAGS(conf.env['ADDITIONAL_LDFLAGS']):
+        conf.env['EXTRA_LDFLAGS'].extend(conf.env['ADDITIONAL_LDFLAGS'])
+
     if path is None:
         conf.write_config_header('config.h', top=True)
     else:
@@ -777,7 +794,7 @@ def CURRENT_CFLAGS(bld, target, cflags, allow_warnings=False, hide_symbols=False
         list = bld.env['PICKY_CFLAGS'];
         ret.extend(list)
     if hide_symbols and bld.env.HAVE_VISIBILITY_ATTR:
-        ret.append('-fvisibility=hidden')
+        ret.append(bld.env.VISIBILITY_CFLAGS)
     return ret
 
 
diff --git a/buildtools/wafsamba/samba_conftests.py b/buildtools/wafsamba/samba_conftests.py
index ec98ba0..1afc6c9 100644
--- a/buildtools/wafsamba/samba_conftests.py
+++ b/buildtools/wafsamba/samba_conftests.py
@@ -4,6 +4,7 @@
 import os, shutil, re
 import Build, Configure, Utils
 from Configure import conf
+import config_c
 from samba_utils import *
 
 
@@ -506,3 +507,84 @@ def CHECK_XSLTPROC_MANPAGES(conf):
     if not conf.CONFIG_SET('XSLTPROC_MANPAGES'):
         print "A local copy of the docbook.xsl wasn't found on your system" \
               " consider installing package like docbook-xsl"
+
+#
+# Determine the standard libpath for the used compiler,
+# so we can later use that to filter out these standard
+# library paths when some tools like cups-config or
+# python-config report standard lib paths with their
+# ldflags (-L...)
+#
+ at conf
+def CHECK_STANDARD_LIBPATH(conf):
+    # at least gcc and clang support this:
+    try:
+        cmd = conf.env.CC + ['-print-search-dirs']
+        out = Utils.cmd_output(cmd).split('\n')
+    except ValueError:
+        # option not supported by compiler - use a standard list of directories
+        dirlist = [ '/usr/lib', '/usr/lib64' ]
+    except:
+        raise Utils.WafError('Unexpected error running "%s"' % (cmd))
+    else:
+        dirlist = []
+        for line in out:
+            line = line.strip()
+            if line.startswith("libraries: ="):
+                dirliststr = line[len("libraries: ="):]
+                dirlist = [ os.path.normpath(x) for x in dirliststr.split(':') ]
+                break
+
+    conf.env.STANDARD_LIBPATH = dirlist
+
+
+waf_config_c_parse_flags = config_c.parse_flags;
+def samba_config_c_parse_flags(line1, uselib, env):
+    #
+    # We do a special treatment of the rpath components
+    # in the linkflags line, because currently the upstream
+    # parse_flags function is incomplete with respect to
+    # treatment of the rpath. The remainder of the linkflags
+    # line is later passed to the original funcion.
+    #
+    lst1 = shlex.split(line1)
+    lst2 = []
+    while lst1:
+        x = lst1.pop(0)
+
+        #
+        # NOTE on special treatment of -Wl,-R and -Wl,-rpath:
+        #
+        # It is important to not put a library provided RPATH
+        # into the LINKFLAGS but in the RPATH instead, since
+        # the provided LINKFLAGS get prepended to our own internal
+        # RPATH later, and hence can potentially lead to linking
+        # in too old versions of our internal libs.
+        #
+        # We do this filtering here on our own because of some
+        # bugs in the real parse_flags() function.
+        #
+        if x == '-Wl,-rpath' or x == '-Wl,-R':
+            linkflags.remove(x)
+            x = lst1.pop(0)
+            if x.startswith('-Wl,'):
+                rpath = x[4:]
+            else:
+                rpath = x
+        elif x.startswith('-Wl,-R,'):
+            rpath = x[7:]
+        elif x.startswith('-Wl,-R'):
+            rpath = x[6:]
+        elif x.startswith('-Wl,-rpath,'):
+            rpath = x[11:]
+        else:
+            lst2.append(x)
+            continue
+
+        env.append_value('RPATH_' + uselib, rpath)
+
+    line2 = ' '.join(lst2)
+    waf_config_c_parse_flags(line2, uselib, env)
+
+    return
+config_c.parse_flags = samba_config_c_parse_flags
diff --git a/buildtools/wafsamba/samba_optimisation.py b/buildtools/wafsamba/samba_optimisation.py
index 1333f8b..5def580 100644
--- a/buildtools/wafsamba/samba_optimisation.py
+++ b/buildtools/wafsamba/samba_optimisation.py
@@ -6,9 +6,10 @@
 
 # overall this makes some build tasks quite a bit faster
 
+import os
 import Build, Utils, Node
-from TaskGen import feature, after
-import preproc, Task
+from TaskGen import feature, after, before
+import preproc
 
 @feature('cc', 'cxx')
 @after('apply_type_vars', 'apply_lib_vars', 'apply_core')
@@ -123,50 +124,6 @@ def hash_constraints(self):
     return sum
 Task.TaskBase.hash_constraints = hash_constraints
 
-
-# import cc
-# from TaskGen import extension
-# import Utils
-
-# @extension(cc.EXT_CC)
-# def c_hook(self, node):
-#     task = self.create_task('cc', node, node.change_ext('.o'))
-#     try:
-#         self.compiled_tasks.append(task)
-#     except AttributeError:
-#         raise Utils.WafError('Have you forgotten to set the feature "cc" on %s?' % str(self))
-
-#     bld = self.bld
-#     try:
-#         dc = bld.dc
-#     except AttributeError:
-#         dc = bld.dc = {}
-
-#     if task.outputs[0].id in dc:
-#         raise Utils.WafError('Samba, you are doing it wrong %r %s %s' % (task.outputs, task.generator, dc[task.outputs[0].id].generator))
-#     else:
-#         dc[task.outputs[0].id] = task
-
-#     return task
-
-
-def suncc_wrap(cls):
-    '''work around a problem with cc on solaris not handling module aliases
-    which have empty libs'''
-    if getattr(cls, 'solaris_wrap', False):
-        return
-    cls.solaris_wrap = True
-    oldrun = cls.run
-    def run(self):
-        if self.env.CC_NAME == "sun" and not self.inputs:
-            self.env = self.env.copy()
-            self.env.append_value('LINKFLAGS', '-')
-        return oldrun(self)
-    cls.run = run
-suncc_wrap(Task.TaskBase.classes['cc_link'])
-
-
-
 def hash_env_vars(self, env, vars_lst):
     idx = str(id(env)) + str(vars_lst)
     try:
@@ -308,3 +265,67 @@ def apply_lib_vars(self):
             val = self.env[v + '_' + x]
             if val:
                 self.env.append_value(v, val)
+
+ at feature('cprogram', 'cshlib', 'cstaticlib')
+ at after('apply_lib_vars')
+ at before('apply_obj_vars')
+def samba_before_apply_obj_vars(self):
+    """before apply_obj_vars for uselib, this removes the standard pathes"""
+
+    def is_standard_libpath(env, path):
+        for _path in env.STANDARD_LIBPATH:
+            if _path == os.path.normpath(path):
+                return True
+        return False
+
+    v = self.env
+
+    for i in v['RPATH']:
+        if is_standard_libpath(v, i):
+            v['RPATH'].remove(i)
+
+    for i in v['LIBPATH']:
+        if is_standard_libpath(v, i):
+            v['LIBPATH'].remove(i)
+
+ at feature('cc')
+ at before('apply_incpaths', 'apply_obj_vars_cc')
+def samba_stash_cppflags(self):
+    """Fix broken waf ordering of CPPFLAGS"""
+
+    self.env.SAVED_CPPFLAGS = self.env.CPPFLAGS
+    self.env.CPPFLAGS = []
+
+ at feature('cc')
+ at after('apply_incpaths', 'apply_obj_vars_cc')
+def samba_pop_cppflags(self):
+    """append stashed user CPPFLAGS after our internally computed flags"""
+
+    #
+    # Note that we don't restore the values to 'CPPFLAGS',
+    # but to _CCINCFLAGS instead.
+    #
+    # buildtools/wafadmin/Tools/cc.py defines the 'cc' task generator as
+    # '${CC} ${CCFLAGS} ${CPPFLAGS} ${_CCINCFLAGS} ${_CCDEFFLAGS} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT}'
+    #
+    # Our goal is to effectively invert the order of ${CPPFLAGS} and
+    # ${_CCINCFLAGS}.
+    self.env.append_value('_CCINCFLAGS', self.env.SAVED_CPPFLAGS)
+    self.env.SAVED_CPPFLAGS = []
+
+ at feature('cprogram', 'cshlib', 'cstaticlib')
+ at before('apply_obj_vars', 'add_extra_flags')
+def samba_stash_linkflags(self):
+    """stash away LINKFLAGS in order to fix waf's broken ordering wrt or
+    user LDFLAGS"""
+
+    self.env.SAVE_LINKFLAGS = self.env.LINKFLAGS
+    self.env.LINKFLAGS = []
+
+ at feature('cprogram', 'cshlib', 'cstaticlib')
+ at after('apply_obj_vars', 'add_extra_flags')
+def samba_pop_linkflags(self):
+    """after apply_obj_vars append saved LDFLAGS"""
+
+    self.env.append_value('LINKFLAGS', self.env.SAVE_LINKFLAGS)
+    self.env.SAVE_LINKFLAGS = []
diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py
index 0b0bb48..9ac1066 100644
--- a/buildtools/wafsamba/samba_utils.py
+++ b/buildtools/wafsamba/samba_utils.py
@@ -214,7 +214,8 @@ def TO_LIST(str, delimiter=None):
     if str is None:
         return []
     if isinstance(str, list):
-        return str
+        # we need to return a new independent list...
+        return list(str)
     if len(str) == 0:
         return []
     lst = str.split(delimiter)
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index 5fef9be..82a9d6f 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -94,6 +94,11 @@ def ADD_INIT_FUNCTION(bld, subsystem, target, init_function):
 Build.BuildContext.ADD_INIT_FUNCTION = ADD_INIT_FUNCTION
 
 
+def generate_empty_file(task):
+    target_fname = installed_location=task.outputs[0].bldpath(task.env)
+    target_file = open(installed_location, 'w')
+    target_file.close()
+    return 0
 
 #################################################################
 def SAMBA_LIBRARY(bld, libname, source,
@@ -149,9 +154,15 @@ def SAMBA_LIBRARY(bld, libname, source,
         source = bld.SUBDIR(subdir, source)
 
     # remember empty libraries, so we can strip the dependencies
-    if ((source == '') or (source == [])) and deps == '' and public_deps == '':
-        SET_TARGET_TYPE(bld, libname, 'EMPTY')
-        return
+    if ((source == '') or (source == [])):
+        if deps == '' and public_deps == '':
+            SET_TARGET_TYPE(bld, libname, 'EMPTY')
+            return
+        empty_c = libname + '.empty.c'
+        bld.SAMBA_GENERATOR('%s_empty_c' % libname,
+                            rule=generate_empty_file,
+                            target=empty_c)
+        source=empty_c
 
     if BUILTIN_LIBRARY(bld, libname):
         obj_target = libname
@@ -537,9 +548,15 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
         return
 
     # remember empty subsystems, so we can strip the dependencies
-    if ((source == '') or (source == [])) and deps == '' and public_deps == '':
-        SET_TARGET_TYPE(bld, modname, 'EMPTY')
-        return
+    if ((source == '') or (source == [])):
+        if deps == '' and public_deps == '':
+            SET_TARGET_TYPE(bld, modname, 'EMPTY')
+            return
+        empty_c = modname + '.empty.c'
+        bld.SAMBA_GENERATOR('%s_empty_c' % modname,
+                            rule=generate_empty_file,
+                            target=empty_c)
+        source=empty_c
 
     if not SET_TARGET_TYPE(bld, modname, 'SUBSYSTEM'):
         return
diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript
index 1a30d2f..c81a7b3 100755
--- a/buildtools/wafsamba/wscript
+++ b/buildtools/wafsamba/wscript
@@ -211,6 +211,8 @@ def configure(conf):
 
     conf.check_tool('compiler_cc')
 
+    conf.CHECK_STANDARD_LIBPATH()
+
     # we need git for 'waf dist'
     conf.find_program('git', var='GIT')
 
@@ -295,6 +297,19 @@ def configure(conf):
                     headers='stdio.h',
                     msg='Checking simple C program')
 
+    # Try to find the right extra flags for -Werror behaviour
+    for f in ["-Werror",       # GCC
+              "-errwarn=%all", # Sun Studio
+              "-qhalt=w",     # IBM xlc
+              "-w2",           # Tru64
+             ]:
+        if conf.CHECK_CFLAGS([f], '''
+'''):
+            if not 'WERROR_CFLAGS' in conf.env:
+                conf.env['WERROR_CFLAGS'] = []
+            conf.env['WERROR_CFLAGS'].extend([f])
+            break
+
     # check which compiler/linker flags are needed for rpath support
     if not conf.CHECK_LDFLAGS(['-Wl,-rpath,.']) and conf.CHECK_LDFLAGS(['-Wl,-R,.']):
         conf.env['RPATH_ST'] = '-Wl,-R,%s'
@@ -328,6 +343,13 @@ def configure(conf):
     else:
         conf.env.HAVE_LD_VERSION_SCRIPT = False
 
+    if conf.CHECK_CFLAGS(['-fvisibility=hidden'] + conf.env.WERROR_CFLAGS):
+        conf.env.VISIBILITY_CFLAGS = '-fvisibility=hidden'
+        conf.CHECK_CODE('''int main(void) { return 0; }
+                           __attribute__((visibility("default"))) void vis_foo2(void) {}''',
+                        cflags=conf.env.VISIBILITY_CFLAGS,
+                        define='HAVE_VISIBILITY_ATTR', addmain=False)
+
     if sys.platform.startswith('aix'):
         conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True)
         # Might not be needed if ALL_SOURCE is defined
@@ -363,6 +385,27 @@ def configure(conf):
     conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True)
     conf.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags=True)
 
+    # on Tru64 certain features are only available with _OSF_SOURCE set to 1
+    # and _XOPEN_SOURCE set to 600
+    if conf.env['SYSTEM_UNAME_SYSNAME'] == 'OSF1':
+        conf.DEFINE('_OSF_SOURCE', 1, add_to_cflags=True)
+        conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
+
+    # SCM_RIGHTS is only avail if _XOPEN_SOURCE iѕ defined on IRIX
+    if conf.env['SYSTEM_UNAME_SYSNAME'] == 'IRIX':
+        conf.DEFINE('_XOPEN_SOURCE', 600, add_to_cflags=True)
+        conf.DEFINE('_BSD_TYPES', 1, add_to_cflags=True)
+
+    # Try to find the right extra flags for C99 initialisers
+    for f in ["", "-AC99", "-qlanglvl=extc99", "-qlanglvl=stdc99", "-c99"]:
+        if conf.CHECK_CFLAGS([f], '''
+struct foo {int x;char y;};
+struct foo bar = { .y = 'X', .x = 1 };
+'''):
+            if f != "":
+                conf.ADD_CFLAGS(f)
+            break
+
     # get the base headers we'll use for the rest of the tests
     conf.CHECK_HEADERS('stdio.h sys/types.h sys/stat.h stdlib.h stddef.h memory.h string.h',
                        add_headers=True)
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 7bbe1d6..4d4d182 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -32,44 +32,6 @@ def configure(conf):
     conf.DEFINE('HAVE_LIBREPLACE', 1)
     conf.DEFINE('LIBREPLACE_NETWORK_CHECKS', 1)
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list