Unverified Commit 1e82ea61 authored by Markus Kowalewski's avatar Markus Kowalewski Committed by GitHub
Browse files

codec2: fix pkg-config file, split outputs (#403036)

parents 369688f0 32f80f80
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
diff --git a/codec2.pc.in b/codec2.pc.in
index ecca704..94fca12 100644
--- a/codec2.pc.in
+++ b/codec2.pc.in
@@ -1,6 +1,5 @@
-prefix=@CMAKE_INSTALL_PREFIX@
-libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@
-includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/codec2
+libdir=@CMAKE_INSTALL_LIBDIR@
+includedir=@CMAKE_INSTALL_INCLUDEDIR@/codec2
 
 Name: codec2
 Description: A speech codec for 2400 bit/s and below
+30 −7
Original line number Diff line number Diff line
{
  lib,
  testers,
  stdenv,
  buildPackages,
  fetchFromGitHub,
@@ -8,17 +9,28 @@
  lpcnetfreedv,
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "codec2";
  version = "1.2.0";

  src = fetchFromGitHub {
    owner = "drowe67";
    repo = "codec2";
    rev = "${version}";
    rev = finalAttrs.version;
    hash = "sha256-69Mp4o3MgV98Fqfai4txv5jQw2WpoPuoWcwHsNAFPQM=";
  };

  patches = [
    # Fix nix-store path dupliucations
    ./fix-pkg-config.patch
  ];

  outputs = [
    "out"
    "lib"
    "dev"
  ];

  nativeBuildInputs = [
    cmake
    buildPackages.stdenv.cc # needs to build a C program to run at build time
@@ -40,9 +52,17 @@ stdenv.mkDerivation rec {
    install -Dm0755 src/{c2enc,c2sim,freedv_rx,freedv_tx,cohpsk_*,fdmdv_*,fsk_*,ldpc_*,ofdm_*} -t $out/bin/
  '';

  postFixup =
    # Swap keyword order to satisfy SWIG parser
  postFixup = ''
    sed -r -i 's/(\<_Complex)(\s+)(float|double)/\3\2\1/' $out/include/$pname/freedv_api.h
    ''
      sed -r -i 's/(\<_Complex)(\s+)(float|double)/\3\2\1/' $dev/include/$pname/freedv_api.h
    ''
    +
      # generated cmake module is not compatible with multiple outputs
      ''
        substituteInPlace $dev/lib/cmake/codec2/codec2-config.cmake --replace-fail \
          '"''${_IMPORT_PREFIX}/include/codec2' \
          "\"$dev/include/codec2"
      '';

  cmakeFlags =
@@ -56,6 +76,8 @@ stdenv.mkDerivation rec {
      "-DLPCNET=ON"
    ];

  passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;

  meta = with lib; {
    description = "Speech codec designed for communications quality speech at low data rates";
    homepage = "https://www.rowetel.com/codec2.html";
@@ -64,5 +86,6 @@ stdenv.mkDerivation rec {
    maintainers = with maintainers; [ markuskowa ];
    # generate_codebook only built for host platform
    broken = !stdenv.buildPlatform.canExecute stdenv.hostPlatform;
    pkgConfigModules = [ "codec2" ];
  };
}
})