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