build: cope with perl not being in /usr/bin/perl
[samba.git] / buildtools / wafsamba / samba_autoconf.py
index fcd900dec13c28d632e57434b3bd0a4b62ed2a60..dd7abe2864c810a4fb8e8bcd157437e8995d64c9 100644 (file)
@@ -4,6 +4,7 @@ import Build, os, Options, preproc, Logs
 import string
 from Configure import conf
 from samba_utils import *
+import samba_cross
 
 missing_headers = set()
 
@@ -187,9 +188,11 @@ def CHECK_VARIABLE(conf, v, define=None, always=False,
         msg="Checking for variable %s" % v
 
     return CHECK_CODE(conf,
+                      # we need to make sure the compiler doesn't
+                      # optimize it out...
                       '''
                       #ifndef %s
-                      void *_x; _x=(void *)&%s;
+                      void *_x; _x=(void *)&%s; return (int)_x;
                       #endif
                       return 0
                       ''' % (v, v),
@@ -204,7 +207,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 +222,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
 
@@ -262,7 +266,9 @@ def CHECK_FUNC(conf, f, link=True, lib=None, headers=None):
         if not ret:
             ret = CHECK_CODE(conf,
                              # it might be a macro
-                             'void *__x = (void *)%s' % f,
+                             # we need to make sure the compiler doesn't
+                             # optimize it out...
+                             'void *__x = (void *)%s; return (int)__x' % f,
                              execute=False,
                              link=True,
                              addmain=True,
@@ -366,6 +372,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 +385,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,7 +458,7 @@ 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)
@@ -529,6 +538,7 @@ def CHECK_FUNCS_IN(conf, list, library, mandatory=False, checklibc=False,
 def IN_LAUNCH_DIR(conf):
     '''return True if this rule is being run from the launch directory'''
     return os.path.realpath(conf.curdir) == os.path.realpath(Options.launch_dir)
+Options.Handler.IN_LAUNCH_DIR = IN_LAUNCH_DIR
 
 
 @conf
@@ -594,7 +604,7 @@ def ADD_EXTRA_INCLUDES(conf, includes):
 
 
 
-def CURRENT_CFLAGS(bld, target, cflags):
+def CURRENT_CFLAGS(bld, target, cflags, hide_symbols=False):
     '''work out the current flags. local flags are added first'''
     if not 'EXTRA_CFLAGS' in bld.env:
         list = []
@@ -602,6 +612,8 @@ def CURRENT_CFLAGS(bld, target, cflags):
         list = bld.env['EXTRA_CFLAGS'];
     ret = TO_LIST(cflags)
     ret.extend(list)
+    if hide_symbols and bld.env.HAVE_VISIBILITY_ATTR:
+        ret.append('-fvisibility=hidden')
     return ret