ctdb: Use str_list_add_printf() in lock_helper_args()
[Samba.git] / lib / talloc / wscript
blob8b5e02d36c5446efeace85b9588e2c8188f41827
1 #!/usr/bin/env python
3 APPNAME = 'talloc'
4 VERSION = '2.4.2'
6 import os
7 import sys
9 # find the buildtools directory
10 top = '.'
11 while not os.path.exists(top+'/buildtools') and len(top.split('/')) < 5:
12 top = top + '/..'
13 sys.path.insert(0, top + '/buildtools/wafsamba')
15 out = 'bin'
17 import 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""")
26 def options(opt):
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)
36 def configure(conf):
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')
56 conf.SAMBA_CONFIG_H()
58 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
60 conf.SAMBA_CHECK_PYTHON()
61 conf.SAMBA_CHECK_PYTHON_HEADERS()
63 if not conf.env.standalone_talloc:
64 if conf.CHECK_BUNDLED_SYSTEM_PKG('talloc', minversion=VERSION,
65 implied_deps='replace'):
66 conf.define('USING_SYSTEM_TALLOC', 1)
68 if conf.env.disable_python:
69 using_system_pytalloc_util = False
70 else:
71 using_system_pytalloc_util = True
72 name = 'pytalloc-util' + conf.all_envs['default']['PYTHON_SO_ABI_FLAG']
73 if not conf.CHECK_BUNDLED_SYSTEM_PKG(name, minversion=VERSION,
74 implied_deps='talloc replace'):
75 using_system_pytalloc_util = False
77 if using_system_pytalloc_util:
78 conf.define('USING_SYSTEM_PYTALLOC_UTIL', 1)
81 def build(bld):
82 bld.RECURSE('lib/replace')
84 if bld.env.standalone_talloc:
85 private_library = False
87 # should we also install the symlink to libtalloc1.so here?
88 bld.SAMBA_LIBRARY('talloc-compat1-%s' % (VERSION),
89 'compat/talloc_compat1.c',
90 public_deps='talloc',
91 soname='libtalloc.so.1',
92 pc_files=[],
93 public_headers=[],
94 enabled=bld.env.TALLOC_COMPAT1)
96 testsuite_deps = 'talloc'
97 if bld.CONFIG_SET('HAVE_PTHREAD'):
98 testsuite_deps += ' pthread'
100 bld.SAMBA_BINARY('talloc_testsuite',
101 'testsuite_main.c testsuite.c',
102 testsuite_deps,
103 install=False)
105 bld.SAMBA_BINARY('talloc_test_magic_differs_helper',
106 'test_magic_differs_helper.c',
107 'talloc', install=False)
109 else:
110 private_library = True
112 if not bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
114 bld.SAMBA_LIBRARY('talloc',
115 'talloc.c',
116 deps='replace',
117 provide_builtin_linking=True,
118 abi_directory='ABI',
119 abi_match='talloc* _talloc*',
120 hide_symbols=True,
121 vnum=VERSION,
122 public_headers=('' if private_library else 'talloc.h'),
123 pc_files='talloc.pc',
124 public_headers_install=not private_library,
125 private_library=private_library,
126 manpages='man/talloc.3')
128 if not bld.CONFIG_SET('USING_SYSTEM_PYTALLOC_UTIL'):
129 name = bld.pyembed_libname('pytalloc-util')
131 bld.SAMBA_LIBRARY(name,
132 source='pytalloc_util.c',
133 public_deps='talloc',
134 pyembed=True,
135 vnum=VERSION,
136 hide_symbols=True,
137 abi_directory='ABI',
138 abi_match='pytalloc_* _pytalloc_*',
139 private_library=private_library,
140 public_headers=('' if private_library else 'pytalloc.h'),
141 pc_files='pytalloc-util.pc',
142 enabled=bld.PYTHON_BUILD_IS_ENABLED()
144 bld.SAMBA_PYTHON('pytalloc',
145 'pytalloc.c',
146 deps='talloc ' + name,
147 enabled=bld.PYTHON_BUILD_IS_ENABLED(),
148 realname='talloc.so')
150 bld.SAMBA_PYTHON('test_pytalloc',
151 'test_pytalloc.c',
152 deps=name,
153 enabled=bld.PYTHON_BUILD_IS_ENABLED(),
154 realname='_test_pytalloc.so',
155 install=False)
158 def testonly(ctx):
159 '''run talloc testsuite'''
160 import samba_utils
162 samba_utils.ADD_LD_LIBRARY_PATH('bin/shared')
163 samba_utils.ADD_LD_LIBRARY_PATH('bin/shared/private')
165 cmd = os.path.join(Context.g_module.out, 'talloc_testsuite')
166 ret = samba_utils.RUN_COMMAND(cmd)
167 print("testsuite returned %d" % ret)
168 magic_helper_cmd = os.path.join(Context.g_module.out, 'talloc_test_magic_differs_helper')
169 magic_cmd = os.path.join(Context.g_module.top, 'lib', 'talloc',
170 'test_magic_differs.sh')
171 if not os.path.exists(magic_cmd):
172 magic_cmd = os.path.join(Context.g_module.top, 'test_magic_differs.sh')
174 magic_ret = samba_utils.RUN_COMMAND(magic_cmd + " " + magic_helper_cmd)
175 print("magic differs test returned %d" % magic_ret)
176 pyret = samba_utils.RUN_PYTHON_TESTS(['test_pytalloc.py'])
177 print("python testsuite returned %d" % pyret)
178 sys.exit(ret or magic_ret or pyret)
180 # WAF doesn't build the unit tests for this, maybe because they don't link with talloc?
181 # This forces it
182 def test(ctx):
183 Options.commands.append('build')
184 Options.commands.append('testonly')
186 def dist():
187 '''makes a tarball for distribution'''
188 samba_dist.dist()
190 def reconfigure(ctx):
191 '''reconfigure if config scripts have changed'''
192 samba_utils.reconfigure(ctx)