tevent: Only check for pkg-config file when checking for system tevent.
[metze/samba/wip.git] / lib / tevent / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'tevent'
4 VERSION = '0.9.14'
5
6 blddir = 'bin'
7
8 import sys, os
9
10 # find the buildtools directory
11 srcdir = '.'
12 while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
13     srcdir = '../' + srcdir
14 sys.path.insert(0, srcdir + '/buildtools/wafsamba')
15
16 import wafsamba, samba_dist, Options, Logs
17
18 samba_dist.DIST_DIRS('lib/tevent:. lib/replace:lib/replace lib/talloc:lib/talloc buildtools:buildtools')
19
20 def set_options(opt):
21     opt.BUILTIN_DEFAULT('replace')
22     opt.PRIVATE_EXTENSION_DEFAULT('tevent', noextension='tevent')
23     opt.RECURSE('lib/replace')
24     opt.RECURSE('lib/talloc')
25     if opt.IN_LAUNCH_DIR():
26         opt.add_option('--disable-python',
27                        help=("disable the pytevent module"),
28                        action="store_true", dest='disable_python', default=False)
29
30
31 def configure(conf):
32     conf.RECURSE('lib/replace')
33     conf.RECURSE('lib/talloc')
34
35     conf.env.standalone_tevent = conf.IN_LAUNCH_DIR()
36
37     if not conf.env.standalone_tevent:
38         if conf.CHECK_BUNDLED_SYSTEM_PKG('tevent', minversion=VERSION,
39                                      onlyif='talloc', implied_deps='replace talloc'):
40             conf.define('USING_SYSTEM_TEVENT', 1)
41             if conf.CHECK_BUNDLED_SYSTEM_PYTHON('pytevent', 'tevent', minversion=VERSION):
42                 conf.define('USING_SYSTEM_PYTEVENT', 1)
43
44     if conf.CHECK_FUNCS('epoll_create', headers='sys/epoll.h'):
45         conf.DEFINE('HAVE_EPOLL', 1)
46
47     conf.env.disable_python = getattr(Options.options, 'disable_python', False)
48
49     if not conf.env.disable_python:
50         # also disable if we don't have the python libs installed
51         conf.find_program('python', var='PYTHON')
52         conf.check_tool('python')
53         conf.check_python_version((2,4,2))
54         conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
55         if not conf.env.HAVE_PYTHON_H:
56             Logs.warn('Disabling pytevent as python devel libs not found')
57             conf.env.disable_python = True
58
59     conf.SAMBA_CONFIG_H()
60
61 def build(bld):
62     bld.RECURSE('lib/replace')
63     bld.RECURSE('lib/talloc')
64
65     SRC = '''tevent.c tevent_debug.c tevent_fd.c tevent_immediate.c
66              tevent_queue.c tevent_req.c tevent_select.c
67          tevent_poll.c
68              tevent_signal.c tevent_standard.c tevent_timed.c tevent_util.c tevent_wakeup.c'''
69
70     if bld.CONFIG_SET('HAVE_EPOLL'):
71         SRC += ' tevent_epoll.c'
72
73     if bld.env.standalone_tevent:
74         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
75         private_library = False
76     else:
77         private_library = True
78
79     if not bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
80         bld.SAMBA_LIBRARY('tevent',
81                           SRC,
82                           deps='replace talloc',
83                           enabled= not bld.CONFIG_SET('USING_SYSTEM_TEVENT'),
84                           includes='.',
85                           abi_directory='ABI',
86                           abi_match='tevent_* _tevent_*',
87                           vnum=VERSION,
88                           public_headers='tevent.h',
89                           public_headers_install=not private_library,
90                           pc_files='tevent.pc',
91                           private_library=private_library)
92
93     if not bld.CONFIG_SET('USING_SYSTEM_PYTDB'):
94         bld.SAMBA_PYTHON('pytevent',
95                          'pytevent.c',
96                          deps='tevent',
97                          realname='_tevent.so')
98
99
100 def test(ctx):
101     '''test tevent'''
102     print("The tevent testsuite is part of smbtorture in samba4")
103
104
105 def dist():
106     '''makes a tarball for distribution'''
107     samba_dist.dist()
108
109 def reconfigure(ctx):
110     '''reconfigure if config scripts have changed'''
111     import samba_utils
112     samba_utils.reconfigure(ctx)