tdb2: tie it into build process if --enable-tdb2-breaks-compat
[ira/wip.git] / source4 / lib / ldb / wscript
old mode 100644 (file)
new mode 100755 (executable)
index 54ecc00..7de9549
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'ldb'
-VERSION = '0.9.22'
+VERSION = '1.1.0'
 
 blddir = 'bin'
 
@@ -16,22 +16,32 @@ sys.path.insert(0, srcdir + '/buildtools/wafsamba')
 import wafsamba, samba_dist, Options
 
 samba_dist.DIST_DIRS('''source4/lib/ldb:. lib/replace:lib/replace lib/talloc:lib/talloc
-                        lib/tdb:lib/tdb lib/tevent:lib/tevent lib/popt:lib/popt
+                        lib/tdb:lib/tdb lib/tdb2:lib/tdb2 lib/tdb_compat:lib/tdb_compat lib/ccan:lib/ccan lib/tevent:lib/tevent lib/popt:lib/popt
                         buildtools:buildtools''')
 
 
 def set_options(opt):
     opt.BUILTIN_DEFAULT('replace')
     opt.PRIVATE_EXTENSION_DEFAULT('ldb', noextension='ldb')
-    opt.RECURSE('lib/tdb')
+    opt.RECURSE('lib/tdb_compat')
     opt.RECURSE('lib/tevent')
     opt.RECURSE('lib/replace')
+    opt.tool_options('python') # options for disabling pyc or pyo compilation
 
 def configure(conf):
-    conf.RECURSE('lib/tdb')
+    conf.RECURSE('lib/tdb_compat')
     conf.RECURSE('lib/tevent')
     conf.RECURSE('lib/popt')
     conf.RECURSE('lib/replace')
+    conf.RECURSE('lib/tdb_compat')
+    conf.find_program('python', var='PYTHON')
+    conf.find_program('xsltproc', var='XSLTPROC')
+    conf.check_tool('python')
+    conf.check_python_version((2,4,2))
+    conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
+
+    # This make #include <ccan/...> work.
+    conf.ADD_EXTRA_INCLUDES('''#lib''')
 
     # where does the default LIBDIR end up? in conf.env somewhere?
     #
@@ -56,8 +66,6 @@ def configure(conf):
         if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
             conf.env.ENABLE_LDAP_BACKEND = True
 
-    conf.DEFINE('LDB_VERSION', VERSION, quote=True)
-
     conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
 
     # we don't want any libraries or modules to rely on runtime
@@ -68,15 +76,20 @@ def configure(conf):
     conf.SAMBA_CONFIG_H()
 
 def build(bld):
-    bld.RECURSE('lib/tdb')
+    bld.RECURSE('lib/tdb_compat')
     bld.RECURSE('lib/tevent')
     bld.RECURSE('lib/popt')
     bld.RECURSE('lib/replace')
+    bld.RECURSE('lib/tdb_compat')
 
     if bld.env.standalone_ldb:
         private_library = False
+        ldb_pc_files='ldb.pc'
+        pyldb_pc_files='pyldb-util.pc'
     else:
         private_library = True
+        ldb_pc_files=None
+        pyldb_pc_files=None
 
     LDB_MAP_SRC = bld.SUBDIR('ldb_map',
                              'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
@@ -107,9 +120,10 @@ def build(bld):
                           deps='ldb pytalloc-util',
                           source='pyldb_util.c',
                           public_headers='pyldb.h',
+                          public_headers_install=not private_library,
                           vnum=VERSION,
                           private_library=private_library,
-                          pc_files='pyldb-util.pc',
+                          pc_files=pyldb_pc_files,
                           pyext=True)
 
     if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
@@ -128,13 +142,24 @@ def build(bld):
                           includes='include',
                           public_headers='include/ldb.h include/ldb_errors.h '\
                           'include/ldb_module.h include/ldb_handlers.h',
-                          pc_files='ldb.pc',
+                          public_headers_install=not private_library,
+                          pc_files=ldb_pc_files,
                           vnum=VERSION,
                           private_library=private_library,
                           manpages='man/ldb.3',
                           abi_directory = 'ABI',
                           abi_match = abi_match)
 
+        # generate a include/ldb_version.h
+        t = bld.SAMBA_GENERATOR('ldb_version.h',
+                                rule='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
+                                target='include/ldb_version.h',
+                                public_headers='include/ldb_version.h',
+                                public_headers_install=not private_library)
+        t.env.LDB_VERSION = VERSION
+        bld.add_manual_dependency(bld.path.find_or_declare('include/ldb_version.h'), VERSION)
+
+
 
         bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
                          deps='ldb pyldb-util',
@@ -213,14 +238,14 @@ def build(bld):
                          init_function='ldb_tdb_init',
                          module_init_name='ldb_init_module',
                          internal_module=False,
-                         deps='tdb ldb',
+                         deps='tdb_compat ldb',
                          subsystem='ldb')
 
         # have a separate subsystem for common/ldb.c, so it can rebuild
         # for install with a different -DLDB_MODULESDIR=
         bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
                             'common/ldb.c',
-                            deps='tevent',
+                            deps='tevent tdb_compat',
                             includes='include',
                             cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
 
@@ -245,7 +270,7 @@ def test(ctx):
     test_prefix = "%s/st" % (Utils.g_module.blddir)
     shutil.rmtree(test_prefix, ignore_errors=True)
     os.makedirs(test_prefix)
-    os.putenv('TEST_DATA_PREFIX', test_prefix)
+    os.environ['TEST_DATA_PREFIX'] = test_prefix
     cmd = 'tests/test-tdb.sh'
     ret = samba_utils.RUN_COMMAND(cmd)
     print("testsuite returned %d" % ret)