build: fixed a typo that prevented --bundled-libraries from working correctly
[samba.git] / buildtools / wafsamba / samba_autoconf.py
index 4ee0852b75ac862f6720ceb481eb868ae702af43..cbb10a27caf49b0da61ff5ec1e4a81b90bbc0478 100644 (file)
@@ -1,9 +1,10 @@
 # a waf tool to add autoconf-like macros to the configure section
 
-import Build, os, Options, preproc
+import Build, os, Options, preproc, Logs
 import string
 from Configure import conf
 from samba_utils import *
+import samba_cross
 
 missing_headers = set()
 
@@ -204,7 +205,7 @@ def CHECK_VARIABLE(conf, v, define=None, always=False,
 
 
 @conf
-def CHECK_DECLS(conf, vars, reverse=False, headers=None):
+def CHECK_DECLS(conf, vars, reverse=False, headers=None, always=False):
     '''check a list of variable declarations, using the HAVE_DECL_xxx form
        of define
 
@@ -219,7 +220,8 @@ def CHECK_DECLS(conf, vars, reverse=False, headers=None):
         if not CHECK_VARIABLE(conf, v,
                               define=define,
                               headers=headers,
-                              msg='Checking for declaration of %s' % v):
+                              msg='Checking for declaration of %s' % v,
+                              always=always):
             ret = False
     return ret
 
@@ -366,6 +368,8 @@ def CHECK_CODE(conf, code, define,
     cflags = TO_LIST(cflags)
     cflags.extend(ccflags)
 
+    exec_args = conf.SAMBA_CROSS_ARGS()
+
     ret = conf.check(fragment=fragment,
                      execute=execute,
                      define_name = define,
@@ -377,6 +381,7 @@ def CHECK_CODE(conf, code, define,
                      type=type,
                      msg=msg,
                      quote=quote,
+                     exec_args=exec_args,
                      define_ret=define_ret)
     if not ret and CONFIG_SET(conf, define):
         # sometimes conf.check() returns false, but it
@@ -449,14 +454,14 @@ def CHECK_LIB(conf, libs, mandatory=False, empty_decl=True):
     liblist  = TO_LIST(libs)
     ret = True
     for lib in liblist[:]:
-        if GET_TARGET_TYPE(conf, lib):
+        if GET_TARGET_TYPE(conf, lib) == 'SYSLIB':
             continue
 
         (ccflags, ldflags) = library_flags(conf, lib)
 
         if not conf.check(lib=lib, uselib_store=lib, ccflags=ccflags, ldflags=ldflags):
             if mandatory:
-                print("Mandatory library '%s' not found for functions '%s'" % (lib, list))
+                Logs.error("Mandatory library '%s' not found for functions '%s'" % (lib, list))
                 sys.exit(1)
             if empty_decl:
                 # if it isn't a mandatory library, then remove it from dependency lists
@@ -511,7 +516,7 @@ def CHECK_FUNCS_IN(conf, list, library, mandatory=False, checklibc=False,
     for lib in liblist[:]:
         if not GET_TARGET_TYPE(conf, lib) == 'SYSLIB':
             if mandatory:
-                print("Mandatory library '%s' not found for functions '%s'" % (lib, list))
+                Logs.error("Mandatory library '%s' not found for functions '%s'" % (lib, list))
                 sys.exit(1)
             # if it isn't a mandatory library, then remove it from dependency lists
             liblist.remove(lib)
@@ -541,11 +546,17 @@ 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 -Wfatal-errors -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 -Wno-format-y2k',
+        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)
 
+    if Options.options.picky_developer:
+        conf.ADD_CFLAGS('-Werror', testflags=True)
+
+    if Options.options.fatal_errors:
+        conf.ADD_CFLAGS('-Wfatal-errors', testflags=True)
+
     if Options.options.pedantic:
-       conf.ADD_CFLAGS('-W', testflags=True)
+        conf.ADD_CFLAGS('-W', testflags=True)
 
     if path is None:
         conf.write_config_header('config.h', top=True)
@@ -561,8 +572,6 @@ def CONFIG_PATH(conf, name, default):
             conf.env[name] = default
         else:
             conf.env[name] = conf.env['PREFIX'] + default
-    conf.define(name, conf.env[name], quote=True)
-
 
 @conf
 def ADD_CFLAGS(conf, flags, testflags=False):