2023-01-11 07:51:40 +00:00
|
|
|
{ lib
|
2023-04-29 16:46:19 +00:00
|
|
|
, testers
|
2023-01-11 07:51:40 +00:00
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, openssl
|
|
|
|
, libsamplerate
|
2023-02-16 17:41:37 +00:00
|
|
|
, swig
|
2023-01-11 07:51:40 +00:00
|
|
|
, alsa-lib
|
|
|
|
, AppKit
|
2023-03-24 00:07:29 +00:00
|
|
|
, CoreFoundation
|
|
|
|
, Security
|
2023-02-16 17:41:37 +00:00
|
|
|
, python3
|
|
|
|
, pythonSupport ? true
|
2023-03-24 00:07:29 +00:00
|
|
|
, runCommand
|
2023-01-11 07:51:40 +00:00
|
|
|
}:
|
2023-04-29 16:46:19 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "pjsip";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "2.14.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2023-04-29 16:46:19 +00:00
|
|
|
owner = finalAttrs.pname;
|
2020-04-24 23:36:52 +00:00
|
|
|
repo = "pjproject";
|
2023-08-04 22:07:22 +00:00
|
|
|
rev = "refs/tags/${finalAttrs.version}";
|
2024-04-21 15:54:59 +00:00
|
|
|
hash = "sha256-LDA3o1QMrAxcGuOi/YRoMzXmw/wFkfDs2wweZuIJ2RY=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-05-03 17:38:23 +00:00
|
|
|
patches = [
|
|
|
|
./fix-aarch64.patch
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
nativeBuildInputs =
|
|
|
|
lib.optionals pythonSupport [ swig python3 ];
|
|
|
|
|
2020-05-03 17:38:23 +00:00
|
|
|
buildInputs = [ openssl libsamplerate ]
|
2021-06-28 23:13:55 +00:00
|
|
|
++ lib.optional stdenv.isLinux alsa-lib
|
2023-03-24 00:07:29 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ AppKit CoreFoundation Security ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
env = lib.optionalAttrs stdenv.cc.isClang {
|
2024-01-02 11:29:13 +00:00
|
|
|
CXXFLAGS = "-std=c++11";
|
|
|
|
} // lib.optionalAttrs stdenv.isDarwin {
|
|
|
|
NIX_CFLAGS_LINK = "-headerpad_max_install_names";
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
preConfigure = ''
|
|
|
|
export LD=$CC
|
|
|
|
'';
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
postBuild = lib.optionalString pythonSupport ''
|
|
|
|
make -C pjsip-apps/src/swig/python
|
|
|
|
'';
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
configureFlags = [ "--enable-shared" ];
|
|
|
|
|
2023-02-16 17:41:37 +00:00
|
|
|
outputs = [ "out" ]
|
|
|
|
++ lib.optional pythonSupport "py";
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
cp pjsip-apps/bin/pjsua-* $out/bin/pjsua
|
2023-04-29 16:46:19 +00:00
|
|
|
mkdir -p $out/share/${finalAttrs.pname}-${finalAttrs.version}/samples
|
|
|
|
cp pjsip-apps/bin/samples/*/* $out/share/${finalAttrs.pname}-${finalAttrs.version}/samples
|
2023-02-16 17:41:37 +00:00
|
|
|
'' + lib.optionalString pythonSupport ''
|
|
|
|
(cd pjsip-apps/src/swig/python && \
|
|
|
|
python setup.py install --prefix=$py
|
|
|
|
)
|
2023-03-24 00:07:29 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
# On MacOS relative paths are used to refer to libraries. All libraries use
|
|
|
|
# a relative path like ../lib/*.dylib or ../../lib/*.dylib. We need to
|
|
|
|
# rewrite these to use absolute ones.
|
|
|
|
|
|
|
|
# First, find all libraries (and their symlinks) in our outputs to define
|
|
|
|
# the install_name_tool -change arguments we should pass.
|
|
|
|
readarray -t libraries < <(
|
|
|
|
for outputName in $(getAllOutputNames); do
|
|
|
|
find "''${!outputName}" \( -name '*.dylib*' -o -name '*.so*' \)
|
|
|
|
done
|
|
|
|
)
|
|
|
|
|
|
|
|
# Determine the install_name_tool -change arguments that are going to be
|
|
|
|
# applied to all libraries.
|
|
|
|
change_args=()
|
|
|
|
for lib in "''${libraries[@]}"; do
|
|
|
|
lib_name="$(basename $lib)"
|
|
|
|
change_args+=(-change ../lib/$lib_name $lib)
|
|
|
|
change_args+=(-change ../../lib/$lib_name $lib)
|
|
|
|
done
|
|
|
|
|
|
|
|
# Rewrite id and library refences for all non-symlinked libraries.
|
|
|
|
for lib in "''${libraries[@]}"; do
|
|
|
|
if [ -f "$lib" ]; then
|
|
|
|
install_name_tool -id $lib "''${change_args[@]}" $lib
|
|
|
|
fi
|
|
|
|
done
|
2023-04-29 16:46:19 +00:00
|
|
|
|
|
|
|
# Rewrite library references for all executables.
|
|
|
|
find "$out" -executable -type f | while read executable; do
|
|
|
|
install_name_tool "''${change_args[@]}" "$executable"
|
|
|
|
done
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# We need the libgcc_s.so.1 loadable (for pthread_cancel to work)
|
|
|
|
dontPatchELF = true;
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
passthru.tests.version = testers.testVersion {
|
|
|
|
package = finalAttrs.finalPackage;
|
|
|
|
command = "pjsua --version";
|
|
|
|
};
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
passthru.tests.pkg-config = testers.hasPkgConfigModules {
|
2023-04-29 16:46:19 +00:00
|
|
|
package = finalAttrs.finalPackage;
|
|
|
|
};
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
passthru.tests.python-pjsua2 = runCommand "python-pjsua2" { } ''
|
|
|
|
${(python3.withPackages (pkgs: [ pkgs.pjsua2 ])).interpreter} -c "import pjsua2" > $out
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A multimedia communication library written in C, implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE";
|
|
|
|
homepage = "https://pjsip.org/";
|
2020-05-03 17:38:23 +00:00
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
maintainers = with maintainers; [ olynch ];
|
2022-04-27 09:35:20 +00:00
|
|
|
mainProgram = "pjsua";
|
2020-05-03 17:38:23 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
2023-08-10 07:59:29 +00:00
|
|
|
pkgConfigModules = [
|
|
|
|
"libpjproject"
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2023-04-29 16:46:19 +00:00
|
|
|
})
|