nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 audiofile,
5 libtiff,
6 buildPackages,
7 fetchpatch,
8 autoconf,
9 automake,
10 fftw,
11 libpcap,
12 libsndfile,
13 libtool,
14 libxml2,
15 netpbm,
16 sox,
17 util-linux,
18 which,
19}:
20
21{
22 version,
23 src,
24 patches ? [ ],
25}:
26
27stdenv.mkDerivation (finalAttrs: {
28 pname = "spandsp";
29 inherit version src;
30
31 patches = [
32 # submitted upstream: https://github.com/freeswitch/spandsp/pull/47
33 (fetchpatch {
34 url = "https://github.com/freeswitch/spandsp/commit/1f810894804d3fa61ab3fc2f3feb0599145a3436.patch";
35 hash = "sha256-Cf8aaoriAvchh5cMb75yP2gsZbZaOLha/j5mq3xlkVA=";
36 })
37
38 # https://github.com/freeswitch/spandsp/pull/110
39 ./Check-for-feenableexcept-explicitly.patch
40
41 # https://github.com/freeswitch/spandsp/pull/111
42 ./Fix-tests-pcap_parse-build-on-musl.patch
43 ]
44 ++ patches;
45
46 postPatch = ''
47 patchShebangs autogen.sh
48 ''
49 # pkg-config? What's that?
50 # Actually *check* the value given for --{en,dis}able-tests, not just whether the option was passed
51 + ''
52 substituteInPlace configure.ac \
53 --replace-fail '$xml2_include_dir /usr/include /usr/local/include /usr/include/libxml2 /usr/local/include/libxml2' '$xml2_include_dir ${lib.getDev libxml2}/include ${lib.getDev libxml2}/include/libxml2 /usr/local/include/libxml2' \
54 --replace-fail 'if test -n "$enable_tests" ; then' 'if test "$enable_tests" = "yes" ; then'
55 ''
56 # Don't install generated test data
57 + ''
58 substituteInPlace test-data/{etsi,itu}/fax/Makefile.am \
59 --replace-fail 'nobase_data_DATA' 'noinst_DATA'
60 '';
61
62 outputs = [
63 "out"
64 "dev"
65 ];
66
67 strictDeps = true;
68
69 nativeBuildInputs = [
70 autoconf
71 automake
72 libtool
73 util-linux
74 which
75 ];
76
77 depsBuildBuild = [ buildPackages.stdenv.cc ];
78
79 propagatedBuildInputs = [
80 audiofile
81 libtiff
82 ];
83
84 nativeCheckInputs = [
85 libtiff
86 netpbm
87 sox
88 ];
89
90 checkInputs = [
91 fftw
92 libpcap
93 libsndfile
94 libxml2
95 ];
96
97 preConfigure = ''
98 ./autogen.sh
99 '';
100
101 configureFlags = [
102 (lib.strings.enableFeature finalAttrs.finalPackage.doCheck "tests")
103
104 # This flag is required to prevent linking error in the cross-compilation case.
105 # I think it's fair to assume that realloc(NULL, size) will return a valid memory
106 # block for most libc implementation, so let's just assume that and hope for the best.
107 "ac_cv_func_malloc_0_nonnull=yes"
108 ];
109
110 # Issues with test asset generation under heavy parallelism
111 enableParallelBuilding = false;
112
113 makeFlags = [
114 "CC=${stdenv.cc.targetPrefix}cc"
115 "CC_FOR_BUILD=${buildPackages.stdenv.cc}/bin/cc"
116 ];
117
118 env.NIX_CFLAGS_COMPILE = toString [
119 # Missing const conversion on some calls
120 "-Wno-error=incompatible-pointer-types"
121 ];
122
123 hardeningDisable = lib.optionals (lib.strings.versionOlder finalAttrs.version "3.0.0") [
124 "format"
125 ];
126
127 doCheck =
128 stdenv.buildPlatform.canExecute stdenv.hostPlatform
129 # Compat with i.e. Clang improved by 0446f4e0c72553f3ea9b50c5333ece6ac980e58d, too big to apply
130 && stdenv.cc.isGNU;
131
132 disabledTests = [
133 # Need proprietary recordings that aren't included
134 "ademco_contactid_tests"
135 "dtmf_rx_tests"
136 "g722_tests"
137 "g726_tests"
138 "gsm0610_tests"
139 "modem_connect_tones_tests"
140 "sig_tone_tests"
141 "t42_tests"
142 "t43_tests"
143 "v42bis_tests"
144
145 # Fails to initialise modem.
146 "data_modems_tests"
147
148 # ERROR PTY Fatal error: failed to create /dev/spandsp/0 symbolic link
149 "dummy_modems_tests" # needs extra setup, but eventually runs into the above error
150 "pseudo_terminal_tests"
151
152 # Hangs. Maybe needs setup / some interaction
153 "fax_tests"
154
155 # Needs an input file, unsure what's suitable
156 "playout_tests"
157
158 # Borked in the packaged versions due to missing audio file - copy-pasting mistake
159 # Maybe fixed after 5394b2cae6c482ccb835335b769469977e6802ae, but too big to apply
160 "super_tone_rx_tests"
161
162 # Stuck
163 "t31_pseudo_terminal_tests"
164
165 # Generated signal has more than the expected maximum samples - 441 vs 422
166 "time_scale_tests"
167
168 # Test failed - -16dBm0 of noise, signal is 9056.993164 (11440.279297)
169 "tone_detect_tests"
170
171 # Fails due to result different from reference
172 "v18_tests"
173
174 # Seemingly runs forever, with tons of output
175 "v22bis_tests"
176 ];
177
178 checkPhase = ''
179 runHook preCheck
180
181 pushd tests
182
183 for test in *_tests; do
184 testArgs=()
185 case "$test" in
186 # Skipped tests
187 ${lib.strings.concatStringsSep "|" finalAttrs.disabledTests})
188 echo "Skipping $test"
189 continue
190 ;;
191
192 # Needs list of subtests to run
193 echo_tests)
194 testArgs+=(
195 sanity 2a 2b 2ca 3a 3ba 3bb 3c 4 5 6 7 8 9 10a 10b 10c 11 12 13 14 15
196 )
197 # Fallthough for running the test
198 ;;&
199
200 *)
201 echo "Running $test"
202 if ! ./"$test" "''${testArgs[@]}" >"$test".log 2>&1; then
203 echo "$test failed! Output:"
204 cat "$test".log
205 exit 1
206 fi
207 ;;
208 esac
209 done
210
211 popd
212
213 runHook postCheck
214 '';
215
216 meta = {
217 description = "Portable and modular SIP User-Agent with audio and video support";
218 homepage = "https://github.com/freeswitch/spandsp";
219 platforms = with lib.platforms; unix;
220 maintainers = with lib.maintainers; [ misuzu ];
221 teams = [ lib.teams.ngi ];
222 license = lib.licenses.gpl2;
223 downloadPage = "http://www.soft-switch.org/downloads/spandsp/";
224 };
225})