build: added waf build rules for ldb
authorAndrew Tridgell <tridge@samba.org>
Wed, 17 Mar 2010 09:32:15 +0000 (20:32 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 6 Apr 2010 10:26:34 +0000 (20:26 +1000)
buildtools/waf
buildtools/waf-1.5.13-fixed [new file with mode: 0755]
lib/replace/wafsamba.py
lib/replace/wscript
lib/talloc/wscript
lib/tdb/wscript
lib/tevent/wscript
source4/lib/ldb/wscript

index 734fbd13a9bf78b85c6b46a652003c10562a4a2e..50ecc12ebb239acc5205511f1c3e7119d48d6891 120000 (symlink)
@@ -1 +1 @@
-waf-1.5.13
\ No newline at end of file
+waf-1.5.13-fixed
\ No newline at end of file
diff --git a/buildtools/waf-1.5.13-fixed b/buildtools/waf-1.5.13-fixed
new file mode 100755 (executable)
index 0000000..a384953
Binary files /dev/null and b/buildtools/waf-1.5.13-fixed differ
index f57ce284174c1f6ad37cb4486d9a6a4cf08f071c..7c05aeaf9c8c199f2551bc90bfaae05bf4222db9 100644 (file)
@@ -1,7 +1,7 @@
 # a waf tool to add autoconf-like macros to the configure section
 # and for SAMBA_ macros for building libraries, binaries etc
 
-import Build
+import Build, os, Logs
 from Configure import conf
 
 
@@ -45,14 +45,14 @@ def CHECK_FUNCS_IN(conf, list, library):
     if conf.check(lib=library, uselib_store=library):
         for f in list.split():
             conf.check(function_name=f, lib=library, header_name=conf.env.hlist)
+        conf.env['LIB_' + library.upper()] = library
 
 #################################################
 # write out config.h in the right directory
 @conf
 def SAMBA_CONFIG_H(conf):
-    import os
-    if os.path.normpath(conf.curdir) == os.path.normpath(conf.srcdir):
-        conf.write_config_header('config.h')
+    if os.path.normpath(conf.curdir) == os.path.normpath(os.environ.get('PWD')):
+        conf.write_config_header('config.h', top=True)
 
 
 ##############################################################
@@ -75,7 +75,7 @@ def set_rpath(bld):
     if Options.is_install:
         bld.env['RPATH'] = ['-Wl,-rpath=' + bld.env.PREFIX + '/lib']
     else:
-        bld.env.append_value('RPATH', '-Wl,-rpath=build/default')
+        bld.env.append_value('RPATH', '-Wl,-rpath=bin/lib')
 Build.BuildContext.set_rpath = set_rpath
 
 
@@ -88,6 +88,16 @@ def SUBDIR(bld, subdir, list):
     return ret
 Build.BuildContext.SUBDIR = SUBDIR
 
+#################################################################
+# create the samba build environment
+def SAMBA_BUILD_ENV(bld):
+    bld(
+        target = 'binlib',
+        rule = 'test -d lib || mkdir -p lib && touch ${TGT}',
+        shell = True
+        )
+Build.BuildContext.SAMBA_BUILD_ENV = SAMBA_BUILD_ENV
+
 
 ################################################################
 # this will contain the set of includes needed per Samba library
@@ -127,21 +137,40 @@ def SAMBA_LIBRARY(bld, libname, source_list,
         features = 'cc cshlib',
         source = source_list,
         target=libname,
-        includes='. ' + ilist,
+        includes='. ' + os.environ.get('PWD') + '/bin/default ' + ilist,
         vnum=vnum)
+
+    # put a link to the library in bin/lib
+    soext=""
+    if vnum is not None:
+        soext = '.' + vnum.split('.')[0]
+    bld(
+        source = 'lib%s.so' % libname,
+        rule = 'ln -sf ../${SRC}%s lib' % soext,
+        after = 'binlib'
+        )
     bld.SAMBA_LIBRARY_INCLUDES[libname] = ilist
     bld.SAMBA_LIBRARY_DEPS[libname] = libdeps
 Build.BuildContext.SAMBA_LIBRARY = SAMBA_LIBRARY
 
 #################################################################
 # define a Samba binary
-def SAMBA_BINARY(bld, binname, source_list, libdeps='', include_list=''):
+def SAMBA_BINARY(bld, binname, source_list, libdeps='', syslibs='', include_list=''):
+    #print('binname=%s libs=%s' % (binname, bld.SAMBA_LIBRARY_LIB_LIST(libdeps)))
     bld(
         features = 'cc cprogram',
         source = source_list,
         target = binname,
         uselib_local = bld.SAMBA_LIBRARY_LIB_LIST(libdeps),
-        includes = '. ' + bld.SAMBA_LIBRARY_INCLUDE_LIST(libdeps) + include_list)
+        uselib = syslibs,
+        includes = '. ' + os.environ.get('PWD') + '/bin/default ' + bld.SAMBA_LIBRARY_INCLUDE_LIST(libdeps) + include_list,
+        top=True)
+    # put a link to the binary in bin/
+    bld(
+        source = binname,
+        rule = 'ln -sf ${SRC} .',
+        )
+
 Build.BuildContext.SAMBA_BINARY = SAMBA_BINARY
 
 ############################################################
index c2e545f8824dd30fb368f40a0d11ee4f688fad1b..5c1975bf5f969a610198df25b4eeff4c941cd67c 100644 (file)
@@ -1,5 +1,5 @@
-srcdir = '.'
-blddir = 'build'
+srcdir = '../..'
+blddir = 'bin'
 
 import Options, os, wafsamba
 
@@ -89,6 +89,7 @@ def configure(conf):
     conf.CHECK_FUNCS('timegm getifaddrs freeifaddrs')
 
     conf.CHECK_FUNCS_IN('dlopen dlsym dlerror dlclose', 'dl')
+    conf.CHECK_FUNCS_IN('poptGetContext', 'popt')
 
     conf.check_cc(fragment='''
     #include <stdarg.h>
@@ -153,6 +154,8 @@ def build(bld):
 
     REPLACE_SOURCE = 'replace.c snprintf.c'
 
+    bld.SAMBA_BUILD_ENV()
+
     bld.SAMBA_LIBRARY('replace',
                       REPLACE_SOURCE)
 
index 989a8a8b41c161486b4d64cc9e91866efd4b82f3..ad8ef3bd454cb1f5a1d76f1435284b1c5bbc7068 100644 (file)
@@ -1,9 +1,9 @@
 VERSION = '2.0.1'
 
-srcdir = '.'
-blddir = 'build'
+srcdir = '../..'
+blddir = 'bin'
 
-LIBREPLACE_DIR='../replace'
+LIBREPLACE_DIR= srcdir + '/lib/replace'
 
 def set_options(opt):
     opt.recurse(LIBREPLACE_DIR)
index c746af6def02af71df9b88c73b5c397007f36e27..d3184d492277dc63541198d782c341cdd54a87a0 100644 (file)
@@ -1,9 +1,9 @@
 VERSION='1.2.1'
 
-srcdir = '.'
-blddir = 'build'
+srcdir = '../..'
+blddir = 'bin'
 
-LIBREPLACE_DIR='../replace'
+LIBREPLACE_DIR= srcdir + '/lib/replace'
 
 def set_options(opt):
     opt.recurse(LIBREPLACE_DIR)
index 87d6037aea2862653fb98b729a2d57f41ef30a36..aaa3ce7fb710e751e4f099d29b59a524edf689f8 100644 (file)
@@ -1,15 +1,18 @@
 VERSION = '0.9.8'
 
-srcdir = '.'
-blddir = 'build'
+srcdir = '../..'
+blddir = 'bin'
 
-LIBREPLACE_DIR='../replace'
+LIBREPLACE_DIR= srcdir + '/lib/replace'
+LIBTALLOC_DIR=  srcdir + '/lib/talloc'
 
 def set_options(opt):
     opt.recurse(LIBREPLACE_DIR)
+    opt.recurse(LIBTALLOC_DIR)
 
 def configure(conf):
     conf.sub_config(LIBREPLACE_DIR)
+    conf.sub_config(LIBTALLOC_DIR)
 
     conf.CHECK_HEADERS('sys/epoll.h')
     conf.CHECK_FUNCS('epoll_create')
@@ -18,6 +21,7 @@ def configure(conf):
 
 def build(bld):
     bld.add_subdirs(LIBREPLACE_DIR)
+    bld.add_subdirs(LIBTALLOC_DIR)
 
     SRC = '''tevent.c tevent_debug.c tevent_epoll.c tevent_fd.c tevent_immediate.c
              tevent_queue.c tevent_req.c tevent_select.c
index cab5388a943160e5564393273d2b65c6814bedcd..1103ec62994bc0357c9939a7e4d22db84b19dfc5 100644 (file)
@@ -1,26 +1,28 @@
-srcdir = '.'
-blddir = 'build'
+VERSION = '0.9.10'
 
-LIBTDB_DIR='../../../lib/tdb'
-LIBTALLOC_DIR='../../../lib/talloc'
+srcdir = '../../..'
+blddir = 'bin'
+
+LIBTDB_DIR= srcdir + '/lib/tdb'
+LIBTEVENT_DIR= srcdir + '/lib/tevent'
 
 def set_options(opt):
     opt.recurse(LIBTDB_DIR)
-    opt.recurse(LIBTALLOC_DIR)
+    opt.recurse(LIBTEVENT_DIR)
 
 def configure(conf):
     conf.sub_config(LIBTDB_DIR)
-    conf.sub_config(LIBTALLOC_DIR)
+    conf.sub_config(LIBTEVENT_DIR)
+    conf.CONFIG_PATH('LDB_MODULESDIR', conf.env['LIBDIR'] + '/ldb')
     conf.SAMBA_CONFIG_H()
 
 def build(bld):
     bld.add_subdirs(LIBTDB_DIR)
-    bld.add_subdirs(LIBTALLOC_DIR)
+    bld.add_subdirs(LIBTEVENT_DIR)
 
     LDB_TDB_SRC = bld.SUBDIR('ldb_tdb',
                              '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
                              ldb_cache.c ldb_tdb_wrap.c''')
-    print "LDB_TDB_SRC=%s" % LDB_TDB_SRC
 
     LDB_MAP_SRC = bld.SUBDIR('ldb_map',
                              'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
@@ -35,9 +37,13 @@ def build(bld):
 
     bld.SAMBA_LIBRARY('ldb',
                      LDB_TDB_SRC + ' ' + COMMON_SRC + ' ' + MODULES_SRC,
-                     'tdb talloc',
-                     'include')
-
-    bld.SAMBA_BINARY('ldbadd',
-                    'tools/ldbadd.c',
-                    'ldb')
+                     libdeps='tdb tevent',
+                     include_list='include',
+                      vnum=VERSION)
+
+    LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename ldbtest'
+    for t in LDB_TOOLS.split():
+        bld.SAMBA_BINARY(t,
+                         'tools/%s.c tools/ldbutil.c tools/cmdline.c' % t,
+                         libdeps='ldb',
+                         syslibs='dl popt')