Debian Codegraph @

lib/mlrisc-lib/MLRISC/cm/makeallcm

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