X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=win32%2Fgenmk95.pl;h=cf31457ab1047a504a3b3534e6faa2eceb0a39aa;hb=a28509cc00517ad2ad1f6e022f1be6ab8f1ad18e;hp=74788ff3cb10aa739d5c8f7e5157a447d48248a5;hpb=8ec448833410aa8e65370beaffc968d46272417a;p=p5sagit%2Fp5-mst-13.2.git diff --git a/win32/genmk95.pl b/win32/genmk95.pl index 74788ff..cf31457 100644 --- a/win32/genmk95.pl +++ b/win32/genmk95.pl @@ -1,28 +1,28 @@ -# genmk95.pl - uses miniperl to generate a makefile that command.com -# (and dmake) will understand given one that cmd.exe will understand +# genmk95.pl - uses miniperl to generate a makefile that command.com will +# understand given one that cmd.exe will understand # Author: Benjamin K. Stuhl -# Date: 8-18-1999 +# Date: 10-16-1999 # how it works: # dmake supports an alternative form for its recipes, called "group -# recipes", in which all elements of a recipe are run with only one -# shell. This program converts the standard dmake makefile.mk to -# one using group recipes. This is done so that lines using && or -# || (which command.com doesn't understand) may be split into two -# lines. +# recipes", in which all elements of a recipe are run with only one shell. +# This program converts the standard dmake makefile.mk to one using group +# recipes. This is done so that lines using && or || (which command.com +# doesn't understand) may be split into two lines that will still be run +# with one shell. my ($filein, $fileout) = @ARGV; -chomp (my $loc = `cd`); - -open my $in, $filein or die "Error opening input file: $!"; -open my $out, "> $fileout" or die "Error opening output file: $!"; +open my $in, $filein or die "Error opening input file: $!\n"; +open my $out, "> $fileout" or die "Error opening output file: $!\n"; print $out <<_EOH_; # *** Warning: this file is autogenerated from $filein by $0 *** # *** Do not edit this file - edit $filein instead *** +_HOME_DIR := \$(PWD) + _EOH_ my $inrec = 0; @@ -30,12 +30,12 @@ my $inrec = 0; while (<$in>) { chomp; - if (/^[^#.\t][^#=]*?:/) + if (/^[^#.\t][^#=]*?:(?:[^=]|$)/) { if (! $inrec) { print $out "$_\n"; - while (/\\$/) + while (/\\\s*$/) { chomp($_ = <$in>); print $out "$_\n"; @@ -45,9 +45,12 @@ while (<$in>) next; } else { - seek ($out, -3, 2); # no recipe, so back up and undo grouping + if (!/^\t/) { + seek ($out, -4, 2); # no recipe, so back up and undo grouping + # should be -3, but MS has its CR/LF thing... + $inrec = 0; + } print $out "$_\n"; - $inrec = 0; next; } } @@ -61,6 +64,7 @@ while (<$in>) if (/^(.*?)(&&|\|\|)(.*)$/) # two commands separated by && or || { my ($one, $sep, $two) = ($1, $2, $3); + $one =~ s/^\t(?:-(?!-))?\@?(.*?)$/\t$1/; # no -,@ in group recipes LINE_CONT: if ($two =~ /\\\s*$/) { @@ -70,12 +74,14 @@ LINE_CONT: s/^\s*// for ($one, $two); print $out "\t$one\n\t$two\n" if ($sep eq "&&"); print $out "\t$one\n\tif errorlevel 1 $two\n" if ($sep eq "||"); - print $out "\tcd $loc\n"; + print $out "\tcd \$(_HOME_DIR)\n"; next; } # fall through - no need for special handling + s/^\t(?:-(?!-))?\@?(.*?)$/\t$1/; # no -,@ in group recipes print $out "$_\n"; } print $out "]\n" if ($inrec); -close $in; close $out; +close $in or warn "Error closing \$in: $!\n"; +close $out or warn "Error closing \$out: $!\n";