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