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