mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Make mkfiles.pl clean under 'perl -w'. Fixes one minor bug in the
output (a comment from Recipe mistakenly got into the Unix makefile); more importantly, lets mkfiles.pl run in up-to-date Perls (where implicit split to @_ is now obsolete). [originally from svn r8957]
This commit is contained in:
1
Recipe
1
Recipe
@ -169,6 +169,7 @@ version2.def: FORCE
|
|||||||
mv version2.def.new version2.def; \
|
mv version2.def.new version2.def; \
|
||||||
fi
|
fi
|
||||||
.PHONY: FORCE
|
.PHONY: FORCE
|
||||||
|
!end
|
||||||
!specialobj osx version
|
!specialobj osx version
|
||||||
|
|
||||||
# make install for Unix.
|
# make install for Unix.
|
||||||
|
46
mkfiles.pl
46
mkfiles.pl
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl -w
|
||||||
#
|
#
|
||||||
# Cross-platform Makefile generator.
|
# Cross-platform Makefile generator.
|
||||||
#
|
#
|
||||||
@ -49,21 +49,29 @@ $project_name = "project"; # this is a good enough default
|
|||||||
@allobjs = (); # all object file names
|
@allobjs = (); # all object file names
|
||||||
|
|
||||||
readinput: while (1) {
|
readinput: while (1) {
|
||||||
|
$in = $filestack[$#filestack];
|
||||||
while (not defined ($_ = <$in>)) {
|
while (not defined ($_ = <$in>)) {
|
||||||
close $in;
|
close $filestack[$#filestack];
|
||||||
|
pop @filestack;
|
||||||
last readinput if 0 == scalar @filestack;
|
last readinput if 0 == scalar @filestack;
|
||||||
$in = pop @filestack;
|
$in = $filestack[$#filestack];
|
||||||
}
|
}
|
||||||
|
|
||||||
chomp;
|
chomp;
|
||||||
split;
|
@_ = split;
|
||||||
|
|
||||||
# Skip comments (unless the comments belong, for example because
|
# If we're gathering help text, keep doing so.
|
||||||
# they're part of a diversion).
|
if (defined $divert) {
|
||||||
next if /^\s*#/ and !defined $divert;
|
if ((defined $_[0]) && $_[0] eq "!end") {
|
||||||
|
$divert = undef;
|
||||||
|
} else {
|
||||||
|
${$divert} .= "$_\n";
|
||||||
|
}
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
# Skip comments and blank lines.
|
||||||
|
next if /^\s*#/ or scalar @_ == 0;
|
||||||
|
|
||||||
if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }
|
if ($_[0] eq "!begin" and $_[1] eq "help") { $divert = \$help; next; }
|
||||||
if ($_[0] eq "!end") { $divert = undef; next; }
|
|
||||||
if ($_[0] eq "!name") { $project_name = $_[1]; next; }
|
if ($_[0] eq "!name") { $project_name = $_[1]; next; }
|
||||||
if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
|
if ($_[0] eq "!srcdir") { push @srcdirs, $_[1]; next; }
|
||||||
if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
|
if ($_[0] eq "!makefile" and &mfval($_[1])) { $makefiles{$_[1]}=$_[2]; next;}
|
||||||
@ -87,13 +95,8 @@ readinput: while (1) {
|
|||||||
open $f, "<$file" or die "unable to open include file '$file'\n";
|
open $f, "<$file" or die "unable to open include file '$file'\n";
|
||||||
push @filestack, $f;
|
push @filestack, $f;
|
||||||
}
|
}
|
||||||
$in = $filestack[$#filestack];
|
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
# If we're gathering help text, keep doing so.
|
|
||||||
if (defined $divert) { ${$divert} .= "$_\n"; next; }
|
|
||||||
# Ignore blank lines.
|
|
||||||
next if scalar @_ == 0;
|
|
||||||
|
|
||||||
# Now we have an ordinary line. See if it's an = line, a : line
|
# Now we have an ordinary line. See if it's an = line, a : line
|
||||||
# or a + line.
|
# or a + line.
|
||||||
@ -206,7 +209,7 @@ foreach $i (@allobjs) {
|
|||||||
foreach $i (@prognames) {
|
foreach $i (@prognames) {
|
||||||
($prog, $type) = split ",", $i;
|
($prog, $type) = split ",", $i;
|
||||||
# Strip duplicate object names.
|
# Strip duplicate object names.
|
||||||
$prev = undef;
|
$prev = '';
|
||||||
@list = grep { $status = ($prev ne $_); $prev=$_; $status }
|
@list = grep { $status = ($prev ne $_); $prev=$_; $status }
|
||||||
sort @{$programs{$i}};
|
sort @{$programs{$i}};
|
||||||
$programs{$i} = [@list];
|
$programs{$i} = [@list];
|
||||||
@ -238,7 +241,6 @@ foreach $i (@prognames) {
|
|||||||
while (scalar @scanlist > 0) {
|
while (scalar @scanlist > 0) {
|
||||||
$file = shift @scanlist;
|
$file = shift @scanlist;
|
||||||
next if defined $further{$file}; # skip if we've already done it
|
next if defined $further{$file}; # skip if we've already done it
|
||||||
$resource = ($file =~ /\.rc$/ ? 1 : 0);
|
|
||||||
$further{$file} = [];
|
$further{$file} = [];
|
||||||
$dirfile = &findfile($file);
|
$dirfile = &findfile($file);
|
||||||
open IN, "$dirfile" or die "unable to open source file $file\n";
|
open IN, "$dirfile" or die "unable to open source file $file\n";
|
||||||
@ -267,7 +269,7 @@ foreach $i (keys %depends) {
|
|||||||
while (scalar @scanlist > 0) {
|
while (scalar @scanlist > 0) {
|
||||||
$file = shift @scanlist;
|
$file = shift @scanlist;
|
||||||
foreach $j (@{$further{$file}}) {
|
foreach $j (@{$further{$file}}) {
|
||||||
if ($dep{$j} != 1) {
|
if (!$dep{$j}) {
|
||||||
$dep{$j} = 1;
|
$dep{$j} = 1;
|
||||||
push @{$depends{$i}}, $j;
|
push @{$depends{$i}}, $j;
|
||||||
push @scanlist, $j;
|
push @scanlist, $j;
|
||||||
@ -296,7 +298,8 @@ sub mfval($) {
|
|||||||
sub dirpfx {
|
sub dirpfx {
|
||||||
my ($path) = shift @_;
|
my ($path) = shift @_;
|
||||||
my ($sep) = shift @_;
|
my ($sep) = shift @_;
|
||||||
my $ret = "", $i;
|
my $ret = "";
|
||||||
|
my $i;
|
||||||
while (($i = index $path, $sep) >= 0) {
|
while (($i = index $path, $sep) >= 0) {
|
||||||
$path = substr $path, ($i + length $sep);
|
$path = substr $path, ($i + length $sep);
|
||||||
$ret .= "..$sep";
|
$ret .= "..$sep";
|
||||||
@ -350,6 +353,7 @@ sub objects {
|
|||||||
my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
|
my ($prog, $otmpl, $rtmpl, $ltmpl, $prefix, $dirsep) = @_;
|
||||||
my @ret;
|
my @ret;
|
||||||
my ($i, $x, $y);
|
my ($i, $x, $y);
|
||||||
|
($otmpl, $rtmpl, $ltmpl) = map { defined $_ ? $_ : "" } ($otmpl, $rtmpl, $ltmpl);
|
||||||
@ret = ();
|
@ret = ();
|
||||||
foreach $ii (@{$programs{$prog}}) {
|
foreach $ii (@{$programs{$prog}}) {
|
||||||
$i = $objname{$ii};
|
$i = $objname{$ii};
|
||||||
@ -384,7 +388,8 @@ sub special {
|
|||||||
|
|
||||||
sub splitline {
|
sub splitline {
|
||||||
my ($line, $width, $splitchar) = @_;
|
my ($line, $width, $splitchar) = @_;
|
||||||
my ($result, $len);
|
my $result = "";
|
||||||
|
my $len;
|
||||||
$len = (defined $width ? $width : 76);
|
$len = (defined $width ? $width : 76);
|
||||||
$splitchar = (defined $splitchar ? $splitchar : '\\');
|
$splitchar = (defined $splitchar ? $splitchar : '\\');
|
||||||
while (length $line > $len) {
|
while (length $line > $len) {
|
||||||
@ -400,7 +405,8 @@ sub splitline {
|
|||||||
sub deps {
|
sub deps {
|
||||||
my ($otmpl, $rtmpl, $prefix, $dirsep, $depchar, $splitchar) = @_;
|
my ($otmpl, $rtmpl, $prefix, $dirsep, $depchar, $splitchar) = @_;
|
||||||
my ($i, $x, $y);
|
my ($i, $x, $y);
|
||||||
my @deps, @ret;
|
my @deps;
|
||||||
|
my @ret;
|
||||||
@ret = ();
|
@ret = ();
|
||||||
$depchar ||= ':';
|
$depchar ||= ':';
|
||||||
foreach $ii (sort keys %depends) {
|
foreach $ii (sort keys %depends) {
|
||||||
|
Reference in New Issue
Block a user