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