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