2024-07-09 12:40:54 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
testers,
|
|
|
|
stdenv,
|
|
|
|
fetchFromGitHub,
|
|
|
|
openssl,
|
|
|
|
libsamplerate,
|
|
|
|
swig,
|
|
|
|
alsa-lib,
|
|
|
|
AppKit,
|
|
|
|
CoreFoundation,
|
|
|
|
Security,
|
|
|
|
python3,
|
|
|
|
pythonSupport ? true,
|
|
|
|
runCommand,
|
2023-01-07 15:30:31 +00:00
|
|
|
}:
|
2023-04-03 13:18:27 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "pjsip";
|
2024-03-11 13:48:36 +00:00
|
|
|
version = "2.14.1";
|
2011-01-13 09:23:40 +00:00
|
|
|
|
2020-03-23 16:16:02 +00:00
|
|
|
src = fetchFromGitHub {
|
2024-07-23 16:28:48 +00:00
|
|
|
owner = "pjsip";
|
2020-03-23 16:16:02 +00:00
|
|
|
repo = "pjproject";
|
2023-07-14 09:50:31 +00:00
|
|
|
rev = "refs/tags/${finalAttrs.version}";
|
2024-03-11 13:48:36 +00:00
|
|
|
hash = "sha256-LDA3o1QMrAxcGuOi/YRoMzXmw/wFkfDs2wweZuIJ2RY=";
|
2011-01-13 09:23:40 +00:00
|
|
|
};
|
|
|
|
|
2024-07-09 12:40:54 +00:00
|
|
|
patches = [ ./fix-aarch64.patch ];
|
2019-07-06 03:01:43 +00:00
|
|
|
|
2024-07-09 12:41:13 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace \
|
|
|
|
pjsip-apps/src/py_pjsua/setup.py \
|
|
|
|
pjsip-apps/src/swig/python/setup.py \
|
|
|
|
pjsip-apps/src/python/setup.py \
|
|
|
|
pjsip-apps/src/python/setup-vc.py \
|
|
|
|
--replace-fail "distutils.core" "setuptools"
|
|
|
|
'';
|
|
|
|
|
2024-07-09 12:40:54 +00:00
|
|
|
nativeBuildInputs = lib.optionals pythonSupport [
|
|
|
|
swig
|
|
|
|
python3
|
2024-07-09 12:41:13 +00:00
|
|
|
python3.pkgs.build
|
|
|
|
python3.pkgs.installer
|
|
|
|
python3.pkgs.setuptools
|
|
|
|
python3.pkgs.wheel
|
2024-07-09 12:40:54 +00:00
|
|
|
];
|
2023-02-01 14:38:11 +00:00
|
|
|
|
2024-07-09 12:40:54 +00:00
|
|
|
buildInputs =
|
|
|
|
[
|
|
|
|
openssl
|
|
|
|
libsamplerate
|
|
|
|
]
|
2021-06-10 02:57:09 +00:00
|
|
|
++ lib.optional stdenv.hostPlatform.isLinux alsa-lib
|
2024-07-09 12:40:54 +00:00
|
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [
|
|
|
|
AppKit
|
|
|
|
CoreFoundation
|
|
|
|
Security
|
|
|
|
];
|
2011-01-13 09:23:40 +00:00
|
|
|
|
2024-07-09 12:40:54 +00:00
|
|
|
env =
|
|
|
|
lib.optionalAttrs stdenv.cc.isClang { CXXFLAGS = "-std=c++11"; }
|
2024-09-24 15:51:25 +00:00
|
|
|
// lib.optionalAttrs stdenv.hostPlatform.isDarwin {
|
|
|
|
NIX_CFLAGS_LINK = "-headerpad_max_install_names";
|
|
|
|
};
|
2023-12-03 15:27:28 +00:00
|
|
|
|
2017-12-27 03:10:49 +00:00
|
|
|
preConfigure = ''
|
|
|
|
export LD=$CC
|
|
|
|
'';
|
|
|
|
|
2023-02-01 14:38:11 +00:00
|
|
|
postBuild = lib.optionalString pythonSupport ''
|
|
|
|
make -C pjsip-apps/src/swig/python
|
|
|
|
'';
|
|
|
|
|
2023-03-19 22:41:47 +00:00
|
|
|
configureFlags = [ "--enable-shared" ];
|
|
|
|
|
2024-07-09 12:40:54 +00:00
|
|
|
outputs = [ "out" ] ++ lib.optional pythonSupport "py";
|
|
|
|
|
|
|
|
postInstall =
|
|
|
|
''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
cp pjsip-apps/bin/pjsua-* $out/bin/pjsua
|
|
|
|
mkdir -p $out/share/${finalAttrs.pname}-${finalAttrs.version}/samples
|
|
|
|
cp pjsip-apps/bin/samples/*/* $out/share/${finalAttrs.pname}-${finalAttrs.version}/samples
|
|
|
|
''
|
|
|
|
+ lib.optionalString pythonSupport ''
|
|
|
|
(cd pjsip-apps/src/swig/python && \
|
2024-07-09 12:41:13 +00:00
|
|
|
python -m build --no-isolation --outdir dist/ --wheel
|
|
|
|
python -m installer --prefix $py dist/*.whl
|
2024-07-09 12:40:54 +00:00
|
|
|
)
|
|
|
|
''
|
|
|
|
+ lib.optionalString stdenv.hostPlatform.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)
|
2023-03-19 22:41:47 +00:00
|
|
|
done
|
2024-07-09 12:40:54 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# Rewrite library references for all executables.
|
|
|
|
find "$out" -executable -type f | while read executable; do
|
|
|
|
install_name_tool "''${change_args[@]}" "$executable"
|
|
|
|
done
|
|
|
|
'';
|
2011-01-16 14:58:37 +00:00
|
|
|
|
2011-01-19 21:16:40 +00:00
|
|
|
# We need the libgcc_s.so.1 loadable (for pthread_cancel to work)
|
|
|
|
dontPatchELF = true;
|
|
|
|
|
2023-04-03 13:18:52 +00:00
|
|
|
passthru.tests.version = testers.testVersion {
|
|
|
|
package = finalAttrs.finalPackage;
|
|
|
|
command = "pjsua --version";
|
|
|
|
};
|
|
|
|
|
2024-07-09 12:40:54 +00:00
|
|
|
passthru.tests.pkg-config = testers.hasPkgConfigModules { package = finalAttrs.finalPackage; };
|
2023-04-03 13:18:52 +00:00
|
|
|
|
2023-03-19 22:41:47 +00:00
|
|
|
passthru.tests.python-pjsua2 = runCommand "python-pjsua2" { } ''
|
|
|
|
${(python3.withPackages (pkgs: [ pkgs.pjsua2 ])).interpreter} -c "import pjsua2" > $out
|
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2016-08-29 16:22:34 +00:00
|
|
|
description = "Multimedia communication library written in C, implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE";
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://pjsip.org/";
|
2020-04-08 19:29:11 +00:00
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
maintainers = with maintainers; [ olynch ];
|
2022-04-01 19:34:55 +00:00
|
|
|
mainProgram = "pjsua";
|
2020-04-08 19:29:11 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
2024-07-09 12:40:54 +00:00
|
|
|
pkgConfigModules = [ "libpjproject" ];
|
2011-01-13 09:23:40 +00:00
|
|
|
};
|
2023-04-03 13:18:27 +00:00
|
|
|
})
|