wafsamba: Fix typo: noextenion -> noextension.
[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.find_program('xsltproc', var='XSLTPROC')
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         # this is only in the s4 build
78         bld.SAMBA_MODULE('ldb_ildap', 'ldb_ildap/ldb_ildap.c',
79                          init_function='LDB_BACKEND(ldapi),LDB_BACKEND(ldaps),LDB_BACKEND(ldap)',
80                          deps='talloc LIBCLI_LDAP CREDENTIALS',
81                          internal_module=not bld.CONFIG_SET('USING_SYSTEM_LDB'),
82                          subsystem='ldb')
83     else:
84         # this is not included in the s4 build
85         bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
86                          init_function='LDB_BACKEND(ldapi),LDB_BACKEND(ldaps),LDB_BACKEND(ldap)',
87                          deps='talloc lber ldap',
88                          enabled=bld.env.ENABLE_LDAP_BACKEND,
89                          subsystem='ldb')
90
91     # we're not currently linking against the ldap libs, but ldb.pc.in
92     # has @LDAP_LIBS@
93     bld.env.LDAP_LIBS = ''
94
95     if not 'PACKAGE_VERSION' in bld.env:
96         bld.env.PACKAGE_VERSION = VERSION
97         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
98
99     abi_file = 'ABI/ldb-%s.sigs' % VERSION
100
101     bld.SAMBA_SUBSYSTEM('pyldb_util', deps='ldb',
102             source='pyldb_util.c', needs_python=True)
103
104     if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
105         modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
106         bld.SAMBA_LIBRARY('ldb',
107                           COMMON_SRC + ' ' + LDB_MAP_SRC,
108                           deps='tevent',
109                           includes='include',
110                           public_headers='include/ldb.h include/ldb_errors.h '\
111                               'include/ldb_module.h include/ldb_handlers.h',
112                           pc_files='ldb.pc',
113                           cflags='-DLDB_MODULESDIR=\"%s\"' % modules_dir,
114                           abi_file=abi_file,
115                           abi_match='!ldb_*module_ops !ldb_*backend_ops ldb_*',
116                           vnum=VERSION, manpages='man/ldb.3',
117                           is_bundled=not bld.env.standalone_ldb)
118
119         bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
120                          deps='ldb pyldb_util',
121                          realname='ldb.so')
122
123         bld.SAMBA_MODULE('ldb_paged_results',
124                          'modules/paged_results.c',
125                          init_function='LDB_MODULE(paged_results)',
126                          subsystem='ldb')
127
128         bld.SAMBA_MODULE('ldb_asq',
129                          'modules/asq.c',
130                          init_function='LDB_MODULE(asq)',
131                          subsystem='ldb')
132
133         bld.SAMBA_MODULE('ldb_server_sort',
134                          'modules/sort.c',
135                          init_function='LDB_MODULE(server_sort)',
136                          subsystem='ldb')
137
138         bld.SAMBA_MODULE('ldb_paged_searches',
139                          'modules/paged_searches.c',
140                          init_function='LDB_MODULE(paged_searches)',
141                          enabled = s4_build,
142                          subsystem='ldb')
143
144         bld.SAMBA_MODULE('ldb_rdn_name',
145                          'modules/rdn_name.c',
146                          init_function='LDB_MODULE(rdn_name)',
147                          subsystem='ldb')
148
149         bld.SAMBA_MODULE('ldb_sample',
150                          'tests/sample_module.c',
151                          init_function='LDB_MODULE(sample)',
152                          subsystem='ldb')
153
154         bld.SAMBA_MODULE('ldb_skel',
155                          'modules/skel.c',
156                          init_function='LDB_MODULE(skel)',
157                          subsystem='ldb')
158
159         bld.SAMBA_MODULE('ldb_sqlite3',
160                          'sqlite3/ldb_sqlite3.c',
161                          init_function='LDB_BACKEND(sqlite3)',
162                          enabled=False,
163                          subsystem='ldb')
164
165         bld.SAMBA_MODULE('ldb_tdb',
166                          bld.SUBDIR('ldb_tdb',
167                                     '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
168                                     ldb_cache.c ldb_tdb_wrap.c'''),
169                          init_function='LDB_BACKEND(tdb)',
170                          deps='tdb',
171                          subsystem='ldb')
172
173     if s4_build:
174         extra_cmdline_deps = ' LDBSAMBA POPT_SAMBA POPT_CREDENTIALS ' \
175                 'LIBCMDLINE_CREDENTIALS gensec'
176     else:
177         extra_cmdline_deps = ''
178
179     bld.SAMBA_SUBSYSTEM('LIBLDB_CMDLINE',
180                         'tools/ldbutil.c tools/cmdline.c',
181                         'ldb dl popt' + extra_cmdline_deps)
182
183     LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
184     for t in LDB_TOOLS.split():
185         bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='LIBLDB_CMDLINE',
186                          manpages='man/%s.1' % t)
187
188     # ldbtest doesn't get installed
189     bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='LIBLDB_CMDLINE',
190                      install=False)
191
192
193 def test(ctx):
194     '''run ldb testsuite'''
195     import Utils
196     cmd = 'tests/test-tdb.sh'
197     os.system(cmd)
198
199 def dist():
200     '''makes a tarball for distribution'''
201     samba_dist.dist()