btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / li / live555 / package.nix
blobc558e806db9d3afe6d6c8d2cf2d082fd62b77eea
2   lib,
3   cctools,
4   fetchpatch,
5   fetchurl,
6   openssl,
7   stdenv,
8   vlc,
9 }:
11 stdenv.mkDerivation (finalAttrs: {
12   pname = "live555";
13   version = "2024.09.20";
15   src = fetchurl {
16     urls = [
17       "http://www.live555.com/liveMedia/public/live.${finalAttrs.version}.tar.gz"
18       "https://src.rrz.uni-hamburg.de/files/src/live555/live.${finalAttrs.version}.tar.gz"
19       "https://download.videolan.org/contrib/live555/live.${finalAttrs.version}.tar.gz"
20       "mirror://sourceforge/slackbuildsdirectlinks/live.${finalAttrs.version}.tar.gz"
21     ];
22     hash = "sha256-TrUneCGaJJxC+GgL1ZZ/ZcONeqDH05Bp44/3lkCs9tg=";
23   };
25   patches = [
26     (fetchpatch {
27       name = "0000-cflags-when-darwin.patch";
28       url = "https://github.com/rgaufman/live555/commit/16701af5486bb3a2d25a28edaab07789c8a9ce57.patch?full_index=1";
29       hash = "sha256-IDSdByBu/EBLsUTBe538rWsDwH61RJfAEhvT68Nb9rU=";
30     })
31   ];
33   nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
34     cctools
35   ];
37   buildInputs = [
38     openssl
39   ];
41   makeFlags = [
42     "PREFIX=${placeholder "out"}"
43     "C_COMPILER=$(CC)"
44     "CPLUSPLUS_COMPILER=$(CXX)"
45     "LIBRARY_LINK=$(AR) cr "
46     "LINK=$(CXX) -o "
47   ];
49   # Since NIX_CFLAGS_COMPILE affects both C and C++ toolchains, we set CXXFLAGS
50   # directly
51   env.CXXFLAGS = "-std=c++20";
53   strictDeps = true;
55   enableParallelBuilding = true;
57   # required for whitespaces in makeFlags
58   __structuredAttrs = true;
60   postPatch = ''
61     substituteInPlace config.macosx-catalina \
62       --replace '/usr/lib/libssl.46.dylib' "${lib.getLib openssl}/lib/libssl.dylib" \
63       --replace '/usr/lib/libcrypto.44.dylib' "${lib.getLib openssl}/lib/libcrypto.dylib"
64     sed -i -e 's|/bin/rm|rm|g' genMakefiles
65     sed -i \
66       -e 's/$(INCLUDES) -I. -O2 -DSOCKLEN_T/$(INCLUDES) -I. -O2 -I. -fPIC -DRTSPCLIENT_SYNCHRONOUS_INTERFACE=1 -DSOCKLEN_T/g' \
67       config.linux
68   ''
69   # condition from icu/base.nix
70   + lib.optionalString (lib.elem stdenv.hostPlatform.libc [ "glibc" "musl" ]) ''
71     substituteInPlace liveMedia/include/Locale.hh \
72       --replace '<xlocale.h>' '<locale.h>'
73   '';
75   configurePhase = let
76     platform =
77       if stdenv.hostPlatform.isLinux then
78         "linux"
79       else if stdenv.hostPlatform.isDarwin then
80         "macosx-catalina"
81       else
82         throw "Unsupported platform: ${stdenv.hostPlatform.system}";
83   in ''
84     runHook preConfigure
86     ./genMakefiles ${platform}
88     runHook postConfigure
89   '';
91   passthru.tests = {
92     # Downstream dependency
93     inherit vlc;
94   };
96   meta = {
97     homepage = "http://www.live555.com/liveMedia/";
98     description = "Set of C++ libraries for multimedia streaming, using open standard protocols (RTP/RTCP, RTSP, SIP)";
99     changelog = "http://www.live555.com/liveMedia/public/changelog.txt";
100     license = with lib.licenses; [ lgpl21Plus ];
101     maintainers = with lib.maintainers; [ AndersonTorres ];
102     platforms = lib.platforms.unix;
103   };