tevent: version 0.9.38
[samba.git] / lib / tevent / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'tevent'
4 VERSION = '0.9.38'
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     if not conf.env.disable_python:
64         # also disable if we don't have the python libs installed
65         conf.find_program('python', var='PYTHON')
66         conf.load('python')
67         conf.check_python_version((2,4,2))
68         conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
69         if not conf.env.HAVE_PYTHON_H:
70             Logs.warn('Disabling pytevent as python devel libs not found')
71             conf.env.disable_python = True
72
73     conf.SAMBA_CONFIG_H()
74
75     conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
76
77 def build(bld):
78     bld.RECURSE('lib/replace')
79     bld.RECURSE('lib/talloc')
80
81     SRC = '''tevent.c tevent_debug.c tevent_fd.c tevent_immediate.c
82              tevent_queue.c tevent_req.c tevent_wrapper.c
83              tevent_poll.c tevent_threads.c
84              tevent_signal.c tevent_standard.c tevent_timed.c tevent_util.c tevent_wakeup.c'''
85
86     if bld.CONFIG_SET('HAVE_EPOLL'):
87         SRC += ' tevent_epoll.c'
88
89     if bld.CONFIG_SET('HAVE_SOLARIS_PORTS'):
90         SRC += ' tevent_port.c'
91
92     if bld.env.standalone_tevent:
93         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
94         private_library = False
95     else:
96         private_library = True
97
98     if not bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
99         tevent_deps = 'replace talloc'
100         if bld.CONFIG_SET('HAVE_PTHREAD'):
101             tevent_deps += ' pthread'
102
103         bld.SAMBA_LIBRARY('tevent',
104                           SRC,
105                           deps=tevent_deps,
106                           enabled= not bld.CONFIG_SET('USING_SYSTEM_TEVENT'),
107                           includes='.',
108                           abi_directory='ABI',
109                           abi_match='tevent_* _tevent_*',
110                           vnum=VERSION,
111                           public_headers=('' if private_library else 'tevent.h'),
112                           public_headers_install=not private_library,
113                           pc_files='tevent.pc',
114                           private_library=private_library)
115
116     if not bld.CONFIG_SET('USING_SYSTEM_PYTEVENT') and not bld.env.disable_python:
117         for env in bld.gen_python_environments(['PKGCONFIGDIR']):
118             bld.SAMBA_PYTHON('_tevent',
119                             'pytevent.c',
120                             deps='tevent',
121                             realname='_tevent.so',
122                             cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
123
124
125             bld.INSTALL_WILDCARD('${PYTHONARCHDIR}', 'tevent.py', flat=False)
126
127         # install out various python scripts for use by make test
128         bld.SAMBA_SCRIPT('tevent_python',
129                          pattern='tevent.py',
130                          installdir='python')
131
132
133 def test(ctx):
134     '''test tevent'''
135     print("The tevent testsuite is part of smbtorture in samba4")
136
137     samba_utils.ADD_LD_LIBRARY_PATH('bin/shared')
138     samba_utils.ADD_LD_LIBRARY_PATH('bin/shared/private')
139
140     pyret = samba_utils.RUN_PYTHON_TESTS(['bindings.py'])
141     sys.exit(pyret)
142
143
144 def dist():
145     '''makes a tarball for distribution'''
146     samba_dist.dist()
147
148 def reconfigure(ctx):
149     '''reconfigure if config scripts have changed'''
150     samba_utils.reconfigure(ctx)