1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
require 5.004;
unless ($^O =~ /Win/i) {
WriteMakefile(
'NAME' => 'MARC',
'VERSION_FROM' => 'MARC.pm', # finds $VERSION
'SKIP' => [qw(tool_autosplit)],
'clean' => {FILES => "*/output* output*"},
);
exit;
}
# On Windows, create substitute scripts for the "make deprived"
use File::Copy;
use File::Path;
use Pod::Html;
use File::Find;
# clean up test and example result files
find(\&wanted, ".");
sub wanted {
return unless (/^output/);
unlink ($_);
}
my $version = simple_version("MARC.pm");
my $INST_LIBDIR = "./lib";
my $INST_HTMLDIR = "./html";
my $INST_FILES = "MARC.pm";
my $INST_NAME = "MARC";
my @HTML_FILES = "MARC";
print <<INTRO3;
MARC version $version
No 'Makefile' will be created
Test with: perl test.pl
Install with: perl install.pl
INTRO3
my $dfile = "test.pl";
unlink $dfile;
print "Creating new $dfile\n";
open (DEFAULT, "> $dfile") or die "Can't create $dfile: $!\n";
print DEFAULT <<"TEST4"; # double quotes - need interpolation
# Created by Makefile.PL
# $INST_NAME Version $version
TEST4
print DEFAULT <<'TEST4'; # single quotes - minimize chaacter quoting
use Test::Harness;
runtests ("t/test1.t","t/test2.t","t/test3.t","t/test4.t","t/test5.t");
print "\nTo run individual tests, type:\n";
print " C:\\> perl t/test?.t Page_Pause_Time (0..5)\n";
print "See README and other documentation for additional information.\n\n";
TEST4
close DEFAULT;
unless (-d $INST_LIBDIR) {
File::Path::mkpath([ "$INST_LIBDIR" ],1,0777) or
die "ERROR creating directories: ($!)\n";
}
unless (-d $INST_HTMLDIR) {
File::Path::mkpath([ "$INST_HTMLDIR" ],1,0777) or
die "ERROR creating directories: ($!)\n";
}
File::Copy::copy($INST_FILES,$INST_LIBDIR) or
die "ERROR copying files: ($!)\n";
foreach $source (@HTML_FILES) {
pod2html(
"--norecurse",
"--infile=$source.pm",
"--outfile=$INST_HTMLDIR/$source.html"
);
}
$dfile = "install.pl";
unlink $dfile, "pod2html-itemcache","pod2html-dircache";
print "Creating new $dfile\n";
open (DEFAULT, "> $dfile") or die "Can't create $dfile: $!\n";
print DEFAULT <<"INST5";
# Created by Makefile.PL
# $INST_NAME Version $version
INST5
my $template = <<'INST5';
use Config qw(%Config);
use strict;
use ExtUtils::Install qw( install );
my $FULLEXT = "%s"; # $INST_NAME
my $INST_LIB = "./lib";
my $HTML_LIB = "./html";
my $html_dest = ""; # edit real html base here if autodetect fails
if (exists $Config{installhtmldir} ) {
$html_dest = "$Config{installhtmldir}";
}
elsif (exists $Config{installprivlib} ) {
$html_dest = "$Config{installprivlib}";
$html_dest =~ s%\\lib%\\html%;
}
if ( length ($html_dest) ) {
$html_dest .= '\lib\site';
}
else {
die "Can't find html base directory. Edit install.pl manually.\n";
}
install({
read => "$Config{sitearchexp}/auto/$FULLEXT/.packlist",
write => "$Config{installsitearch}/auto/$FULLEXT/.packlist",
$INST_LIB => "$Config{installsitelib}",
$HTML_LIB => "$html_dest"
},1,0);
__END__
INST5
printf DEFAULT $template, $INST_NAME;
close DEFAULT;
# a low-fat version of parse_version from ExtUtils::MM_Unix.
sub simple_version {
my $parsefile = shift;
my $result;
open(FH,$parsefile) or die "Could not open '$parsefile': $!";
my $inpod = 0;
while (<FH>) {
$inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
next if $inpod;
chop;
next unless /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
my $eval = qq{
package ExtUtils::MakeMaker::_version;
no strict;
local $1$2;
\$$2=undef; do {
$_
}; \$$2
};
local($^W) = 0;
$result = eval($eval);
die "Could not eval '$eval' in $parsefile: $@" if $@;
$result = "undef" unless defined $result;
last;
}
close FH;
return $result;
}
|