-#!/usr/bin/perl -w
+#!/usr/bin/env perl
+use warnings;
use strict;
use Cwd;
my $validate;
my $curdir;
+# See Trac #11530
+$ENV{GREP_OPTIONS} = '';
+
$required_tag{"-"} = 1;
$validate = 0;
my $tag;
my $dir;
+ if (-d ".git" &&
+ system("git config remote.origin.url | grep github.com > /dev/null") == 0 &&
+ system("git config --get-regexp '^url.*github.com/.*/packages-.insteadOf' > /dev/null") != 0) {
+ # If we cloned from github, make sure the url rewrites are set.
+ # Otherwise 'git submodule update --init' prints confusing errors.
+ die <<EOF;
+It seems you cloned this repository from GitHub. But your git config files
+don't contain the url rewrites that are needed to make this work (GitHub
+doesn't support '/' in repository names, so we use a different naming scheme
+for the submodule repositories there).
+
+Please run the following commands first:
+
+ git config --global url."git://github.com/ghc/packages-".insteadOf git://github.com/ghc/packages/
+ git config --global url."http://github.com/ghc/packages-".insteadOf http://github.com/ghc/packages/
+ git config --global url."https://github.com/ghc/packages-".insteadOf https://github.com/ghc/packages/
+ git config --global url."ssh://git\@github.com/ghc/packages-".insteadOf ssh://git\@github.com/ghc/packages/
+ git config --global url."git\@github.com:/ghc/packages-".insteadOf git\@github.com:/ghc/packages/
+
+And then:
+
+ git submodule update --init
+ ./boot
+
+Or start over, and clone the GHC repository from the haskell server:
+
+ git clone --recursive git://git.haskell.org/ghc.git
+
+For more information, see:
+ * https://ghc.haskell.org/trac/ghc/wiki/Newcomers or
+ * https://ghc.haskell.org/trac/ghc/wiki/Building/GettingTheSources#CloningfromGitHub
+EOF
+ }
+
# Check that we have all boot packages.
open PACKAGES, "< packages";
while (<PACKAGES>) {
# has a LICENSE file instead.
if (! -f "$dir/LICENSE") {
print STDERR "Error: $dir/LICENSE doesn't exist.\n";
- die "Maybe you haven't done './sync-all get'?";
+ die "Maybe you haven't done 'git submodule update --init'?";
}
}
}
# Create libraries/*/{ghc.mk,GNUmakefile}
sub boot_pkgs {
my @library_dirs = ();
- my @tarballs = glob("libraries/tarballs/*");
- my $tarball;
my $package;
- my $stamp;
-
- for $tarball (@tarballs) {
- $package = $tarball;
- $package =~ s#^libraries/tarballs/##;
- $package =~ s/-[0-9.]*(-snapshot)?\.tar\.gz$//;
-
- # Sanity check, so we don't rmtree the wrong thing below
- if (($package eq "") || ($package =~ m#[/.\\]#)) {
- die "Bad package name: $package";
- }
-
- 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))) {
- print "Unpacking $package\n";
- if (-d "libraries/$package") {
- &rmtree("libraries/$package")
- or die "Can't remove libraries/$package: $!";
- }
- mkdir "libraries/$package"
- or die "Can't create libraries/$package: $!";
- system ("sh", "-c", "cd 'libraries/$package' && { cat ../../$tarball | gzip -d | tar xf - ; } && mv */* .") == 0
- or die "Failed to unpack $package";
- open STAMP, "> $stamp"
- or die "Failed to open stamp file: $!";
- close STAMP
- or die "Failed to close stamp file: $!";
- }
- }
- }
for $package (glob "libraries/*/") {
$package =~ s/\/$//;
for $package (@library_dirs) {
my $dir = &basename($package);
- my @cabals = glob("$package/*.cabal");
+ my @cabals = glob("$package/*.cabal.in");
+ if ($#cabals < 0) {
+ @cabals = glob("$package/*.cabal");
+ }
if ($#cabals > 0) {
die "Too many .cabal file in $package\n";
}
if (-f $cabal) {
$pkg = $cabal;
$pkg =~ s#.*/##;
+ $pkg =~ s/\.cabal.in$//;
$pkg =~ s/\.cabal$//;
$top = $package;
$top =~ s#[^/]+#..#g;
or die "Opening $package/ghc.mk failed: $!";
print GHCMK "${package}_PACKAGE = ${pkg}\n";
print GHCMK "${package}_dist-install_GROUP = libraries\n";
- print GHCMK "\$(if \$(filter ${dir},\$(PKGS_THAT_BUILD_WITH_STAGE0)),\$(eval \$(call build-package,${package},dist-boot,0)))\n";
- print GHCMK "\$(eval \$(call build-package,${package},dist-install,\$(if \$(filter ${dir},\$(PKGS_THAT_BUILD_WITH_STAGE2)),2,1)))\n";
+ print GHCMK "\$(if \$(filter ${dir},\$(PACKAGES_STAGE0)),\$(eval \$(call build-package,${package},dist-boot,0)))\n";
+ print GHCMK "\$(if \$(filter ${dir},\$(PACKAGES_STAGE1)),\$(eval \$(call build-package,${package},dist-install,1)))\n";
+ print GHCMK "\$(if \$(filter ${dir},\$(PACKAGES_STAGE2)),\$(eval \$(call build-package,${package},dist-install,2)))\n";
close GHCMK
or die "Closing $package/ghc.mk failed: $!";
# autoreconf everything that needs it.
sub autoreconf {
my $dir;
+ my $fail;
foreach $dir (".", glob("libraries/*/")) {
if (-f "$dir/configure.ac") {
+ next if (my $pid = fork);
+ die "fork failed: $!" if (! defined $pid);
print "Booting $dir\n";
chdir $dir or die "can't change to $dir: $!";
- system("autoreconf") == 0
- or die "Running autoreconf failed with exitcode $?";
- chdir $curdir or die "can't change to $curdir: $!";
+ exec("autoreconf");
+ exit 1;
}
}
+
+ # Wait for all child processes to finish.
+ while (wait() != -1) {
+ $fail = 1 if $?;
+ }
+
+ die "Running autoreconf failed" if $fail;
}
sub checkBuildMk {
than simply building it to use it.
For information on creating a mk/build.mk file, please see:
- http://hackage.haskell.org/trac/ghc/wiki/Building/Using#Buildconfiguration
+ http://ghc.haskell.org/trac/ghc/wiki/Building/Using#Buildconfiguration
EOF
}