5c2ecafd72c9ea639cbb89eae5599b2693dece10
[kai/samba-autobuild/.git] / lib / tdb / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'tdb'
4 VERSION = '1.2.7'
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', noextension='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     conf.env.standalone_tdb = conf.IN_LAUNCH_DIR()
34
35     if not conf.env.standalone_tdb:
36         if conf.CHECK_BUNDLED_SYSTEM('tdb', minversion=VERSION,
37                                      implied_deps='replace'):
38             conf.define('USING_SYSTEM_TDB', 1)
39             if conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion=VERSION):
40                 conf.define('USING_SYSTEM_PYTDB', 1)
41
42     conf.env.disable_python = getattr(Options.options, 'disable_python', False)
43
44     conf.CHECK_XSLTPROC_MANPAGES()
45
46     if not conf.env.disable_python:
47         # also disable if we don't have the python libs installed
48         conf.check_tool('python')
49         conf.check_python_version((2,4,2))
50         conf.check_python_headers(mandatory=False)
51         if not conf.env.HAVE_PYTHON_H:
52             Logs.warn('Disabling pytdb as python devel libs not found')
53             conf.env.disable_python = True
54
55     conf.SAMBA_CONFIG_H()
56
57 def build(bld):
58     bld.RECURSE('lib/replace')
59
60     COMMON_SRC = bld.SUBDIR('common',
61                             '''check.c error.c tdb.c traverse.c
62                             freelistcheck.c lock.c dump.c freelist.c
63                             io.c open.c transaction.c hash.c''')
64
65     if not bld.CONFIG_SET('USING_SYSTEM_TDB'):
66         bld.SAMBA_LIBRARY('tdb',
67                           COMMON_SRC,
68                           deps='replace',
69                           includes='include',
70                           abi_file='ABI/tdb-%s.sigs' % VERSION,
71                           abi_match='tdb_*',
72                           hide_symbols=True,
73                           vnum=VERSION,
74                           private_library=not bld.env.standalone_tdb)
75
76         bld.SAMBA_BINARY('tdbtorture',
77                          'tools/tdbtorture.c',
78                          'tdb',
79                          install=False)
80
81         bld.SAMBA_BINARY('tdbrestore',
82                          'tools/tdbrestore.c',
83                          'tdb', manpages='manpages/tdbrestore.8')
84
85         bld.SAMBA_BINARY('tdbdump',
86                          'tools/tdbdump.c',
87                          'tdb', manpages='manpages/tdbdump.8')
88
89         bld.SAMBA_BINARY('tdbbackup',
90                          'tools/tdbbackup.c',
91                          'tdb',
92                          manpages='manpages/tdbbackup.8')
93
94         bld.SAMBA_BINARY('tdbtool',
95                          'tools/tdbtool.c',
96                          'tdb', manpages='manpages/tdbtool.8')
97
98     if not bld.CONFIG_SET('USING_SYSTEM_PYTDB'):
99         bld.SAMBA_PYTHON('pytdb',
100                          'pytdb.c',
101                          deps='tdb',
102                          enabled=not bld.env.disable_python,
103                          realname='tdb.so',
104                          cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
105
106     if bld.env.standalone_tdb:
107         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
108         bld.PKG_CONFIG_FILES('tdb.pc', vnum=VERSION)
109         bld.INSTALL_FILES('${INCLUDEDIR}', 'include/tdb.h', flat=True)
110
111
112 def test(ctx):
113     '''run tdb testsuite'''
114     import Utils, samba_utils
115     cmd = os.path.join(Utils.g_module.blddir, 'tdbtorture')
116     ret = samba_utils.RUN_COMMAND(cmd)
117     print("testsuite returned %d" % ret)
118     sys.exit(ret)
119
120 def dist():
121     '''makes a tarball for distribution'''
122     samba_dist.dist()