Code

bindings/perl/Makefile.PL: Search for the header file and give up if it cannot be...
[liboping.git] / bindings / perl / Makefile.PL
1 use 5.008007;
2 use ExtUtils::MakeMaker;
4 my @OPING_PREFIX = (qw(/opt/oping /usr /usr/local));
5 my $OPING_PREFIX;
7 for (my $i = 0; $i < @ARGV; $i++)
8 {
9         if ($ARGV[$i] =~ m#^OPING_PREFIX=(.*[^/])#)
10         {
11                 unshift (@OPING_PREFIX, $1);
12                 splice (@ARGV, $i, 1);
13                 $i--;
14         }
15 }
17 for (my $i = 0; $i < @OPING_PREFIX; $i++)
18 {
19         if (!-e $OPING_PREFIX[$i] . '/include/oping.h')
20         {
21                 next;
22         }
24         $OPING_PREFIX = $OPING_PREFIX[$i];
25         print "Found <oping.h> in $OPING_PREFIX/include\n";
26         last;
27 }
29 if (!$OPING_PREFIX)
30 {
31         my $search_path = join (', ', @OPING_PREFIX);
32         print STDERR <<EOF;
33 ******************************************************************************
34 * ERROR: COULD NOT FIND THE NEEDED HEADER FILE <oping.h>!                    *
35 ******************************************************************************
36 The <oping.h> header file could not be found in the usual places. The prefix
37 paths searched right now are:
38   $search_path
40 Please rerun Makefile.PL giving the prefix to the oping library using the
41 `OPING_PREFIX' argument. If you, for example, had installed the oping library
42 to /tmp/oping, the header file would be at /tmp/oping/include/oping.h; you'd
43 then need to run the Makefile.PL as follows:
44   perl Makefile.PL OPING_PREFIX=/tmp/oping
46 As you can see, the argument passed via `OPING_PREFIX' must be the same
47 directory you passed to the liboping configure script using the `--prefix'
48 argument.
50 No Makefile has been created.
51 EOF
52         exit (0);
53 }
55 WriteMakefile(
56     NAME              => 'Net::Oping',
57     VERSION_FROM      => 'lib/Net/Oping.pm',
58     PREREQ_PM         => {},
59     ($] >= 5.005
60      ? (ABSTRACT_FROM => 'lib/Net/Oping.pm',
61         AUTHOR        => 'Florian Forster <octo@verplant.org>')
62      : ()),
63     LIBS              => ["-L$OPING_PREFIX/lib -loping"],
64     DEFINE            => '',
65     INC               => "-I$OPING_PREFIX/include"
66 );