File: makeallcm

package info (click to toggle)
mlton 20210117%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,464 kB
  • sloc: ansic: 27,682; sh: 4,455; asm: 3,569; lisp: 2,879; makefile: 2,347; perl: 1,169; python: 191; pascal: 68; javascript: 7
file content (69 lines) | stat: -rwxr-xr-x 1,488 bytes parent folder | download | duplicates (5)
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;
}