build: Standardise on calling conf.SAMBA_CHECK_PYTHON() in libraries
[sfrench/samba-autobuild/.git] / lib / tevent / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'tevent'
4 VERSION = '0.9.39'
5
6 import sys, os
7
8 # find the buildtools directory
9 top = '.'
10 while not os.path.exists(top+'/buildtools') and len(top.split('/')) < 5:
11     top = top + '/..'
12 sys.path.insert(0, top + '/buildtools/wafsamba')
13
14 out = 'bin'
15
16 import wafsamba
17 from wafsamba import samba_dist, samba_utils
18 from waflib import Options, Logs, Context
19
20 samba_dist.DIST_DIRS('lib/tevent:. lib/replace:lib/replace lib/talloc:lib/talloc buildtools:buildtools third_party/waf:third_party/waf')
21
22 def options(opt):
23     opt.BUILTIN_DEFAULT('replace')
24     opt.PRIVATE_EXTENSION_DEFAULT('tevent', noextension='tevent')
25     opt.RECURSE('lib/replace')
26     opt.RECURSE('lib/talloc')
27
28
29 def configure(conf):
30     conf.RECURSE('lib/replace')
31     conf.RECURSE('lib/talloc')
32
33     conf.env.standalone_tevent = conf.IN_LAUNCH_DIR()
34
35     if not conf.env.standalone_tevent:
36         if conf.CHECK_BUNDLED_SYSTEM_PKG('tevent', minversion=VERSION,
37                                      onlyif='talloc', implied_deps='replace talloc'):
38             conf.define('USING_SYSTEM_TEVENT', 1)
39             if not conf.env.disable_python and \
40                 conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytevent', 'tevent', minversion=VERSION):
41                 conf.define('USING_SYSTEM_PYTEVENT', 1)
42
43     if conf.CHECK_FUNCS('epoll_create', headers='sys/epoll.h'):
44         conf.DEFINE('HAVE_EPOLL', 1)
45
46     tevent_num_signals = 64
47     v = conf.CHECK_VALUEOF('NSIG', headers='signal.h')
48     if v is not None:
49         tevent_num_signals = max(tevent_num_signals, v)
50     v = conf.CHECK_VALUEOF('_NSIG', headers='signal.h')
51     if v is not None:
52         tevent_num_signals = max(tevent_num_signals, v)
53     v = conf.CHECK_VALUEOF('SIGRTMAX', headers='signal.h')
54     if v is not None:
55         tevent_num_signals = max(tevent_num_signals, v)
56     v = conf.CHECK_VALUEOF('SIGRTMIN', headers='signal.h')
57     if v is not None:
58         tevent_num_signals = max(tevent_num_signals, v*2)
59
60     if not conf.CONFIG_SET('USING_SYSTEM_TEVENT'):
61         conf.DEFINE('TEVENT_NUM_SIGNALS', tevent_num_signals)
62
63     conf.SAMBA_CHECK_PYTHON()
64     conf.SAMBA_CHECK_PYTHON_HEADERS()
65
66     conf.SAMBA_CONFIG_H()
67
68     conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
69
70 def build(bld):
71     bld.RECURSE('lib/replace')
72     bld.RECURSE('lib/talloc')
73
74     SRC = '''tevent.c tevent_debug.c tevent_fd.c tevent_immediate.c
75              tevent_queue.c tevent_req.c tevent_wrapper.c
76              tevent_poll.c tevent_threads.c
77              tevent_signal.c tevent_standard.c tevent_timed.c tevent_util.c tevent_wakeup.c'''
78
79     if bld.CONFIG_SET('HAVE_EPOLL'):
80         SRC += ' tevent_epoll.c'
81
82     if bld.CONFIG_SET('HAVE_SOLARIS_PORTS'):
83         SRC += ' tevent_port.c'
84
85     if bld.env.standalone_tevent:
86         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
87         private_library = False
88     else:
89         private_library = True
90
91     if not bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
92         tevent_deps = 'replace talloc'
93         if bld.CONFIG_SET('HAVE_PTHREAD'):
94             tevent_deps += ' pthread'
95
96         bld.SAMBA_LIBRARY('tevent',
97                           SRC,
98                           deps=tevent_deps,
99                           enabled= not bld.CONFIG_SET('USING_SYSTEM_TEVENT'),
100                           includes='.',
101                           abi_directory='ABI',
102                           abi_match='tevent_* _tevent_*',
103                           vnum=VERSION,
104                           public_headers=('' if private_library else 'tevent.h'),
105                           public_headers_install=not private_library,
106                           pc_files='tevent.pc',
107                           private_library=private_library)
108
109     if not bld.CONFIG_SET('USING_SYSTEM_PYTEVENT') and not bld.env.disable_python:
110         bld.SAMBA_PYTHON('_tevent',
111                          'pytevent.c',
112                          deps='tevent',
113                          realname='_tevent.so',
114                          cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
115
116
117         bld.INSTALL_WILDCARD('${PYTHONARCHDIR}', 'tevent.py', flat=False)
118
119         # install out various python scripts for use by make test
120         bld.SAMBA_SCRIPT('tevent_python',
121                          pattern='tevent.py',
122                          installdir='python')
123
124
125 def test(ctx):
126     '''test tevent'''
127     print("The tevent testsuite is part of smbtorture in samba4")
128
129     samba_utils.ADD_LD_LIBRARY_PATH('bin/shared')
130     samba_utils.ADD_LD_LIBRARY_PATH('bin/shared/private')
131
132     pyret = samba_utils.RUN_PYTHON_TESTS(['bindings.py'])
133     sys.exit(pyret)
134
135
136 def dist():
137     '''makes a tarball for distribution'''
138     samba_dist.dist()
139
140 def reconfigure(ctx):
141     '''reconfigure if config scripts have changed'''
142     samba_utils.reconfigure(ctx)