lib/ldb/wscript: pass dep_vars=['LDB_VERSION'] to SAMBA_GENERATOR()
[Samba.git] / lib / ldb / wscript
bloba95133d5f279a3f668d7399c5fbf534c1d586cb0
1 #!/usr/bin/env python
3 APPNAME = 'ldb'
4 VERSION = '1.1.16'
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
18 samba_dist.DIST_DIRS('''lib/ldb:. lib/replace:lib/replace lib/talloc:lib/talloc
19 lib/tdb:lib/tdb lib/tdb:lib/tdb lib/tevent:lib/tevent lib/popt:lib/popt
20 buildtools:buildtools''')
23 def set_options(opt):
24 opt.BUILTIN_DEFAULT('replace')
25 opt.PRIVATE_EXTENSION_DEFAULT('ldb', noextension='ldb')
26 opt.RECURSE('lib/tdb')
27 opt.RECURSE('lib/tevent')
28 opt.RECURSE('lib/replace')
29 opt.tool_options('python') # options for disabling pyc or pyo compilation
31 def configure(conf):
32 conf.RECURSE('lib/tdb')
33 conf.RECURSE('lib/tevent')
34 conf.RECURSE('lib/popt')
35 conf.RECURSE('lib/replace')
36 conf.find_program('python', var='PYTHON')
37 conf.find_program('xsltproc', var='XSLTPROC')
38 conf.check_tool('python')
39 conf.check_python_version((2,4,2))
40 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
42 # where does the default LIBDIR end up? in conf.env somewhere?
44 conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
46 conf.env.standalone_ldb = conf.IN_LAUNCH_DIR()
48 if not conf.env.standalone_ldb:
49 if conf.CHECK_BUNDLED_SYSTEM_PKG('ldb', minversion=VERSION,
50 onlyif='talloc tdb tevent',
51 implied_deps='replace talloc tdb tevent'):
52 conf.define('USING_SYSTEM_LDB', 1)
53 if conf.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util', minversion=VERSION,
54 onlyif='talloc tdb tevent ldb',
55 implied_deps='replace talloc tdb tevent ldb'):
56 conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
58 if conf.env.standalone_ldb:
59 conf.CHECK_XSLTPROC_MANPAGES()
61 # we need this for the ldap backend
62 if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
63 conf.env.ENABLE_LDAP_BACKEND = True
65 # we don't want any libraries or modules to rely on runtime
66 # resolution of symbols
67 if not sys.platform.startswith("openbsd"):
68 conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
70 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
72 conf.SAMBA_CONFIG_H()
74 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
76 def build(bld):
77 bld.RECURSE('lib/tevent')
78 bld.RECURSE('lib/popt')
79 bld.RECURSE('lib/replace')
80 bld.RECURSE('lib/tdb')
82 if bld.env.standalone_ldb:
83 private_library = False
84 else:
85 private_library = True
87 LDB_MAP_SRC = bld.SUBDIR('ldb_map',
88 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
90 COMMON_SRC = bld.SUBDIR('common',
91 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
92 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c ldb_pack.c
93 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
95 bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
96 init_function='ldb_ldap_init',
97 module_init_name='ldb_init_module',
98 deps='talloc lber ldap ldb',
99 enabled=bld.env.ENABLE_LDAP_BACKEND,
100 internal_module=False,
101 subsystem='ldb')
103 # we're not currently linking against the ldap libs, but ldb.pc.in
104 # has @LDAP_LIBS@
105 bld.env.LDAP_LIBS = ''
107 if not 'PACKAGE_VERSION' in bld.env:
108 bld.env.PACKAGE_VERSION = VERSION
109 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
111 if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
112 bld.SAMBA_LIBRARY('pyldb-util',
113 deps='ldb',
114 source='pyldb_util.c',
115 public_headers='pyldb.h',
116 public_headers_install=not private_library,
117 vnum=VERSION,
118 private_library=private_library,
119 pc_files='pyldb-util.pc',
120 pyembed=True,
121 abi_directory='ABI',
122 abi_match='pyldb_*')
124 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
125 if Options.is_install:
126 modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
127 else:
128 # when we run from the source directory, we want to use
129 # the current modules, not the installed ones
130 modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
132 abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
134 bld.SAMBA_LIBRARY('ldb',
135 COMMON_SRC + ' ' + LDB_MAP_SRC,
136 deps='tevent LIBLDB_MAIN',
137 includes='include',
138 public_headers='include/ldb.h include/ldb_errors.h '\
139 'include/ldb_module.h include/ldb_handlers.h',
140 public_headers_install=not private_library,
141 pc_files='ldb.pc',
142 vnum=VERSION,
143 private_library=private_library,
144 manpages='man/ldb.3',
145 abi_directory='ABI',
146 abi_match = abi_match)
148 # generate a include/ldb_version.h
149 t = bld.SAMBA_GENERATOR('ldb_version.h',
150 rule='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
151 dep_vars=['LDB_VERSION'],
152 target='include/ldb_version.h',
153 public_headers='include/ldb_version.h',
154 public_headers_install=not private_library)
155 t.env.LDB_VERSION = VERSION
158 bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
159 deps='ldb pyldb-util',
160 realname='ldb.so',
161 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
163 bld.SAMBA_MODULE('ldb_paged_results',
164 'modules/paged_results.c',
165 init_function='ldb_paged_results_init',
166 module_init_name='ldb_init_module',
167 internal_module=False,
168 deps='ldb',
169 subsystem='ldb')
171 bld.SAMBA_MODULE('ldb_asq',
172 'modules/asq.c',
173 init_function='ldb_asq_init',
174 module_init_name='ldb_init_module',
175 internal_module=False,
176 deps='ldb',
177 subsystem='ldb')
179 bld.SAMBA_MODULE('ldb_server_sort',
180 'modules/sort.c',
181 init_function='ldb_server_sort_init',
182 internal_module=False,
183 module_init_name='ldb_init_module',
184 deps='ldb',
185 subsystem='ldb')
187 bld.SAMBA_MODULE('ldb_paged_searches',
188 'modules/paged_searches.c',
189 init_function='ldb_paged_searches_init',
190 internal_module=False,
191 module_init_name='ldb_init_module',
192 deps='ldb',
193 subsystem='ldb')
195 bld.SAMBA_MODULE('ldb_rdn_name',
196 'modules/rdn_name.c',
197 init_function='ldb_rdn_name_init',
198 internal_module=False,
199 module_init_name='ldb_init_module',
200 deps='ldb',
201 subsystem='ldb')
203 bld.SAMBA_MODULE('ldb_sample',
204 'tests/sample_module.c',
205 init_function='ldb_sample_init',
206 internal_module=False,
207 module_init_name='ldb_init_module',
208 deps='ldb',
209 subsystem='ldb')
211 bld.SAMBA_MODULE('ldb_skel',
212 'modules/skel.c',
213 init_function='ldb_skel_init',
214 internal_module=False,
215 module_init_name='ldb_init_module',
216 deps='ldb',
217 subsystem='ldb')
219 bld.SAMBA_MODULE('ldb_sqlite3',
220 'sqlite3/ldb_sqlite3.c',
221 init_function='ldb_sqlite3_init',
222 internal_module=False,
223 module_init_name='ldb_init_module',
224 enabled=False,
225 deps='ldb',
226 subsystem='ldb')
228 bld.SAMBA_MODULE('ldb_tdb',
229 bld.SUBDIR('ldb_tdb',
230 '''ldb_tdb.c ldb_search.c ldb_index.c
231 ldb_cache.c ldb_tdb_wrap.c'''),
232 init_function='ldb_tdb_init',
233 module_init_name='ldb_init_module',
234 internal_module=False,
235 deps='tdb ldb',
236 subsystem='ldb')
238 # have a separate subsystem for common/ldb.c, so it can rebuild
239 # for install with a different -DLDB_MODULESDIR=
240 bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
241 'common/ldb.c',
242 deps='tevent tdb',
243 includes='include',
244 cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
246 LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
247 for t in LDB_TOOLS.split():
248 bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
249 manpages='man/%s.1' % t)
251 # ldbtest doesn't get installed
252 bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='ldb-cmdline ldb',
253 install=False)
255 # ldbdump doesn't get installed
256 bld.SAMBA_BINARY('ldbdump', 'tools/ldbdump.c', deps='ldb-cmdline ldb',
257 install=False)
259 bld.SAMBA_LIBRARY('ldb-cmdline',
260 source='tools/ldbutil.c tools/cmdline.c',
261 deps='ldb dl popt',
262 private_library=True)
265 def test(ctx):
266 '''run ldb testsuite'''
267 import Utils, samba_utils, shutil
268 test_prefix = "%s/st" % (Utils.g_module.blddir)
269 shutil.rmtree(test_prefix, ignore_errors=True)
270 os.makedirs(test_prefix)
271 os.environ['TEST_DATA_PREFIX'] = test_prefix
272 cmd = 'tests/test-tdb.sh %s' % Utils.g_module.blddir
273 ret = samba_utils.RUN_COMMAND(cmd)
274 print("testsuite returned %d" % ret)
275 # FIXME: Run python testsuite
276 sys.exit(ret)
278 def dist():
279 '''makes a tarball for distribution'''
280 samba_dist.dist()
282 def reconfigure(ctx):
283 '''reconfigure if config scripts have changed'''
284 import samba_utils
285 samba_utils.reconfigure(ctx)