tdb-waf: added build of manpages and config options for RPM build
authorAndrew Tridgell <tridge@samba.org>
Tue, 13 Apr 2010 10:13:00 +0000 (20:13 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 13 Apr 2010 10:15:41 +0000 (20:15 +1000)
Building a RPM from the fedora spec file now works with minimal changes

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

buildtools/wafsamba/samba_autoconf.py
lib/tdb/wscript

index cbb10a27caf49b0da61ff5ec1e4a81b90bbc0478..9d0229e1479ae5553889dcf0734b6c43af2598b4 100644 (file)
@@ -534,6 +534,7 @@ def CHECK_FUNCS_IN(conf, list, library, mandatory=False, checklibc=False,
 def IN_LAUNCH_DIR(conf):
     '''return True if this rule is being run from the launch directory'''
     return os.path.realpath(conf.curdir) == os.path.realpath(Options.launch_dir)
 def IN_LAUNCH_DIR(conf):
     '''return True if this rule is being run from the launch directory'''
     return os.path.realpath(conf.curdir) == os.path.realpath(Options.launch_dir)
+Options.Handler.IN_LAUNCH_DIR = IN_LAUNCH_DIR
 
 
 @conf
 
 
 @conf
index d80b7209b0f814da93337927ed418cc527a21f2a..c5706a2f16192111112a7d837cad8a50b65f557b 100644 (file)
@@ -13,7 +13,7 @@ while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
     srcdir = '../' + srcdir
 sys.path.insert(0, srcdir + '/buildtools/wafsamba')
 
     srcdir = '../' + srcdir
 sys.path.insert(0, srcdir + '/buildtools/wafsamba')
 
-import wafsamba, samba_dist
+import wafsamba, samba_dist, Options, Logs
 
 samba_dist.DIST_DIRS('lib/tdb:. lib/replace:lib/replace buildtools:buildtools')
 
 
 samba_dist.DIST_DIRS('lib/tdb:. lib/replace:lib/replace buildtools:buildtools')
 
@@ -21,6 +21,11 @@ def set_options(opt):
     opt.BUILTIN_DEFAULT('replace')
     opt.BUNDLED_EXTENSION_DEFAULT('tdb', noextenion='tdb')
     opt.RECURSE('lib/replace')
     opt.BUILTIN_DEFAULT('replace')
     opt.BUNDLED_EXTENSION_DEFAULT('tdb', noextenion='tdb')
     opt.RECURSE('lib/replace')
+    if opt.IN_LAUNCH_DIR():
+        opt.add_option('--disable-python',
+                       help=("disable the pytdb module"),
+                       action="store_true", dest='disable_python', default=False)
+
 
 def configure(conf):
     conf.RECURSE('lib/replace')
 
 def configure(conf):
     conf.RECURSE('lib/replace')
@@ -29,6 +34,21 @@ def configure(conf):
                                  implied_deps='replace'):
         conf.define('USING_SYSTEM_TDB', 1)
 
                                  implied_deps='replace'):
         conf.define('USING_SYSTEM_TDB', 1)
 
+    conf.env.standalone_tdb = conf.IN_LAUNCH_DIR()
+    conf.env.disable_python = getattr(Options.options, 'disable_python', False)
+
+    if conf.env.standalone_tdb:
+        conf.find_program('xsltproc', var='XSLTPROC')
+
+    if not conf.env.disable_python:
+        # also disable if we don't have the python libs installed
+        conf.check_tool('python')
+        conf.check_python_version((2,4,2))
+        conf.check_python_headers()
+        if not conf.env.HAVE_PYTHON_H:
+            Logs.warn('Disabling pytdb as python devel libs not found')
+            conf.env.disable_python = True
+
     conf.SAMBA_CONFIG_H()
 
 def build(bld):
     conf.SAMBA_CONFIG_H()
 
 def build(bld):
@@ -48,7 +68,8 @@ def build(bld):
 
     bld.SAMBA_BINARY('tdbtorture',
                      'tools/tdbtorture.c',
 
     bld.SAMBA_BINARY('tdbtorture',
                      'tools/tdbtorture.c',
-                     'tdb')
+                     'tdb',
+                     install=False)
 
     bld.SAMBA_BINARY('tdbdump',
                      'tools/tdbdump.c',
 
     bld.SAMBA_BINARY('tdbdump',
                      'tools/tdbdump.c',
@@ -67,9 +88,29 @@ def build(bld):
     bld.SAMBA_PYTHON('pytdb',
                      'pytdb.c',
                      deps='tdb',
     bld.SAMBA_PYTHON('pytdb',
                      'pytdb.c',
                      deps='tdb',
-                     enabled=s4_build,
+                     enabled=not bld.env.disable_python,
                      realname='tdb.so')
 
                      realname='tdb.so')
 
+    if bld.env.standalone_tdb:
+        bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
+        bld.env.TALLOC_VERSION = VERSION
+        bld.PKG_CONFIG_FILES('tdb.pc', vnum=VERSION)
+        bld.INSTALL_FILES('${INCLUDEDIR}', 'include/tdb.h', flat=True)
+
+        if bld.env.XSLTPROC:
+            manpages = 'manpages/tdbbackup.8 manpages/tdbdump.8 manpages/tdbtool.8'
+
+            bld.env.TDB_MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
+
+            for m in manpages.split():
+                source = m + '.xml'
+                bld.SAMBA_GENERATOR(m,
+                                    source=source,
+                                    target=m,
+                                    rule='${XSLTPROC} -o ${TGT} ${TDB_MAN_XSL} ${SRC}'
+                                    )
+                bld.INSTALL_FILES('${MANDIR}/man8', m, flat=True)
+
 
 def test(ctx):
     '''run tdb testsuite'''
 
 def test(ctx):
     '''run tdb testsuite'''