diff options
author | Larry Wall <lwall@netlabs.com> | 1994-10-17 23:00:00 +0000 |
---|---|---|
committer | Larry Wall <lwall@netlabs.com> | 1994-10-17 23:00:00 +0000 |
commit | a0d0e21ea6ea90a22318550944fe6cb09ae10cda (patch) | |
tree | faca1018149b736b1142f487e44d1ff2de5cc1fa /vms/mms2make.pl | |
parent | 85e6fe838fb25b257a1b363debf8691c0992ef71 (diff) | |
download | perl-a0d0e21ea6ea90a22318550944fe6cb09ae10cda.tar.gz |
perl 5.000perl-5.000
[editor's note: this commit combines approximate 4 months of furious
releases of Andy Dougherty and Larry Wall - see pod/perlhist.pod for
details. Andy notes that;
Alas neither my "Irwin AccuTrack" nor my DC 600A quarter-inch cartridge
backup tapes from that era seem to be readable anymore. I guess 13 years
exceeds the shelf life for that backup technology :-(.
]
Diffstat (limited to 'vms/mms2make.pl')
-rw-r--r-- | vms/mms2make.pl | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/vms/mms2make.pl b/vms/mms2make.pl new file mode 100644 index 0000000000..54db616c86 --- /dev/null +++ b/vms/mms2make.pl @@ -0,0 +1,102 @@ +#!/usr/bin/perl +# +# mms2make.pl - convert Descrip.MMS file to Makefile +# Version 2.0 29-Sep-1994 +# David Denholm <denholm@conmat.phys.soton.ac.uk> +# +# 1.0 06-Aug-1994 Charles Bailey bailey@genetics.upenn.edu +# - original version +# 2.0 29-Sep-1994 David Denholm <denholm@conmat.phys.soton.ac.uk> +# - take action based on MMS .if / .else / .endif +# any command line options after filenames are set in an assoc array %macros +# maintain "@condition as a stack of current conditions +# we unshift a 0 or 1 to front of @conditions at an .ifdef +# we invert top of stack at a .else +# we pop at a .endif +# we deselect any other line if $conditions[0] is 0 +# I'm being very lazy - push a 1 at start, then dont need to check for +# an empty @conditions [assume nesting in descrip.mms is correct] + +if ($#ARGV > -1 && $ARGV[0] =~ /^[\-\/]trim/i) { + $do_trim = 1; + shift @ARGV; +} +$infile = $#ARGV > -1 ? shift(@ARGV) : "Descrip.MMS"; +$outfile = $#ARGV > -1 ? shift(@ARGV) : "Makefile."; + +# set any other args in %macros - set VAXC by default +foreach (@ARGV) { $macros{"\U$_"}=1 } + +# consistency check +$macros{"DECC"} = 1 if $macros{"__AXP__"}; + +# set conditions as if there was a .if 1 around whole file +# [lazy - saves having to check for empty array - just test [0]==1] +@conditions = (1); + +open(INFIL,$infile) || die "Can't open $infile: $!\n"; +open(OUTFIL,">$outfile") || die "Can't open $outfile: $!\n"; + +print OUTFIL "#> This file produced from $infile by $0\n"; +print OUTFIL "#> Lines beginning with \"#>\" were commented out during the\n"; +print OUTFIL "#> conversion process. For more information, see $0\n"; +print OUTFIL "#>\n"; + +while (<INFIL>) { + s/$infile/$outfile/eoi; + if (/^\#/) { + if (!/^\#\:/) {print OUTFIL;} + next; + } + +# look for ".ifdef macro" and push 1 or 0 to head of @conditions +# push 0 if we are in false branch of another if + if (/^\.ifdef\s*(.+)/i) + { + print OUTFIL "#> ",$_ unless $do_trim; + unshift @conditions, ($macros{"\U$1"} ? $conditions[0] : 0); + next; + } + +# reverse $conditions[0] for .else provided surrounding if is active + if (/^\.else/i) + { + print OUTFIL "#> ",$_ unless $do_trim; + $conditions[0] = $conditions[1] && !$conditions[0]; + next; + } + +# pop top condition for .endif + if (/^\.endif/i) + { + print OUTFIL "#> ",$_ unless $do_trim; + shift @conditions; + next; + } + + next if ($do_trim && !$conditions[0]); + +# spot new rule and pick up first source file, since some versions of +# Make don't provide a macro for this + if (/[^#!]*:\s+/) { + if (/:\s+([^\s,]+)/) { $firstsrc = $1 } + else { $firstsrc = "\$<" } + } + + s/^ +/\t/; + s/^\.first/\.first:/i; + s/^\.suffixes/\.suffixes:/i; + s/\@\[\.vms\]/\$\$\@\[\.vms\]/; + s/f\$/f\$\$/goi; + s/\$\(mms\$source\)/$firstsrc/i; + s/\$\(mms\$target\)/\$\@/i; + s/\$\(mms\$target_name\)\$\(O\)/\$\@/i; + s/\$\(mms\$target_name\)/\$\*/i; + s/sys\$([^\(])/sys\$\$$1/gi; + print OUTFIL "#> " unless $conditions[0]; + print OUTFIL $_; +} + +close INFIL; +close OUTFIL; + |