waf: put -Wl,-no-undefined only in the linker flags, not when compiling C
authorAndrew Tridgell <tridge@samba.org>
Mon, 18 Oct 2010 04:17:56 +0000 (15:17 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 19 Oct 2010 00:22:35 +0000 (11:22 +1100)
buildtools/wafsamba/samba_autoconf.py
buildtools/wafsamba/wafsamba.py
source4/heimdal_build/wscript_build

index 98352044b52fb34d865212ed3dc8238b68415ae1..dffc5f0bdb47f3aad26be9cd84a5397d68a81e37 100644 (file)
@@ -562,8 +562,10 @@ def SAMBA_CONFIG_H(conf, path=None):
 
     if Options.options.developer:
         # we add these here to ensure that -Wstrict-prototypes is not set during configure
-        conf.ADD_CFLAGS('-Wall -g -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 -Wno-format-y2k -Wl,-no-undefined',
+        conf.ADD_CFLAGS('-Wall -g -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 -Wno-format-y2k',
                         testflags=True)
+        conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
+
 
     if Options.options.picky_developer:
         conf.ADD_CFLAGS('-Werror', testflags=True)
@@ -605,6 +607,21 @@ def ADD_CFLAGS(conf, flags, testflags=False):
         conf.env['EXTRA_CFLAGS'] = []
     conf.env['EXTRA_CFLAGS'].extend(TO_LIST(flags))
 
+@conf
+def ADD_LDFLAGS(conf, flags, testflags=False):
+    '''add some LDFLAGS to the command line
+       optionally set testflags to ensure all the flags work
+    '''
+    if testflags:
+        ok_flags=[]
+        for f in flags.split():
+            if CHECK_CFLAGS(conf, f):
+                ok_flags.append(f)
+        flags = ok_flags
+    if not 'EXTRA_LDFLAGS' in conf.env:
+        conf.env['EXTRA_LDFLAGS'] = []
+    conf.env['EXTRA_LDFLAGS'].extend(TO_LIST(flags))
+
 
 
 @conf
@@ -629,6 +646,14 @@ def CURRENT_CFLAGS(bld, target, cflags, hide_symbols=False):
     return ret
 
 
+def CURRENT_LDFLAGS(bld, target, cflags, hide_symbols=False):
+    '''work out the current loader flags. local flags are added first'''
+    flags = CURRENT_CFLAGS(bld, target, cflags, hide_symbols=hide_symbols)
+    if 'EXTRA_LDFLAGS' in bld.env:
+        flags.extend(bld.env['EXTRA_LDFLAGS'])
+    return flags
+
+
 @conf
 def CHECK_CC_ENV(conf):
     """trim whitespaces from 'CC'.
index 02dc44a13966468dd775edd0c4ebc96108177ee7..e848d39333b00404c32f2cfabbf29304611ea6f2 100644 (file)
@@ -191,7 +191,7 @@ def SAMBA_LIBRARY(bld, libname, source,
         features        = features,
         source          = [],
         target          = bundled_name,
-        samba_cflags    = CURRENT_CFLAGS(bld, libname, cflags),
+        samba_cflags    = CURRENT_LDFLAGS(bld, libname, cflags),
         depends_on      = depends_on,
         samba_deps      = deps,
         samba_includes  = includes,
@@ -289,7 +289,7 @@ def SAMBA_BINARY(bld, binname, source,
         features       = features,
         source         = [],
         target         = binname,
-        samba_cflags   = CURRENT_CFLAGS(bld, binname, cflags),
+        samba_cflags   = CURRENT_LDFLAGS(bld, binname, cflags),
         samba_deps     = deps,
         samba_includes = includes,
         local_include  = local_include,
index 1a00bd5f4f8a3ec45d6c02e27a84515eac448ddf..cc5dcdc9d168d87cfc37ba2829933ddc6ace5672 100644 (file)
@@ -2,7 +2,7 @@
 
 import os
 from samba_utils import SET_TARGET_TYPE
-from samba_autoconf import CURRENT_CFLAGS
+from samba_autoconf import CURRENT_CFLAGS, CURRENT_LDFLAGS
 
 def to_list(str):
     '''Split a list, preserving quoted strings and existing lists'''
@@ -219,7 +219,7 @@ def HEIMDAL_LIBRARY(libname, source, deps, vnum,
         features        = features,
         source          = [],
         target          = bundled_name,
-        samba_cflags    = CURRENT_CFLAGS(bld, libname, cflags),
+        samba_cflags    = CURRENT_LDFLAGS(bld, libname, cflags),
         samba_deps      = deps,
         samba_includes  = includes,
         vnum            = vnum,
@@ -320,7 +320,7 @@ def HEIMDAL_BINARY(binname, source,
         features       = features,
         source         = [],
         target         = binname,
-        samba_cflags   = CURRENT_CFLAGS(bld, binname, cflags),
+        samba_cflags   = CURRENT_LDFLAGS(bld, binname, cflags),
         samba_deps     = deps,
         samba_includes = includes,
         local_include  = True,