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