s4-waf: fixed waf distcheck for our standalone libs and s4
[samba.git] / lib / replace / wscript
index b10db870540a9eb6d1eb92080c60403aac0b3614..511cbeac30f46767ef91e93bbc53e8ac61b1a915 100644 (file)
@@ -1,19 +1,31 @@
 #!/usr/bin/env python
 
-srcdir = '../..'
+APPNAME = 'libreplace'
+VERSION = '1.2.1'
+
 blddir = 'bin'
 
-import sys
-sys.path.insert(0, srcdir+"/buildtools/wafsamba")
-import wafsamba
+import sys, os, Utils
+
+# find the buildtools directory
+srcdir = '.'
+while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
+    srcdir = '../' + srcdir
+sys.path.insert(0, srcdir + '/buildtools/wafsamba')
+
+import wafsamba, samba_dist
 import Options, os, preproc
 
+samba_dist.DIST_DIRS('lib/replace buildtools:buildtools')
+
 def set_options(opt):
-    opt.recurse('../../buildtools/wafsamba')
+    opt.BUILTIN_DEFAULT('NONE')
+    opt.BUNDLED_EXTENSION_DEFAULT('')
+    opt.RECURSE('buildtools/wafsamba')
 
 @wafsamba.runonce
 def configure(conf):
-    conf.sub_config('../../buildtools/wafsamba')
+    conf.RECURSE('buildtools/wafsamba')
 
     conf.DEFINE('LIBREPLACE_NETWORK_CHECKS', 1)
 
@@ -38,7 +50,7 @@ def configure(conf):
     conf.CHECK_HEADERS('windows.h winsock2.h ws2tcpip.h')
     conf.CHECK_HEADERS('libintl.h errno.h')
     conf.CHECK_HEADERS('gcrypt.h getopt.h iconv.h')
-    conf.CHECK_HEADERS('sys/inotify.h memory.h nss.h popt.h sasl/sasl.h')
+    conf.CHECK_HEADERS('sys/inotify.h memory.h nss.h sasl/sasl.h')
     conf.CHECK_HEADERS('security/pam_appl.h sys/inotify.h zlib.h asm/unistd.h')
     conf.CHECK_HEADERS('aio.h sys/unistd.h rpc/rpc.h rpc/nettype.h alloca.h float.h')
 
@@ -117,7 +129,7 @@ def configure(conf):
     conf.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull')
     conf.CHECK_FUNCS('strtouq strtoll __strtoll strtoq')
     conf.CHECK_FUNCS('if_nametoindex strerror_r')
-    conf.CHECK_FUNCS('dirfd getdirentries getdents syslog')
+    conf.CHECK_FUNCS('getdirentries getdents syslog')
     conf.CHECK_FUNCS('gai_strerror get_current_dir_name')
     conf.CHECK_FUNCS('timegm getifaddrs freeifaddrs mmap setgroups setsid')
     conf.CHECK_FUNCS('getgrent_r getgrgid_r getgrnam_r getgrouplist getpagesize')
@@ -125,7 +137,9 @@ def configure(conf):
 
     conf.CHECK_FUNCS_IN('dlopen dlsym dlerror dlclose', 'dl',
                         checklibc=True, headers='dlfcn.h dl.h')
-    conf.CHECK_FUNCS_IN('poptGetContext', 'popt')
+
+    conf.CHECK_C_PROTOTYPE('dlopen', 'void *dlopen(const char* filename, unsigned int flags)',
+                           define='DLOPEN_TAKES_UNSIGNED_FLAGS', headers='dlfcn.h dl.h')
 
     conf.CHECK_FUNCS_IN('fdatasync', 'rt', checklibc=True)
 
@@ -145,7 +159,6 @@ def configure(conf):
 
     conf.CHECK_DECLS('snprintf vsnprintf asprintf vasprintf')
 
-    conf.CHECK_DECLS('dirfd', reverse=True, headers='dirent.h')
     conf.CHECK_DECLS('errno', headers='errno.h', reverse=True)
     conf.CHECK_DECLS('environ getgrent_r getpwent_r', reverse=True, headers='pwd.h grp.h')
     conf.CHECK_DECLS('pread pwrite setenv setresgid setresuid', reverse=True)
@@ -275,12 +288,12 @@ def configure(conf):
                     define='REPLACE_GETPASS',
                     cflags='-DNO_CONFIG_H')
 
-    conf.sub_config('system')
+    conf.RECURSE('system')
     conf.SAMBA_CONFIG_H()
 
 
 def build(bld):
-    bld.BUILD_SUBDIR('../../buildtools/wafsamba')
+    bld.RECURSE('buildtools/wafsamba')
 
     REPLACE_SOURCE = 'replace.c snprintf.c'
 
@@ -306,21 +319,27 @@ def build(bld):
                      install=False)
 
     NET_SOURCES = []
-    if bld.CONFIG_SET('HAVE_INET_NTOA'):  NET_SOURCES.append('inet_ntoa.c')
-    if bld.CONFIG_SET('HAVE_INET_ATON'):  NET_SOURCES.append('inet_aton.c')
-    if bld.CONFIG_SET('HAVE_INET_NTOP'):  NET_SOURCES.append('inet_ntop.c')
-    if bld.CONFIG_SET('HAVE_INET_PTON'):  NET_SOURCES.append('inet_pton.c')
-    if bld.CONFIG_SET('HAVE_SOCKETPAIR'): NET_SOURCES.append('socketpair.c')
+    if not bld.CONFIG_SET('HAVE_INET_NTOA'):  NET_SOURCES.append('inet_ntoa.c')
+    if not bld.CONFIG_SET('HAVE_INET_ATON'):  NET_SOURCES.append('inet_aton.c')
+    if not bld.CONFIG_SET('HAVE_INET_NTOP'):  NET_SOURCES.append('inet_ntop.c')
+    if not bld.CONFIG_SET('HAVE_INET_PTON'):  NET_SOURCES.append('inet_pton.c')
+    if not bld.CONFIG_SET('HAVE_SOCKETPAIR'): NET_SOURCES.append('socketpair.c')
+    if not bld.CONFIG_SET('HAVE_GETADDRINFO'):NET_SOURCES.append('getaddrinfo.c')
 
-    bld.SAMBA_SUBSYSTEM('LIBREPLACE_NETWORK', NET_SOURCES, deps='replace')
+    bld.SAMBA_SUBSYSTEM('LIBREPLACE_NETWORK', NET_SOURCES,
+                        group='base_libraries',
+                        deps='replace')
 
 
     CRYPT_SOURCES = []
     if not 'HAVE_CRYPT' in bld.env: CRYPT_SOURCES.append('crypt.c')
 
-    bld.SAMBA_SUBSYSTEM('LIBREPLACE_EXT', CRYPT_SOURCES)
+    bld.SAMBA_SUBSYSTEM('LIBREPLACE_EXT',
+                        CRYPT_SOURCES,
+                        group='base_libraries')
 
     bld.SAMBA_SUBSYSTEM('LIBREPLACE_GETPASS', 'getpass.c',
+                        group='base_libraries',
                         enabled=bld.CONFIG_SET('REPLACE_GETPASS'))
 
     # build replacements for stdint.h and stdbool.h if needed
@@ -334,3 +353,7 @@ def build(bld):
                         source='hdr_replace.h',
                         target='stdbool.h',
                         enabled = not bld.CONFIG_SET('HAVE_STDBOOL_H'))
+
+def dist():
+    '''makes a tarball for distribution'''
+    samba_dist.dist()