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