s4-waf: use cflags for LDB_MODULESDIR
[Samba/ekacnet.git] / source4 / lib / ldb / wscript
blobde70fa454ae472d213587a66a99064b8f67f7191
1 #!/usr/bin/env python
3 VERSION = '0.9.10'
5 srcdir = '../../..'
6 blddir = 'bin'
8 import sys
9 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
10 import wafsamba
13 LIBTDB_DIR= srcdir + '/lib/tdb'
14 LIBTEVENT_DIR= srcdir + '/lib/tevent'
15 LIBPOPT_DIR= srcdir + '/lib/popt'
17 def set_options(opt):
18 opt.BUILTIN_DEFAULT('replace')
19 opt.BUNDLED_EXTENSION_DEFAULT('ldb', noextenion='ldb')
20 opt.recurse(LIBTDB_DIR)
21 opt.recurse(LIBTEVENT_DIR)
23 def configure(conf):
24 conf.sub_config(LIBTDB_DIR)
25 conf.sub_config(LIBTEVENT_DIR)
26 conf.sub_config(LIBPOPT_DIR)
27 # where does the default LIBDIR end up? in conf.env somewhere?
29 conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
31 s4_build = getattr(conf.env, '_SAMBA_BUILD_', 0) == 4
34 if not s4_build:
35 if conf.CHECK_BUNDLED_SYSTEM('ldb', minversion=VERSION,
36 onlyif='talloc tdb tevent',
37 implied_deps='replace talloc tdb tevent'):
38 conf.define('USING_SYSTEM_LDB', 1)
39 # we need this for the ldap backend
40 conf.CHECK_FUNCS_IN('ber_flush ldap_open', 'lber ldap', headers='lber.h ldap.h', mandatory=True)
42 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
44 conf.SAMBA_CONFIG_H()
46 def build(bld):
47 bld.BUILD_SUBDIR(LIBTDB_DIR)
48 bld.BUILD_SUBDIR(LIBTEVENT_DIR)
49 bld.BUILD_SUBDIR(LIBPOPT_DIR)
51 # in Samba4 we build some extra modules, and add extra
52 # capabilities to the ldb cmdline tools
53 s4_build = getattr(bld.env, '_SAMBA_BUILD_', 0) == 4
55 LDB_MAP_SRC = bld.SUBDIR('ldb_map',
56 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
58 COMMON_SRC = bld.SUBDIR('common',
59 '''ldb.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
60 ldb_debug.c ldb_dn.c ldb_match.c
61 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
63 bld.SAMBA_SUBSYSTEM('LIBLDB',
64 includes='include',
65 deps='tevent',
66 source='common/ldb_modules.c')
68 bld.SAMBA_MODULE('ldb_asq',
69 'modules/asq.c',
70 init_function='LDB_MODULE(asq)',
71 subsystem='LIBLDB')
73 bld.SAMBA_MODULE('ldb_server_sort',
74 'modules/sort.c',
75 init_function='LDB_MODULE(server_sort)',
76 subsystem='LIBLDB')
78 bld.SAMBA_MODULE('ldb_paged_results',
79 'modules/paged_results.c',
80 init_function='LDB_MODULE(paged_results)',
81 subsystem='LIBLDB')
83 bld.SAMBA_MODULE('ldb_paged_searches',
84 'modules/paged_searches.c',
85 init_function='LDB_MODULE(paged_searches)',
86 enabled = s4_build,
87 subsystem='LIBLDB')
89 bld.SAMBA_MODULE('ldb_rdn_name',
90 'modules/rdn_name.c',
91 init_function='LDB_MODULE(rdn_name)',
92 subsystem='LIBLDB')
94 bld.SAMBA_MODULE('ldb_sample',
95 'tests/sample_module.c',
96 init_function='LDB_MODULE(sample)',
97 subsystem='LIBLDB')
99 bld.SAMBA_MODULE('ldb_skel',
100 'modules/skel.c',
101 init_function='LDB_MODULE(skel)',
102 subsystem='LIBLDB')
104 bld.SAMBA_MODULE('ldb_sqlite3',
105 'sqlite3/ldb_sqlite3.c',
106 init_function='LDB_BACKEND(sqlite3)',
107 enabled=False,
108 subsystem='LIBLDB')
110 bld.SAMBA_MODULE('ldb_tdb',
111 bld.SUBDIR('ldb_tdb',
112 '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
113 ldb_cache.c ldb_tdb_wrap.c'''),
114 init_function='LDB_BACKEND(tdb)',
115 deps='tdb',
116 subsystem='LIBLDB')
118 # this is only in the s4 build
119 bld.SAMBA_MODULE('ldb_ildap', 'ldb_ildap/ldb_ildap.c',
120 init_function='LDB_BACKEND(ldapi),LDB_BACKEND(ldaps),LDB_BACKEND(ldap)',
121 deps='talloc LIBCLI_LDAP CREDENTIALS',
122 enabled=s4_build,
123 subsystem='LIBLDB')
125 # this is not included in the s4 build
126 bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
127 init_function='LDB_BACKEND(ldapi),LDB_BACKEND(ldaps),LDB_BACKEND(ldap)',
128 deps='talloc lber ldap',
129 enabled=not s4_build,
130 subsystem='LIBLDB')
132 # we're not currently linking against the ldap libs, but ldb.pc.in
133 # has @LDAP_LIBS@
134 bld.env.LDAP_LIBS = ''
136 if not 'PACKAGE_VERSION' in bld.env:
137 bld.env.PACKAGE_VERSION = VERSION
138 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
140 ldb_deps = 'tevent LIBLDB'
141 if s4_build:
142 ldb_deps += ' LDBSAMBA POPT_CREDENTIALS POPT_SAMBA LIBCMDLINE_CREDENTIALS gensec'
144 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
145 modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
146 bld.SAMBA_LIBRARY('ldb',
147 COMMON_SRC + ' ' + LDB_MAP_SRC,
148 deps=ldb_deps,
149 includes='include',
150 public_headers='include/ldb.h include/ldb_errors.h',
151 pc_files='ldb.pc',
152 cflags='-DLDB_MODULESDIR=\"%s\"' % modules_dir,
153 vnum=VERSION)
155 bld.SAMBA_SUBSYSTEM('LIBLDB_CMDLINE',
156 'tools/ldbutil.c tools/cmdline.c',
157 'ldb dl popt')
159 LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
160 for t in LDB_TOOLS.split():
161 bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='LIBLDB_CMDLINE')
163 # ldbtest doesn't get installed
164 bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='LIBLDB_CMDLINE', install=False)
166 if s4_build:
167 bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
168 deps='ldb',
169 realname='ldb.so')