Improve the VFS Makefile so that it is easier for use out of tree but still works...
[Samba/gebeck_regimport.git] / lib / tdb / wscript
blobd475204d0b6c0f2b53c3c2b2982f392da6513d8e
1 #!/usr/bin/env python
3 APPNAME = 'tdb'
4 VERSION = '1.2.10'
6 blddir = 'bin'
8 import sys, os
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')
16 import wafsamba, samba_dist, Options, Logs
18 samba_dist.DIST_DIRS('lib/tdb:. lib/replace:lib/replace buildtools:buildtools')
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)
30 def configure(conf):
31 conf.RECURSE('lib/replace')
33 conf.env.standalone_tdb = conf.IN_LAUNCH_DIR()
34 conf.env.building_tdb = True
36 if not conf.env.standalone_tdb:
37 if conf.CHECK_BUNDLED_SYSTEM_PKG('tdb', minversion=VERSION,
38 implied_deps='replace'):
39 conf.define('USING_SYSTEM_TDB', 1)
40 conf.env.building_tdb = False
41 if conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytdb', 'tdb', minversion=VERSION):
42 conf.define('USING_SYSTEM_PYTDB', 1)
44 conf.env.disable_python = getattr(Options.options, 'disable_python', False)
46 conf.CHECK_XSLTPROC_MANPAGES()
48 if not conf.env.disable_python:
49 # also disable if we don't have the python libs installed
50 conf.find_program('python', var='PYTHON')
51 conf.check_tool('python')
52 conf.check_python_version((2,4,2))
53 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
54 if not conf.env.HAVE_PYTHON_H:
55 Logs.warn('Disabling pytdb as python devel libs not found')
56 conf.env.disable_python = True
58 conf.SAMBA_CONFIG_H()
60 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
62 def build(bld):
63 bld.RECURSE('lib/replace')
65 COMMON_SRC = bld.SUBDIR('common',
66 '''check.c error.c tdb.c traverse.c
67 freelistcheck.c lock.c dump.c freelist.c
68 io.c open.c transaction.c hash.c summary.c''')
70 if bld.env.standalone_tdb:
71 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
72 private_library = False
73 else:
74 private_library = True
76 if not bld.CONFIG_SET('USING_SYSTEM_TDB'):
77 bld.SAMBA_LIBRARY('tdb',
78 COMMON_SRC,
79 deps='replace',
80 includes='include',
81 abi_directory='ABI',
82 abi_match='tdb_*',
83 hide_symbols=True,
84 vnum=VERSION,
85 public_headers='include/tdb.h',
86 public_headers_install=not private_library,
87 pc_files='tdb.pc',
88 private_library=private_library)
90 bld.SAMBA_BINARY('tdbtorture',
91 'tools/tdbtorture.c',
92 'tdb',
93 install=False)
95 bld.SAMBA_BINARY('tdbrestore',
96 'tools/tdbrestore.c',
97 'tdb', manpages='manpages/tdbrestore.8')
99 bld.SAMBA_BINARY('tdbdump',
100 'tools/tdbdump.c',
101 'tdb', manpages='manpages/tdbdump.8')
103 bld.SAMBA_BINARY('tdbbackup',
104 'tools/tdbbackup.c',
105 'tdb',
106 manpages='manpages/tdbbackup.8')
108 bld.SAMBA_BINARY('tdbtool',
109 'tools/tdbtool.c',
110 'tdb', manpages='manpages/tdbtool.8')
112 # FIXME: This hardcoded list is stupid, stupid, stupid.
113 bld.SAMBA_SUBSYSTEM('tdb-test-helpers',
114 'test/external-agent.c test/lock-tracking.c test/logging.c',
115 'replace',
116 includes='include')
118 bld.SAMBA_BINARY('tdb1-run-3G-file', 'test/run-3G-file.c',
119 'replace tdb-test-helpers', includes='include', install=False)
120 bld.SAMBA_BINARY('tdb1-run-bad-tdb-header', 'test/run-bad-tdb-header.c',
121 'replace tdb-test-helpers', includes='include', install=False)
122 bld.SAMBA_BINARY('tdb1-run', 'test/run.c',
123 'replace tdb-test-helpers', includes='include', install=False)
124 bld.SAMBA_BINARY('tdb1-run-check', 'test/run-check.c',
125 'replace tdb-test-helpers', includes='include', install=False)
126 bld.SAMBA_BINARY('tdb1-run-corrupt', 'test/run-corrupt.c',
127 'replace tdb-test-helpers', includes='include', install=False)
128 bld.SAMBA_BINARY('tdb1-run-die-during-transaction', 'test/run-die-during-transaction.c',
129 'replace tdb-test-helpers', includes='include', install=False)
130 bld.SAMBA_BINARY('tdb1-run-endian', 'test/run-endian.c',
131 'replace tdb-test-helpers', includes='include', install=False)
132 bld.SAMBA_BINARY('tdb1-run-incompatible', 'test/run-incompatible.c',
133 'replace tdb-test-helpers', includes='include', install=False)
134 bld.SAMBA_BINARY('tdb1-run-nested-transactions', 'test/run-nested-transactions.c',
135 'replace tdb-test-helpers', includes='include', install=False)
136 bld.SAMBA_BINARY('tdb1-run-nested-traverse', 'test/run-nested-traverse.c',
137 'replace tdb-test-helpers', includes='include', install=False)
138 bld.SAMBA_BINARY('tdb1-run-no-lock-during-traverse', 'test/run-no-lock-during-traverse.c',
139 'replace tdb-test-helpers', includes='include', install=False)
140 bld.SAMBA_BINARY('tdb1-run-oldhash', 'test/run-oldhash.c',
141 'replace tdb-test-helpers', includes='include', install=False)
142 bld.SAMBA_BINARY('tdb1-run-open-during-transaction', 'test/run-open-during-transaction.c',
143 'replace tdb-test-helpers', includes='include', install=False)
144 bld.SAMBA_BINARY('tdb1-run-readonly-check', 'test/run-readonly-check.c',
145 'replace tdb-test-helpers', includes='include', install=False)
146 bld.SAMBA_BINARY('tdb1-run-rwlock-check', 'test/run-rwlock-check.c',
147 'replace tdb-test-helpers', includes='include', install=False)
148 bld.SAMBA_BINARY('tdb1-run-summary', 'test/run-summary.c',
149 'replace tdb-test-helpers', includes='include', install=False)
150 bld.SAMBA_BINARY('tdb1-run-transaction-expand', 'test/run-transaction-expand.c',
151 'replace tdb-test-helpers', includes='include', install=False)
152 bld.SAMBA_BINARY('tdb1-run-traverse-in-transaction', 'test/run-traverse-in-transaction.c',
153 'replace tdb-test-helpers', includes='include', install=False)
154 bld.SAMBA_BINARY('tdb1-run-wronghash-fail', 'test/run-wronghash-fail.c',
155 'replace tdb-test-helpers', includes='include', install=False)
156 bld.SAMBA_BINARY('tdb1-run-zero-append', 'test/run-zero-append.c',
157 'replace tdb-test-helpers', includes='include', install=False)
159 if not bld.CONFIG_SET('USING_SYSTEM_PYTDB'):
160 bld.SAMBA_PYTHON('pytdb',
161 'pytdb.c',
162 deps='tdb',
163 enabled=not bld.env.disable_python,
164 realname='tdb.so',
165 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
167 def testonly(ctx):
168 '''run tdb testsuite'''
169 import Utils, samba_utils, shutil
170 ecode = 0;
172 test_prefix = "%s/st" % (Utils.g_module.blddir)
173 shutil.rmtree(test_prefix, ignore_errors=True)
174 os.makedirs(test_prefix)
175 os.environ['TEST_DATA_PREFIX'] = test_prefix
177 env = samba_utils.LOAD_ENVIRONMENT()
178 # FIXME: This is horrible :(
179 if env.building_tdb:
180 # Create scratch directory for tests.
181 testdir = os.path.join(test_prefix, 'tdb-tests')
182 samba_utils.mkdir_p(testdir)
183 # Symlink back to source dir so it can find tests in test/
184 link = os.path.join(testdir, 'test')
185 if not os.path.exists(link):
186 os.symlink(os.path.abspath(os.path.join(env.cwd, 'test')), link)
188 for f in 'tdb1-run-3G-file', 'tdb1-run-bad-tdb-header', 'tdb1-run', 'tdb1-run-check', 'tdb1-run-corrupt', 'tdb1-run-die-during-transaction', 'tdb1-run-endian', 'tdb1-run-incompatible', 'tdb1-run-nested-transactions', 'tdb1-run-nested-traverse', 'tdb1-run-no-lock-during-traverse', 'tdb1-run-oldhash', 'tdb1-run-open-during-transaction', 'tdb1-run-readonly-check', 'tdb1-run-rwlock-check', 'tdb1-run-summary', 'tdb1-run-transaction-expand', 'tdb1-run-traverse-in-transaction', 'tdb1-run-wronghash-fail', 'tdb1-run-zero-append':
189 cmd = "cd " + testdir + " && " + os.path.abspath(os.path.join(Utils.g_module.blddir, f)) + " > test-output 2>&1"
190 print("..." + f)
191 ret = samba_utils.RUN_COMMAND(cmd)
192 if ret != 0:
193 print("%s failed:" % f)
194 samba_utils.RUN_COMMAND("cat " + os.path.join(testdir, 'test-output'))
195 ecode = ret;
196 break;
198 if ecode == 0:
199 cmd = os.path.join(Utils.g_module.blddir, 'tdbtorture')
200 ret = samba_utils.RUN_COMMAND(cmd)
201 print("testsuite returned %d" % ret)
202 if ret != 0:
203 ecode = ret;
204 sys.exit(ecode)
206 # WAF doesn't build the unit tests for this, maybe because they don't link with tdb?
207 # This forces it
208 def test(ctx):
209 import Scripting
210 Scripting.commands.append('build')
211 Scripting.commands.append('testonly')
213 def dist():
214 '''makes a tarball for distribution'''
215 samba_dist.dist()
217 def reconfigure(ctx):
218 '''reconfigure if config scripts have changed'''
219 import samba_utils
220 samba_utils.reconfigure(ctx)