wafsamba: Only install .pc files if libraries are public.
[Samba/gebeck_regimport.git] / lib / ldb / wscript
blob07134641b654b35233e8692747373dc1d50b2b72
1 #!/usr/bin/env python
3 APPNAME = 'ldb'
4 VERSION = '1.1.2'
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/tdb2:lib/tdb2 lib/tdb_compat:lib/tdb_compat lib/ccan:lib/ccan 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_compat')
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_compat')
33 conf.RECURSE('lib/tevent')
34 conf.RECURSE('lib/popt')
35 conf.RECURSE('lib/replace')
36 conf.RECURSE('lib/tdb_compat')
37 conf.find_program('python', var='PYTHON')
38 conf.find_program('xsltproc', var='XSLTPROC')
39 conf.check_tool('python')
40 conf.check_python_version((2,4,2))
41 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
43 # This make #include <ccan/...> work.
44 conf.ADD_EXTRA_INCLUDES('''#lib''')
46 # where does the default LIBDIR end up? in conf.env somewhere?
48 conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
50 conf.env.standalone_ldb = conf.IN_LAUNCH_DIR()
52 if not conf.env.standalone_ldb:
53 if conf.CHECK_BUNDLED_SYSTEM('ldb', minversion=VERSION,
54 onlyif='talloc tdb tevent',
55 implied_deps='replace talloc tdb tevent'):
56 conf.define('USING_SYSTEM_LDB', 1)
57 if conf.CHECK_BUNDLED_SYSTEM('pyldb-util', minversion=VERSION,
58 onlyif='talloc tdb tevent ldb',
59 implied_deps='replace talloc tdb tevent ldb'):
60 conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
62 if conf.env.standalone_ldb:
63 conf.CHECK_XSLTPROC_MANPAGES()
65 # we need this for the ldap backend
66 if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
67 conf.env.ENABLE_LDAP_BACKEND = True
69 # we don't want any libraries or modules to rely on runtime
70 # resolution of symbols
71 if sys.platform != "openbsd4":
72 conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
74 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
76 conf.SAMBA_CONFIG_H()
78 def build(bld):
79 bld.RECURSE('lib/tdb_compat')
80 bld.RECURSE('lib/tevent')
81 bld.RECURSE('lib/popt')
82 bld.RECURSE('lib/replace')
83 bld.RECURSE('lib/tdb_compat')
85 if bld.env.standalone_ldb:
86 private_library = False
87 else:
88 private_library = True
90 LDB_MAP_SRC = bld.SUBDIR('ldb_map',
91 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
93 COMMON_SRC = bld.SUBDIR('common',
94 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
95 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c
96 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
98 bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
99 init_function='ldb_ldap_init',
100 module_init_name='ldb_init_module',
101 deps='talloc lber ldap ldb',
102 enabled=bld.env.ENABLE_LDAP_BACKEND,
103 internal_module=False,
104 subsystem='ldb')
106 # we're not currently linking against the ldap libs, but ldb.pc.in
107 # has @LDAP_LIBS@
108 bld.env.LDAP_LIBS = ''
110 if not 'PACKAGE_VERSION' in bld.env:
111 bld.env.PACKAGE_VERSION = VERSION
112 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
114 if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
115 bld.SAMBA_LIBRARY('pyldb-util',
116 deps='ldb pytalloc-util',
117 source='pyldb_util.c',
118 public_headers='pyldb.h',
119 public_headers_install=not private_library,
120 vnum=VERSION,
121 private_library=private_library,
122 pc_files='pyldb-util.pc',
123 pyext=True,
124 abi_directory='ABI',
125 abi_match='pyldb_*')
127 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
128 if Options.is_install:
129 modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
130 else:
131 # when we run from the source directory, we want to use
132 # the current modules, not the installed ones
133 modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
135 abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
137 bld.SAMBA_LIBRARY('ldb',
138 COMMON_SRC + ' ' + LDB_MAP_SRC,
139 deps='tevent LIBLDB_MAIN',
140 includes='include',
141 public_headers='include/ldb.h include/ldb_errors.h '\
142 'include/ldb_module.h include/ldb_handlers.h',
143 public_headers_install=not private_library,
144 pc_files='ldb.pc',
145 vnum=VERSION,
146 private_library=private_library,
147 manpages='man/ldb.3',
148 abi_directory='ABI',
149 abi_match = abi_match)
151 # generate a include/ldb_version.h
152 t = bld.SAMBA_GENERATOR('ldb_version.h',
153 rule='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
154 target='include/ldb_version.h',
155 public_headers='include/ldb_version.h',
156 public_headers_install=not private_library)
157 t.env.LDB_VERSION = VERSION
158 bld.add_manual_dependency(bld.path.find_or_declare('include/ldb_version.h'), VERSION)
162 bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
163 deps='ldb pyldb-util',
164 realname='ldb.so',
165 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
167 bld.SAMBA_MODULE('ldb_paged_results',
168 'modules/paged_results.c',
169 init_function='ldb_paged_results_init',
170 module_init_name='ldb_init_module',
171 internal_module=False,
172 deps='ldb',
173 subsystem='ldb')
175 bld.SAMBA_MODULE('ldb_asq',
176 'modules/asq.c',
177 init_function='ldb_asq_init',
178 module_init_name='ldb_init_module',
179 internal_module=False,
180 deps='ldb',
181 subsystem='ldb')
183 bld.SAMBA_MODULE('ldb_server_sort',
184 'modules/sort.c',
185 init_function='ldb_server_sort_init',
186 internal_module=False,
187 module_init_name='ldb_init_module',
188 deps='ldb',
189 subsystem='ldb')
191 bld.SAMBA_MODULE('ldb_paged_searches',
192 'modules/paged_searches.c',
193 init_function='ldb_paged_searches_init',
194 internal_module=False,
195 module_init_name='ldb_init_module',
196 deps='ldb',
197 subsystem='ldb')
199 bld.SAMBA_MODULE('ldb_rdn_name',
200 'modules/rdn_name.c',
201 init_function='ldb_rdn_name_init',
202 internal_module=False,
203 module_init_name='ldb_init_module',
204 deps='ldb',
205 subsystem='ldb')
207 bld.SAMBA_MODULE('ldb_sample',
208 'tests/sample_module.c',
209 init_function='ldb_sample_init',
210 internal_module=False,
211 module_init_name='ldb_init_module',
212 deps='ldb',
213 subsystem='ldb')
215 bld.SAMBA_MODULE('ldb_skel',
216 'modules/skel.c',
217 init_function='ldb_skel_init',
218 internal_module=False,
219 module_init_name='ldb_init_module',
220 deps='ldb',
221 subsystem='ldb')
223 bld.SAMBA_MODULE('ldb_sqlite3',
224 'sqlite3/ldb_sqlite3.c',
225 init_function='ldb_sqlite3_init',
226 internal_module=False,
227 module_init_name='ldb_init_module',
228 enabled=False,
229 deps='ldb',
230 subsystem='ldb')
232 bld.SAMBA_MODULE('ldb_tdb',
233 bld.SUBDIR('ldb_tdb',
234 '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
235 ldb_cache.c ldb_tdb_wrap.c'''),
236 init_function='ldb_tdb_init',
237 module_init_name='ldb_init_module',
238 internal_module=False,
239 deps='tdb_compat ldb',
240 subsystem='ldb')
242 # have a separate subsystem for common/ldb.c, so it can rebuild
243 # for install with a different -DLDB_MODULESDIR=
244 bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
245 'common/ldb.c',
246 deps='tevent tdb_compat',
247 includes='include',
248 cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
250 LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
251 for t in LDB_TOOLS.split():
252 bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
253 manpages='man/%s.1' % t)
255 # ldbtest doesn't get installed
256 bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.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'
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)