Support the 'PYTHON' environment variable.
[kai/samba.git] / lib / tdb / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'tdb'
4 VERSION = '1.2.9'
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.PRIVATE_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.find_program('python', var='PYTHON')
49         conf.check_tool('python')
50         conf.check_python_version((2,4,2))
51         conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
52         if not conf.env.HAVE_PYTHON_H:
53             Logs.warn('Disabling pytdb as python devel libs not found')
54             conf.env.disable_python = True
55
56     conf.SAMBA_CONFIG_H()
57
58 def build(bld):
59     bld.RECURSE('lib/replace')
60
61     COMMON_SRC = bld.SUBDIR('common',
62                             '''check.c error.c tdb.c traverse.c
63                             freelistcheck.c lock.c dump.c freelist.c
64                             io.c open.c transaction.c hash.c summary.c''')
65
66     if bld.env.standalone_tdb:
67         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
68         bld.PKG_CONFIG_FILES('tdb.pc', vnum=VERSION)
69         private_library = False
70     else:
71         private_library = True
72
73     if not bld.CONFIG_SET('USING_SYSTEM_TDB'):
74         bld.SAMBA_LIBRARY('tdb',
75                           COMMON_SRC,
76                           deps='replace',
77                           includes='include',
78                           abi_directory='ABI',
79                           abi_match='tdb_*',
80                           hide_symbols=True,
81                           vnum=VERSION,
82                           public_headers='include/tdb.h',
83                           public_headers_install=not private_library,
84                           private_library=private_library)
85
86         bld.SAMBA_BINARY('tdbtorture',
87                          'tools/tdbtorture.c',
88                          'tdb',
89                          install=False)
90
91         bld.SAMBA_BINARY('tdbrestore',
92                          'tools/tdbrestore.c',
93                          'tdb', manpages='manpages/tdbrestore.8')
94
95         bld.SAMBA_BINARY('tdbdump',
96                          'tools/tdbdump.c',
97                          'tdb', manpages='manpages/tdbdump.8')
98
99         bld.SAMBA_BINARY('tdbbackup',
100                          'tools/tdbbackup.c',
101                          'tdb',
102                          manpages='manpages/tdbbackup.8')
103
104         bld.SAMBA_BINARY('tdbtool',
105                          'tools/tdbtool.c',
106                          'tdb', manpages='manpages/tdbtool.8')
107
108     if not bld.CONFIG_SET('USING_SYSTEM_PYTDB'):
109         bld.SAMBA_PYTHON('pytdb',
110                          'pytdb.c',
111                          deps='tdb',
112                          enabled=not bld.env.disable_python,
113                          realname='tdb.so',
114                          cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
115
116
117
118 def test(ctx):
119     '''run tdb testsuite'''
120     import Utils, samba_utils, shutil
121     test_prefix = "%s/st" % (Utils.g_module.blddir)
122     shutil.rmtree(test_prefix, ignore_errors=True)
123     os.makedirs(test_prefix)
124     os.environ['TEST_DATA_PREFIX'] = test_prefix
125     cmd = os.path.join(Utils.g_module.blddir, 'tdbtorture')
126     ret = samba_utils.RUN_COMMAND(cmd)
127     print("testsuite returned %d" % ret)
128     sys.exit(ret)
129
130 def dist():
131     '''makes a tarball for distribution'''
132     samba_dist.dist()
133
134 def reconfigure(ctx):
135     '''reconfigure if config scripts have changed'''
136     import samba_utils
137     samba_utils.reconfigure(ctx)