waf: Stop automaticaly changing dashes to underscores in library names.
[sfrench/samba-autobuild/.git] / source4 / lib / ldb / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'ldb'
4 VERSION = '0.9.17'
5
6 blddir = 'bin'
7
8 import sys, os
9
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')
15
16 import wafsamba, samba_dist, Options
17
18 samba_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
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
30 def 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     s4_build = getattr(conf.env, '_SAMBA_BUILD_', 0) == 4
41
42     conf.env.standalone_ldb = conf.IN_LAUNCH_DIR()
43
44     if not conf.env.standalone_ldb:
45         if conf.CHECK_BUNDLED_SYSTEM('ldb', minversion=VERSION,
46                                      onlyif='talloc tdb tevent',
47                                      implied_deps='replace talloc tdb tevent'):
48             conf.define('USING_SYSTEM_LDB', 1)
49         if conf.CHECK_BUNDLED_SYSTEM('pyldb-util', minversion=VERSION,
50                                      onlyif='talloc tdb tevent ldb',
51                                      implied_deps='replace talloc tdb tevent ldb'):
52             conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
53
54     if conf.env.standalone_ldb:
55         conf.CHECK_XSLTPROC_MANPAGES()
56
57         # we need this for the ldap backend
58         if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
59             conf.env.ENABLE_LDAP_BACKEND = True
60
61     conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
62
63     # we don't want any libraries or modules to rely on runtime
64     # resolution of symbols
65     conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
66
67     conf.SAMBA_CONFIG_H()
68
69 def build(bld):
70     bld.RECURSE('lib/tdb')
71     bld.RECURSE('lib/tevent')
72     bld.RECURSE('lib/popt')
73     bld.RECURSE('lib/replace')
74
75     # in Samba4 we build some extra modules, and add extra
76     # capabilities to the ldb cmdline tools
77     s4_build = getattr(bld.env, '_SAMBA_BUILD_', 0) == 4
78
79     LDB_MAP_SRC = bld.SUBDIR('ldb_map',
80                              'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
81
82     COMMON_SRC = bld.SUBDIR('common',
83                             '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
84                             ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c
85                             ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
86
87     if s4_build:
88         # this is only in the s4 build
89         bld.SAMBA_MODULE('ldb_ildap', 'ldb_ildap/ldb_ildap.c',
90                          init_function='LDB_BACKEND(ldapi),LDB_BACKEND(ldaps),LDB_BACKEND(ldap)',
91                          deps='talloc cli-ldap CREDENTIALS auth_system_session',
92                          aliases='ldb_ldaps ldb_ldapi ldb_ldap',
93                          internal_module=False,
94                          subsystem='ldb')
95     else:
96         # this is not included in the s4 build
97         bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
98                          init_function='LDB_BACKEND(ldapi),LDB_BACKEND(ldaps),LDB_BACKEND(ldap)',
99                          deps='talloc lber ldap',
100                          enabled=bld.env.ENABLE_LDAP_BACKEND,
101                          internal_module=False,
102                          subsystem='ldb')
103
104     # we're not currently linking against the ldap libs, but ldb.pc.in
105     # has @LDAP_LIBS@
106     bld.env.LDAP_LIBS = ''
107
108     if not 'PACKAGE_VERSION' in bld.env:
109         bld.env.PACKAGE_VERSION = VERSION
110         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
111
112     if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
113         bld.SAMBA_LIBRARY('pyldb-util',
114                           deps='ldb',
115                           source='pyldb_util.c',
116                           public_headers='pyldb.h',
117                           vnum=VERSION,
118                           pc_files='pyldb-util.pc',
119                           pyext=True)
120
121     if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
122         if Options.is_install:
123             modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
124         else:
125             # when we run from the source directory, we want to use
126             # the current modules, not the installed ones
127             modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
128
129         if bld.env.standalone_ldb:
130             # do ABI checking on the standalone ldb
131             abi_file = 'ABI/ldb-%s.sigs' % VERSION
132             abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
133         else:
134             abi_file = None
135             abi_match = None
136
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                           pc_files='ldb.pc',
144                           vnum=VERSION, manpages='man/ldb.3',
145                           abi_file = abi_file,
146                           abi_match = abi_match,
147                           private_library=not bld.env.standalone_ldb)
148
149         bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
150                          deps='ldb pyldb-util',
151                          realname='ldb.so',
152                          cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
153
154         bld.SAMBA_MODULE('ldb_paged_results',
155                          'modules/paged_results.c',
156                          init_function='LDB_MODULE(paged_results)',
157                          subsystem='ldb')
158
159         bld.SAMBA_MODULE('ldb_asq',
160                          'modules/asq.c',
161                          init_function='LDB_MODULE(asq)',
162                          subsystem='ldb')
163
164         bld.SAMBA_MODULE('ldb_server_sort',
165                          'modules/sort.c',
166                          init_function='LDB_MODULE(server_sort)',
167                          subsystem='ldb')
168
169         bld.SAMBA_MODULE('ldb_paged_searches',
170                          'modules/paged_searches.c',
171                          init_function='LDB_MODULE(paged_searches)',
172                          enabled = s4_build,
173                          subsystem='ldb')
174
175         bld.SAMBA_MODULE('ldb_rdn_name',
176                          'modules/rdn_name.c',
177                          init_function='LDB_MODULE(rdn_name)',
178                          subsystem='ldb')
179
180         bld.SAMBA_MODULE('ldb_sample',
181                          'tests/sample_module.c',
182                          init_function='LDB_MODULE(sample)',
183                          subsystem='ldb')
184
185         bld.SAMBA_MODULE('ldb_skel',
186                          'modules/skel.c',
187                          init_function='LDB_MODULE(skel)',
188                          subsystem='ldb')
189
190         bld.SAMBA_MODULE('ldb_sqlite3',
191                          'sqlite3/ldb_sqlite3.c',
192                          init_function='LDB_BACKEND(sqlite3)',
193                          enabled=False,
194                          subsystem='ldb')
195
196         bld.SAMBA_MODULE('ldb_tdb',
197                          bld.SUBDIR('ldb_tdb',
198                                     '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
199                                     ldb_cache.c ldb_tdb_wrap.c'''),
200                          init_function='LDB_BACKEND(tdb)',
201                          deps='tdb',
202                          subsystem='ldb')
203
204         # have a separate subsystem for common/ldb.c, so it can rebuild
205         # for install with a different -DLDB_MODULESDIR=
206         bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
207                             'common/ldb.c',
208                             deps='tevent',
209                             includes='include',
210                             cflags='-DLDB_MODULESDIR=\"%s\"' % modules_dir)
211
212     if s4_build:
213         extra_cmdline_deps = ' LDBSAMBA POPT_SAMBA POPT_CREDENTIALS ' \
214                 'LIBCMDLINE_CREDENTIALS gensec'
215     else:
216         extra_cmdline_deps = ''
217
218     bld.SAMBA_SUBSYSTEM('LIBLDB_CMDLINE',
219                         'tools/ldbutil.c tools/cmdline.c',
220                         'ldb dl popt' + extra_cmdline_deps)
221
222     LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
223     for t in LDB_TOOLS.split():
224         bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='LIBLDB_CMDLINE',
225                          manpages='man/%s.1' % t)
226
227     # ldbtest doesn't get installed
228     bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='LIBLDB_CMDLINE',
229                      install=False)
230
231
232 def test(ctx):
233     '''run ldb testsuite'''
234     import Utils, samba_utils
235     cmd = 'tests/test-tdb.sh'
236     ret = samba_utils.RUN_COMMAND(cmd)
237     print("testsuite returned %d" % ret)
238     sys.exit(ret)
239
240 def dist():
241     '''makes a tarball for distribution'''
242     samba_dist.dist()