Make the boot script complain if mk/build.mk doesn't exist
[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 # Create libraries/*/{ghc.mk,GNUmakefile}
28 system("/usr/bin/perl", "-w", "boot-pkgs") == 0
29     or die "Running boot-pkgs failed: $?";
30
31 my $tag;
32 my $dir;
33 my $curdir;
34
35 $curdir = &cwd()
36     or die "Can't find current directory: $!";
37
38 # Check that we have all boot packages.
39 open PACKAGES, "< packages";
40 while (<PACKAGES>) {
41     if (/^#/) {
42         # Comment; do nothing
43     }
44     elsif (/^([a-zA-Z0-9\/.-]+) +([^ ]+) +[^ ]+ +[^ ]+ +[^ ]+$/) {
45         $dir = $1;
46         $tag = $2;
47         
48         # If $tag is not "-" then it is an optional repository, so its
49         # absence isn't an error.
50         if (defined($required_tag{$tag})) {
51             # We would like to just check for a .git directory here,
52             # but in an lndir tree we avoid making .git directories,
53             # so it doesn't exist. We therefore require that every repo
54             # has a LICENSE file instead.
55             if (! -f "$dir/LICENSE") {
56                 print STDERR "Error: $dir/LICENSE doesn't exist.\n";
57                 die "Maybe you haven't done './sync-all get'?";
58             }
59         }
60     }
61     else {
62         die "Bad line in packages file: $_";
63     }
64 }
65 close PACKAGES;
66
67 # autoreconf everything that needs it.
68 foreach $dir (".", glob("libraries/*/")) {
69     if (-f "$dir/configure.ac") {
70         print "Booting $dir\n";
71         chdir $dir or die "can't change to $dir: $!";
72         system("autoreconf") == 0
73             or die "Running autoreconf failed with exitcode $?";
74         chdir $curdir or die "can't change to $curdir: $!";
75     }
76 }
77
78 if ($validate eq 0 && ! -f "mk/build.mk") {
79     print <<EOF;
80
81 WARNING: You don't have a mk/build.mk file.
82
83 By default a standard GHC build will be done, which uses optimisation
84 and builds the profiling libraries. This will take a long time, so may
85 not be what you want if you are developing GHC or the libraries, rather
86 than simply building it to use it.
87
88 For information on creating a mk/build.mk file, please see:
89     http://hackage.haskell.org/trac/ghc/wiki/Building/Using#Buildconfiguration
90
91 EOF
92 }
93