diff --git a/pkgs/os-specific/gnu/hurd/default.nix b/pkgs/os-specific/gnu/hurd/default.nix index 609955668e8..b53dd98d9e7 100644 --- a/pkgs/os-specific/gnu/hurd/default.nix +++ b/pkgs/os-specific/gnu/hurd/default.nix @@ -1,14 +1,21 @@ { fetchgit, stdenv, autoconf, automake, libtool, texinfo -, machHeaders, mig, headersOnly ? true }: +, machHeaders, mig, headersOnly ? true +, cross ? null, gccCross ? null, glibcCross ? null +, buildTarget ? "all", installTarget ? "install" }: assert (cross != null) -> (gccCross != null); let - date = "2010-05-12"; - rev = "master@{${date}}"; + date = "2010-05-12"; + rev = "master@{${date}}"; + suffix = if headersOnly + then "-headers" + else (if buildTarget != "all" + then "-minimal" + else ""); in stdenv.mkDerivation ({ - name = "hurd${if headersOnly then "-headers" else ""}-${date}"; + name = "hurd${suffix}-${date}"; src = fetchgit { url = "git://git.sv.gnu.org/hurd/hurd.git"; @@ -16,13 +23,19 @@ stdenv.mkDerivation ({ inherit rev; }; - buildInputs = [ autoconf automake libtool texinfo mig ]; + buildInputs = [ autoconf automake libtool texinfo mig ] + ++ stdenv.lib.optional (gccCross != null) gccCross + ++ stdenv.lib.optional (glibcCross != null) glibcCross; + propagatedBuildInputs = [ machHeaders ]; - configureFlags = "--build=i586-pc-gnu"; + configureFlags = stdenv.lib.optionals headersOnly [ "--build=i586-pc-gnu" ]; preConfigure = "autoreconf -vfi"; + buildPhase = "make ${buildTarget}"; + installPhase = "make ${installTarget}"; + meta = { description = "The GNU Hurd, GNU project's replacement for the Unix kernel"; @@ -46,4 +59,12 @@ stdenv.mkDerivation ({ (if headersOnly then { buildPhase = ":"; installPhase = "make install-headers"; } - else {})) + else (if (cross != null) + then { + crossConfig = cross.config; + + # The `configure' script wants to build executables so tell it where + # to find `crt1.o' et al. + LDFLAGS = "-B${glibcCross}/lib"; + } + else { }))) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0c4b60ceb99..127e6c09d99 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6085,6 +6085,24 @@ let inherit fetchurl stdenv ncurses; }; + hurdCrossIntermediate = forceBuildDrv(import ../os-specific/gnu/hurd { + inherit fetchgit stdenv autoconf libtool texinfo machHeaders + mig glibcCross; + automake = automake111x; + headersOnly = false; + cross = assert crossSystem != null; crossSystem; + + # The "final" GCC needs glibc and the Hurd libraries (libpthread in + # particular) so we first need an intermediate Hurd built with the + # intermediate GCC. + gccCross = gccCrossStageStatic; + + # This intermediate Hurd is only needed to build libpthread, which really + # only needs libihash. + buildTarget = "libihash"; + installTarget = "libihash-install"; + }); + hurdHeaders = import ../os-specific/gnu/hurd { inherit fetchgit stdenv autoconf libtool texinfo machHeaders; mig = migCross;