tdb-waf: added build of manpages and config options for RPM build
[samba.git] / lib / tdb / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'tdb'
4 VERSION = '1.2.1'
5
6 blddir = 'bin'
7
8 import sys, os
9
10 # find the buildtools directory
11 srcdir = '.'
12 while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
13     srcdir = '../' + srcdir
14 sys.path.insert(0, srcdir + '/buildtools/wafsamba')
15
16 import wafsamba, samba_dist, Options, Logs
17
18 samba_dist.DIST_DIRS('lib/tdb:. lib/replace:lib/replace buildtools:buildtools')
19
20 def set_options(opt):
21     opt.BUILTIN_DEFAULT('replace')
22     opt.BUNDLED_EXTENSION_DEFAULT('tdb', noextenion='tdb')
23     opt.RECURSE('lib/replace')
24     if opt.IN_LAUNCH_DIR():
25         opt.add_option('--disable-python',
26                        help=("disable the pytdb module"),
27                        action="store_true", dest='disable_python', default=False)
28
29
30 def configure(conf):
31     conf.RECURSE('lib/replace')
32
33     if conf.CHECK_BUNDLED_SYSTEM('tdb', minversion=VERSION,
34                                  implied_deps='replace'):
35         conf.define('USING_SYSTEM_TDB', 1)
36
37     conf.env.standalone_tdb = conf.IN_LAUNCH_DIR()
38     conf.env.disable_python = getattr(Options.options, 'disable_python', False)
39
40     if conf.env.standalone_tdb:
41         conf.find_program('xsltproc', var='XSLTPROC')
42
43     if not conf.env.disable_python:
44         # also disable if we don't have the python libs installed
45         conf.check_tool('python')
46         conf.check_python_version((2,4,2))
47         conf.check_python_headers()
48         if not conf.env.HAVE_PYTHON_H:
49             Logs.warn('Disabling pytdb as python devel libs not found')
50             conf.env.disable_python = True
51
52     conf.SAMBA_CONFIG_H()
53
54 def build(bld):
55     bld.RECURSE('lib/replace')
56
57     COMMON_SRC = bld.SUBDIR('common',
58                             '''check.c error.c tdb.c traverse.c
59                             freelistcheck.c lock.c dump.c freelist.c
60                             io.c open.c transaction.c''')
61
62     if not bld.CONFIG_SET('USING_SYSTEM_TDB'):
63         bld.SAMBA_LIBRARY('tdb',
64                           COMMON_SRC,
65                           deps='replace rt',
66                           includes='include',
67                           vnum=VERSION)
68
69     bld.SAMBA_BINARY('tdbtorture',
70                      'tools/tdbtorture.c',
71                      'tdb',
72                      install=False)
73
74     bld.SAMBA_BINARY('tdbdump',
75                      'tools/tdbdump.c',
76                      'tdb')
77
78     bld.SAMBA_BINARY('tdbbackup',
79                      'tools/tdbbackup.c',
80                      'tdb')
81
82     bld.SAMBA_BINARY('tdbtool',
83                      'tools/tdbtool.c',
84                      'tdb')
85
86     s4_build = getattr(bld.env, '_SAMBA_BUILD_', 0) == 4
87
88     bld.SAMBA_PYTHON('pytdb',
89                      'pytdb.c',
90                      deps='tdb',
91                      enabled=not bld.env.disable_python,
92                      realname='tdb.so')
93
94     if bld.env.standalone_tdb:
95         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
96         bld.env.TALLOC_VERSION = VERSION
97         bld.PKG_CONFIG_FILES('tdb.pc', vnum=VERSION)
98         bld.INSTALL_FILES('${INCLUDEDIR}', 'include/tdb.h', flat=True)
99
100         if bld.env.XSLTPROC:
101             manpages = 'manpages/tdbbackup.8 manpages/tdbdump.8 manpages/tdbtool.8'
102
103             bld.env.TDB_MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
104
105             for m in manpages.split():
106                 source = m + '.xml'
107                 bld.SAMBA_GENERATOR(m,
108                                     source=source,
109                                     target=m,
110                                     rule='${XSLTPROC} -o ${TGT} ${TDB_MAN_XSL} ${SRC}'
111                                     )
112                 bld.INSTALL_FILES('${MANDIR}/man8', m, flat=True)
113
114
115 def test(ctx):
116     '''run tdb testsuite'''
117     import Utils
118     cmd = os.path.join(Utils.g_module.blddir, 'tdbtorture')
119     os.system(cmd)
120
121 def dist():
122     '''makes a tarball for distribution'''
123     samba_dist.dist()