talloc-waf: added the manpage generation and talloc1-compat generation
[samba.git] / lib / talloc / wscript
1 #!/usr/bin/env python
2
3 APPNAME = 'talloc'
4 VERSION = '2.0.2'
5
6
7 blddir = 'bin'
8
9 import os, sys
10
11 # find the buildtools directory
12 srcdir = '.'
13 while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
14     srcdir = '../' + srcdir
15 sys.path.insert(0, srcdir + '/buildtools/wafsamba')
16
17 import sys
18 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
19 import wafsamba, samba_dist, Options
20
21 # setup what directories to put in a tarball
22 samba_dist.DIST_DIRS('lib/talloc:. lib/replace:lib/replace buildtools:buildtools')
23
24
25 def set_options(opt):
26     opt.BUILTIN_DEFAULT('replace')
27     opt.BUNDLED_EXTENSION_DEFAULT('talloc', noextenion='talloc')
28     opt.RECURSE('lib/replace')
29     opt.add_option('--enable-talloc-compat1',
30                    help=("Build talloc 1.x.x compat library [False]"),
31                    action="store_true", dest='TALLOC_COMPAT1', default=False)
32
33 def configure(conf):
34     conf.RECURSE('lib/replace')
35
36     if conf.CHECK_BUNDLED_SYSTEM('talloc', minversion=VERSION,
37                                  implied_deps='replace'):
38         conf.define('USING_SYSTEM_TALLOC', 1)
39
40     conf.env.standalone_talloc = conf.IN_LAUNCH_DIR()
41
42     conf.env.TALLOC_COMPAT1 = Options.options.TALLOC_COMPAT1
43
44     if conf.env.standalone_talloc:
45         conf.find_program('xsltproc', var='XSLTPROC')
46
47     conf.SAMBA_CONFIG_H()
48
49
50
51 def build(bld):
52     bld.RECURSE('lib/replace')
53
54     if not bld.CONFIG_SET('USING_SYSTEM_TALLOC'):
55
56         bld.SAMBA_LIBRARY('talloc',
57                           'talloc.c',
58                           deps='replace',
59                           vnum=VERSION)
60
61         # should we also install the symlink to libtalloc1.so here?
62         bld.SAMBA_LIBRARY('talloc-compat1',
63                           'talloc.c compat/talloc_compat1.c',
64                           deps='replace',
65                           enabled = bld.env.TALLOC_COMPAT1,
66                           vnum=VERSION)
67
68     if not getattr(bld.env, '_SAMBA_BUILD_', 0) == 4:
69         # s4 already has the talloc testsuite builtin to smbtorture
70         bld.SAMBA_BINARY('talloc_testsuite',
71                          'testsuite_main.c testsuite.c',
72                          deps='talloc',
73                          install=False)
74
75     if bld.env.standalone_talloc:
76         bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
77         bld.env.TALLOC_VERSION = VERSION
78         bld.PKG_CONFIG_FILES('talloc.pc', vnum=VERSION)
79         bld.INSTALL_FILES('${INCLUDEDIR}', 'talloc.h')
80
81         if bld.env.XSLTPROC:
82             bld.env.TALLOC_MAN_XSL = 'http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl'
83             bld.env.TALLOC_WEB_XSL = 'http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl'
84             bld.SAMBA_GENERATOR('talloc.3',
85                                 source='talloc.3.xml',
86                                 target='talloc.3',
87                                 rule='${XSLTPROC} -o ${TGT} ${TALLOC_MAN_XSL} ${SRC}'
88                                 )
89             bld.SAMBA_GENERATOR('talloc.3.html',
90                                 source='talloc.3.xml',
91                                 target='talloc.3.html',
92                                 rule='${XSLTPROC} -o ${TGT} ${TALLOC_WEB_XSL} ${SRC}'
93                                 )
94             bld.INSTALL_FILES('${MANDIR}/man3', 'talloc.3')
95
96
97 def test(ctx):
98     '''run talloc testsuite'''
99     import Utils
100     cmd = os.path.join(Utils.g_module.blddir, 'talloc_testsuite')
101     os.system(cmd)
102
103 def dist():
104     '''makes a tarball for distribution'''
105     samba_dist.dist()