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