1{ lib
2, stdenv
3, fetchurl
4, fetchpatch
5, ncurses
6, alsa-lib
7, CoreServices
8, AudioUnit
9, Cocoa
10}:
11
12stdenv.mkDerivation rec {
13 pname = "speech_tools";
14 version = "2.5.0";
15
16 src = fetchurl {
17 url = "http://www.festvox.org/packed/festival/${lib.versions.majorMinor version}/speech_tools-${version}-release.tar.gz";
18 sha256 = "1k2xh13miyv48gh06rgsq2vj25xwj7z6vwq9ilsn8i7ig3nrgzg4";
19 };
20
21 patches = [
22 # Fix build on Apple Silicon. Remove in the next release.
23 (fetchpatch {
24 url = "https://github.com/festvox/speech_tools/commit/06141f69d21bf507a9becb5405265dc362edb0df.patch";
25 hash = "sha256-tRestCBuRhak+2ccsB6mvDxGm/TIYX4eZ3oppCOEP9s=";
26 })
27 ];
28
29 buildInputs = [
30 ncurses
31 ] ++ lib.optionals stdenv.isLinux [
32 alsa-lib
33 ] ++ lib.optionals stdenv.isDarwin [
34 CoreServices
35 AudioUnit
36 Cocoa
37 ];
38
39 makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" "CXX=${stdenv.cc.targetPrefix}c++" ];
40
41 # Workaround build failure on -fno-common toolchains:
42 # ld: libestools.a(editline.o):(.bss+0x28): multiple definition of
43 # `editline_history_file'; libestools.a(siodeditline.o):(.data.rel.local+0x8): first defined here
44 env.NIX_CFLAGS_COMPILE = "-fcommon";
45
46 preConfigure = ''
47 sed -e s@/usr/bin/@@g -i $( grep -rl '/usr/bin/' . )
48 sed -re 's@/bin/(rm|printf|uname)@\1@g' -i $( grep -rl '/bin/' . )
49
50 # c99 makes isnan valid for float and double
51 substituteInPlace include/EST_math.h \
52 --replace '__isnanf(X)' 'isnan(X)'
53 '';
54
55 installPhase = ''
56 mkdir -p "$out"/{bin,lib}
57 for d in bin lib; do
58 for i in ./$d/*; do
59 test "$(basename "$i")" = "Makefile" ||
60 cp -r "$(readlink -f $i)" "$out/$d"
61 done
62 done
63 '';
64
65 doCheck = true;
66
67 checkTarget = "test";
68
69 meta = with lib; {
70 description = "Text-to-speech engine";
71 maintainers = with maintainers; [ raskin ];
72 platforms = platforms.unix;
73 license = licenses.free;
74 };
75
76 passthru = {
77 updateInfo = {
78 downloadPage = "http://www.festvox.org/packed/festival/";
79 };
80 };
81}