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