Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
libgcrypt: Fix cross-compilation
  • Loading branch information
shlevy committed Feb 25, 2018
1 parent f4a0c57 commit 1c1a6df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkgs/development/libraries/libgcrypt/default.nix
@@ -1,4 +1,6 @@
{ stdenv, fetchurl, gettext, libgpgerror, enableCapabilities ? false, libcap }:
{ stdenv, fetchurl, gettext, libgpgerror, enableCapabilities ? false, libcap
, buildPackages
}:

assert enableCapabilities -> stdenv.isLinux;

Expand All @@ -19,10 +21,19 @@ stdenv.mkDerivation rec {
# The build enables -O2 by default for everything else.
hardeningDisable = stdenv.lib.optional stdenv.cc.isClang "fortify";

depsBuildBuild = stdenv.lib.optional stdenv.isCross buildPackages.stdenv.cc;

buildInputs = [ libgpgerror ]
++ stdenv.lib.optional stdenv.isDarwin gettext
++ stdenv.lib.optional enableCapabilities libcap;

preConfigure = if stdenv.isCross then ''
# This is intentional: gpg-error-config is a shell script that will work during the build
mkdir -p "$NIX_BUILD_TOP"/bin
ln -s ${libgpgerror.dev}/bin/gpg-error-config "$NIX_BUILD_TOP/bin"
export PATH="$NIX_BUILD_TOP/bin:$PATH"
'' else null;

# Make sure libraries are correct for .pc and .la files
# Also make sure includes are fixed for callers who don't use libgpgcrypt-config
postFixup = ''
Expand Down
2 changes: 2 additions & 0 deletions pkgs/stdenv/generic/default.nix
Expand Up @@ -135,6 +135,8 @@ let
inherit overrides;

inherit cc;

isCross = targetPlatform != buildPlatform;
}

# Propagate any extra attributes. For instance, we use this to
Expand Down

0 comments on commit 1c1a6df

Please sign in to comment.