waf: remove the restriction that private libraries must not have a vnum
[nivanova/samba-autobuild/.git] / source4 / lib / ldb / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'ldb'
4 VERSION = '0.9.20'
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, Options
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.PRIVATE_EXTENSION_DEFAULT('ldb', noextension='ldb')
26     opt.RECURSE('lib/tdb')
27     opt.RECURSE('lib/tevent')
28     opt.RECURSE('lib/replace')
29
30 def configure(conf):
31     conf.RECURSE('lib/tdb')
32     conf.RECURSE('lib/tevent')
33     conf.RECURSE('lib/popt')
34     conf.RECURSE('lib/replace')
35
36     # where does the default LIBDIR end up? in conf.env somewhere?
37     #
38     conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
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         if conf.CHECK_BUNDLED_SYSTEM('pyldb-util', minversion=VERSION,
48                                      onlyif='talloc tdb tevent ldb',
49                                      implied_deps='replace talloc tdb tevent ldb'):
50             conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
51
52     if conf.env.standalone_ldb:
53         conf.CHECK_XSLTPROC_MANPAGES()
54
55         # we need this for the ldap backend
56         if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
57             conf.env.ENABLE_LDAP_BACKEND = True
58
59     conf.DEFINE('LDB_VERSION', VERSION, quote=True)
60
61     conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
62
63     # we don't want any libraries or modules to rely on runtime
64     # resolution of symbols
65     conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
66
67     conf.SAMBA_CONFIG_H()
68
69 def build(bld):
70     bld.RECURSE('lib/tdb')
71     bld.RECURSE('lib/tevent')
72     bld.RECURSE('lib/popt')
73     bld.RECURSE('lib/replace')
74
75     if bld.env.standalone_ldb:
76         private_library = False
77     else:
78         private_library = True
79
80     LDB_MAP_SRC = bld.SUBDIR('ldb_map',
81                              'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
82
83     COMMON_SRC = bld.SUBDIR('common',
84                             '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
85                             ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c
86                             ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
87
88     bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
89                      init_function='ldb_ldap_init',
90                      module_init_name='ldb_init_module',
91                      deps='talloc lber ldap ldb',
92                      enabled=bld.env.ENABLE_LDAP_BACKEND,
93                      internal_module=False,
94                      subsystem='ldb')
95
96     # we're not currently linking against the ldap libs, but ldb.pc.in
97     # has @LDAP_LIBS@
98     bld.env.LDAP_LIBS = ''
99
100     if not 'PACKAGE_VERSION' in bld.env:
101         bld.env.PACKAGE_VERSION = VERSION
102         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
103
104     if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
105         bld.SAMBA_LIBRARY('pyldb-util',
106                           deps='ldb',
107                           source='pyldb_util.c',
108                           public_headers='pyldb.h',
109                           vnum=VERSION,
110                           private_library=private_library,
111                           pc_files='pyldb-util.pc',
112                           pyext=True)
113
114     if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
115         if Options.is_install:
116             modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
117         else:
118             # when we run from the source directory, we want to use
119             # the current modules, not the installed ones
120             modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
121
122         abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
123
124         bld.SAMBA_LIBRARY('ldb',
125                           COMMON_SRC + ' ' + LDB_MAP_SRC,
126                           deps='tevent LIBLDB_MAIN',
127                           includes='include',
128                           public_headers='include/ldb.h include/ldb_errors.h '\
129                           'include/ldb_module.h include/ldb_handlers.h',
130                           pc_files='ldb.pc',
131                           vnum=VERSION,
132                           private_library=private_library,
133                           manpages='man/ldb.3',
134                           abi_directory = 'ABI',
135                           abi_match = abi_match)
136
137
138         bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
139                          deps='ldb pyldb-util',
140                          realname='ldb.so',
141                          cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
142
143         bld.SAMBA_MODULE('ldb_paged_results',
144                          'modules/paged_results.c',
145                          init_function='ldb_paged_results_init',
146                          module_init_name='ldb_init_module',
147                          deps='ldb',
148                          subsystem='ldb')
149
150         bld.SAMBA_MODULE('ldb_asq',
151                          'modules/asq.c',
152                          init_function='ldb_asq_init',
153                          module_init_name='ldb_init_module',
154                          deps='ldb',
155                          subsystem='ldb')
156
157         bld.SAMBA_MODULE('ldb_server_sort',
158                          'modules/sort.c',
159                          init_function='ldb_server_sort_init',
160                          module_init_name='ldb_init_module',
161                          deps='ldb',
162                          subsystem='ldb')
163
164         bld.SAMBA_MODULE('ldb_paged_searches',
165                          'modules/paged_searches.c',
166                          init_function='ldb_paged_searches_init',
167                          module_init_name='ldb_init_module',
168                          deps='ldb',
169                          subsystem='ldb')
170
171         bld.SAMBA_MODULE('ldb_rdn_name',
172                          'modules/rdn_name.c',
173                          init_function='ldb_rdn_name_init',
174                          module_init_name='ldb_init_module',
175                          deps='ldb',
176                          subsystem='ldb')
177
178         bld.SAMBA_MODULE('ldb_sample',
179                          'tests/sample_module.c',
180                          init_function='ldb_sample_init',
181                          module_init_name='ldb_init_module',
182                          deps='ldb',
183                          subsystem='ldb')
184
185         bld.SAMBA_MODULE('ldb_skel',
186                          'modules/skel.c',
187                          init_function='ldb_skel_init',
188                          module_init_name='ldb_init_module',
189                          deps='ldb',
190                          subsystem='ldb')
191
192         bld.SAMBA_MODULE('ldb_sqlite3',
193                          'sqlite3/ldb_sqlite3.c',
194                          init_function='ldb_sqlite3_init',
195                          module_init_name='ldb_init_module',
196                          enabled=False,
197                          deps='ldb',
198                          subsystem='ldb')
199
200         bld.SAMBA_MODULE('ldb_tdb',
201                          bld.SUBDIR('ldb_tdb',
202                                     '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
203                                     ldb_cache.c ldb_tdb_wrap.c'''),
204                          init_function='ldb_tdb_init',
205                          module_init_name='ldb_init_module',
206                          deps='tdb ldb',
207                          subsystem='ldb')
208
209         # have a separate subsystem for common/ldb.c, so it can rebuild
210         # for install with a different -DLDB_MODULESDIR=
211         bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
212                             'common/ldb.c',
213                             deps='tevent',
214                             includes='include',
215                             cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
216
217         LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
218         for t in LDB_TOOLS.split():
219             bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
220                              manpages='man/%s.1' % t)
221
222         # ldbtest doesn't get installed
223         bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='ldb-cmdline ldb',
224                          install=False)
225
226     bld.SAMBA_LIBRARY('ldb-cmdline',
227                       source='tools/ldbutil.c tools/cmdline.c',
228                       deps='ldb dl popt',
229                       private_library=True)
230
231
232 def test(ctx):
233     '''run ldb testsuite'''
234     import Utils, samba_utils
235     cmd = 'tests/test-tdb.sh'
236     ret = samba_utils.RUN_COMMAND(cmd)
237     print("testsuite returned %d" % ret)
238     # FIXME: Run python testsuite
239     sys.exit(ret)
240
241 def dist():
242     '''makes a tarball for distribution'''
243     samba_dist.dist()
244
245 def reconfigure(ctx):
246     '''reconfigure if config scripts have changed'''
247     import samba_utils
248     samba_utils.reconfigure(ctx)