Add magic init-script comments (I think from John)
[ZOOM-Perl-moved-to-github.git] / Makefile.PL
1 # Use: perl Makefile.PL OPTIMIZE="-O0 -g -Wdeclaration-after-statement"
2 #  or: perl Makefile.PL PREFIX=/home/mike/universe
3
4 use 5.008;
5 use ExtUtils::MakeMaker;
6 use strict;
7
8 my $yazconf = "yaz-config";
9 my $yazver = `$yazconf --version`;
10 my $yazinc = `$yazconf --cflags threads`;
11 my $yazlibs = `$yazconf --libs threads`;
12 if (!$yazver || !$yazinc || !$yazlibs) {
13     die qq[
14 ERROR: Unable to call script: yaz-config
15 If you are using a YAZ installation from the Debian package "yaz", you
16 will also need to install "libyaz-dev" in order to build this module.
17 ];
18 }
19
20 chomp($yazver);
21 check_version($yazver, "4.0.0");
22
23 # For Windows use
24 # $yazinc = '-Ic:\yaz\include';
25 # $yazlibs = 'c:\yaz\lib\yaz.lib';
26
27 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
28 # the contents of the Makefile that is written.
29 WriteMakefile(
30     NAME              => 'Net::Z3950::ZOOM',
31     VERSION_FROM      => 'lib/Net/Z3950/ZOOM.pm', # finds $VERSION
32     PREREQ_PM         => { "MARC::Record" => 1.38 },
33     ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
34       (ABSTRACT_FROM  => 'lib/Net/Z3950/ZOOM.pm', # retrieve abstract from module
35        AUTHOR         => 'Mike Taylor <mike@>') : ()),
36     LIBS              => [ $yazlibs ], # e.g., '-lm'
37     DEFINE            => '', # e.g., '-DHAVE_SOMETHING'
38         # Insert -I. if you add *.h files later:
39     INC               => $yazinc, # e.g., '-I/usr/include/other'
40         # Un-comment this if you add C files to link with later:
41     # OBJECT            => '$(O_FILES)', # link all the C files too
42 # Use this to test for illegal code that GCC stupidly permits by default:
43 #   OPTIMIZE          => "-Wdeclaration-after-statement -g -O0",
44     EXE_FILES    => [ 'samples/zoom/zselect', 'samples/zoom/zoomdump',
45                       'samples/zoom/zoom-delete-records' ],
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 -us -uc -rfakeroot -d
70         rm -rf debian/output
71         mkdir debian/output
72         mv ../libnet-z3950-zoom-perl* debian/output
73
74 debclean:
75         rm -rf debian/libnet-z3950-zoom-perl debian/output
76 ";
77 }