Add noalias and nocapture attributes to pointer stg registers
[ghc.git] / boot-pkgs
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 use File::Path 'rmtree';
6 use File::Basename;
7
8 my @library_dirs = ();
9 my @tarballs = glob("libraries/tarballs/*");
10
11 my $tarball;
12 my $package;
13 my $stamp;
14
15 for $tarball (@tarballs) {
16     $package = $tarball;
17     $package =~ s#^libraries/tarballs/##;
18     $package =~ s/-[0-9.]*(-snapshot)?\.tar\.gz$//;
19
20     # Sanity check, so we don't rmtree the wrong thing below
21     if (($package eq "") || ($package =~ m#[/.\\]#)) {
22         die "Bad package name: $package";
23     }
24
25     if (-d "libraries/$package/_darcs") {
26         print "Ignoring libraries/$package as it looks like a darcs checkout\n"
27     }
28     else {
29         $stamp = "libraries/stamp/$package";
30         if ((! -d "libraries/$package") || (! -f "$stamp")
31          || ((-M "libraries/stamp/$package") > (-M $tarball))) {
32             print "Unpacking $package\n";
33             if (-d "libraries/$package") {
34                 &rmtree("libraries/$package")
35                     or die "Can't remove libraries/$package: $!";
36             }
37             mkdir "libraries/$package";
38             system ("sh", "-c", "cd 'libraries/$package' && { cat ../../$tarball | gzip -d | tar xf - ; } && mv */* .") == 0
39                 or die "Failed to unpack $package";
40             open STAMP, "> $stamp";
41             close STAMP;
42         }
43     }
44 }
45
46 for $package (glob "libraries/*/") {
47     $package =~ s/\/$//;
48     my $pkgs = "$package/ghc-packages";
49     if (-f $pkgs) {
50         open PKGS, "< $pkgs";
51         while (<PKGS>) {
52             chomp;
53             if (/.+/) {
54                 push @library_dirs, "$package/$_";
55             }
56         }
57     }
58     else {
59         push @library_dirs, $package;
60     }
61 }
62
63 for $package (@library_dirs) {
64     my $dir = &basename($package);
65     my @cabals = glob("$package/*.cabal");
66     if ($#cabals > 0) {
67         die "Too many .cabal file in $package\n";
68     }
69     if ($#cabals eq 0) {
70         my $cabal = $cabals[0];
71         my $pkg;
72         my $stage;
73         my $top;
74         if (-f $cabal) {
75             $pkg = $cabal;
76             $pkg =~ s#.*/##;
77             $pkg =~ s/\.cabal$//;
78             if (-f "$package/ghc-stage") {
79                 open STAGE, "< $package/ghc-stage";
80                 $stage = int(<STAGE>);
81                 close STAGE;
82             }
83             else {
84                 $stage = 1;
85             }
86             $top = $package;
87             $top =~ s#[^/]+#..#g;
88
89             print "Creating $package/ghc.mk\n";
90             open GHCMK, "> $package/ghc.mk";
91             print GHCMK "${package}_PACKAGE = ${pkg}\n";
92             print GHCMK "${package}_dist-install_GROUP = libraries\n";
93             print GHCMK "\$(eval \$(call build-package,${package},dist-install,${stage}))\n";
94             close GHCMK;
95
96             print "Creating $package/GNUmakefile\n";
97             open GNUMAKEFILE, "> $package/GNUmakefile";
98             print GNUMAKEFILE "dir = ${package}\n";
99             print GNUMAKEFILE "TOP = ${top}\n";
100             print GNUMAKEFILE "include \$(TOP)/mk/sub-makefile.mk\n";
101             close GNUMAKEFILE;
102         }
103     }
104 }
105