summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-03-28 21:00:51 +1100
committerAndrew Tridgell <tridge@samba.org>2010-04-06 20:27:14 +1000
commit88b6b86c59c6ecd78fe677ee97e4baad2291285d (patch)
tree5961d70272f92617872c7bb57e1c33ce314063c4
parent67a59c33fcff5ed63aacf0c2d05aee628dfadfe6 (diff)
downloadsamba-88b6b86c59c6ecd78fe677ee97e4baad2291285d.tar.gz
samba-88b6b86c59c6ecd78fe677ee97e4baad2291285d.tar.bz2
samba-88b6b86c59c6ecd78fe677ee97e4baad2291285d.zip
s4-waf: added auto-detection of perl manpage extensions
some systems produce pidl.1p, others pidl.1. We need to know which one to use.
-rw-r--r--buildtools/wafsamba/samba_conftests.py93
-rw-r--r--pidl/wscript17
2 files changed, 87 insertions, 23 deletions
diff --git a/buildtools/wafsamba/samba_conftests.py b/buildtools/wafsamba/samba_conftests.py
index 47bef40a3d..94ddf3a5a9 100644
--- a/buildtools/wafsamba/samba_conftests.py
+++ b/buildtools/wafsamba/samba_conftests.py
@@ -1,7 +1,7 @@
# a set of config tests that use the samba_autoconf functions
# to test for commonly needed configuration options
-import os, Build, shutil, Utils
+import os, Build, shutil, Utils, re
from Configure import conf
from samba_utils import *
@@ -63,21 +63,8 @@ def CHECK_CHARSET_EXISTS(conf, charset, outcharset='UCS-2LE', headers=None, defi
lib='iconv',
headers=headers)
-
-
-# this one is quite complex, and should probably be broken up
-# into several parts. I'd quite like to create a set of CHECK_COMPOUND()
-# functions that make writing complex compound tests like this much easier
-@conf
-def CHECK_LIBRARY_SUPPORT(conf, rpath=False, msg=None):
- '''see if the platform supports building libraries'''
-
- if msg is None:
- if rpath:
- msg = "rpath library support"
- else:
- msg = "building library support"
-
+def find_config_dir(conf):
+ '''find a directory to run tests in'''
k = 0
while k < 10000:
dir = os.path.join(conf.blddir, '.conf_check_%d' % k)
@@ -100,6 +87,23 @@ def CHECK_LIBRARY_SUPPORT(conf, rpath=False, msg=None):
os.stat(dir)
except:
conf.fatal('cannot use the configuration test folder %r' % dir)
+ return dir
+
+
+# this one is quite complex, and should probably be broken up
+# into several parts. I'd quite like to create a set of CHECK_COMPOUND()
+# functions that make writing complex compound tests like this much easier
+@conf
+def CHECK_LIBRARY_SUPPORT(conf, rpath=False, msg=None):
+ '''see if the platform supports building libraries'''
+
+ if msg is None:
+ if rpath:
+ msg = "rpath library support"
+ else:
+ msg = "building library support"
+
+ dir = find_config_dir(conf)
bdir = os.path.join(dir, 'testbuild')
if not os.path.exists(bdir):
@@ -174,3 +178,60 @@ def CHECK_LIBRARY_SUPPORT(conf, rpath=False, msg=None):
conf.check_message(msg, '', ret)
return ret
+
+
+
+@conf
+def CHECK_PERL_MANPAGE(conf, msg=None, section=None):
+ '''work out what extension perl uses for manpages'''
+
+ if msg is None:
+ if section:
+ msg = "perl man%s extension" % section
+ else:
+ msg = "perl manpage generation"
+
+ conf.check_message_1(msg)
+
+ dir = find_config_dir(conf)
+
+ bdir = os.path.join(dir, 'testbuild')
+ if not os.path.exists(bdir):
+ os.makedirs(bdir)
+
+ dest = open(os.path.join(bdir, 'Makefile.PL'), 'w')
+ dest.write("""
+use ExtUtils::MakeMaker;
+WriteMakefile(
+ 'NAME' => 'WafTest',
+ 'EXE_FILES' => [ 'WafTest' ]
+);
+""")
+ dest.close()
+ back = os.path.abspath('.')
+ os.chdir(bdir)
+ proc = Utils.pproc.Popen(['perl', 'Makefile.PL'],
+ stdout=Utils.pproc.PIPE,
+ stderr=Utils.pproc.PIPE)
+ (out, err) = proc.communicate()
+ os.chdir(back)
+
+ ret = (proc.returncode == 0)
+ if not ret:
+ conf.check_message_2('not found', color='YELLOW')
+ return
+
+ if section:
+ f = open(os.path.join(bdir,'Makefile'), 'r')
+ man = f.read()
+ f.close()
+ m = re.search('MAN%sEXT\s+=\s+(\w+)' % section, man)
+ if not m:
+ conf.check_message_2('not found', color='YELLOW')
+ return
+ ext = m.group(1)
+ conf.check_message_2(ext)
+ return ext
+
+ conf.check_message_2('ok')
+ return True
diff --git a/pidl/wscript b/pidl/wscript
index 35681b9299..52e4bae662 100644
--- a/pidl/wscript
+++ b/pidl/wscript
@@ -8,8 +8,9 @@ def set_options(opt):
def configure(conf):
conf.check_tool('perl')
# we need a recent version of MakeMaker to get the right man page names
- if conf.check_perl_module('ExtUtils::MakeMaker 6.42'):
- conf.DEFINE('HAVE_PERL_MAKEMAKER', 1)
+ if conf.CHECK_PERL_MANPAGE():
+ conf.env.PERLMAN1EXT = conf.CHECK_PERL_MANPAGE(section='1')
+ conf.env.PERLMAN3EXT = conf.CHECK_PERL_MANPAGE(section='3')
def build(bld):
bld.INSTALL_FILES('${BINDIR}', 'pidl', chmod=0755)
@@ -22,11 +23,13 @@ def build(bld):
pidl_src = ['pidl']
pidl_src.extend(bld.path.ant_glob('lib/**/*.pm').split())
- pidl_manpages = '''blib/man1/pidl.1p blib/man3/Parse::Pidl::NDR.3pm
- blib/man3/Parse::Pidl::Wireshark::Conformance.3pm
- blib/man3/Parse::Pidl::Dump.3pm
- blib/man3/Parse::Pidl::Util.3pm
- blib/man3/Parse::Pidl::Wireshark::NDR.3pm'''.split()
+ pidl_manpages = '''blib/man1/pidl.${PERLMAN1EXT} blib/man3/Parse::Pidl::NDR.${PERLMAN3EXT}
+ blib/man3/Parse::Pidl::Wireshark::Conformance.${PERLMAN3EXT}
+ blib/man3/Parse::Pidl::Dump.${PERLMAN3EXT}
+ blib/man3/Parse::Pidl::Util.${PERLMAN3EXT}
+ blib/man3/Parse::Pidl::Wireshark::NDR.${PERLMAN3EXT}'''.split()
+
+ pidl_manpages = bld.EXPAND_VARIABLES(pidl_manpages)
# use perl to build the manpages
bld.env.pidl_srcdir = os.path.join(bld.srcnode.abspath(), 'pidl')