build:wafsamba: dead code removal in gettext detection
[sfrench/samba-autobuild/.git] / buildtools / wafsamba / wscript
index 0e2afe11490c0cf1b452650f365c1a4a2727f5b7..f3e019c0b73bf4280e9038f68691461fac6c5b9c 100755 (executable)
@@ -41,10 +41,10 @@ def set_options(opt):
                    help=("comma separated list of libraries to not apply extension to [%s]" % extension_exception),
                    action="store", dest='PRIVATE_EXTENSION_EXCEPTION', default=extension_exception)
 
-    builtin_defauilt = Options.options['BUILTIN_LIBRARIES_DEFAULT']
+    builtin_default = Options.options['BUILTIN_LIBRARIES_DEFAULT']
     gr.add_option('--builtin-libraries',
-                   help=("command separated list of libraries to build directly into binaries [%s]" % builtin_defauilt),
-                   action="store", dest='BUILTIN_LIBRARIES', default=builtin_defauilt)
+                   help=("command separated list of libraries to build directly into binaries [%s]" % builtin_default),
+                   action="store", dest='BUILTIN_LIBRARIES', default=builtin_default)
 
     gr.add_option('--minimum-library-version',
                    help=("list of minimum system library versions (LIBNAME1:version,LIBNAME2:version)"),
@@ -78,9 +78,6 @@ def set_options(opt):
                    help='additional directory to search for libiconv',
                    action='store', dest='iconv_open', default='/usr/local',
                    match = ['Checking for library iconv', 'Checking for iconv_open', 'Checking for header iconv.h'])
-    opt.add_option('--with-gettext',
-                   help='additional directory to search for gettext',
-                   action='store', dest='gettext_location', default='None')
     opt.add_option('--without-gettext',
                    help=("Disable use of gettext"),
                    action="store_true", dest='disable_gettext', default=False)
@@ -117,6 +114,9 @@ def set_options(opt):
     gr.add_option('--git-local-changes',
                   help=("mark version with + if local git changes"),
                   action='store_true', dest='GIT_LOCAL_CHANGES', default=False)
+    gr.add_option('--address-sanitizer',
+                   help=("Enable address sanitizer compile and linker flags"),
+                   action="store_true", dest='address_sanitizer', default=False)
 
     gr.add_option('--abi-check',
                   help=("Check ABI signatures for libraries"),
@@ -192,6 +192,12 @@ def set_options(opt):
                    help='tag release in git at the same time',
                    type='string', action='store', dest='TAG_RELEASE')
 
+    opt.add_option('--extra-python', type=str,
+                    help=("build selected libraries for the specified "
+                          "additional version of Python "
+                          "(example: --extra-python=/usr/bin/python3)"),
+                    metavar="PYTHON", dest='EXTRA_PYTHON', default=None)
+
 
 @wafsamba.runonce
 def configure(conf):
@@ -211,6 +217,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')
 
@@ -230,7 +238,7 @@ def configure(conf):
         cc.run = Task.compile_fun_noshell('cc', '${CC} ${CCFLAGS} ${CPPFLAGS} ${_CCINCFLAGS} ${_CCDEFFLAGS} ${CC_SRC_F}${SRC} ${CC_TGT_F}${TGT[0].abspath(env)}')[0]
         try:
             try:
-                conf.check(features='cc testd', fragment='int main() {return 0;}\n', ccflags=['-MD'], mandatory=True, msg='Check for -MD')
+                conf.check(features='c testd', fragment='int main() {return 0;}\n', ccflags=['-MD'], mandatory=True, msg='Check for -MD')
             except:
                 pass
             else:
@@ -261,6 +269,8 @@ def configure(conf):
     conf.env.AUTOCONF_HOST  = Options.options.AUTOCONF_HOST
     conf.env.AUTOCONF_PROGRAM_PREFIX = Options.options.AUTOCONF_PROGRAM_PREFIX
 
+    conf.env.EXTRA_PYTHON = Options.options.EXTRA_PYTHON
+
     if (conf.env.AUTOCONF_HOST and
         conf.env.AUTOCONF_BUILD and
         conf.env.AUTOCONF_BUILD != conf.env.AUTOCONF_HOST):
@@ -341,6 +351,47 @@ 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)
+
+    # check HAVE_CONSTRUCTOR_ATTRIBUTE
+    conf.CHECK_CODE('''
+            void test_constructor_attribute(void) __attribute__ ((constructor));
+
+            void test_constructor_attribute(void)
+            {
+                return;
+            }
+
+            int main(void) {
+                return 0;
+            }
+            ''',
+            'HAVE_CONSTRUCTOR_ATTRIBUTE',
+            addmain=False,
+            msg='Checking for library constructor support')
+
+        # check HAVE_DESTRUCTOR_ATTRIBUTE
+    conf.CHECK_CODE('''
+            void test_destructor_attribute(void) __attribute__ ((destructor));
+
+            void test_destructor_attribute(void)
+            {
+                return;
+            }
+
+            int main(void) {
+                return 0;
+            }
+            ''',
+            'HAVE_DESTRUCTOR_ATTRIBUTE',
+            addmain=False,
+            msg='Checking for library destructor support')
+
     if sys.platform.startswith('aix'):
         conf.DEFINE('_ALL_SOURCE', 1, add_to_cflags=True)
         # Might not be needed if ALL_SOURCE is defined
@@ -371,7 +422,7 @@ def configure(conf):
     conf.CHECK_INLINE()
 
     # check for pkgconfig
-    conf.check_cfg(atleast_pkgconfig_version='0.0.0')
+    conf.CHECK_CFG(atleast_pkgconfig_version='0.0.0')
 
     conf.DEFINE('_GNU_SOURCE', 1, add_to_cflags=True)
     conf.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags=True)