rpcsvc-proto: pull patch to follow RPCGEN_CPP env var and replace fallback cpp

setting RPCGEN_CPP is to fix the build of host != build rpcsvc-proto
because buildPackages.rpcsvc-proto is used

to fix usage in cross-compilation
This commit is contained in:
Artturin 2022-09-12 00:02:17 +03:00
parent 2c286b47f5
commit 9fa0e55f24

View File

@ -1,4 +1,4 @@
{ stdenv, lib, fetchFromGitHub, autoreconfHook, buildPackages }:
{ stdenv, lib, fetchFromGitHub, autoreconfHook, buildPackages, fetchpatch, targetPackages }:
stdenv.mkDerivation rec {
pname = "rpcsvc-proto";
@ -11,12 +11,27 @@ stdenv.mkDerivation rec {
sha256 = "sha256-DXRLEpOanWcxCSTC8OxEw5SWKpgFz7oTPukzfnPrAOk=";
};
patches = [
# https://github.com/thkukuk/rpcsvc-proto/pull/14
(fetchpatch {
name = "follow-RPCGEN_CPP-env-var";
url = "https://github.com/thkukuk/rpcsvc-proto/commit/e772270774ff45172709e39f744cab875a816667.diff";
sha256 = "sha256-KrUD6YwdyxW9S99h4TB21ahnAOgQmQr2tYz++MIbk1Y=";
})
];
outputs = [ "out" "man" ];
depsBuildBuild = [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ autoreconfHook ];
postPatch = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
RPCGEN_CPP = "${stdenv.cc.targetPrefix}cpp";
postPatch = ''
# replace fallback cpp with the target prefixed cpp
substituteInPlace rpcgen/rpc_main.c \
--replace 'CPP = "cpp"' \
'CPP = "${targetPackages.stdenv.cc.targetPrefix}cpp"'
'' + lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
substituteInPlace rpcsvc/Makefile.am \
--replace '$(top_builddir)/rpcgen/rpcgen' '${buildPackages.rpcsvc-proto}/bin/rpcgen'
'';