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
|
use strict;
use warnings;
use 5.008;
use ExtUtils::MakeMaker 6.30;
use Config;
use File::Slurp;
#use lib 'lib'; # to find FixTeXMakefile.pm
#use Games::Go::Sgf2Dg::FixTexMakefile;
eval { require PDF::Create; }; # is this module available?
if ($@) {
print "\nPDF::Create not available\n",
" I'll install Games::Go::Sgf2Dg, but the PDF converter (Dg2PDF) needs PDF::Create.\n",
" You can find PDF::Create in the same repository where you found\n",
" Games::Go::Sgf2Dg, or from http://search.cpan.org/\n\n";
} else {
my $v = ($PDF::Create::VERSION =~ m/(^\d*\.\d*)/)[0];
if (not defined($v)) {
print("\n\n Hmm, can't extract package version from \$PDF::Create::VERSION.\n" .
" There may be a more recent version at:\n\n" .
" http://www.sourceforge.net/projects/perl-pdf.\n\n");
} elsif ($v < 0.06) {
print("\n\n Note: your PDF::Create package is version $v.\n" .
" You might want to pick up a more recent version from:\n\n" .
" http://www.sourceforge.net/projects/perl-pdf.\n\n");
}
}
eval { require PostScript::File; }; # is this module available?
if ($@) {
print "\nPostScript::File not available\n",
" I'll install Games::Go::Sgf2Dg, but the PostScript converter (Dg2Ps) needs\n",
" PostScript::File.\n",
" You can find PostScript::File in the same repository where you found\n",
" Games::Go::Sgf2Dg, or from http://search.cpan.org/\n\n";
}
my %makeMakerOpts = (
EXE_FILES => [ 'bin/sgf2dg' ],
MAN1PODS => { 'bin/sgf2dg' => "\$(INST_MAN1DIR)/sgf2dg.1p" },
);
if (($Config{osname} eq 'dos') or ($Config{osname} eq 'win32')) { # punt
print "\nI'm sorry, but since this is a DOS platform, if you need sgfsplit, you'll\n",
" need to compile it yourself. If you've got all the right tools, you may\n",
" be able to type 'make sgfsplit.exe'.\n\n";
} else {
push @{$makeMakerOpts{EXE_FILES}}, 'sgfsplit';
$makeMakerOpts{OBJECT} = ('sgfsplit.o');
$makeMakerOpts{MAN1PODS}{'sgfsplit.c'} = '$(INST_MAN1DIR)/sgfsplit.1p';
}
my %WriteMakefileArgs = (
"ABSTRACT" => "Sgf2Dg.pm",
"AUTHOR" => "Reid Augustin <reid\@hellosix.com>",
"BUILD_REQUIRES" => {
"Test::More" => 0
},
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => "6.30"
},
"DISTNAME" => "Games-Go-Sgf2Dg",
%makeMakerOpts,
"LICENSE" => "perl",
"NAME" => "Games::Go::Sgf2Dg",
"PREREQ_PM" => {
"Carp" => 0,
"Config" => 0,
"Exporter" => 0,
"ExtUtils::MakeMaker" => 0,
"File::Find" => 0,
"File::Slurp" => 0,
"File::Spec" => 0,
"IO::File" => 0,
"PDF::Create" => 0,
"POSIX" => 0,
"PostScript::File" => 0,
"Tk" => 0,
"Tk::Canvas" => 0,
"Tk::NoteBook" => 0,
"constant" => 0,
"strict" => 0,
"warnings" => 0
},
"VERSION" => "4.252",
"test" => {
"TESTS" => "t/*.t"
}
);
unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) {
my $br = delete $WriteMakefileArgs{BUILD_REQUIRES};
my $pp = $WriteMakefileArgs{PREREQ_PM};
for my $mod ( keys %$br ) {
if ( exists $pp->{$mod} ) {
$pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod};
}
else {
$pp->{$mod} = $br->{$mod};
}
}
}
delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
WriteMakefile(%WriteMakefileArgs);
# no dynamic targets for this package:
sub MY::dynamic {
return '';
}
# add install_tex and fonts rules in the postamble
sub MY::postamble {
return q{
# how to make a manual.tex file into a manual.pdf
manual.pdf : manual.tex
env TEXINPUTS=.:tex: MFINPUTS=.:tex: TEXMFONTS=.:tex: pdftex $<
# how to install tex portion of Sgf2Dg
install_tex :
cd tex; ${MAKE} install
# how to make fonts
fonts :
cd tex; ${MAKE} fonts
};
}
# modify the Makefile slightly
my $content = read_file('Makefile');
# add install_tex target to install tex subdirectory
$content =~ s/^(install\b[^\n]*)/$1 install_tex manual.pdf/m;
# remove all references to after_build.pl
$content =~ s/\S*after_build.pl//g;
# remove all references to FixTexMakefile.pm
$content =~ s/\S*FixTexMakefile.pm'?//g;
write_file('Makefile', $content);
# Find TeX stuff on the system and modify tex/Makefile accordingly
#Games::Go::Sgf2Dg::FixTexMakefile::fix();
|