Remove unused "squatter" symbols; regen Configure.
[p5sagit/p5-mst-13.2.git] / win32 / genmk95.pl
CommitLineData
8ec44883 1# genmk95.pl - uses miniperl to generate a makefile that command.com
2# (and dmake) will understand given one that cmd.exe will understand
3
4# Author: Benjamin K. Stuhl
5# Date: 8-18-1999
6
7# how it works:
8# dmake supports an alternative form for its recipes, called "group
9# recipes", in which all elements of a recipe are run with only one
10# shell. This program converts the standard dmake makefile.mk to
11# one using group recipes. This is done so that lines using && or
12# || (which command.com doesn't understand) may be split into two
13# lines.
14
15my ($filein, $fileout) = @ARGV;
16
17chomp (my $loc = `cd`);
18
19open my $in, $filein or die "Error opening input file: $!";
20open my $out, "> $fileout" or die "Error opening output file: $!";
21
22print $out <<_EOH_;
23# *** Warning: this file is autogenerated from $filein by $0 ***
24# *** Do not edit this file - edit $filein instead ***
25
26_EOH_
27
28my $inrec = 0;
29
30while (<$in>)
31{
32 chomp;
33 if (/^[^#.\t][^#=]*?:/)
34 {
35 if (! $inrec)
36 {
37 print $out "$_\n";
38 while (/\\$/)
39 {
40 chomp($_ = <$in>);
41 print $out "$_\n";
42 }
43 print $out "@[\n";
44 $inrec = 1;
45 next;
46 }
47 else {
48 seek ($out, -3, 2); # no recipe, so back up and undo grouping
49 print $out "$_\n";
50 $inrec = 0;
51 next;
52 }
53 }
54 if ((/^\s*$/ || /^[^#.\t][^#=]*?:/) && $inrec)
55 {
56 print $out "]\n";
57 print $out "$_\n";
58 $inrec = 0;
59 next;
60 }
61 if (/^(.*?)(&&|\|\|)(.*)$/) # two commands separated by && or ||
62 {
63 my ($one, $sep, $two) = ($1, $2, $3);
64LINE_CONT:
65 if ($two =~ /\\\s*$/)
66 {
67 chomp ($two .= "\n" . scalar <$in>);
68 goto LINE_CONT;
69 }
70 s/^\s*// for ($one, $two);
71 print $out "\t$one\n\t$two\n" if ($sep eq "&&");
72 print $out "\t$one\n\tif errorlevel 1 $two\n" if ($sep eq "||");
73 print $out "\tcd $loc\n";
74 next;
75 }
76 # fall through - no need for special handling
77 print $out "$_\n";
78}
79print $out "]\n" if ($inrec);
80
81close $in; close $out;