1 # genmk95.pl - uses miniperl to generate a makefile that command.com will
2 # understand given one that cmd.exe will understand
4 # Author: Benjamin K. Stuhl
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 shell.
10 # This program converts the standard dmake makefile.mk to one using group
11 # recipes. This is done so that lines using && or || (which command.com
12 # doesn't understand) may be split into two lines that will still be run
15 my ($filein, $fileout) = @ARGV;
17 open my $in, $filein or die "Error opening input file: $!\n";
18 open my $out, "> $fileout" or die "Error opening output file: $!\n";
21 # *** Warning: this file is autogenerated from $filein by $0 ***
22 # *** Do not edit this file - edit $filein instead ***
33 if (/^[^#.\t][^#=]*?:(?:[^=]|$)/)
49 seek ($out, -4, 2); # no recipe, so back up and undo grouping
50 # should be -3, but MS has its CR/LF thing...
57 if ((/^\s*$/ || /^[^#.\t][^#=]*?:/) && $inrec)
64 if (/^(.*?)(&&|\|\|)(.*)$/) # two commands separated by && or ||
66 my ($one, $sep, $two) = ($1, $2, $3);
70 chomp ($two .= "\n" . scalar <$in>);
73 s/^\s*// for ($one, $two);
74 print $out "\t$one\n\t$two\n" if ($sep eq "&&");
75 print $out "\t$one\n\tif errorlevel 1 $two\n" if ($sep eq "||");
76 print $out "\tcd \$(_HOME_DIR)\n";
79 # fall through - no need for special handling
82 print $out "]\n" if ($inrec);
84 close $in or warn "Error closing \$in: $!\n";
85 close $out or warn "Error closing \$out: $!\n";