replace: Only include C files from which there are actually functions used.
authorJelmer Vernooij <jelmer@samba.org>
Tue, 31 Jan 2012 10:25:17 +0000 (11:25 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 31 Jan 2012 14:21:04 +0000 (15:21 +0100)
Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Tue Jan 31 15:21:04 CET 2012 on sn-devel-104

lib/replace/wscript

index e85d33cf611d5fbacb25aec50fdb2f157d685108..4b4f0a8a6a8b732b04ff819470b10547654d27ae 100644 (file)
@@ -401,13 +401,32 @@ def configure(conf):
     conf.SAMBA_CONFIG_H()
 
 
+REPLACEMENT_FUNCTIONS = {
+    'replace.c': ['ftruncate', 'strlcpy', 'strlcat', 'mktime', 'initgroups',
+                  'memmove', 'strdup', 'setlinebuf', 'vsyslog', 'strnlen',
+                  'strndup', 'waitpid', 'seteuid', 'setegid', 'chroot',
+                  'mkstemp', 'mkdtemp', 'pread', 'pwrite', 'strcasestr',
+                  'strtok_r', 'strtoll', 'strtoull', 'setenv', 'unsetenv',
+                  'utime', 'utimes', 'dup2', 'chown', 'link', 'readlink',
+                  'symlink', 'lchown', 'realpath', 'memmem', 'vdprintf',
+                  'dprintf', 'get_current_dir_name',
+                  'strerror_r', 'clock_gettime'],
+    'timegm.c': ['timegm'],
+    'snprintf.c': ['snprintf'],
+    }
+
+
 def build(bld):
     bld.RECURSE('buildtools/wafsamba')
 
-    REPLACE_HOSTCC_SOURCE = 'replace.c snprintf.c'
+    REPLACE_HOSTCC_SOURCE = ''
 
     if bld.CONFIG_SET('REPLACE_STRPTIME'):       REPLACE_HOSTCC_SOURCE += ' strptime.c'
-    if not bld.CONFIG_SET('HAVE_TIMEGM'):        REPLACE_HOSTCC_SOURCE += ' timegm.c'
+    for filename, functions in REPLACEMENT_FUNCTIONS.iteritems():
+        for function in functions:
+            if not bld.CONFIG_SET('HAVE_%s' % function.upper()):
+                REPLACE_HOSTCC_SOURCE += ' %s' % filename
+                break
 
     bld.SAMBA_SUBSYSTEM('LIBREPLACE_HOSTCC',
         REPLACE_HOSTCC_SOURCE,