s4-waf: only build the pidl manpages if we have MakeMaker.pm
[nivanova/samba-autobuild/.git] / pidl / wscript
1 import os
2
3 def set_options(opt):
4     opt.tool_options('perl')
5
6 def configure(conf):
7     conf.check_tool('perl')
8     if conf.check_perl_module('ExtUtils::MakeMaker'):
9         conf.DEFINE('HAVE_PERL_MAKEMAKER', 1)
10
11 def build(bld):
12     bld.INSTALL_FILES('${BINDIR}', 'pidl', chmod=0755)
13
14     bld.BUILD_SUBDIR('lib')
15
16     if not bld.CONFIG_SET('HAVE_PERL_MAKEMAKER'):
17         return
18
19     pidl_src = ['pidl']
20     pidl_src.extend(bld.path.ant_glob('lib/**/*.pm').split())
21
22     pidl_manpages = '''blib/man1/pidl.1p blib/man3/Parse::Pidl::NDR.3pm
23                        blib/man3/Parse::Pidl::Wireshark::Conformance.3pm
24                        blib/man3/Parse::Pidl::Dump.3pm
25                        blib/man3/Parse::Pidl::Util.3pm
26                        blib/man3/Parse::Pidl::Wireshark::NDR.3pm'''.split()
27
28     # use perl to build the manpages
29     bld.env.pidl_srcdir = os.path.join(bld.srcnode.abspath(), 'pidl')
30
31     bld.SAMBA_GENERATOR('pidl_manpages',
32                         source=pidl_src,
33                         target=pidl_manpages,
34                         rule='cd ${pidl_srcdir} && ${PERL} Makefile.PL && make && rm -f Makefile Makefile.old')
35
36     for m in pidl_manpages:
37         dname=os.path.dirname(m)[5:]
38         bld.INSTALL_FILES('${MANDIR}/'+dname, m, flat=True)