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