add support for hetmet_flatten casting variable
[ghc-hetmet.git] / boot-pkgs
index 677ae52..de3008c 100644 (file)
--- a/boot-pkgs
+++ b/boot-pkgs
@@ -25,7 +25,13 @@ for $tarball (@tarballs) {
     if (-d "libraries/$package/_darcs") {
         print "Ignoring libraries/$package as it looks like a darcs checkout\n"
     }
+    elsif (-d "libraries/$package/.git") {
+        print "Ignoring libraries/$package as it looks like a git checkout\n"
+    }
     else {
+        if (! -d "libraries/stamp") {
+            mkdir "libraries/stamp";
+        }
         $stamp = "libraries/stamp/$package";
         if ((! -d "libraries/$package") || (! -f "$stamp")
          || ((-M "libraries/stamp/$package") > (-M $tarball))) {
@@ -54,6 +60,7 @@ for $package (glob "libraries/*/") {
             or die "Failed to open $pkgs: $!";
         while (<PKGS>) {
             chomp;
+            s/\r//g;
             if (/.+/) {
                 push @library_dirs, "$package/$_";
             }
@@ -73,31 +80,22 @@ for $package (@library_dirs) {
     if ($#cabals eq 0) {
         my $cabal = $cabals[0];
         my $pkg;
-        my $stage;
         my $top;
         if (-f $cabal) {
             $pkg = $cabal;
             $pkg =~ s#.*/##;
             $pkg =~ s/\.cabal$//;
-            if (-f "$package/ghc-stage") {
-                open STAGE, "< $package/ghc-stage"
-                    or die "Can't open $package/ghc-stage: $!";
-                $stage = int(<STAGE>);
-                close STAGE
-                    or die "Failed closing $package/ghc-stage: $!";
-            }
-            else {
-                $stage = 1;
-            }
             $top = $package;
             $top =~ s#[^/]+#..#g;
+            $dir = $package;
+            $dir =~ s#^libraries/##g;
 
             print "Creating $package/ghc.mk\n";
             open GHCMK, "> $package/ghc.mk"
                 or die "Opening $package/ghc.mk failed: $!";
             print GHCMK "${package}_PACKAGE = ${pkg}\n";
             print GHCMK "${package}_dist-install_GROUP = libraries\n";
-            print GHCMK "\$(eval \$(call build-package,${package},dist-install,${stage}))\n";
+            print GHCMK "\$(eval \$(call build-package,${package},dist-install,\$(if \$(filter ${dir},\$(STAGE2_PACKAGES)),2,1)))\n";
             close GHCMK
                 or die "Closing $package/ghc.mk failed: $!";