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