New -- should be part of the test suite but this is better than nothing.
[irspy-moved-to-github.git] / Makefile.PL
1 # $Id: Makefile.PL,v 1.12 2007-02-27 18:16:26 mike Exp $
2
3 use 5.008;
4 use strict;
5 use warnings;
6 use ExtUtils::MakeMaker;
7
8 my $yazver = `yaz-config --version`;
9 if (!$yazver) {
10     die qq[
11 ERROR: Unable to call script: yaz-config
12 If you are using a YAZ installation from the Debian package "yaz", you
13 will also need to install "libyaz-dev" in order to build this module.
14 ];
15 }
16
17 chomp($yazver);
18 # 2.1.51 is the first version with support for polling arbitrarily
19 # many file descriptors: earlier YAZ versions had a hardwired
20 # 1024-element array so that working with more file descriptors than
21 # this would cause a segmentation fault.
22 check_version($yazver, "2.1.51");
23
24 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
25 # the contents of the Makefile that is written.
26 WriteMakefile(
27     NAME              => 'ZOOM::IRSpy',
28     VERSION_FROM      => 'lib/ZOOM/IRSpy.pm', # finds $VERSION
29     PREREQ_PM         => {
30         "Net::Z3950::ZOOM" => 1.18,
31         "XML::LibXML::XPathContext" => 0.07, # For Web UI
32         "XML::LibXML" => 1.58,
33         "XML::LibXSLT" => 1.57,
34         "URI::Escape" => 3.28, # For Web UI
35     },
36     ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
37       (ABSTRACT_FROM  => 'lib/ZOOM/IRSpy.pm', # retrieve abstract from module
38        AUTHOR         => 'Mike Taylor <mike@indexdata.com>') : ()),
39 );
40
41
42 sub check_version {
43     my($got, $want) = @_;
44
45     my($gmajor, $gminor, $gtrivial) = ($got =~ /(\d+)\.(\d+)\.(\d+)/);
46     my($wmajor, $wminor, $wtrivial) = ($want =~ /(\d+)\.(\d+)\.(\d+)/);
47     if (($gmajor < $wmajor) ||
48         ($gmajor == $wmajor && $gminor < $wminor) ||
49         ($gmajor == $wmajor && $gminor == $wminor && $gtrivial < $wtrivial)) {
50         print <<__EOT__;
51 *** ERROR!
52 ZOOM-Perl requires at least version $want of YAZ,
53 but is currently you only have version $got.
54 __EOT__
55         exit 1;
56     }
57 }