s4-ldb: use CHECK_XSLTPROC_MANPAGES()
[nivanova/samba-autobuild/.git] / source4 / lib / ldb / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'ldb'
4 VERSION = '0.9.12'
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
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.BUNDLED_EXTENSION_DEFAULT('ldb', noextension='ldb')
26     opt.RECURSE('lib/tdb')
27     opt.RECURSE('lib/tevent')
28
29 def configure(conf):
30     conf.RECURSE('lib/tdb')
31     conf.RECURSE('lib/tevent')
32     conf.RECURSE('lib/popt')
33
34     # where does the default LIBDIR end up? in conf.env somewhere?
35     #
36     conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
37
38     s4_build = getattr(conf.env, '_SAMBA_BUILD_', 0) == 4
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
48     if conf.env.standalone_ldb:
49         conf.CHECK_XSLTPROC_MANPAGES()
50
51         # we need this for the ldap backend
52         if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
53             conf.env.ENABLE_LDAP_BACKEND = True
54
55     conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
56
57     conf.SAMBA_CONFIG_H()
58
59 def build(bld):
60     bld.RECURSE('lib/tdb')
61     bld.RECURSE('lib/tevent')
62     bld.RECURSE('lib/popt')
63
64     # in Samba4 we build some extra modules, and add extra
65     # capabilities to the ldb cmdline tools
66     s4_build = getattr(bld.env, '_SAMBA_BUILD_', 0) == 4
67
68     LDB_MAP_SRC = bld.SUBDIR('ldb_map',
69                              'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
70
71     COMMON_SRC = bld.SUBDIR('common',
72                             '''ldb.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
73                             ldb_debug.c ldb_dn.c ldb_match.c ldb_modules.c
74                             ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
75
76     if s4_build:
77         builtin_ildap = not bld.CONFIG_SET('USING_SYSTEM_LDB')
78         # this is only in the s4 build
79         bld.SAMBA_MODULE('ldb_ildap', 'ldb_ildap/ldb_ildap.c',
80                          init_function='LDB_BACKEND(ldapi),LDB_BACKEND(ldaps),LDB_BACKEND(ldap)',
81                          deps='talloc LIBCLI_LDAP CREDENTIALS',
82                          internal_module=builtin_ildap,
83                          subsystem='ldb')
84     else:
85         builtin_ildap = False
86         # this is not included in the s4 build
87         bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
88                          init_function='LDB_BACKEND(ldapi),LDB_BACKEND(ldaps),LDB_BACKEND(ldap)',
89                          deps='talloc lber ldap',
90                          enabled=bld.env.ENABLE_LDAP_BACKEND,
91                          subsystem='ldb')
92
93     # we're not currently linking against the ldap libs, but ldb.pc.in
94     # has @LDAP_LIBS@
95     bld.env.LDAP_LIBS = ''
96
97     if not 'PACKAGE_VERSION' in bld.env:
98         bld.env.PACKAGE_VERSION = VERSION
99         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
100
101     if builtin_ildap:
102         abi_file = 'ABI/ldb-ildap-%s.sigs' % VERSION
103     else:
104         abi_file = 'ABI/ldb-%s.sigs' % VERSION
105
106     bld.SAMBA_SUBSYSTEM('pyldb_util', deps='ldb',
107             source='pyldb_util.c', needs_python=True)
108
109     if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
110         modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
111         if bld.env.standalone_ldb:
112             bld.SAMBA_LIBRARY('ldb',
113                               COMMON_SRC + ' ' + LDB_MAP_SRC,
114                               deps='tevent',
115                               includes='include',
116                               public_headers='include/ldb.h include/ldb_errors.h '\
117                                   'include/ldb_module.h include/ldb_handlers.h',
118                               pc_files='ldb.pc',
119                               cflags='-DLDB_MODULESDIR=\"%s\"' % modules_dir,
120                               abi_file=abi_file,
121                               abi_match='!ldb_*module_ops !ldb_*backend_ops ldb_*',
122                               vnum=VERSION, manpages='man/ldb.3',
123                               is_bundled=not bld.env.standalone_ldb)
124         else:
125             bld.SAMBA_LIBRARY('ldb',
126                               COMMON_SRC + ' ' + LDB_MAP_SRC,
127                               deps='tevent',
128                               includes='include',
129                               public_headers='include/ldb.h include/ldb_errors.h '\
130                                   'include/ldb_module.h include/ldb_handlers.h',
131                               pc_files='ldb.pc',
132                               cflags='-DLDB_MODULESDIR=\"%s\"' % modules_dir,
133                               vnum=VERSION, manpages='man/ldb.3',
134                               is_bundled=not bld.env.standalone_ldb)
135
136         bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
137                          deps='ldb pyldb_util',
138                          realname='ldb.so')
139
140         bld.SAMBA_MODULE('ldb_paged_results',
141                          'modules/paged_results.c',
142                          init_function='LDB_MODULE(paged_results)',
143                          subsystem='ldb')
144
145         bld.SAMBA_MODULE('ldb_asq',
146                          'modules/asq.c',
147                          init_function='LDB_MODULE(asq)',
148                          subsystem='ldb')
149
150         bld.SAMBA_MODULE('ldb_server_sort',
151                          'modules/sort.c',
152                          init_function='LDB_MODULE(server_sort)',
153                          subsystem='ldb')
154
155         bld.SAMBA_MODULE('ldb_paged_searches',
156                          'modules/paged_searches.c',
157                          init_function='LDB_MODULE(paged_searches)',
158                          enabled = s4_build,
159                          subsystem='ldb')
160
161         bld.SAMBA_MODULE('ldb_rdn_name',
162                          'modules/rdn_name.c',
163                          init_function='LDB_MODULE(rdn_name)',
164                          subsystem='ldb')
165
166         bld.SAMBA_MODULE('ldb_sample',
167                          'tests/sample_module.c',
168                          init_function='LDB_MODULE(sample)',
169                          subsystem='ldb')
170
171         bld.SAMBA_MODULE('ldb_skel',
172                          'modules/skel.c',
173                          init_function='LDB_MODULE(skel)',
174                          subsystem='ldb')
175
176         bld.SAMBA_MODULE('ldb_sqlite3',
177                          'sqlite3/ldb_sqlite3.c',
178                          init_function='LDB_BACKEND(sqlite3)',
179                          enabled=False,
180                          subsystem='ldb')
181
182         bld.SAMBA_MODULE('ldb_tdb',
183                          bld.SUBDIR('ldb_tdb',
184                                     '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
185                                     ldb_cache.c ldb_tdb_wrap.c'''),
186                          init_function='LDB_BACKEND(tdb)',
187                          deps='tdb',
188                          subsystem='ldb')
189
190     if s4_build:
191         extra_cmdline_deps = ' LDBSAMBA POPT_SAMBA POPT_CREDENTIALS ' \
192                 'LIBCMDLINE_CREDENTIALS gensec'
193     else:
194         extra_cmdline_deps = ''
195
196     bld.SAMBA_SUBSYSTEM('LIBLDB_CMDLINE',
197                         'tools/ldbutil.c tools/cmdline.c',
198                         'ldb dl popt' + extra_cmdline_deps)
199
200     LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
201     for t in LDB_TOOLS.split():
202         bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='LIBLDB_CMDLINE',
203                          manpages='man/%s.1' % t)
204
205     # ldbtest doesn't get installed
206     bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='LIBLDB_CMDLINE',
207                      install=False)
208
209
210 def test(ctx):
211     '''run ldb testsuite'''
212     import Utils
213     cmd = 'tests/test-tdb.sh'
214     os.system(cmd)
215
216 def dist():
217     '''makes a tarball for distribution'''
218     samba_dist.dist()