s4-waf: added simple 'waf test' support for tdb, talloc and ldb
[nivanova/samba-autobuild/.git] / source4 / lib / ldb / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'ldb'
4 VERSION = '0.9.10'
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('''lib/ldb:. lib/replace:lib/replace lib/talloc:lib/talloc
19                         lib/tdb:lib/tdb lib/tevent:lib/tevent buildtools:buildtools''')
20
21
22 def set_options(opt):
23     opt.BUILTIN_DEFAULT('replace')
24     opt.BUNDLED_EXTENSION_DEFAULT('ldb', noextenion='ldb')
25     opt.RECURSE('lib/tdb')
26     opt.RECURSE('lib/tevent')
27
28 def configure(conf):
29     conf.RECURSE('lib/tdb')
30     conf.RECURSE('lib/tevent')
31     conf.RECURSE('lib/popt')
32
33     # where does the default LIBDIR end up? in conf.env somewhere?
34     #
35     conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
36
37     s4_build = getattr(conf.env, '_SAMBA_BUILD_', 0) == 4
38
39
40     if not s4_build:
41         if conf.CHECK_BUNDLED_SYSTEM('ldb', minversion=VERSION,
42                                      onlyif='talloc tdb tevent',
43                                      implied_deps='replace talloc tdb tevent'):
44             conf.define('USING_SYSTEM_LDB', 1)
45         # we need this for the ldap backend
46         conf.CHECK_FUNCS_IN('ber_flush ldap_open', 'lber ldap', headers='lber.h ldap.h', mandatory=True)
47
48     conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
49
50     conf.SAMBA_CONFIG_H()
51
52 def build(bld):
53     bld.RECURSE('lib/tdb')
54     bld.RECURSE('lib/tevent')
55     bld.RECURSE('lib/popt')
56
57     # in Samba4 we build some extra modules, and add extra
58     # capabilities to the ldb cmdline tools
59     s4_build = getattr(bld.env, '_SAMBA_BUILD_', 0) == 4
60
61     LDB_MAP_SRC = bld.SUBDIR('ldb_map',
62                              'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
63
64     COMMON_SRC = bld.SUBDIR('common',
65                             '''ldb.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
66                             ldb_debug.c ldb_dn.c ldb_match.c
67                             ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
68
69     bld.SAMBA_SUBSYSTEM('LIBLDB',
70                         includes='include',
71                         deps='tevent',
72                         source='common/ldb_modules.c')
73
74     bld.SAMBA_MODULE('ldb_asq',
75                      'modules/asq.c',
76                      init_function='LDB_MODULE(asq)',
77                      subsystem='LIBLDB')
78
79     bld.SAMBA_MODULE('ldb_server_sort',
80                      'modules/sort.c',
81                      init_function='LDB_MODULE(server_sort)',
82                      subsystem='LIBLDB')
83
84     bld.SAMBA_MODULE('ldb_paged_results',
85                      'modules/paged_results.c',
86                      init_function='LDB_MODULE(paged_results)',
87                      subsystem='LIBLDB')
88
89     bld.SAMBA_MODULE('ldb_paged_searches',
90                      'modules/paged_searches.c',
91                      init_function='LDB_MODULE(paged_searches)',
92                      enabled = s4_build,
93                      subsystem='LIBLDB')
94
95     bld.SAMBA_MODULE('ldb_rdn_name',
96                      'modules/rdn_name.c',
97                      init_function='LDB_MODULE(rdn_name)',
98                      subsystem='LIBLDB')
99
100     bld.SAMBA_MODULE('ldb_sample',
101                      'tests/sample_module.c',
102                      init_function='LDB_MODULE(sample)',
103                      subsystem='LIBLDB')
104
105     bld.SAMBA_MODULE('ldb_skel',
106                      'modules/skel.c',
107                      init_function='LDB_MODULE(skel)',
108                      subsystem='LIBLDB')
109
110     bld.SAMBA_MODULE('ldb_sqlite3',
111                      'sqlite3/ldb_sqlite3.c',
112                      init_function='LDB_BACKEND(sqlite3)',
113                      enabled=False,
114                      subsystem='LIBLDB')
115
116     bld.SAMBA_MODULE('ldb_tdb',
117                      bld.SUBDIR('ldb_tdb',
118                                 '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
119                                 ldb_cache.c ldb_tdb_wrap.c'''),
120                      init_function='LDB_BACKEND(tdb)',
121                      deps='tdb',
122                      subsystem='LIBLDB')
123
124     # this is only in the s4 build
125     bld.SAMBA_MODULE('ldb_ildap', 'ldb_ildap/ldb_ildap.c',
126                      init_function='LDB_BACKEND(ldapi),LDB_BACKEND(ldaps),LDB_BACKEND(ldap)',
127                      deps='talloc LIBCLI_LDAP CREDENTIALS',
128                      enabled=s4_build,
129                      subsystem='LIBLDB')
130
131     # this is not included in the s4 build
132     bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
133                      init_function='LDB_BACKEND(ldapi),LDB_BACKEND(ldaps),LDB_BACKEND(ldap)',
134                      deps='talloc lber ldap',
135                      enabled=not s4_build,
136                      subsystem='LIBLDB')
137
138     # we're not currently linking against the ldap libs, but ldb.pc.in
139     # has @LDAP_LIBS@
140     bld.env.LDAP_LIBS = ''
141
142     if not 'PACKAGE_VERSION' in bld.env:
143         bld.env.PACKAGE_VERSION = VERSION
144         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
145
146     ldb_deps = 'tevent LIBLDB'
147     if s4_build:
148         ldb_deps += ' LDBSAMBA POPT_CREDENTIALS POPT_SAMBA LIBCMDLINE_CREDENTIALS gensec'
149
150     if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
151         modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
152         bld.SAMBA_LIBRARY('ldb',
153                           COMMON_SRC + ' ' + LDB_MAP_SRC,
154                           deps=ldb_deps,
155                           includes='include',
156                           public_headers='include/ldb.h include/ldb_errors.h',
157                           pc_files='ldb.pc',
158                           cflags='-DLDB_MODULESDIR=\"%s\"' % modules_dir,
159                           vnum=VERSION)
160
161     bld.SAMBA_SUBSYSTEM('LIBLDB_CMDLINE',
162                         'tools/ldbutil.c tools/cmdline.c',
163                         'ldb dl popt')
164
165     LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
166     for t in LDB_TOOLS.split():
167         bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='LIBLDB_CMDLINE')
168
169     # ldbtest doesn't get installed
170     bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='LIBLDB_CMDLINE', install=False)
171
172     if s4_build:
173         bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
174                          deps='ldb',
175                          realname='ldb.so')
176
177
178 def test(ctx):
179     '''run ldb testsuite'''
180     import Utils
181     cmd = 'tests/test-tdb.sh'
182     os.system(cmd)