tdb: workaround starvation problem in locking entire database.
[kai/samba.git] / lib / tdb / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'tdb'
4 VERSION = '1.2.3'
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
40     conf.env.disable_python = getattr(Options.options, 'disable_python', False)
41
42     conf.CHECK_XSLTPROC_MANPAGES()
43
44     if not conf.env.disable_python:
45         # also disable if we don't have the python libs installed
46         conf.check_tool('python')
47         conf.check_python_version((2,4,2))
48         conf.check_python_headers(mandatory=False)
49         if not conf.env.HAVE_PYTHON_H:
50             Logs.warn('Disabling pytdb as python devel libs not found')
51             conf.env.disable_python = True
52
53     conf.SAMBA_CONFIG_H()
54
55 def build(bld):
56     bld.RECURSE('lib/replace')
57
58     COMMON_SRC = bld.SUBDIR('common',
59                             '''check.c error.c tdb.c traverse.c
60                             freelistcheck.c lock.c dump.c freelist.c
61                             io.c open.c transaction.c''')
62
63     if not bld.CONFIG_SET('USING_SYSTEM_TDB'):
64         bld.SAMBA_LIBRARY('tdb',
65                           COMMON_SRC,
66                           deps='replace rt',
67                           includes='include',
68                           abi_file='ABI/tdb-%s.sigs' % VERSION,
69                           abi_match='tdb_*',
70                           hide_symbols=True,
71                           vnum=VERSION, is_bundled=not bld.env.standalone_tdb)
72
73         bld.SAMBA_BINARY('tdbtorture',
74                          'tools/tdbtorture.c',
75                          'tdb',
76                          install=False)
77
78         bld.SAMBA_BINARY('tdbdump',
79                          'tools/tdbdump.c',
80                          'tdb', manpages='manpages/tdbdump.8')
81
82         bld.SAMBA_BINARY('tdbbackup',
83                          'tools/tdbbackup.c',
84                          'tdb',
85                          manpages='manpages/tdbbackup.8')
86
87         bld.SAMBA_BINARY('tdbtool',
88                          'tools/tdbtool.c',
89                          'tdb', manpages='manpages/tdbtool.8')
90
91     s4_build = getattr(bld.env, '_SAMBA_BUILD_', 0) == 4
92
93     bld.SAMBA_PYTHON('pytdb',
94                      'pytdb.c',
95                      deps='tdb',
96                      enabled=not bld.env.disable_python,
97                      realname='tdb.so')
98
99     if bld.env.standalone_tdb:
100         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
101         bld.PKG_CONFIG_FILES('tdb.pc', vnum=VERSION)
102         bld.INSTALL_FILES('${INCLUDEDIR}', 'include/tdb.h', flat=True)
103
104
105 def test(ctx):
106     '''run tdb testsuite'''
107     import Utils
108     cmd = os.path.join(Utils.g_module.blddir, 'tdbtorture')
109     os.system(cmd)
110
111 def dist():
112     '''makes a tarball for distribution'''
113     samba_dist.dist()