| 1 | #!/usr/bin/env python
|
|---|
| 2 |
|
|---|
| 3 | APPNAME = 'ldb'
|
|---|
| 4 | VERSION = '1.1.26'
|
|---|
| 5 |
|
|---|
| 6 | blddir = 'bin'
|
|---|
| 7 |
|
|---|
| 8 | import sys, os
|
|---|
| 9 |
|
|---|
| 10 | # find the buildtools directory
|
|---|
| 11 | srcdir = '.'
|
|---|
| 12 | while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
|
|---|
| 13 | srcdir = srcdir + '/..'
|
|---|
| 14 | sys.path.insert(0, srcdir + '/buildtools/wafsamba')
|
|---|
| 15 |
|
|---|
| 16 | import wafsamba, samba_dist, Utils
|
|---|
| 17 |
|
|---|
| 18 | samba_dist.DIST_DIRS('''lib/ldb:. lib/replace:lib/replace lib/talloc:lib/talloc
|
|---|
| 19 | lib/tdb:lib/tdb lib/tdb:lib/tdb lib/tevent:lib/tevent
|
|---|
| 20 | third_party/popt:third_party/popt
|
|---|
| 21 | buildtools:buildtools third_party/waf:third_party/waf''')
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | def set_options(opt):
|
|---|
| 25 | opt.BUILTIN_DEFAULT('replace')
|
|---|
| 26 | opt.PRIVATE_EXTENSION_DEFAULT('ldb', noextension='ldb')
|
|---|
| 27 | opt.RECURSE('lib/tdb')
|
|---|
| 28 | opt.RECURSE('lib/tevent')
|
|---|
| 29 | opt.RECURSE('lib/replace')
|
|---|
| 30 | opt.tool_options('python') # options for disabling pyc or pyo compilation
|
|---|
| 31 |
|
|---|
| 32 | def configure(conf):
|
|---|
| 33 | conf.RECURSE('lib/tdb')
|
|---|
| 34 | conf.RECURSE('lib/tevent')
|
|---|
| 35 |
|
|---|
| 36 | if conf.CHECK_FOR_THIRD_PARTY():
|
|---|
| 37 | conf.RECURSE('third_party/popt')
|
|---|
| 38 | else:
|
|---|
| 39 | if not conf.CHECK_POPT():
|
|---|
| 40 | raise Utils.WafError('popt development packages have not been found.\nIf third_party is installed, check that it is in the proper place.')
|
|---|
| 41 | else:
|
|---|
| 42 | conf.define('USING_SYSTEM_POPT', 1)
|
|---|
| 43 |
|
|---|
| 44 | conf.RECURSE('lib/replace')
|
|---|
| 45 | conf.find_program('python', var='PYTHON')
|
|---|
| 46 | conf.find_program('xsltproc', var='XSLTPROC')
|
|---|
| 47 | conf.check_tool('python')
|
|---|
| 48 | conf.check_python_version((2,4,2))
|
|---|
| 49 | conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
|
|---|
| 50 |
|
|---|
| 51 | # where does the default LIBDIR end up? in conf.env somewhere?
|
|---|
| 52 | #
|
|---|
| 53 | conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
|
|---|
| 54 |
|
|---|
| 55 | conf.env.standalone_ldb = conf.IN_LAUNCH_DIR()
|
|---|
| 56 |
|
|---|
| 57 | if not conf.env.standalone_ldb:
|
|---|
| 58 | if conf.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util', minversion=VERSION,
|
|---|
| 59 | onlyif='talloc tdb tevent',
|
|---|
| 60 | implied_deps='replace talloc tdb tevent ldb'):
|
|---|
| 61 | conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
|
|---|
| 62 | if conf.CHECK_BUNDLED_SYSTEM_PKG('ldb', minversion=VERSION,
|
|---|
| 63 | onlyif='talloc tdb tevent pyldb-util',
|
|---|
| 64 | implied_deps='replace talloc tdb tevent'):
|
|---|
| 65 | conf.define('USING_SYSTEM_LDB', 1)
|
|---|
| 66 |
|
|---|
| 67 | if conf.env.standalone_ldb:
|
|---|
| 68 | conf.CHECK_XSLTPROC_MANPAGES()
|
|---|
| 69 |
|
|---|
| 70 | # we need this for the ldap backend
|
|---|
| 71 | if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
|
|---|
| 72 | conf.env.ENABLE_LDAP_BACKEND = True
|
|---|
| 73 |
|
|---|
| 74 | # we don't want any libraries or modules to rely on runtime
|
|---|
| 75 | # resolution of symbols
|
|---|
| 76 | if not sys.platform.startswith("openbsd"):
|
|---|
| 77 | conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
|
|---|
| 78 |
|
|---|
| 79 | conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
|
|---|
| 80 |
|
|---|
| 81 | conf.SAMBA_CONFIG_H()
|
|---|
| 82 |
|
|---|
| 83 | conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
|
|---|
| 84 |
|
|---|
| 85 | def build(bld):
|
|---|
| 86 | bld.RECURSE('lib/tevent')
|
|---|
| 87 |
|
|---|
| 88 | if bld.CHECK_FOR_THIRD_PARTY():
|
|---|
| 89 | bld.RECURSE('third_party/popt')
|
|---|
| 90 |
|
|---|
| 91 | bld.RECURSE('lib/replace')
|
|---|
| 92 | bld.RECURSE('lib/tdb')
|
|---|
| 93 |
|
|---|
| 94 | if bld.env.standalone_ldb:
|
|---|
| 95 | private_library = False
|
|---|
| 96 | else:
|
|---|
| 97 | private_library = True
|
|---|
| 98 |
|
|---|
| 99 | LDB_MAP_SRC = bld.SUBDIR('ldb_map',
|
|---|
| 100 | 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
|
|---|
| 101 |
|
|---|
| 102 | COMMON_SRC = bld.SUBDIR('common',
|
|---|
| 103 | '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
|
|---|
| 104 | ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c ldb_pack.c
|
|---|
| 105 | ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
|
|---|
| 106 |
|
|---|
| 107 | bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
|
|---|
| 108 | init_function='ldb_ldap_init',
|
|---|
| 109 | module_init_name='ldb_init_module',
|
|---|
| 110 | deps='talloc lber ldap ldb',
|
|---|
| 111 | enabled=bld.env.ENABLE_LDAP_BACKEND,
|
|---|
| 112 | internal_module=False,
|
|---|
| 113 | subsystem='ldb')
|
|---|
| 114 |
|
|---|
| 115 | # we're not currently linking against the ldap libs, but ldb.pc.in
|
|---|
| 116 | # has @LDAP_LIBS@
|
|---|
| 117 | bld.env.LDAP_LIBS = ''
|
|---|
| 118 |
|
|---|
| 119 | if not 'PACKAGE_VERSION' in bld.env:
|
|---|
| 120 | bld.env.PACKAGE_VERSION = VERSION
|
|---|
| 121 | bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
|
|---|
| 122 |
|
|---|
| 123 | if not bld.env.disable_python:
|
|---|
| 124 | if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
|
|---|
| 125 | for env in bld.gen_python_environments(['PKGCONFIGDIR']):
|
|---|
| 126 | name = bld.pyembed_libname('pyldb-util')
|
|---|
| 127 | bld.SAMBA_LIBRARY(name,
|
|---|
| 128 | deps='ldb',
|
|---|
| 129 | source='pyldb_util.c',
|
|---|
| 130 | public_headers=('' if private_library else 'pyldb.h'),
|
|---|
| 131 | public_headers_install=not private_library,
|
|---|
| 132 | vnum=VERSION,
|
|---|
| 133 | private_library=private_library,
|
|---|
| 134 | pc_files='pyldb-util.pc',
|
|---|
| 135 | pyembed=True,
|
|---|
| 136 | abi_directory='ABI',
|
|---|
| 137 | abi_match='pyldb_*')
|
|---|
| 138 |
|
|---|
| 139 | if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
|
|---|
| 140 | bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
|
|---|
| 141 | deps='ldb ' + name,
|
|---|
| 142 | realname='ldb.so',
|
|---|
| 143 | cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
|
|---|
| 144 |
|
|---|
| 145 | for env in bld.gen_python_environments(['PKGCONFIGDIR']):
|
|---|
| 146 | bld.SAMBA_SCRIPT('_ldb_text.py',
|
|---|
| 147 | pattern='_ldb_text.py',
|
|---|
| 148 | installdir='python')
|
|---|
| 149 |
|
|---|
| 150 | bld.INSTALL_FILES('${PYTHONARCHDIR}', '_ldb_text.py')
|
|---|
| 151 |
|
|---|
| 152 | if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
|
|---|
| 153 | if bld.is_install:
|
|---|
| 154 | modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
|
|---|
| 155 | else:
|
|---|
| 156 | # when we run from the source directory, we want to use
|
|---|
| 157 | # the current modules, not the installed ones
|
|---|
| 158 | modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
|
|---|
| 159 |
|
|---|
| 160 | abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
|
|---|
| 161 |
|
|---|
| 162 | ldb_headers = ('include/ldb.h include/ldb_errors.h '
|
|---|
| 163 | 'include/ldb_module.h include/ldb_handlers.h')
|
|---|
| 164 |
|
|---|
| 165 | bld.SAMBA_LIBRARY('ldb',
|
|---|
| 166 | COMMON_SRC + ' ' + LDB_MAP_SRC,
|
|---|
| 167 | deps='tevent LIBLDB_MAIN replace',
|
|---|
| 168 | includes='include',
|
|---|
| 169 | public_headers=('' if private_library else ldb_headers),
|
|---|
| 170 | public_headers_install=not private_library,
|
|---|
| 171 | pc_files='ldb.pc',
|
|---|
| 172 | vnum=VERSION,
|
|---|
| 173 | private_library=private_library,
|
|---|
| 174 | manpages='man/ldb.3',
|
|---|
| 175 | abi_directory='ABI',
|
|---|
| 176 | abi_match = abi_match)
|
|---|
| 177 |
|
|---|
| 178 | # generate a include/ldb_version.h
|
|---|
| 179 | t = bld.SAMBA_GENERATOR('ldb_version.h',
|
|---|
| 180 | rule='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
|
|---|
| 181 | dep_vars=['LDB_VERSION'],
|
|---|
| 182 | target='include/ldb_version.h',
|
|---|
| 183 | public_headers='include/ldb_version.h',
|
|---|
| 184 | public_headers_install=not private_library)
|
|---|
| 185 | t.env.LDB_VERSION = VERSION
|
|---|
| 186 |
|
|---|
| 187 |
|
|---|
| 188 | bld.SAMBA_MODULE('ldb_paged_results',
|
|---|
| 189 | 'modules/paged_results.c',
|
|---|
| 190 | init_function='ldb_paged_results_init',
|
|---|
| 191 | module_init_name='ldb_init_module',
|
|---|
| 192 | internal_module=False,
|
|---|
| 193 | deps='ldb',
|
|---|
| 194 | subsystem='ldb')
|
|---|
| 195 |
|
|---|
| 196 | bld.SAMBA_MODULE('ldb_asq',
|
|---|
| 197 | 'modules/asq.c',
|
|---|
| 198 | init_function='ldb_asq_init',
|
|---|
| 199 | module_init_name='ldb_init_module',
|
|---|
| 200 | internal_module=False,
|
|---|
| 201 | deps='ldb',
|
|---|
| 202 | subsystem='ldb')
|
|---|
| 203 |
|
|---|
| 204 | bld.SAMBA_MODULE('ldb_server_sort',
|
|---|
| 205 | 'modules/sort.c',
|
|---|
| 206 | init_function='ldb_server_sort_init',
|
|---|
| 207 | internal_module=False,
|
|---|
| 208 | module_init_name='ldb_init_module',
|
|---|
| 209 | deps='ldb',
|
|---|
| 210 | subsystem='ldb')
|
|---|
| 211 |
|
|---|
| 212 | bld.SAMBA_MODULE('ldb_paged_searches',
|
|---|
| 213 | 'modules/paged_searches.c',
|
|---|
| 214 | init_function='ldb_paged_searches_init',
|
|---|
| 215 | internal_module=False,
|
|---|
| 216 | module_init_name='ldb_init_module',
|
|---|
| 217 | deps='ldb',
|
|---|
| 218 | subsystem='ldb')
|
|---|
| 219 |
|
|---|
| 220 | bld.SAMBA_MODULE('ldb_rdn_name',
|
|---|
| 221 | 'modules/rdn_name.c',
|
|---|
| 222 | init_function='ldb_rdn_name_init',
|
|---|
| 223 | internal_module=False,
|
|---|
| 224 | module_init_name='ldb_init_module',
|
|---|
| 225 | deps='ldb',
|
|---|
| 226 | subsystem='ldb')
|
|---|
| 227 |
|
|---|
| 228 | bld.SAMBA_MODULE('ldb_sample',
|
|---|
| 229 | 'tests/sample_module.c',
|
|---|
| 230 | init_function='ldb_sample_init',
|
|---|
| 231 | internal_module=False,
|
|---|
| 232 | module_init_name='ldb_init_module',
|
|---|
| 233 | deps='ldb',
|
|---|
| 234 | subsystem='ldb')
|
|---|
| 235 |
|
|---|
| 236 | bld.SAMBA_MODULE('ldb_skel',
|
|---|
| 237 | 'modules/skel.c',
|
|---|
| 238 | init_function='ldb_skel_init',
|
|---|
| 239 | internal_module=False,
|
|---|
| 240 | module_init_name='ldb_init_module',
|
|---|
| 241 | deps='ldb',
|
|---|
| 242 | subsystem='ldb')
|
|---|
| 243 |
|
|---|
| 244 | bld.SAMBA_MODULE('ldb_sqlite3',
|
|---|
| 245 | 'sqlite3/ldb_sqlite3.c',
|
|---|
| 246 | init_function='ldb_sqlite3_init',
|
|---|
| 247 | internal_module=False,
|
|---|
| 248 | module_init_name='ldb_init_module',
|
|---|
| 249 | enabled=False,
|
|---|
| 250 | deps='ldb',
|
|---|
| 251 | subsystem='ldb')
|
|---|
| 252 |
|
|---|
| 253 | bld.SAMBA_MODULE('ldb_tdb',
|
|---|
| 254 | bld.SUBDIR('ldb_tdb',
|
|---|
| 255 | '''ldb_tdb.c ldb_search.c ldb_index.c
|
|---|
| 256 | ldb_cache.c ldb_tdb_wrap.c'''),
|
|---|
| 257 | init_function='ldb_tdb_init',
|
|---|
| 258 | module_init_name='ldb_init_module',
|
|---|
| 259 | internal_module=False,
|
|---|
| 260 | deps='tdb ldb',
|
|---|
| 261 | subsystem='ldb')
|
|---|
| 262 |
|
|---|
| 263 | # have a separate subsystem for common/ldb.c, so it can rebuild
|
|---|
| 264 | # for install with a different -DLDB_MODULESDIR=
|
|---|
| 265 | bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
|
|---|
| 266 | 'common/ldb.c',
|
|---|
| 267 | deps='tevent tdb',
|
|---|
| 268 | includes='include',
|
|---|
| 269 | cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
|
|---|
| 270 |
|
|---|
| 271 | LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
|
|---|
| 272 | for t in LDB_TOOLS.split():
|
|---|
| 273 | bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
|
|---|
| 274 | manpages='man/%s.1' % t)
|
|---|
| 275 |
|
|---|
| 276 | # ldbtest doesn't get installed
|
|---|
| 277 | bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='ldb-cmdline ldb',
|
|---|
| 278 | install=False)
|
|---|
| 279 |
|
|---|
| 280 | # ldbdump doesn't get installed
|
|---|
| 281 | bld.SAMBA_BINARY('ldbdump', 'tools/ldbdump.c', deps='ldb-cmdline ldb',
|
|---|
| 282 | install=False)
|
|---|
| 283 |
|
|---|
| 284 | bld.SAMBA_LIBRARY('ldb-cmdline',
|
|---|
| 285 | source='tools/ldbutil.c tools/cmdline.c',
|
|---|
| 286 | deps='ldb dl popt',
|
|---|
| 287 | private_library=True)
|
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 | def test(ctx):
|
|---|
| 291 | '''run ldb testsuite'''
|
|---|
| 292 | import Utils, samba_utils, shutil
|
|---|
| 293 | test_prefix = "%s/st" % (Utils.g_module.blddir)
|
|---|
| 294 | shutil.rmtree(test_prefix, ignore_errors=True)
|
|---|
| 295 | os.makedirs(test_prefix)
|
|---|
| 296 | os.environ['TEST_DATA_PREFIX'] = test_prefix
|
|---|
| 297 | cmd = 'tests/test-tdb.sh %s' % Utils.g_module.blddir
|
|---|
| 298 | ret = samba_utils.RUN_COMMAND(cmd)
|
|---|
| 299 | print("testsuite returned %d" % ret)
|
|---|
| 300 |
|
|---|
| 301 | tmp_dir = os.path.join(test_prefix, 'tmp')
|
|---|
| 302 | if not os.path.exists(tmp_dir):
|
|---|
| 303 | os.mkdir(tmp_dir)
|
|---|
| 304 | pyret = samba_utils.RUN_PYTHON_TESTS(
|
|---|
| 305 | ['tests/python/api.py'],
|
|---|
| 306 | extra_env={'SELFTEST_PREFIX': test_prefix})
|
|---|
| 307 | print("Python testsuite returned %d" % pyret)
|
|---|
| 308 | sys.exit(ret or pyret)
|
|---|
| 309 |
|
|---|
| 310 | def dist():
|
|---|
| 311 | '''makes a tarball for distribution'''
|
|---|
| 312 | samba_dist.dist()
|
|---|
| 313 |
|
|---|
| 314 | def reconfigure(ctx):
|
|---|
| 315 | '''reconfigure if config scripts have changed'''
|
|---|
| 316 | import samba_utils
|
|---|
| 317 | samba_utils.reconfigure(ctx)
|
|---|