1#!/usr/bin/perl -w
2use 5.006001;
3use strict;
4use vars qw($VERSION $opt_n $opt_y);
5$VERSION = "0.05";
6
7use ExtUtils::MakeMaker;
8BEGIN {
9    @Heap::Simple::implementors = qw(CGI) unless @Heap::Simple::implementors;
10}
11
12# Allows to suppress all questions with -n or -y
13use Getopt::Std;
14getopts("ny") || die "Usage: $0 [-n] [-y]\n";
15
16my $benchmark = 0;
17my $benchmark_others = 0;
18
19if (!$opt_n || $opt_y) {
20    print <<EOT
21
22   Note that you can avoid these questions by passing
23   the '-n' or '-y' option to 'Makefile.PL'.
24
25EOT
26;
27    $benchmark =
28        $opt_y ||
29        prompt("Run Heap::Simple benchmarks during 'make test' ?", "n") =~ /^y/i;
30    if ($benchmark) {
31        $benchmark_others =
32            $opt_y ||
33            prompt("Benchmarks against other heap modules that happen to be installed on this machine during 'make test' ?", "n") =~ /^y/i;
34    }
35}
36my $option_file = "t/options";
37my $new = "$option_file.new.$$";
38open(my $fh, ">", $new) || die "Could not open '$new': $!";
39printf($fh "BENCHMARK=%d\nBENCHMARK_OTHERS=%d\n",
40       $benchmark ? 1 : 0,
41       $benchmark_others ? 1 : 0) || die "Error writing to '$new': $!";
42eval {
43    close($fh) || die "Could not close '$new': $!";
44    rename($new, $option_file) ||
45        die "Could not rename '$new' to '$option_file': $!";
46};
47if ($@) {
48    $fh = undef;	# close file if open
49    unlink($new) || die "Could not unlink '$new': $! after $@";
50    die $@;
51}
52
53WriteMakefile
54    (NAME		=> 'Heap::Simple::XS',
55     VERSION_FROM	=> "lib/Heap/Simple/XS/Package.pm",
56     PERL_MALLOC_OK	=> 1,
57     'PREREQ_PM'	=> {
58         "Heap::Simple"	=> 0.09,	# implementor switch
59         "Test::More"	=> 0.11,	# For the tests only
60     },
61     AUTHOR	=> 'Ton Hospel <Heap-Simple-XS@ton.iguana.be>',
62     # OPTIMIZE		=> "-g",
63     LIBS	=> [''], # e.g., '-lm'
64     DEFINE	=> '', # e.g., '-DHAVE_SOMETHING'
65     INC	=> '-I.', # e.g., '-I. -I/usr/include/other'
66     $^O eq "MSWin32" ? (
67         PM_FILTER	=> '$(PERL) -p -e1',
68     ) : (),
69     clean		=> {
70         FILES => '$(DISTNAME).ppd ppm',
71     },
72);
73
74package MY;
75sub postamble {
76    return shift->SUPER::postamble() . <<"EOF";
77ppm: \$(DISTNAME).ppd
78
79\$(DISTNAME).ppd: all ppd
80	makeppd.pl --perl=\$(PERL) --min_version=1.011 --binary --zip=\$(ZIP) --tar=\$(TAR) --compress="\$(COMPRESS)" --leave=ppm \$(DISTNAME).ppd \$(VERSION)
81
82ppm_install: \$(DISTNAME).ppd
83	ppm install ppm/\$(DISTNAME).ppd
84
85ppm_upgrade: \$(DISTNAME).ppd
86	ppm upgrade -install ppm/\$(DISTNAME).ppd
87EOF
88}
89