1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#!/usr/bin/perl
## usage: makeallcm
##
## This script looks at ALL.cm and create all the CM files.
##
$SPECIAL_CM{"smlnj-lib.cm"} = 1;
$SPECIAL_CM{"ml-yacc-lib.cm"} = 1;
makeallcm("ALL.cm");
sub makeallcm
{ my($cmfile) = @_;
$new = 1;
open(MLRISC,$cmfile) || die ("$!: $cmfile\n");
while (<MLRISC>)
{ push @FOOTER, $_;
next if $_ =~ /\(\*.*\*\)/;
next if $_ =~ /^\s*$/;
($comment=1, next) if $_ =~ /^\s*\(\*.*/;
($comment=0, next) if $_ =~ /^.*\*\)/;
next if $comment;
if (/^(.*):$/)
{ finish();
$outfile = $1;
open(OUT,">$outfile") || die("$!: $outfile\n");
print STDERR "[$outfile]";
print OUT <<"END";
(* This file is created by makeallcm *)
Library
is
END
next;
}
if (/^\s*(.*\.cm)\s*$/)
{ push @CMFILES, $1;
next;
}
if ($new) { dumpCMfiles(); }
print OUT $_;
}
finish();
}
sub finish
{ close(OUT);
@CMFILES=();
$new = 1;
if ($outfile)
{ system("perl makecm $outfile");
}
}
sub dumpCMfiles()
{ print OUT <<"END";
#if defined(NEW_CM)
#if SMLNJ_VERSION * 100 + SMLNJ_MINOR_VERSION >= 11030
\$/basis.cm
END
foreach $f (@CMFILES) { print OUT "\t\$/$f\n"; }
print OUT "#else\n";
print OUT "\tbasis.cm\n";
foreach $f (@CMFILES) { print OUT "\t$f\n"; }
print OUT "#endif\n#else\n";
foreach $f (@CMFILES) { print OUT "\t$f\n"; }
print OUT "#endif\n";
@CMFILES=();
$new = 0;
}
|