12 # find the buildtools directory
14 while not os
.path
.exists(srcdir
+'/buildtools') and len(srcdir
.split('/')) < 5:
15 srcdir
= srcdir
+ '/..'
16 sys
.path
.insert(0, srcdir
+ '/buildtools/wafsamba')
19 sys
.path
.insert(0, srcdir
+"/buildtools/wafsamba")
20 import wafsamba
, samba_dist
, Options
22 # setup what directories to put in a tarball
23 samba_dist
.DIST_DIRS("""lib/talloc:. lib/replace:lib/replace
24 buildtools:buildtools third_party/waf:third_party/waf""")
28 opt
.BUILTIN_DEFAULT('replace')
29 opt
.PRIVATE_EXTENSION_DEFAULT('talloc', noextension
='talloc')
30 opt
.RECURSE('lib/replace')
31 if opt
.IN_LAUNCH_DIR():
32 opt
.add_option('--enable-talloc-compat1',
33 help=("Build talloc 1.x.x compat library [False]"),
34 action
="store_true", dest
='TALLOC_COMPAT1', default
=False)
38 conf
.RECURSE('lib/replace')
40 conf
.env
.standalone_talloc
= conf
.IN_LAUNCH_DIR()
42 conf
.define('TALLOC_BUILD_VERSION_MAJOR', int(VERSION
.split('.')[0]))
43 conf
.define('TALLOC_BUILD_VERSION_MINOR', int(VERSION
.split('.')[1]))
44 conf
.define('TALLOC_BUILD_VERSION_RELEASE', int(VERSION
.split('.')[2]))
46 conf
.env
.TALLOC_COMPAT1
= False
47 if conf
.env
.standalone_talloc
:
48 conf
.env
.TALLOC_COMPAT1
= Options
.options
.TALLOC_COMPAT1
49 conf
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
50 conf
.env
.TALLOC_VERSION
= VERSION
52 conf
.CHECK_XSLTPROC_MANPAGES()
54 conf
.CHECK_HEADERS('sys/auxv.h')
55 conf
.CHECK_FUNCS('getauxval')
59 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
61 # We need to set everything non-python up before here, because
62 # SAMBA_CHECK_PYTHON makes a copy of conf and we need it set up correctly
64 if not conf
.env
.disable_python
:
65 # also disable if we don't have the python libs installed
66 conf
.SAMBA_CHECK_PYTHON(mandatory
=False, version
=(2,4,2))
67 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=False)
68 if not conf
.env
.HAVE_PYTHON_H
:
69 Logs
.warn('Disabling pytalloc-util as python devel libs not found')
70 conf
.env
.disable_python
= True
72 if not conf
.env
.standalone_talloc
:
73 if conf
.CHECK_BUNDLED_SYSTEM_PKG('talloc', minversion
=VERSION
,
74 implied_deps
='replace'):
75 conf
.define('USING_SYSTEM_TALLOC', 1)
77 if conf
.env
.disable_python
:
78 using_system_pytalloc_util
= False
80 using_system_pytalloc_util
= True
81 if not conf
.CHECK_BUNDLED_SYSTEM_PKG('pytalloc-util', minversion
=VERSION
,
82 implied_deps
='talloc replace'):
83 using_system_pytalloc_util
= False
85 # We need to get a pytalloc-util for all the python versions
87 if conf
.env
['EXTRA_PYTHON']:
88 name
= 'pytalloc-util' + conf
.all_envs
['extrapython']['PYTHON_SO_ABI_FLAG']
89 if not conf
.CHECK_BUNDLED_SYSTEM_PKG(name
, minversion
=VERSION
,
90 implied_deps
='talloc replace'):
91 using_system_pytalloc_util
= False
93 if using_system_pytalloc_util
:
94 conf
.define('USING_SYSTEM_PYTALLOC_UTIL', 1)
98 bld
.RECURSE('lib/replace')
100 if bld
.env
.standalone_talloc
:
101 private_library
= False
103 # should we also install the symlink to libtalloc1.so here?
104 bld
.SAMBA_LIBRARY('talloc-compat1-%s' % (VERSION
),
105 'compat/talloc_compat1.c',
106 public_deps
='talloc',
107 soname
='libtalloc.so.1',
110 enabled
=bld
.env
.TALLOC_COMPAT1
)
112 testsuite_deps
= 'talloc'
113 if bld
.CONFIG_SET('HAVE_PTHREAD'):
114 testsuite_deps
+= ' pthread'
116 bld
.SAMBA_BINARY('talloc_testsuite',
117 'testsuite_main.c testsuite.c',
121 bld
.SAMBA_BINARY('talloc_test_magic_differs_helper',
122 'test_magic_differs_helper.c',
123 'talloc', install
=False)
126 private_library
= True
128 if not bld
.CONFIG_SET('USING_SYSTEM_TALLOC'):
130 bld
.SAMBA_LIBRARY('talloc',
134 abi_match
='talloc* _talloc*',
137 public_headers
=('' if private_library
else 'talloc.h'),
138 pc_files
='talloc.pc',
139 public_headers_install
=not private_library
,
140 private_library
=private_library
,
141 manpages
='man/talloc.3')
143 if not bld
.CONFIG_SET('USING_SYSTEM_PYTALLOC_UTIL'):
144 for env
in bld
.gen_python_environments(['PKGCONFIGDIR']):
145 name
= bld
.pyembed_libname('pytalloc-util')
147 bld
.SAMBA_LIBRARY(name
,
148 source
='pytalloc_util.c',
149 public_deps
='talloc',
154 abi_match
='pytalloc_* _pytalloc_*',
155 private_library
=private_library
,
156 public_headers
=('' if private_library
else 'pytalloc.h'),
157 pc_files
='pytalloc-util.pc',
158 enabled
=bld
.PYTHON_BUILD_IS_ENABLED()
160 bld
.SAMBA_PYTHON('pytalloc',
162 deps
='talloc ' + name
,
163 enabled
=bld
.PYTHON_BUILD_IS_ENABLED(),
164 realname
='talloc.so')
166 bld
.SAMBA_PYTHON('test_pytalloc',
169 enabled
=bld
.PYTHON_BUILD_IS_ENABLED(),
170 realname
='_test_pytalloc.so',
175 '''run talloc testsuite'''
176 import Utils
, samba_utils
178 samba_utils
.ADD_LD_LIBRARY_PATH('bin/shared')
179 samba_utils
.ADD_LD_LIBRARY_PATH('bin/shared/private')
181 cmd
= os
.path
.join(Utils
.g_module
.blddir
, 'talloc_testsuite')
182 ret
= samba_utils
.RUN_COMMAND(cmd
)
183 print("testsuite returned %d" % ret
)
184 magic_helper_cmd
= os
.path
.join(Utils
.g_module
.blddir
, 'talloc_test_magic_differs_helper')
185 magic_cmd
= os
.path
.join(srcdir
, 'lib', 'talloc',
186 'test_magic_differs.sh')
187 if not os
.path
.exists(magic_cmd
):
188 magic_cmd
= os
.path
.join(srcdir
, 'test_magic_differs.sh')
190 magic_ret
= samba_utils
.RUN_COMMAND(magic_cmd
+ " " + magic_helper_cmd
)
191 print("magic differs test returned %d" % magic_ret
)
192 pyret
= samba_utils
.RUN_PYTHON_TESTS(['test_pytalloc.py'])
193 print("python testsuite returned %d" % pyret
)
194 sys
.exit(ret
or magic_ret
or pyret
)
197 '''makes a tarball for distribution'''
200 def reconfigure(ctx
):
201 '''reconfigure if config scripts have changed'''
203 samba_utils
.reconfigure(ctx
)
207 '''build python apidocs'''
208 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.*'
209 print("Running: %s" % cmd
)