source: trunk/server/source4/lib/ldb/wscript

Last change on this file was 920, checked in by Silvan Scherrer, 9 years ago

Samba Server: apply latest security patches to trunk

File size: 10.5 KB
Line 
1#!/usr/bin/env python
2
3APPNAME = 'ldb'
4VERSION = '1.0.2'
5
6blddir = 'bin'
7
8import sys, os
9
10# find the buildtools directory
11srcdir = '.'
12while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
13 srcdir = '../' + srcdir
14sys.path.insert(0, srcdir + '/buildtools/wafsamba')
15
16import wafsamba, samba_dist, Options
17
18samba_dist.DIST_DIRS('''source4/lib/ldb:. lib/replace:lib/replace lib/talloc:lib/talloc
19 lib/tdb:lib/tdb lib/tevent:lib/tevent lib/popt:lib/popt
20 buildtools:buildtools''')
21
22
23def 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
30def configure(conf):
31 conf.RECURSE('lib/tdb')
32 conf.RECURSE('lib/tevent')
33 conf.RECURSE('lib/popt')
34 conf.RECURSE('lib/replace')
35
36 # where does the default LIBDIR end up? in conf.env somewhere?
37 #
38 conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
39
40 conf.env.standalone_ldb = conf.IN_LAUNCH_DIR()
41
42 if not conf.env.standalone_ldb:
43 if conf.CHECK_BUNDLED_SYSTEM('ldb', minversion=VERSION,
44 onlyif='talloc tdb tevent',
45 implied_deps='replace talloc tdb tevent'):
46 conf.define('USING_SYSTEM_LDB', 1)
47 if conf.CHECK_BUNDLED_SYSTEM('pyldb-util', minversion=VERSION,
48 onlyif='talloc tdb tevent ldb',
49 implied_deps='replace talloc tdb tevent ldb'):
50 conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
51
52 if conf.env.standalone_ldb:
53 conf.CHECK_XSLTPROC_MANPAGES()
54
55 # we need this for the ldap backend
56 if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
57 conf.env.ENABLE_LDAP_BACKEND = True
58
59 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
60
61 # we don't want any libraries or modules to rely on runtime
62 # resolution of symbols
63 if sys.platform != "openbsd4":
64 conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
65
66 conf.SAMBA_CONFIG_H()
67
68def build(bld):
69 bld.RECURSE('lib/tdb')
70 bld.RECURSE('lib/tevent')
71 bld.RECURSE('lib/popt')
72 bld.RECURSE('lib/replace')
73
74 if bld.env.standalone_ldb:
75 private_library = False
76 ldb_pc_files='ldb.pc'
77 pyldb_pc_files='pyldb-util.pc'
78 else:
79 private_library = True
80 ldb_pc_files=None
81 pyldb_pc_files=None
82
83 LDB_MAP_SRC = bld.SUBDIR('ldb_map',
84 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
85
86 COMMON_SRC = bld.SUBDIR('common',
87 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
88 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c
89 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
90
91 bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
92 init_function='ldb_ldap_init',
93 module_init_name='ldb_init_module',
94 deps='talloc lber ldap ldb',
95 enabled=bld.env.ENABLE_LDAP_BACKEND,
96 internal_module=False,
97 subsystem='ldb')
98
99 # we're not currently linking against the ldap libs, but ldb.pc.in
100 # has @LDAP_LIBS@
101 bld.env.LDAP_LIBS = ''
102
103 if not 'PACKAGE_VERSION' in bld.env:
104 bld.env.PACKAGE_VERSION = VERSION
105 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
106
107 if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
108 bld.SAMBA_LIBRARY('pyldb-util',
109 deps='ldb pytalloc-util',
110 source='pyldb_util.c',
111 public_headers='pyldb.h',
112 public_headers_install=not private_library,
113 vnum=VERSION,
114 private_library=private_library,
115 pc_files=pyldb_pc_files,
116 pyext=True)
117
118 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
119 if Options.is_install:
120 modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
121 else:
122 # when we run from the source directory, we want to use
123 # the current modules, not the installed ones
124 modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
125
126 abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
127
128 bld.SAMBA_LIBRARY('ldb',
129 COMMON_SRC + ' ' + LDB_MAP_SRC,
130 deps='tevent LIBLDB_MAIN',
131 includes='include',
132 public_headers='include/ldb.h include/ldb_errors.h '\
133 'include/ldb_module.h include/ldb_handlers.h',
134 public_headers_install=not private_library,
135 pc_files=ldb_pc_files,
136 vnum=VERSION,
137 private_library=private_library,
138 manpages='man/ldb.3')
139
140 # generate a include/ldb_version.h
141 t = bld.SAMBA_GENERATOR('ldb_version.h',
142 rule='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
143 target='include/ldb_version.h',
144 public_headers='include/ldb_version.h',
145 public_headers_install=not private_library)
146 t.env.LDB_VERSION = VERSION
147 bld.add_manual_dependency(bld.path.find_or_declare('include/ldb_version.h'), VERSION)
148
149
150
151 bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
152 deps='ldb pyldb-util',
153 realname='ldb.so',
154 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
155
156 bld.SAMBA_MODULE('ldb_paged_results',
157 'modules/paged_results.c',
158 init_function='ldb_paged_results_init',
159 module_init_name='ldb_init_module',
160 internal_module=False,
161 deps='ldb',
162 subsystem='ldb')
163
164 bld.SAMBA_MODULE('ldb_asq',
165 'modules/asq.c',
166 init_function='ldb_asq_init',
167 module_init_name='ldb_init_module',
168 internal_module=False,
169 deps='ldb',
170 subsystem='ldb')
171
172 bld.SAMBA_MODULE('ldb_server_sort',
173 'modules/sort.c',
174 init_function='ldb_server_sort_init',
175 internal_module=False,
176 module_init_name='ldb_init_module',
177 deps='ldb',
178 subsystem='ldb')
179
180 bld.SAMBA_MODULE('ldb_paged_searches',
181 'modules/paged_searches.c',
182 init_function='ldb_paged_searches_init',
183 internal_module=False,
184 module_init_name='ldb_init_module',
185 deps='ldb',
186 subsystem='ldb')
187
188 bld.SAMBA_MODULE('ldb_rdn_name',
189 'modules/rdn_name.c',
190 init_function='ldb_rdn_name_init',
191 internal_module=False,
192 module_init_name='ldb_init_module',
193 deps='ldb',
194 subsystem='ldb')
195
196 bld.SAMBA_MODULE('ldb_sample',
197 'tests/sample_module.c',
198 init_function='ldb_sample_init',
199 internal_module=False,
200 module_init_name='ldb_init_module',
201 deps='ldb',
202 subsystem='ldb')
203
204 bld.SAMBA_MODULE('ldb_skel',
205 'modules/skel.c',
206 init_function='ldb_skel_init',
207 internal_module=False,
208 module_init_name='ldb_init_module',
209 deps='ldb',
210 subsystem='ldb')
211
212 bld.SAMBA_MODULE('ldb_sqlite3',
213 'sqlite3/ldb_sqlite3.c',
214 init_function='ldb_sqlite3_init',
215 internal_module=False,
216 module_init_name='ldb_init_module',
217 enabled=False,
218 deps='ldb',
219 subsystem='ldb')
220
221 bld.SAMBA_MODULE('ldb_tdb',
222 bld.SUBDIR('ldb_tdb',
223 '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
224 ldb_cache.c ldb_tdb_wrap.c'''),
225 init_function='ldb_tdb_init',
226 module_init_name='ldb_init_module',
227 internal_module=False,
228 deps='tdb ldb',
229 subsystem='ldb')
230
231 # have a separate subsystem for common/ldb.c, so it can rebuild
232 # for install with a different -DLDB_MODULESDIR=
233 bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
234 'common/ldb.c',
235 deps='tevent',
236 includes='include',
237 cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
238
239 LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
240 for t in LDB_TOOLS.split():
241 bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
242 manpages='man/%s.1' % t)
243
244 # ldbtest doesn't get installed
245 bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='ldb-cmdline ldb',
246 install=False)
247
248 bld.SAMBA_LIBRARY('ldb-cmdline',
249 source='tools/ldbutil.c tools/cmdline.c',
250 deps='ldb dl popt',
251 private_library=True)
252
253
254def test(ctx):
255 '''run ldb testsuite'''
256 import Utils, samba_utils, shutil
257 test_prefix = "%s/st" % (Utils.g_module.blddir)
258 shutil.rmtree(test_prefix, ignore_errors=True)
259 os.makedirs(test_prefix)
260 os.environ['TEST_DATA_PREFIX'] = test_prefix
261 cmd = 'tests/test-tdb.sh'
262 ret = samba_utils.RUN_COMMAND(cmd)
263 print("testsuite returned %d" % ret)
264 # FIXME: Run python testsuite
265 sys.exit(ret)
266
267def dist():
268 '''makes a tarball for distribution'''
269 samba_dist.dist()
270
271def reconfigure(ctx):
272 '''reconfigure if config scripts have changed'''
273 import samba_utils
274 samba_utils.reconfigure(ctx)
Note: See TracBrowser for help on using the repository browser.