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