8 # find the buildtools directory
10 while not os
.path
.exists(top
+'/buildtools') and len(top
.split('/')) < 5:
12 sys
.path
.insert(0, top
+ '/buildtools/wafsamba')
17 from wafsamba
import samba_dist
, samba_utils
18 from waflib
import Options
, Logs
, Context
, Errors
20 samba_dist
.DIST_DIRS('''lib/tevent:. lib/replace:lib/replace
21 lib/talloc:lib/talloc buildtools:buildtools
22 third_party/cmocka:third_party/cmocka
23 third_party/waf:third_party/waf''')
26 opt
.BUILTIN_DEFAULT('replace')
27 opt
.PRIVATE_EXTENSION_DEFAULT('tevent', noextension
='tevent')
28 opt
.RECURSE('lib/replace')
29 opt
.RECURSE('lib/talloc')
33 conf
.RECURSE('lib/replace')
34 conf
.RECURSE('lib/talloc')
36 if conf
.CHECK_FOR_THIRD_PARTY():
37 conf
.RECURSE('third_party/cmocka')
39 if not conf
.CHECK_CMOCKA():
40 raise Errors
.WafError('cmocka development package have not been found.\nIf third_party is installed, check that it is in the proper place.')
42 conf
.define('USING_SYSTEM_CMOCKA', 1)
44 conf
.env
.standalone_tevent
= conf
.IN_LAUNCH_DIR()
46 if not conf
.env
.standalone_tevent
:
47 if conf
.CHECK_BUNDLED_SYSTEM_PKG('tevent', minversion
=VERSION
,
48 onlyif
='talloc', implied_deps
='replace talloc'):
49 conf
.define('USING_SYSTEM_TEVENT', 1)
50 if not conf
.env
.disable_python
and \
51 conf
.CHECK_BUNDLED_SYSTEM_PYTHON('pytevent', 'tevent', minversion
=VERSION
):
52 conf
.define('USING_SYSTEM_PYTEVENT', 1)
54 if conf
.CHECK_FUNCS('epoll_create1', headers
='sys/epoll.h'):
55 conf
.DEFINE('HAVE_EPOLL', 1)
57 tevent_num_signals
= 64
58 v
= conf
.CHECK_VALUEOF('NSIG', headers
='signal.h')
60 tevent_num_signals
= max(tevent_num_signals
, v
)
61 v
= conf
.CHECK_VALUEOF('_NSIG', headers
='signal.h')
63 tevent_num_signals
= max(tevent_num_signals
, v
)
64 v
= conf
.CHECK_VALUEOF('SIGRTMAX', headers
='signal.h')
66 tevent_num_signals
= max(tevent_num_signals
, v
)
67 v
= conf
.CHECK_VALUEOF('SIGRTMIN', headers
='signal.h')
69 tevent_num_signals
= max(tevent_num_signals
, v
*2)
71 if not conf
.CONFIG_SET('USING_SYSTEM_TEVENT'):
72 conf
.DEFINE('TEVENT_NUM_SIGNALS', tevent_num_signals
)
74 conf
.SAMBA_CHECK_PYTHON()
75 conf
.SAMBA_CHECK_PYTHON_HEADERS()
79 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
82 bld
.RECURSE('lib/replace')
83 bld
.RECURSE('lib/talloc')
85 if bld
.CHECK_FOR_THIRD_PARTY():
86 bld
.RECURSE('third_party/cmocka')
88 SRC
= '''tevent.c tevent_debug.c tevent_fd.c tevent_immediate.c
89 tevent_queue.c tevent_req.c tevent_wrapper.c
90 tevent_poll.c tevent_threads.c
91 tevent_signal.c tevent_standard.c tevent_timed.c tevent_util.c tevent_wakeup.c'''
93 if bld
.CONFIG_SET('HAVE_EPOLL'):
94 SRC
+= ' tevent_epoll.c'
96 if bld
.env
.standalone_tevent
:
97 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
98 private_library
= False
100 private_library
= True
102 if not bld
.CONFIG_SET('USING_SYSTEM_TEVENT'):
103 tevent_deps
= 'replace talloc'
104 if bld
.CONFIG_SET('HAVE_PTHREAD'):
105 tevent_deps
+= ' pthread'
107 bld
.SAMBA_LIBRARY('tevent',
110 enabled
= not bld
.CONFIG_SET('USING_SYSTEM_TEVENT'),
113 abi_match
='tevent_* _tevent_* __tevent_*',
115 public_headers
=('' if private_library
else 'tevent.h'),
116 public_headers_install
=not private_library
,
117 pc_files
='tevent.pc',
118 private_library
=private_library
)
120 if not bld
.CONFIG_SET('USING_SYSTEM_PYTEVENT') and not bld
.env
.disable_python
:
121 bld
.SAMBA_PYTHON('_tevent',
124 realname
='_tevent.so',
125 cflags
='-DPACKAGE_VERSION=\"%s\"' % VERSION
)
128 bld
.INSTALL_WILDCARD('${PYTHONARCHDIR}', 'tevent.py', flat
=False)
130 # install out various python scripts for use by make test
131 bld
.SAMBA_SCRIPT('tevent_python',
135 bld
.SAMBA_BINARY('test_tevent_tag',
136 source
='tests/test_tevent_tag.c',
137 deps
='cmocka tevent',
140 bld
.SAMBA_BINARY('test_tevent_trace',
141 source
='tests/test_tevent_trace.c',
142 deps
='cmocka tevent',
147 print("The tevent testsuite is part of smbtorture in samba4")
149 samba_utils
.ADD_LD_LIBRARY_PATH('bin/shared')
150 samba_utils
.ADD_LD_LIBRARY_PATH('bin/shared/private')
152 pyret
= samba_utils
.RUN_PYTHON_TESTS(['bindings.py'])
160 for unit_test
in unit_tests
:
161 unit_test_cmd
= os
.path
.join(Context
.g_module
.out
, unit_test
)
162 unit_test_ret
= unit_test_ret
or samba_utils
.RUN_COMMAND(unit_test_cmd
)
164 sys
.exit(pyret
or unit_test_ret
)
167 '''makes a tarball for distribution'''
170 def reconfigure(ctx
):
171 '''reconfigure if config scripts have changed'''
172 samba_utils
.reconfigure(ctx
)