Convert boot and boot-pkgs to perl
[ghc-hetmet.git] / boot
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use Cwd;
6
7 # Create libraries/*/{ghc.mk,GNUmakefile}
8 system("/usr/bin/perl", "-w", "boot-pkgs") == 0
9     or die "Running boot-pkgs failed: $?";
10
11 my $dir;
12 my $curdir;
13
14 $curdir = &cwd();
15
16 # Check that we have all boot packages.
17 open PACKAGES, "< packages";
18 while (<PACKAGES>) {
19     if (/^#/) {
20         # Comment; do nothing
21     }
22     elsif (/^([a-zA-Z0-9\/.-]+) *[^ ]+ *[^ ]+$/) {
23         $dir = $1;
24         
25         # We would like to just check for an _darcs directory here, but in
26         # an lndir tree we avoid making _darcs directories, so it doesn't
27         # exist. We therefore require that every repo has a LICENSE file
28         # instead.
29         if (! -f "$dir/LICENSE") {
30             print STDERR "Error: $dir/LICENSE doesn't exist.\n";
31             die "Maybe you haven't done './darcs-all get'?";
32         }
33     }
34     elsif (/^([a-zA-Z0-9\/.-]+) *[^ ]+ *[^ ]+ *[^ ]+$/) {
35         # These are lines which refer to optional repositories, so their
36         # absence isn't an error.
37     }
38     else {
39         die "Bad line in packages file: $_";
40     }
41 }
42 close PACKAGES;
43
44 # autoreconf everything that needs it.
45 foreach $dir (".", glob("libraries/*/")) {
46     if (-f "$dir/configure.ac") {
47         print "Booting $dir\n";
48         chdir $dir;
49         system "autoreconf";
50         chdir $curdir;
51     }
52 }
53
54 # Alas, darcs doesn't handle file permissions, so fix a few of them.
55 for my $file ("boot", "darcs-all", "push-all", "validate") {
56     chmod 0755, $file if -f $file;
57 }