codec2: fix cross compilation (#384418)

This commit is contained in:
h7x4
2025-02-26 15:00:00 +01:00
committed by GitHub
+15 -1
View File
@@ -1,6 +1,7 @@
{
lib,
stdenv,
buildPackages,
fetchFromGitHub,
cmake,
freedvSupport ? false,
@@ -18,12 +19,23 @@ stdenv.mkDerivation rec {
hash = "sha256-69Mp4o3MgV98Fqfai4txv5jQw2WpoPuoWcwHsNAFPQM=";
};
nativeBuildInputs = [ cmake ];
nativeBuildInputs = [
cmake
buildPackages.stdenv.cc # needs to build a C program to run at build time
];
buildInputs = lib.optionals freedvSupport [
lpcnetfreedv
];
# we need to unset these variables from stdenv here and then set their equivalents in the cmake flags
# otherwise it will pass the same compiler to the native and cross phases and crash trying to execute
# host binaries (generate_codebook) on the build system.
preConfigure = ''
unset CC
unset CXX
'';
postInstall = ''
install -Dm0755 src/{c2enc,c2sim,freedv_rx,freedv_tx,cohpsk_*,fdmdv_*,fsk_*,ldpc_*,ofdm_*} -t $out/bin/
'';
@@ -37,6 +49,8 @@ stdenv.mkDerivation rec {
[
# RPATH of binary /nix/store/.../bin/freedv_rx contains a forbidden reference to /build/
"-DCMAKE_SKIP_BUILD_RPATH=ON"
"-DCMAKE_C_COMPILER=${stdenv.cc.targetPrefix}cc"
"-DCMAKE_CXX_COMPILER=${stdenv.cc.targetPrefix}c++"
]
++ lib.optionals freedvSupport [
"-DLPCNET=ON"