summary refs log tree commit diff
path: root/pkgs/development/libraries/gsm/default.nix
diff options
context:
space:
mode:
authorcodyopel <codyopel@gmail.com>2015-04-08 21:17:11 -0400
committercodyopel <codyopel@gmail.com>2015-04-08 21:17:11 -0400
commitf7c72d38f68204f283ae216d79442be036d8612d (patch)
treeb7bcac85486b57e9571aff6fa35b5674752a4b50 /pkgs/development/libraries/gsm/default.nix
parent74b2253ef8b7abf4d98eca975969a164a85cc5b1 (diff)
downloadnixpkgs-f7c72d38f68204f283ae216d79442be036d8612d.tar
nixpkgs-f7c72d38f68204f283ae216d79442be036d8612d.tar.gz
nixpkgs-f7c72d38f68204f283ae216d79442be036d8612d.tar.bz2
nixpkgs-f7c72d38f68204f283ae216d79442be036d8612d.tar.lz
nixpkgs-f7c72d38f68204f283ae216d79442be036d8612d.tar.xz
nixpkgs-f7c72d38f68204f283ae216d79442be036d8612d.tar.zst
nixpkgs-f7c72d38f68204f283ae216d79442be036d8612d.zip
libgsm: 1.0.13 -> 1.0.14 & improve cross platform support
Diffstat (limited to 'pkgs/development/libraries/gsm/default.nix')
-rw-r--r--pkgs/development/libraries/gsm/default.nix52
1 files changed, 31 insertions, 21 deletions
diff --git a/pkgs/development/libraries/gsm/default.nix b/pkgs/development/libraries/gsm/default.nix
index 581f8b1b222..706bd769219 100644
--- a/pkgs/development/libraries/gsm/default.nix
+++ b/pkgs/development/libraries/gsm/default.nix
@@ -1,45 +1,55 @@
-{ stdenv, fetchurl }:
+{ stdenv, fetchurl
+, staticSupport ? false # Compile statically (support for packages that look for the static object)
+}:
+
+let
+  inherit (stdenv) isDarwin;
+  inherit (stdenv.lib) optional optionalString;
+in
 
-with stdenv.lib;
 stdenv.mkDerivation rec {
   name = "gsm-${version}";
-  version = "1.0.13";
+  version = "1.0.14";
 
   src = fetchurl {
     url = "http://www.quut.com/gsm/${name}.tar.gz";
-    sha256 = "1bcjl2h60gvr1dc5a963h3vnz9zl6n8qrfa3qmb2x3229lj1iiaj";
+    sha256 = "0b1mx69jq88wva3wk0hi6fcl5a52qhnq2f9p3f3jdh5k61ma252q";
   };
 
   patchPhase = ''
     # Fix include directory
     sed -e 's,$(GSM_INSTALL_ROOT)/inc,$(GSM_INSTALL_ROOT)/include/gsm,' -i Makefile
-
-    makeFlags="$makeFlags INSTALL_ROOT=$out"
-
-    # Build shared library instead of static
-    sed -e 's,-c -O2 -DNeedFunctionPrototypes=1,-c -O2 -fPIC -DNeedFunctionPrototypes=1,' -i Makefile
-    sed -e 's,libgsm.a,libgsm.so,' -i Makefile
-    sed -e 's/$(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)/$(LD) -shared -Wl,-soname,libgsm.so -o $(LIBGSM) $(GSM_OBJECTS) -lc/' -i Makefile
-    sed -e 's,$(RANLIB) $(LIBGSM),,' -i Makefile
-  '';
+  '' + optionalString (!staticSupport) (
+    (if isDarwin then  ''
+      # Build dylib on Darwin
+      sed -e 's,libgsm.a,libgsm.dylib,' -i Makefile
+      sed -e 's,$(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS),$(LD) -o $(LIBGSM) -dynamiclib -install_name $(GSM_INSTALL_ROOT)/$(LIBGSM) $(GSM_OBJECTS) -lc,' -i Makefile
+    '' else ''
+      # Build ELF shared object by default
+      sed -e 's,libgsm.a,libgsm.so,' -i Makefile
+      sed -e 's/$(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)/$(LD) -shared -Wl,-soname,libgsm.so -o $(LIBGSM) $(GSM_OBJECTS) -lc/' -i Makefile
+    '') + ''
+      # Remove line that is unused when building shared libraries
+      sed -e 's,$(RANLIB) $(LIBGSM),,' -i Makefile
+    ''
+  );
 
   makeFlags = [
-    ''SHELL=${stdenv.shell}''
-  ];
+    "SHELL=${stdenv.shell}"
+    "INSTALL_ROOT=$(out)"
+  ] ++ optional (stdenv.cc.cc.isClang or false) "CC=clang";
 
-  preInstall = ''
-    mkdir -p "$out/"{bin,lib,man/man1,man/man3,include/gsm}
-  '';
+  preInstall = "mkdir -p $out/{bin,lib,man/man1,man/man3,include/gsm}";
 
-  NIX_CFLAGS_COMPILE = "-fPIC";
+  NIX_CFLAGS_COMPILE = optional (!staticSupport) "-fPIC";
 
   parallelBuild = false;
 
-  meta = {
+  meta = with stdenv.lib; {
     description = "Lossy speech compression codec";
     homepage    = http://www.quut.com/gsm/;
     license     = licenses.bsd2;
     maintainers = with maintainers; [ codyopel raskin ];
-    platforms   = platforms.all;
+    platforms   = platforms.unix;
   };
 }