2010-03-28 09:48:49 +11:00
#!/usr/bin/env python
2010-04-04 09:57:33 +10:00
APPNAME = 'talloc'
2017-02-22 08:00:10 +01:00
VERSION = '2.1.9'
2010-03-17 20:31:46 +11:00
2010-04-13 17:32:14 +10:00
2010-03-17 20:32:15 +11:00
blddir = 'bin'
2010-02-20 16:25:37 +11:00
2010-10-24 12:37:08 -07:00
import Logs
2010-04-04 11:40:05 +10:00
import os, sys
2010-04-04 10:18:39 +10:00
# find the buildtools directory
2010-04-04 13:16:49 +10:00
srcdir = '.'
while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
2014-06-20 18:04:44 +02:00
srcdir = srcdir + '/..'
2010-04-04 13:16:49 +10:00
sys.path.insert(0, srcdir + '/buildtools/wafsamba')
2010-03-17 20:31:46 +11:00
2010-03-28 15:42:28 +11:00
import sys
sys.path.insert(0, srcdir+"/buildtools/wafsamba")
2010-04-13 17:32:14 +10:00
import wafsamba, samba_dist, Options
2010-03-28 15:42:28 +11:00
2010-04-04 11:00:42 +10:00
# setup what directories to put in a tarball
2015-03-25 11:13:40 +00:00
samba_dist.DIST_DIRS("""lib/talloc:. lib/replace:lib/replace
buildtools:buildtools third_party/waf:third_party/waf""")
2010-04-04 11:00:42 +10:00
2010-02-20 16:25:37 +11:00
def set_options(opt):
2010-03-28 15:42:28 +11:00
opt.BUILTIN_DEFAULT('replace')
2010-10-23 23:26:43 +02:00
opt.PRIVATE_EXTENSION_DEFAULT('talloc', noextension='talloc')
2010-04-04 13:16:49 +10:00
opt.RECURSE('lib/replace')
2010-10-24 12:37:08 -07:00
if opt.IN_LAUNCH_DIR():
2013-05-07 14:15:35 +02:00
opt.add_option('--enable-talloc-compat1',
help=("Build talloc 1.x.x compat library [False]"),
action="store_true", dest='TALLOC_COMPAT1', default=False)
2010-10-24 12:37:08 -07:00
opt.add_option('--disable-python',
2010-11-05 03:00:45 +01:00
help=("disable the pytalloc module"),
2010-10-24 12:37:08 -07:00
action="store_true", dest='disable_python', default=False)
2010-02-20 16:25:37 +11:00
def configure(conf):
2010-04-04 13:16:49 +10:00
conf.RECURSE('lib/replace')
2010-03-28 16:38:27 +11:00
2010-04-03 23:26:35 +11:00
conf.env.standalone_talloc = conf.IN_LAUNCH_DIR()
2017-02-14 12:33:32 +01:00
conf.define('TALLOC_BUILD_VERSION_MAJOR', int(VERSION.split('.')[0]))
conf.define('TALLOC_BUILD_VERSION_MINOR', int(VERSION.split('.')[1]))
conf.define('TALLOC_BUILD_VERSION_RELEASE', int(VERSION.split('.')[2]))
2010-10-24 12:37:08 -07:00
conf.env.disable_python = getattr(Options.options, 'disable_python', False)
2013-05-07 14:15:35 +02:00
conf.env.TALLOC_COMPAT1 = False
if conf.env.standalone_talloc:
conf.env.TALLOC_COMPAT1 = Options.options.TALLOC_COMPAT1
2017-03-06 19:25:13 +13:00
conf.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
conf.env.TALLOC_VERSION = VERSION
2010-04-13 17:32:14 +10:00
2010-10-30 08:27:12 +02:00
conf.CHECK_XSLTPROC_MANPAGES()
2010-04-13 17:32:14 +10:00
2017-03-06 19:25:13 +13:00
conf.CHECK_HEADERS('sys/auxv.h')
conf.CHECK_FUNCS('getauxval')
conf.SAMBA_CONFIG_H()
conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
# We need to set everything non-python up before here, because
# SAMBA_CHECK_PYTHON makes a copy of conf and we need it set up correctly
2010-10-24 12:37:08 -07:00
if not conf.env.disable_python:
# also disable if we don't have the python libs installed
2015-01-15 14:07:09 +01:00
conf.SAMBA_CHECK_PYTHON(mandatory=False, version=(2,4,2))
2010-12-10 01:42:32 +03:00
conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
2010-10-24 12:37:08 -07:00
if not conf.env.HAVE_PYTHON_H:
Logs.warn('Disabling pytalloc-util as python devel libs not found')
conf.env.disable_python = True
2010-02-20 16:25:37 +11:00
2017-03-06 19:25:13 +13:00
if not conf.env.standalone_talloc:
if conf.CHECK_BUNDLED_SYSTEM_PKG('talloc', minversion=VERSION,
implied_deps='replace'):
conf.define('USING_SYSTEM_TALLOC', 1)
2013-10-17 10:30:23 +13:00
2017-03-06 19:25:13 +13:00
using_system_pytalloc_util = True
if not conf.CHECK_BUNDLED_SYSTEM_PKG('pytalloc-util', minversion=VERSION,
implied_deps='talloc replace'):
using_system_pytalloc_util = False
2010-03-28 16:38:27 +11:00
2017-03-06 19:25:13 +13:00
# We need to get a pytalloc-util for all the python versions
# we are building for
if conf.env['EXTRA_PYTHON']:
name = 'pytalloc-util' + conf.all_envs['extrapython']['PYTHON_SO_ABI_FLAG']
if not conf.CHECK_BUNDLED_SYSTEM_PKG(name, minversion=VERSION,
implied_deps='talloc replace'):
using_system_pytalloc_util = False
if using_system_pytalloc_util:
conf.define('USING_SYSTEM_PYTALLOC_UTIL', 1)
2011-11-13 18:01:09 +01:00
2010-03-28 16:38:27 +11:00
2010-02-20 16:25:37 +11:00
def build(bld):
2010-04-04 13:16:49 +10:00
bld.RECURSE('lib/replace')
2010-02-20 16:25:37 +11:00
2010-10-24 11:50:47 -07:00
if bld.env.standalone_talloc:
private_library = False
# should we also install the symlink to libtalloc1.so here?
2010-10-27 02:56:10 +02:00
bld.SAMBA_LIBRARY('talloc-compat1-%s' % (VERSION),
2010-10-24 11:50:47 -07:00
'compat/talloc_compat1.c',
2010-10-27 02:56:10 +02:00
public_deps='talloc',
soname='libtalloc.so.1',
2011-08-21 03:19:17 +02:00
pc_files=[],
public_headers=[],
2010-10-27 02:56:10 +02:00
enabled=bld.env.TALLOC_COMPAT1)
2011-10-22 09:38:22 +02:00
2015-03-16 12:18:17 -07:00
testsuite_deps = 'talloc'
if bld.CONFIG_SET('HAVE_PTHREAD'):
testsuite_deps += ' pthread'
2011-10-22 09:38:22 +02:00
bld.SAMBA_BINARY('talloc_testsuite',
'testsuite_main.c testsuite.c',
2015-03-16 12:18:17 -07:00
testsuite_deps,
2011-10-22 09:38:22 +02:00
install=False)
2015-09-04 12:59:57 +12:00
bld.SAMBA_BINARY('talloc_test_magic_differs_helper',
'test_magic_differs_helper.c',
'talloc', install=False)
2010-10-24 11:50:47 -07:00
else:
private_library = True
2010-03-28 16:38:27 +11:00
if not bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
2010-04-13 17:32:14 +10:00
2010-03-28 16:38:27 +11:00
bld.SAMBA_LIBRARY('talloc',
'talloc.c',
deps='replace',
2010-12-09 11:10:45 +11:00
abi_directory='ABI',
2010-04-18 12:46:04 +10:00
abi_match='talloc* _talloc*',
hide_symbols=True,
2010-12-09 21:58:20 +11:00
vnum=VERSION,
2016-01-04 15:21:21 +00:00
public_headers=('' if private_library else 'talloc.h'),
2011-08-21 03:19:17 +02:00
pc_files='talloc.pc',
2011-03-03 17:19:33 +11:00
public_headers_install=not private_library,
2010-10-24 11:50:47 -07:00
private_library=private_library,
2012-11-30 09:43:33 +01:00
manpages='man/talloc.3')
2010-02-20 16:25:37 +11:00
2010-10-24 12:37:08 -07:00
if not bld.CONFIG_SET('USING_SYSTEM_PYTALLOC_UTIL') and not bld.env.disable_python:
2015-05-06 17:50:57 +02:00
for env in bld.gen_python_environments(['PKGCONFIGDIR']):
name = bld.pyembed_libname('pytalloc-util')
bld.SAMBA_LIBRARY(name,
source='pytalloc_util.c',
public_deps='talloc',
pyembed=True,
vnum=VERSION,
hide_symbols=True,
abi_directory='ABI',
2016-02-22 14:29:15 +13:00
abi_match='pytalloc_* _pytalloc_*',
2015-05-06 17:50:57 +02:00
private_library=private_library,
2016-01-04 15:21:21 +00:00
public_headers=('' if private_library else 'pytalloc.h'),
2015-05-06 17:50:57 +02:00
pc_files='pytalloc-util.pc'
)
bld.SAMBA_PYTHON('pytalloc',
'pytalloc.c',
deps='talloc ' + name,
realname='talloc.so')
bld.SAMBA_PYTHON('test_pytalloc',
'test_pytalloc.c',
deps='pytalloc',
realname='_test_pytalloc.so',
install=False)
2015-05-06 18:17:06 +02:00
2010-04-04 22:11:30 +10:00
def test(ctx):
'''run talloc testsuite'''
2010-10-07 12:25:42 +11:00
import Utils, samba_utils
2010-04-04 22:11:30 +10:00
cmd = os.path.join(Utils.g_module.blddir, 'talloc_testsuite')
2010-10-07 12:25:42 +11:00
ret = samba_utils.RUN_COMMAND(cmd)
print("testsuite returned %d" % ret)
2016-02-23 11:04:51 +13:00
magic_helper_cmd = os.path.join(Utils.g_module.blddir, 'talloc_test_magic_differs_helper')
2015-09-04 12:59:57 +12:00
magic_cmd = os.path.join(srcdir, 'lib', 'talloc',
'test_magic_differs.sh')
2016-02-23 11:04:51 +13:00
magic_ret = samba_utils.RUN_COMMAND(magic_cmd + " " + magic_helper_cmd)
2015-09-04 12:59:57 +12:00
print("magic differs test returned %d" % magic_ret)
2015-05-06 18:05:18 +02:00
pyret = samba_utils.RUN_PYTHON_TESTS(['test_pytalloc.py'])
2015-03-05 10:06:05 +01:00
print("python testsuite returned %d" % pyret)
2015-09-04 12:59:57 +12:00
sys.exit(ret or magic_ret or pyret)
2010-04-05 09:58:23 +10:00
def dist():
'''makes a tarball for distribution'''
samba_dist.dist()
2010-11-03 12:09:23 +11:00
def reconfigure(ctx):
'''reconfigure if config scripts have changed'''
import samba_utils
samba_utils.reconfigure(ctx)
2010-12-11 01:05:13 +01:00
def pydoctor(ctx):
'''build python apidocs'''
cmd='PYTHONPATH=bin/python pydoctor --project-name=talloc --project-url=http://talloc.samba.org/ --make-html --docformat=restructuredtext --introspect-c-modules --add-module bin/python/talloc.*'
print("Running: %s" % cmd)
os.system(cmd)