9efc895b5589744a71390f48ee5e5b8f9aa866c8
[sfrench/samba-autobuild/.git] / lib / talloc / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'talloc'
4 VERSION = '2.1.2'
5
6
7 blddir = 'bin'
8
9 import Logs
10 import os, sys
11
12 # find the buildtools directory
13 srcdir = '.'
14 while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
15     srcdir = srcdir + '/..'
16 sys.path.insert(0, srcdir + '/buildtools/wafsamba')
17
18 import sys
19 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
20 import wafsamba, samba_dist, Options
21
22 # setup what directories to put in a tarball
23 samba_dist.DIST_DIRS('lib/talloc:. lib/replace:lib/replace buildtools:buildtools')
24
25
26 def set_options(opt):
27     opt.BUILTIN_DEFAULT('replace')
28     opt.PRIVATE_EXTENSION_DEFAULT('talloc', noextension='talloc')
29     opt.RECURSE('lib/replace')
30     if opt.IN_LAUNCH_DIR():
31         opt.add_option('--enable-talloc-compat1',
32                        help=("Build talloc 1.x.x compat library [False]"),
33                        action="store_true", dest='TALLOC_COMPAT1', default=False)
34         opt.add_option('--disable-python',
35                        help=("disable the pytalloc module"),
36                        action="store_true", dest='disable_python', default=False)
37
38
39 def configure(conf):
40     conf.RECURSE('lib/replace')
41
42     conf.env.standalone_talloc = conf.IN_LAUNCH_DIR()
43
44     conf.env.disable_python = getattr(Options.options, 'disable_python', False)
45
46     if not conf.env.standalone_talloc:
47         if conf.CHECK_BUNDLED_SYSTEM_PKG('talloc', minversion=VERSION,
48                                      implied_deps='replace'):
49             conf.define('USING_SYSTEM_TALLOC', 1)
50         if conf.CHECK_BUNDLED_SYSTEM_PKG('pytalloc-util', minversion=VERSION,
51                                      implied_deps='talloc replace'):
52             conf.define('USING_SYSTEM_PYTALLOC_UTIL', 1)
53
54     conf.env.TALLOC_COMPAT1 = False
55     if conf.env.standalone_talloc:
56         conf.env.TALLOC_COMPAT1 = Options.options.TALLOC_COMPAT1
57
58     conf.CHECK_XSLTPROC_MANPAGES()
59
60     if not conf.env.disable_python:
61         # also disable if we don't have the python libs installed
62         conf.find_program('python', var='PYTHON')
63         conf.check_tool('python')
64         conf.check_python_version((2,4,2))
65         conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=False)
66         if not conf.env.HAVE_PYTHON_H:
67             Logs.warn('Disabling pytalloc-util as python devel libs not found')
68             conf.env.disable_python = True
69
70     conf.SAMBA_CONFIG_H()
71
72     conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
73
74
75 def build(bld):
76     bld.RECURSE('lib/replace')
77
78     if bld.env.standalone_talloc:
79         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
80         bld.env.TALLOC_VERSION = VERSION
81         private_library = False
82
83         # should we also install the symlink to libtalloc1.so here?
84         bld.SAMBA_LIBRARY('talloc-compat1-%s' % (VERSION),
85                           'compat/talloc_compat1.c',
86                           public_deps='talloc',
87                           soname='libtalloc.so.1',
88                           pc_files=[],
89                           public_headers=[],
90                           enabled=bld.env.TALLOC_COMPAT1)
91
92         testsuite_deps = 'talloc'
93         if bld.CONFIG_SET('HAVE_PTHREAD'):
94             testsuite_deps += ' pthread'
95
96         bld.SAMBA_BINARY('talloc_testsuite',
97                          'testsuite_main.c testsuite.c',
98                          testsuite_deps,
99                          install=False)
100
101     else:
102         private_library = True
103
104     if not bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
105
106         bld.SAMBA_LIBRARY('talloc',
107                           'talloc.c',
108                           deps='replace',
109                           abi_directory='ABI',
110                           abi_match='talloc* _talloc*',
111                           hide_symbols=True,
112                           vnum=VERSION,
113                           public_headers='talloc.h',
114                           pc_files='talloc.pc',
115                           public_headers_install=not private_library,
116                           private_library=private_library,
117                           manpages='man/talloc.3')
118
119     if not bld.CONFIG_SET('USING_SYSTEM_PYTALLOC_UTIL') and not bld.env.disable_python:
120         bld.SAMBA_LIBRARY('pytalloc-util',
121             source='pytalloc_util.c',
122             public_deps='talloc',
123             pyembed=True,
124             vnum=VERSION,
125             hide_symbols=True,
126             abi_directory='ABI',
127             abi_match='pytalloc_*',
128             private_library=private_library,
129             public_headers='pytalloc.h',
130             pc_files='pytalloc-util.pc'
131             )
132         bld.SAMBA_PYTHON('pytalloc',
133                          'pytalloc.c',
134                          deps='talloc pytalloc-util',
135                          enabled=True,
136                          realname='talloc.so')
137
138 def test(ctx):
139     '''run talloc testsuite'''
140     import Utils, samba_utils
141     cmd = os.path.join(Utils.g_module.blddir, 'talloc_testsuite')
142     ret = samba_utils.RUN_COMMAND(cmd)
143     print("testsuite returned %d" % ret)
144     sys.exit(ret)
145
146 def dist():
147     '''makes a tarball for distribution'''
148     samba_dist.dist()
149
150 def reconfigure(ctx):
151     '''reconfigure if config scripts have changed'''
152     import samba_utils
153     samba_utils.reconfigure(ctx)
154
155
156 def pydoctor(ctx):
157     '''build python apidocs'''
158     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.*'
159     print("Running: %s" % cmd)
160     os.system(cmd)