From d8fc49e1b0057f77b3b8ad6403520a91e4c970b9 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sat, 26 Jan 2008 18:50:40 +0100 Subject: [PATCH] bindings/perl/Makefile.PL: Search for the header file and give up if it cannot be found. --- bindings/perl/Changes | 9 +++++++- bindings/perl/Makefile.PL | 55 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/bindings/perl/Changes b/bindings/perl/Changes index 974a189..ea4a612 100644 --- a/bindings/perl/Changes +++ b/bindings/perl/Changes @@ -1,8 +1,15 @@ Revision history for Perl extension Net::Oping. +1.01 ... + - Have `Makefile.PL' exit if the header file cannot be found + _before_ a Makefile is generated. This is done because + `ExtUtils::MakeMaker' doesn't check whether libraries exist and this + seems to be the standard way of dealing with this. A (hopefully) + informative message is written to STDERR in this case. + 1.00 Sat Jan 26 13:52:11 2008 - The module has been renamed from `Oping' to `Net::Oping'. - - The XS code has been simplyfied and a high-level interface has been + - The XS code has been simplified and a high-level interface has been created in Perl. 0.01 Wed Oct 24 01:32:19 2007 diff --git a/bindings/perl/Makefile.PL b/bindings/perl/Makefile.PL index 4e375a5..f2ddf0a 100644 --- a/bindings/perl/Makefile.PL +++ b/bindings/perl/Makefile.PL @@ -1,6 +1,57 @@ use 5.008007; use ExtUtils::MakeMaker; +my @OPING_PREFIX = (qw(/opt/oping /usr /usr/local)); +my $OPING_PREFIX; + +for (my $i = 0; $i < @ARGV; $i++) +{ + if ($ARGV[$i] =~ m#^OPING_PREFIX=(.*[^/])#) + { + unshift (@OPING_PREFIX, $1); + splice (@ARGV, $i, 1); + $i--; + } +} + +for (my $i = 0; $i < @OPING_PREFIX; $i++) +{ + if (!-e $OPING_PREFIX[$i] . '/include/oping.h') + { + next; + } + + $OPING_PREFIX = $OPING_PREFIX[$i]; + print "Found in $OPING_PREFIX/include\n"; + last; +} + +if (!$OPING_PREFIX) +{ + my $search_path = join (', ', @OPING_PREFIX); + print STDERR <! * +****************************************************************************** +The header file could not be found in the usual places. The prefix +paths searched right now are: + $search_path + +Please rerun Makefile.PL giving the prefix to the oping library using the +`OPING_PREFIX' argument. If you, for example, had installed the oping library +to /tmp/oping, the header file would be at /tmp/oping/include/oping.h; you'd +then need to run the Makefile.PL as follows: + perl Makefile.PL OPING_PREFIX=/tmp/oping + +As you can see, the argument passed via `OPING_PREFIX' must be the same +directory you passed to the liboping configure script using the `--prefix' +argument. + +No Makefile has been created. +EOF + exit (0); +} + WriteMakefile( NAME => 'Net::Oping', VERSION_FROM => 'lib/Net/Oping.pm', @@ -9,7 +60,7 @@ WriteMakefile( ? (ABSTRACT_FROM => 'lib/Net/Oping.pm', AUTHOR => 'Florian Forster ') : ()), - LIBS => ['-loping', '-L/opt/oping/lib/ -loping'], + LIBS => ["-L$OPING_PREFIX/lib -loping"], DEFINE => '', - INC => '-I/opt/oping/include/' + INC => "-I$OPING_PREFIX/include" ); -- 2.11.0