9 # find the buildtools directory
11 while not os.path.exists(top+'/buildtools') and len(top.split('/')) < 5:
13 sys.path.insert(0, top + '/buildtools/wafsamba')
18 from wafsamba import samba_dist, samba_utils
19 from waflib import Logs, Options, Context
21 # setup what directories to put in a tarball
22 samba_dist.DIST_DIRS("""lib/talloc:. lib/replace:lib/replace
23 buildtools:buildtools third_party/waf:third_party/waf""")
27 opt.BUILTIN_DEFAULT('replace')
28 opt.PRIVATE_EXTENSION_DEFAULT('talloc', noextension='talloc')
29 opt.RECURSE('lib/replace')
30 if opt.IN_LAUNCH_DIR():
31 opt.add_option('--enable-talloc-compat1',
32 help=("Build talloc 1.x.x compat library [False]"),
33 action="store_true", dest='TALLOC_COMPAT1', default=False)
37 conf.RECURSE('lib/replace')
39 conf.env.standalone_talloc = conf.IN_LAUNCH_DIR()
41 conf.define('TALLOC_BUILD_VERSION_MAJOR', int(VERSION.split('.')[0]))
42 conf.define('TALLOC_BUILD_VERSION_MINOR', int(VERSION.split('.')[1]))
43 conf.define('TALLOC_BUILD_VERSION_RELEASE', int(VERSION.split('.')[2]))
45 conf.env.TALLOC_COMPAT1 = False
46 if conf.env.standalone_talloc:
47 conf.env.TALLOC_COMPAT1 = Options.options.TALLOC_COMPAT1
48 conf.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
49 conf.env.TALLOC_VERSION = VERSION
51 conf.CHECK_XSLTPROC_MANPAGES()
53 conf.CHECK_HEADERS('sys/auxv.h')
54 conf.CHECK_FUNCS('getauxval')
58 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
60 # We need to set everything non-python up before here, because
61 # SAMBA_CHECK_PYTHON makes a copy of conf and we need it set up correctly
63 if not conf.env.disable_python:
64 # also disable if we don't have the python libs installed
65 conf.SAMBA_CHECK_PYTHON(mandatory=False, version=(2,4,2))
66 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
67 if not conf.env.HAVE_PYTHON_H:
68 Logs.warn('Disabling pytalloc-util as python devel libs not found')
69 conf.env.disable_python = True
71 if not conf.env.standalone_talloc:
72 if conf.CHECK_BUNDLED_SYSTEM_PKG('talloc', minversion=VERSION,
73 implied_deps='replace'):
74 conf.define('USING_SYSTEM_TALLOC', 1)
76 if conf.env.disable_python:
77 using_system_pytalloc_util = False
79 using_system_pytalloc_util = True
80 name = 'pytalloc-util' + conf.all_envs['default']['PYTHON_SO_ABI_FLAG']
81 if not conf.CHECK_BUNDLED_SYSTEM_PKG(name, minversion=VERSION,
82 implied_deps='talloc replace'):
83 using_system_pytalloc_util = False
85 if using_system_pytalloc_util:
86 conf.define('USING_SYSTEM_PYTALLOC_UTIL', 1)
90 bld.RECURSE('lib/replace')
92 if bld.env.standalone_talloc:
93 private_library = False
95 # should we also install the symlink to libtalloc1.so here?
96 bld.SAMBA_LIBRARY('talloc-compat1-%s' % (VERSION),
97 'compat/talloc_compat1.c',
99 soname='libtalloc.so.1',
102 enabled=bld.env.TALLOC_COMPAT1)
104 testsuite_deps = 'talloc'
105 if bld.CONFIG_SET('HAVE_PTHREAD'):
106 testsuite_deps += ' pthread'
108 bld.SAMBA_BINARY('talloc_testsuite',
109 'testsuite_main.c testsuite.c',
113 bld.SAMBA_BINARY('talloc_test_magic_differs_helper',
114 'test_magic_differs_helper.c',
115 'talloc', install=False)
118 private_library = True
120 if not bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
122 bld.SAMBA_LIBRARY('talloc',
126 abi_match='talloc* _talloc*',
129 public_headers=('' if private_library else 'talloc.h'),
130 pc_files='talloc.pc',
131 public_headers_install=not private_library,
132 private_library=private_library,
133 manpages='man/talloc.3')
135 if not bld.CONFIG_SET('USING_SYSTEM_PYTALLOC_UTIL'):
136 for env in bld.gen_python_environments(['PKGCONFIGDIR']):
137 name = bld.pyembed_libname('pytalloc-util')
139 bld.SAMBA_LIBRARY(name,
140 source='pytalloc_util.c',
141 public_deps='talloc',
146 abi_match='pytalloc_* _pytalloc_*',
147 private_library=private_library,
148 public_headers=('' if private_library else 'pytalloc.h'),
149 pc_files='pytalloc-util.pc',
150 enabled=bld.PYTHON_BUILD_IS_ENABLED()
152 bld.SAMBA_PYTHON('pytalloc',
154 deps='talloc ' + name,
155 enabled=bld.PYTHON_BUILD_IS_ENABLED(),
156 realname='talloc.so')
158 bld.SAMBA_PYTHON('test_pytalloc',
161 enabled=bld.PYTHON_BUILD_IS_ENABLED(),
162 realname='_test_pytalloc.so',
167 '''run talloc testsuite'''
170 samba_utils.ADD_LD_LIBRARY_PATH('bin/shared')
171 samba_utils.ADD_LD_LIBRARY_PATH('bin/shared/private')
173 cmd = os.path.join(Context.g_module.out, 'talloc_testsuite')
174 ret = samba_utils.RUN_COMMAND(cmd)
175 print("testsuite returned %d" % ret)
176 magic_helper_cmd = os.path.join(Context.g_module.out, 'talloc_test_magic_differs_helper')
177 magic_cmd = os.path.join(Context.g_module.top, 'lib', 'talloc',
178 'test_magic_differs.sh')
179 if not os.path.exists(magic_cmd):
180 magic_cmd = os.path.join(Context.g_module.top, 'test_magic_differs.sh')
182 magic_ret = samba_utils.RUN_COMMAND(magic_cmd + " " + magic_helper_cmd)
183 print("magic differs test returned %d" % magic_ret)
184 pyret = samba_utils.RUN_PYTHON_TESTS(['test_pytalloc.py'])
185 print("python testsuite returned %d" % pyret)
186 sys.exit(ret or magic_ret or pyret)
189 '''makes a tarball for distribution'''
192 def reconfigure(ctx):
193 '''reconfigure if config scripts have changed'''
194 samba_utils.reconfigure(ctx)
198 '''build python apidocs'''
199 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.*'
200 print("Running: %s" % cmd)