1{ stdenv, fetchurl
2, staticSupport ? false # Compile statically (support for packages that look for the static object)
3}:
4
5let
6 inherit (stdenv) isDarwin;
7 inherit (stdenv.lib) optional optionalString;
8in
9
10stdenv.mkDerivation rec {
11 name = "gsm-${version}";
12 version = "1.0.14";
13
14 src = fetchurl {
15 url = "http://www.quut.com/gsm/${name}.tar.gz";
16 sha256 = "0b1mx69jq88wva3wk0hi6fcl5a52qhnq2f9p3f3jdh5k61ma252q";
17 };
18
19 patchPhase = ''
20 # Fix include directory
21 sed -e 's,$(GSM_INSTALL_ROOT)/inc,$(GSM_INSTALL_ROOT)/include/gsm,' -i Makefile
22 '' + optionalString (!staticSupport) (
23 (if isDarwin then ''
24 # Build dylib on Darwin
25 sed -e 's,libgsm.a,libgsm.dylib,' -i Makefile
26 sed -e 's,$(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS),$(LD) -o $(LIBGSM) -dynamiclib -install_name $(GSM_INSTALL_ROOT)/$(LIBGSM) $(GSM_OBJECTS) -lc,' -i Makefile
27 '' else ''
28 # Build ELF shared object by default
29 sed -e 's,libgsm.a,libgsm.so,' -i Makefile
30 sed -e 's/$(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)/$(LD) -shared -Wl,-soname,libgsm.so -o $(LIBGSM) $(GSM_OBJECTS) -lc/' -i Makefile
31 '') + ''
32 # Remove line that is unused when building shared libraries
33 sed -e 's,$(RANLIB) $(LIBGSM),,' -i Makefile
34 ''
35 );
36
37 makeFlags = [
38 "SHELL=${stdenv.shell}"
39 "INSTALL_ROOT=$(out)"
40 ] ++ optional stdenv.cc.isClang "CC=clang";
41
42 preInstall = "mkdir -p $out/{bin,lib,man/man1,man/man3,include/gsm}";
43
44 NIX_CFLAGS_COMPILE = optional (!staticSupport) "-fPIC";
45
46 parallelBuild = false;
47
48 meta = with stdenv.lib; {
49 description = "Lossy speech compression codec";
50 homepage = http://www.quut.com/gsm/;
51 license = licenses.bsd2;
52 maintainers = with maintainers; [ codyopel raskin ];
53 platforms = platforms.unix;
54 };
55}