tdb: add utility function check_merge_ptr_with_left_record()
[Samba.git] / pidl / wscript
blob49658700f128a682b3cf72dfcd7c89a95811df35
1 #!/usr/bin/env python
3 import os, sys, Logs
4 from samba_utils import MODE_755
6 # This function checks if a perl module is installed on the system.
7 def check_system_perl_module(conf, module, version=None):
8 bundle_name = module.replace('::', '_')
9 module_check = module
10 found = False
12 # Create module string with version
13 if version:
14 module_check = module + ' ' + str(version)
16 # Check if we have to bundle it.
17 if conf.LIB_MUST_BE_BUNDLED(bundle_name.lower()):
18 return False
20 # Check for system perl module
21 if not conf.check_perl_module(module_check):
22 return False
24 conf.define('USING_SYSTEM_%s' % bundle_name.upper(), 1)
26 return True
28 def set_options(opt):
29 opt.tool_options('perl')
31 def configure(conf):
32 conf.check_tool('perl')
33 conf.check_perl_ext_devel()
35 # Check if perl(Parse::Yapp::Driver) is available.
36 check_system_perl_module(conf, "Parse::Yapp::Driver", 1.05)
38 # we need a recent version of MakeMaker to get the right man page names
39 if conf.CHECK_PERL_MANPAGE():
40 conf.env.PERLMAN1EXT = conf.CHECK_PERL_MANPAGE(section='1')
41 conf.env.PERLMAN3EXT = conf.CHECK_PERL_MANPAGE(section='3')
42 conf.DEFINE('HAVE_PERL_MAKEMAKER', 1)
44 # yapp is used for building the parser
45 conf.find_program('yapp', var='YAPP')
46 conf.find_program('pod2man', var='POD2MAN')
48 def build(bld):
49 bld.INSTALL_FILES('${BINDIR}', 'pidl', chmod=MODE_755)
51 bld.RECURSE('lib')
53 if not bld.CONFIG_SET('HAVE_PERL_MAKEMAKER'):
54 return
56 pidl_manpages = {
57 'pidl': 'man1/pidl.${PERLMAN1EXT}',
58 'lib/Parse/Pidl/NDR.pm': 'man3/Parse::Pidl::NDR.${PERLMAN3EXT}',
59 'lib/Parse/Pidl/Wireshark/Conformance.pm': 'man3/Parse::Pidl::Wireshark::Conformance.${PERLMAN3EXT}',
60 'lib/Parse/Pidl/Dump.pm': 'man3/Parse::Pidl::Dump.${PERLMAN3EXT}',
61 'lib/Parse/Pidl/Util.pm': 'man3/Parse::Pidl::Util.${PERLMAN3EXT}',
62 'lib/Parse/Pidl/Wireshark/NDR.pm': 'man3/Parse::Pidl::Wireshark::NDR.${PERLMAN3EXT}'
65 for k, v in pidl_manpages.iteritems():
66 pidl_manpages[k] = bld.EXPAND_VARIABLES(v)
68 # use perl to build the manpages
69 bld.env.pidl_srcdir = os.path.join(bld.srcnode.abspath(), 'pidl')
71 blib_bld = os.path.join(bld.srcnode.abspath(bld.env), 'pidl/blib')
73 bld.SET_BUILD_GROUP('final')
74 if 'POD2MAN' in bld.env and bld.env['POD2MAN'] != '':
75 for src, manpage in pidl_manpages.iteritems():
76 bld(rule='${POD2MAN} -c "Samba Documentation" ${SRC} ${TGT}',
77 shell=True,
78 source=src,
79 install_path=os.path.dirname(bld.EXPAND_VARIABLES('${MANDIR}/'+manpage)),
80 target=os.path.basename(manpage))
82 # we want to prefer the git version of the parsers if we can.
83 # Only if the source has changed do we want to re-run yapp
84 # But we force the developer to use the pidl standalone build
85 # to regenerate the files.
86 # TODO: only warn in developer mode and if 'git diff HEAD'
87 # shows a difference
88 warn_about_grammar_changes = ('PIDL_BUILD_WARNINGS' in bld.env and (
89 bld.IS_NEWER('idl.yp', 'lib/Parse/Pidl/IDL.pm') or
90 bld.IS_NEWER('expr.yp', 'lib/Parse/Pidl/Expr.pm')))
92 if warn_about_grammar_changes:
93 Logs.warn('''
94 Pidl grammar files have changed. Please use the pidl standalone build
95 to regenerate them with yapp.
97 $ cd ../pidl
98 $ perl Makefile.PL
99 $ make lib/Parse/Pidl/IDL.pm lib/Parse/Pidl/Expr.pm
100 $ git add lib/Parse/Pidl/IDL.pm lib/Parse/Pidl/Expr.pm
101 $ git commit
102 $ cd -
104 If your 100% sure you haven't changed idl.yp and expr.yp
105 try this to avoid this message:
107 $ touch ../pidl/lib/Parse/Pidl/IDL.pm ../pidl/lib/Parse/Pidl/Expr.pm
108 ''')