Needs YAZ version 2.1.50 or better.
[ZOOM-Perl-moved-to-github.git] / Makefile.PL
1 # $Id: Makefile.PL,v 1.19 2007-02-26 14:37:20 mike Exp $
2
3 use 5.008;
4 use ExtUtils::MakeMaker;
5 use strict;
6
7 my $yazver = `yaz-config --version`;
8 my $yazinc = `yaz-config --cflags threads`;
9 my $yazlibs = `yaz-config --libs threads`;
10 if (!$yazver || !$yazinc || !$yazlibs) {
11     die qq[
12 ERROR: Unable to call script: yaz-config
13 If you are using a YAZ installation from the Debian package "yaz", you
14 will also need to install "libyaz-dev" in order to build this module.
15 ];
16 }
17
18 chomp($yazver);
19 check_version($yazver, "2.1.50");
20
21 # For Windows use
22 # $yazinc = '-Ic:\yaz\include'
23 # $yazlibs = 'c:\yaz\lib\yaz.lib'
24
25 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
26 # the contents of the Makefile that is written.
27 WriteMakefile(
28     NAME              => 'Net::Z3950::ZOOM',
29     VERSION_FROM      => 'lib/Net/Z3950/ZOOM.pm', # finds $VERSION
30     PREREQ_PM         => { "MARC::Record" => 1.38 },
31     ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
32       (ABSTRACT_FROM  => 'lib/Net/Z3950/ZOOM.pm', # retrieve abstract from module
33        AUTHOR         => 'Mike Taylor <mike@>') : ()),
34     LIBS              => [ $yazlibs ], # e.g., '-lm'
35     DEFINE            => '', # e.g., '-DHAVE_SOMETHING'
36         # Insert -I. if you add *.h files later:
37     INC               => $yazinc, # e.g., '-I/usr/include/other'
38         # Un-comment this if you add C files to link with later:
39     # OBJECT            => '$(O_FILES)', # link all the C files too
40 # Use this to test for illegal code that GCC stupidly permits by default:
41 #   OPTIMIZE          => "-Wdeclaration-after-statement -g -O0",
42     EXE_FILES    => [ 'samples/zoom/zselect' ],
43 );
44
45
46 sub check_version {
47     my($got, $want) = @_;
48
49     my($gmajor, $gminor, $gtrivial) = ($got =~ /(\d+)\.(\d+)\.(\d+)/);
50     my($wmajor, $wminor, $wtrivial) = ($want =~ /(\d+)\.(\d+)\.(\d+)/);
51     if (($gmajor < $wmajor) ||
52         ($gmajor == $wmajor && $gminor < $wminor) ||
53         ($gmajor == $wmajor && $gminor == $wminor && $gtrivial < $wtrivial)) {
54         print <<__EOT__;
55 *** WARNING!
56 ZOOM-Perl requires at least version $want of YAZ,
57 but is currently you only have version $got.
58 __EOT__
59         exit 1;
60     }
61 }