Pretty-print type variables that are operators correctly
[ghc-hetmet.git] / boot
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use Cwd;
6
7 my %required_tag;
8 my $validate;
9
10 $required_tag{"-"} = 1;
11 $validate = 0;
12
13 while ($#ARGV ne -1) {
14     my $arg = shift @ARGV;
15
16     if ($arg =~ /^--required-tag=(.*)/) {
17         $required_tag{$1} = 1;
18     }
19     elsif ($arg =~ /^--validate$/) {
20         $validate = 1;
21     }
22     else {
23         die "Bad arg: $arg";
24     }
25 }
26
27 {
28     local $/ = undef;
29     open FILE, "packages" or die "Couldn't open file: $!";
30     binmode FILE;
31     my $string = <FILE>;
32     close FILE;
33
34     if ($string =~ /\r/) {
35         print STDERR <<EOF;
36 Found ^M in packages.
37 Perhaps you need to run
38     git config --global core.autocrlf false
39 and re-check out the tree?
40 EOF
41         exit 1;
42     }
43 }
44
45 # Create libraries/*/{ghc.mk,GNUmakefile}
46 system("/usr/bin/perl", "-w", "boot-pkgs") == 0
47     or die "Running boot-pkgs failed: $?";
48
49 my $tag;
50 my $dir;
51 my $curdir;
52
53 $curdir = &cwd()
54     or die "Can't find current directory: $!";
55
56 # Check that we have all boot packages.
57 open PACKAGES, "< packages";
58 while (<PACKAGES>) {
59     if (/^#/) {
60         # Comment; do nothing
61     }
62     elsif (/^([a-zA-Z0-9\/.-]+) +([^ ]+) +[^ ]+ +[^ ]+ +[^ ]+$/) {
63         $dir = $1;
64         $tag = $2;
65         
66         # If $tag is not "-" then it is an optional repository, so its
67         # absence isn't an error.
68         if (defined($required_tag{$tag})) {
69             # We would like to just check for a .git directory here,
70             # but in an lndir tree we avoid making .git directories,
71             # so it doesn't exist. We therefore require that every repo
72             # has a LICENSE file instead.
73             if (! -f "$dir/LICENSE") {
74                 print STDERR "Error: $dir/LICENSE doesn't exist.\n";
75                 die "Maybe you haven't done './sync-all get'?";
76             }
77         }
78     }
79     else {
80         die "Bad line in packages file: $_";
81     }
82 }
83 close PACKAGES;
84
85 # autoreconf everything that needs it.
86 foreach $dir (".", glob("libraries/*/")) {
87     if (-f "$dir/configure.ac") {
88         print "Booting $dir\n";
89         chdir $dir or die "can't change to $dir: $!";
90         system("autoreconf") == 0
91             or die "Running autoreconf failed with exitcode $?";
92         chdir $curdir or die "can't change to $curdir: $!";
93     }
94 }
95
96 if ($validate eq 0 && ! -f "mk/build.mk") {
97     print <<EOF;
98
99 WARNING: You don't have a mk/build.mk file.
100
101 By default a standard GHC build will be done, which uses optimisation
102 and builds the profiling libraries. This will take a long time, so may
103 not be what you want if you are developing GHC or the libraries, rather
104 than simply building it to use it.
105
106 For information on creating a mk/build.mk file, please see:
107     http://hackage.haskell.org/trac/ghc/wiki/Building/Using#Buildconfiguration
108
109 EOF
110 }
111