2016-12-16 13:22:02 +00:00
|
|
|
|
{ lib
|
2019-01-02 17:19:25 +00:00
|
|
|
|
, localSystem, crossSystem, config, overlays, crossOverlays ? []
|
2016-11-30 23:51:13 +00:00
|
|
|
|
}:
|
|
|
|
|
|
2018-12-05 03:06:46 +00:00
|
|
|
|
assert crossSystem == localSystem;
|
2004-03-08 16:02:46 +00:00
|
|
|
|
|
2016-12-16 13:22:02 +00:00
|
|
|
|
let
|
2018-07-20 19:36:12 +00:00
|
|
|
|
inherit (localSystem) system;
|
2004-03-08 16:02:46 +00:00
|
|
|
|
|
2012-11-29 13:10:49 +00:00
|
|
|
|
shell =
|
2011-11-21 14:11:04 +00:00
|
|
|
|
if system == "i686-freebsd" || system == "x86_64-freebsd" then "/usr/local/bin/bash"
|
2011-11-18 17:41:21 +00:00
|
|
|
|
else "/bin/bash";
|
2008-06-18 15:09:13 +00:00
|
|
|
|
|
2012-11-29 13:10:49 +00:00
|
|
|
|
path =
|
2011-11-21 14:11:04 +00:00
|
|
|
|
(if system == "i686-solaris" then [ "/usr/gnu" ] else []) ++
|
2009-10-16 10:03:27 +00:00
|
|
|
|
(if system == "i686-netbsd" then [ "/usr/pkg" ] else []) ++
|
2013-02-20 09:20:07 +00:00
|
|
|
|
(if system == "x86_64-solaris" then [ "/opt/local/gnu" ] else []) ++
|
2009-09-30 15:19:25 +00:00
|
|
|
|
["/" "/usr" "/usr/local"];
|
2008-06-18 15:09:13 +00:00
|
|
|
|
|
2012-01-19 15:56:17 +00:00
|
|
|
|
prehookBase = ''
|
2008-06-18 15:09:13 +00:00
|
|
|
|
# Disable purity tests; it's allowed (even needed) to link to
|
|
|
|
|
# libraries outside the Nix store (like the C library).
|
|
|
|
|
export NIX_ENFORCE_PURITY=
|
2016-03-15 16:35:07 +00:00
|
|
|
|
export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
|
2008-06-18 15:09:13 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2012-01-19 15:56:17 +00:00
|
|
|
|
prehookFreeBSD = ''
|
|
|
|
|
${prehookBase}
|
2012-11-29 13:10:49 +00:00
|
|
|
|
|
2010-02-10 11:54:49 +00:00
|
|
|
|
alias make=gmake
|
|
|
|
|
alias tar=gtar
|
|
|
|
|
alias sed=gsed
|
2008-06-18 15:09:13 +00:00
|
|
|
|
export MAKE=gmake
|
|
|
|
|
shopt -s expand_aliases
|
|
|
|
|
'';
|
|
|
|
|
|
2012-01-19 15:56:17 +00:00
|
|
|
|
prehookOpenBSD = ''
|
|
|
|
|
${prehookBase}
|
2012-11-29 13:10:49 +00:00
|
|
|
|
|
2010-02-08 12:41:15 +00:00
|
|
|
|
alias make=gmake
|
|
|
|
|
alias grep=ggrep
|
|
|
|
|
alias mv=gmv
|
|
|
|
|
alias ln=gln
|
|
|
|
|
alias sed=gsed
|
|
|
|
|
alias tar=gtar
|
2012-11-29 13:10:49 +00:00
|
|
|
|
|
2009-09-23 13:30:04 +00:00
|
|
|
|
export MAKE=gmake
|
|
|
|
|
shopt -s expand_aliases
|
|
|
|
|
'';
|
|
|
|
|
|
2012-01-19 15:56:17 +00:00
|
|
|
|
prehookNetBSD = ''
|
|
|
|
|
${prehookBase}
|
2012-11-29 13:10:49 +00:00
|
|
|
|
|
2009-10-16 10:03:27 +00:00
|
|
|
|
alias make=gmake
|
|
|
|
|
alias sed=gsed
|
2009-10-16 10:09:33 +00:00
|
|
|
|
alias tar=gtar
|
2009-10-16 10:03:27 +00:00
|
|
|
|
export MAKE=gmake
|
|
|
|
|
shopt -s expand_aliases
|
|
|
|
|
'';
|
|
|
|
|
|
2015-05-26 13:18:49 +00:00
|
|
|
|
# prevent libtool from failing to find dynamic libraries
|
2012-01-19 15:56:17 +00:00
|
|
|
|
prehookCygwin = ''
|
|
|
|
|
${prehookBase}
|
2012-11-29 13:10:49 +00:00
|
|
|
|
|
2015-05-26 13:18:49 +00:00
|
|
|
|
shopt -s expand_aliases
|
|
|
|
|
export lt_cv_deplibs_check_method=pass_all
|
2008-06-18 15:09:13 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2017-08-15 15:30:45 +00:00
|
|
|
|
extraNativeBuildInputsCygwin = [
|
2015-05-26 13:18:49 +00:00
|
|
|
|
../cygwin/all-buildinputs-as-runtimedep.sh
|
|
|
|
|
../cygwin/wrap-exes-to-find-dlls.sh
|
|
|
|
|
] ++ (if system == "i686-cygwin" then [
|
|
|
|
|
../cygwin/rebase-i686.sh
|
|
|
|
|
] else if system == "x86_64-cygwin" then [
|
|
|
|
|
../cygwin/rebase-x86_64.sh
|
|
|
|
|
] else []);
|
2008-06-18 15:09:13 +00:00
|
|
|
|
|
|
|
|
|
# A function that builds a "native" stdenv (one that uses tools in
|
2012-11-29 13:10:49 +00:00
|
|
|
|
# /usr etc.).
|
2009-02-02 15:03:38 +00:00
|
|
|
|
makeStdenv =
|
2020-08-25 22:54:27 +00:00
|
|
|
|
{ cc, fetchurl, extraPath ? [], overrides ? (self: super: { }), extraNativeBuildInputs ? [] }:
|
2009-02-02 15:03:38 +00:00
|
|
|
|
|
|
|
|
|
import ../generic {
|
2017-07-06 01:47:48 +00:00
|
|
|
|
buildPlatform = localSystem;
|
2017-05-22 01:37:16 +00:00
|
|
|
|
hostPlatform = localSystem;
|
|
|
|
|
targetPlatform = localSystem;
|
|
|
|
|
|
2009-02-02 15:03:38 +00:00
|
|
|
|
preHook =
|
|
|
|
|
if system == "i686-freebsd" then prehookFreeBSD else
|
2011-11-18 17:41:21 +00:00
|
|
|
|
if system == "x86_64-freebsd" then prehookFreeBSD else
|
2009-09-23 13:30:04 +00:00
|
|
|
|
if system == "i686-openbsd" then prehookOpenBSD else
|
2012-11-29 13:10:49 +00:00
|
|
|
|
if system == "i686-netbsd" then prehookNetBSD else
|
2015-05-26 13:18:49 +00:00
|
|
|
|
if system == "i686-cygwin" then prehookCygwin else
|
|
|
|
|
if system == "x86_64-cygwin" then prehookCygwin else
|
2009-02-02 15:03:38 +00:00
|
|
|
|
prehookBase;
|
2008-06-18 15:09:13 +00:00
|
|
|
|
|
2020-08-25 22:54:27 +00:00
|
|
|
|
extraNativeBuildInputs = extraNativeBuildInputs ++
|
|
|
|
|
(if system == "i686-cygwin" then extraNativeBuildInputsCygwin else
|
2017-08-15 15:30:45 +00:00
|
|
|
|
if system == "x86_64-cygwin" then extraNativeBuildInputsCygwin else
|
2020-08-25 22:54:27 +00:00
|
|
|
|
[]);
|
2015-05-26 13:18:49 +00:00
|
|
|
|
|
2009-02-02 15:03:38 +00:00
|
|
|
|
initialPath = extraPath ++ path;
|
2008-06-18 15:09:13 +00:00
|
|
|
|
|
2009-02-02 15:03:38 +00:00
|
|
|
|
fetchurlBoot = fetchurl;
|
2008-06-18 15:09:13 +00:00
|
|
|
|
|
2017-06-02 17:22:06 +00:00
|
|
|
|
inherit shell cc overrides config;
|
2008-06-18 15:09:13 +00:00
|
|
|
|
};
|
|
|
|
|
|
2016-12-16 13:22:02 +00:00
|
|
|
|
in
|
2008-06-18 15:09:13 +00:00
|
|
|
|
|
2016-12-16 13:22:02 +00:00
|
|
|
|
[
|
2012-11-29 13:10:49 +00:00
|
|
|
|
|
2016-12-16 13:22:02 +00:00
|
|
|
|
({}: rec {
|
|
|
|
|
__raw = true;
|
2009-02-02 15:03:38 +00:00
|
|
|
|
|
2016-12-16 13:22:02 +00:00
|
|
|
|
stdenv = makeStdenv {
|
|
|
|
|
cc = null;
|
|
|
|
|
fetchurl = null;
|
|
|
|
|
};
|
2017-09-20 15:07:52 +00:00
|
|
|
|
stdenvNoCC = stdenv;
|
2004-03-29 17:23:01 +00:00
|
|
|
|
|
2018-04-14 12:05:09 +00:00
|
|
|
|
cc = let
|
2016-12-16 13:22:02 +00:00
|
|
|
|
nativePrefix = { # switch
|
2019-08-13 21:52:01 +00:00
|
|
|
|
i686-solaris = "/usr/gnu";
|
|
|
|
|
x86_64-solaris = "/opt/local/gcc47";
|
2016-12-16 13:22:02 +00:00
|
|
|
|
}.${system} or "/usr";
|
2018-04-14 12:05:09 +00:00
|
|
|
|
in
|
|
|
|
|
import ../../build-support/cc-wrapper {
|
|
|
|
|
name = "cc-native";
|
|
|
|
|
nativeTools = true;
|
|
|
|
|
nativeLibc = true;
|
2021-04-21 15:56:55 +00:00
|
|
|
|
inherit lib nativePrefix;
|
2018-04-14 12:05:09 +00:00
|
|
|
|
bintools = import ../../build-support/bintools-wrapper {
|
|
|
|
|
name = "bintools";
|
2021-06-07 05:37:29 +00:00
|
|
|
|
inherit lib stdenvNoCC nativePrefix;
|
2018-04-14 12:05:09 +00:00
|
|
|
|
nativeTools = true;
|
|
|
|
|
nativeLibc = true;
|
|
|
|
|
};
|
2017-09-20 15:07:52 +00:00
|
|
|
|
inherit stdenvNoCC;
|
2016-12-16 13:22:02 +00:00
|
|
|
|
};
|
2012-11-29 13:10:49 +00:00
|
|
|
|
|
2016-12-16 13:22:02 +00:00
|
|
|
|
fetchurl = import ../../build-support/fetchurl {
|
2018-02-17 18:44:43 +00:00
|
|
|
|
inherit lib stdenvNoCC;
|
2016-12-16 13:22:02 +00:00
|
|
|
|
# Curl should be in /usr/bin or so.
|
|
|
|
|
curl = null;
|
|
|
|
|
};
|
2012-11-29 13:10:49 +00:00
|
|
|
|
|
2016-12-16 13:22:02 +00:00
|
|
|
|
})
|
2012-11-29 13:10:49 +00:00
|
|
|
|
|
2008-06-18 15:09:13 +00:00
|
|
|
|
# First build a stdenv based only on tools outside the store.
|
2016-12-16 13:22:02 +00:00
|
|
|
|
(prevStage: {
|
2016-12-24 18:55:11 +00:00
|
|
|
|
inherit config overlays;
|
2016-12-16 13:22:02 +00:00
|
|
|
|
stdenv = makeStdenv {
|
|
|
|
|
inherit (prevStage) cc fetchurl;
|
|
|
|
|
} // { inherit (prevStage) fetchurl; };
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
# Using that, build a stdenv that adds the ‘xz’ command (which most systems
|
|
|
|
|
# don't have, so we mustn't rely on the native environment providing it).
|
|
|
|
|
(prevStage: {
|
2016-12-24 18:55:11 +00:00
|
|
|
|
inherit config overlays;
|
2016-12-16 13:22:02 +00:00
|
|
|
|
stdenv = makeStdenv {
|
|
|
|
|
inherit (prevStage.stdenv) cc fetchurl;
|
|
|
|
|
extraPath = [ prevStage.xz ];
|
|
|
|
|
overrides = self: super: { inherit (prevStage) xz; };
|
2020-08-25 22:54:27 +00:00
|
|
|
|
extraNativeBuildInputs = if localSystem.isLinux then [ prevStage.patchelf ] else [];
|
2016-12-16 13:22:02 +00:00
|
|
|
|
};
|
|
|
|
|
})
|
2009-02-02 15:03:38 +00:00
|
|
|
|
|
2016-12-16 13:22:02 +00:00
|
|
|
|
]
|