waf: check the linker accepts a set of ldflags before using them
[abartlet/samba.git/.git] / buildtools / wafsamba / samba_autoconf.py
index 8cab1285956b075547c1d6a08d6882c74bd73b45..ea2ef0980687720e77117343ab1a6976d9c1bfa9 100644 (file)
@@ -436,6 +436,15 @@ def CHECK_CFLAGS(conf, cflags):
                       ccflags=cflags,
                       msg="Checking compiler accepts %s" % cflags)
 
+@conf
+def CHECK_LDFLAGS(conf, ldflags):
+    '''check if the given ldflags are accepted by the linker
+    '''
+    return conf.check(fragment='int main(void) { return 0; }\n',
+                      execute=0,
+                      ldflags=ldflags,
+                      msg="Checking linker accepts %s" % ldflags)
+
 
 @conf
 def CONFIG_SET(conf, option):
@@ -619,7 +628,7 @@ def ADD_LDFLAGS(conf, flags, testflags=False):
     if testflags:
         ok_flags=[]
         for f in flags.split():
-            if CHECK_CFLAGS(conf, f):
+            if CHECK_LDFLAGS(conf, f):
                 ok_flags.append(f)
         flags = ok_flags
     if not 'EXTRA_LDFLAGS' in conf.env: