bash: Modernize derivation, hopefully fixing cross compilation

This commit is contained in:
John Ericson 2017-06-01 12:24:16 -04:00 committed by John Ericson
parent ef0b07e94a
commit f75ad79375

View File

@ -1,15 +1,16 @@
{ stdenv, fetchurl, readline70 ? null, interactive ? false, texinfo ? null { stdenv, buildPackages
, binutils ? null, bison , fetchurl, readline70 ? null, texinfo ? null, binutils ? null, bison
, buildPlatform, hostPlatform
, interactive ? false
}: }:
assert interactive -> readline70 != null; assert interactive -> readline70 != null;
assert stdenv.isDarwin -> binutils != null; assert hostPlatform.isDarwin -> binutils != null;
let let
version = "4.4"; version = "4.4";
realName = "bash-${version}"; realName = "bash-${version}";
shortName = "bash44"; shortName = "bash44";
baseConfigureFlags = if interactive then "--with-installed-readline" else "--disable-readline";
sha256 = "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq"; sha256 = "1jyz6snd63xjn6skk7za6psgidsd53k05cr3lksqybi0q6936syq";
upstreamPatches = upstreamPatches =
@ -22,7 +23,7 @@ let
in in
import ./bash-4.4-patches.nix patch; import ./bash-4.4-patches.nix patch;
inherit (stdenv.lib) optional optionalString; inherit (stdenv.lib) optional optionals;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
@ -52,26 +53,25 @@ stdenv.mkDerivation rec {
patchFlags = "-p0"; patchFlags = "-p0";
patches = upstreamPatches patches = upstreamPatches
++ optional stdenv.isCygwin ./cygwin-bash-4.3.33-1.src.patch; ++ optional hostPlatform.isCygwin ./cygwin-bash-4.3.33-1.src.patch;
crossAttrs = { configureFlags = [
configureFlags = baseConfigureFlags + (if interactive then "--with-installed-readline" else "--disable-readline")
" bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing bash_cv_getcwd_malloc=yes" + ] ++ optionals (hostPlatform != buildPlatform) [
optionalString stdenv.isCygwin '' "bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing bash_cv_getcwd_malloc=yes"
--without-libintl-prefix --without-libiconv-prefix ] ++ optionals hostPlatform.isCygwin [
--with-installed-readline "--without-libintl-prefix --without-libiconv-prefix"
bash_cv_dev_stdin=present "--with-installed-readline"
bash_cv_dev_fd=standard "bash_cv_dev_stdin=present"
bash_cv_termcap_lib=libncurses "bash_cv_dev_fd=standard"
''; "bash_cv_termcap_lib=libncurses"
}; ];
configureFlags = baseConfigureFlags;
# Note: Bison is needed because the patches above modify parse.y. # Note: Bison is needed because the patches above modify parse.y.
nativeBuildInputs = [bison] nativeBuildInputs = [bison]
++ optional (texinfo != null) texinfo ++ optional (texinfo != null) texinfo
++ optional stdenv.isDarwin binutils; ++ optional hostPlatform.isDarwin binutils
++ optional (hostPlatform != buildPlatform) buildPackages.stdenv.cc;
buildInputs = optional interactive readline70; buildInputs = optional interactive readline70;