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