git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #7254 from codyopel/gsm-cross

[WIP][DARWIN] libgsm: 1.0.13 -> 1.0.14 & improve cross platform support

commit42e996308e0ee83024d6c58ddab5aa76ad299cd1 authorWilliam A. Kennington III <william@wkennington.com> dateSat 18 Apr 2015, 23:56 (12 years ago) parentade440ff7c72d3
1 file changed+31−21
pkgs/development/libraries/gsm/default.nix+31−21
pkgs/development/libraries/gsm/default.nix+31−21
@@ -1,45 +1,55 @@
1−{ stdenv, fetchurl }:
1+{ stdenv, fetchurl
2+, staticSupport ? false # Compile statically (support for packages that look for the static object)
3+}:
4+
5+let
6+ inherit (stdenv) isDarwin;
7+ inherit (stdenv.lib) optional optionalString;
8+in
29
3−with stdenv.lib;
410stdenv.mkDerivation rec {
511 name = "gsm-${version}";
6− version = "1.0.13";
12+ version = "1.0.14";
713
814 src = fetchurl {
915 url = "http://www.quut.com/gsm/${name}.tar.gz";
10− sha256 = "1bcjl2h60gvr1dc5a963h3vnz9zl6n8qrfa3qmb2x3229lj1iiaj";
16+ sha256 = "0b1mx69jq88wva3wk0hi6fcl5a52qhnq2f9p3f3jdh5k61ma252q";
1117 };
1218
1319 patchPhase = ''
1420 # Fix include directory
1521 sed -e 's,$(GSM_INSTALL_ROOT)/inc,$(GSM_INSTALL_ROOT)/include/gsm,' -i Makefile
16−
17− makeFlags="$makeFlags INSTALL_ROOT=$out"
18−
19− # Build shared library instead of static
20− sed -e 's,-c -O2 -DNeedFunctionPrototypes=1,-c -O2 -fPIC -DNeedFunctionPrototypes=1,' -i Makefile
21− sed -e 's,libgsm.a,libgsm.so,' -i Makefile
22− sed -e 's/$(AR) $(ARFLAGS) $(LIBGSM) $(GSM_OBJECTS)/$(LD) -shared -Wl,-soname,libgsm.so -o $(LIBGSM) $(GSM_OBJECTS) -lc/' -i Makefile
23− sed -e 's,$(RANLIB) $(LIBGSM),,' -i Makefile
24− '';
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+ );
2536
2637 makeFlags = [
27− ''SHELL=${stdenv.shell}''
28− ];
38+ "SHELL=${stdenv.shell}"
39+ "INSTALL_ROOT=$(out)"
40+ ] ++ optional (stdenv.cc.cc.isClang or false) "CC=clang";
2941
30− preInstall = ''
31− mkdir -p "$out/"{bin,lib,man/man1,man/man3,include/gsm}
32− '';
42+ preInstall = "mkdir -p $out/{bin,lib,man/man1,man/man3,include/gsm}";
3343
34− NIX_CFLAGS_COMPILE = "-fPIC";
44+ NIX_CFLAGS_COMPILE = optional (!staticSupport) "-fPIC";
3545
3646 parallelBuild = false;
3747
38− meta = {
48+ meta = with stdenv.lib; {
3949 description = "Lossy speech compression codec";
4050 homepage = http://www.quut.com/gsm/;
4151 license = licenses.bsd2;
4252 maintainers = with maintainers; [ codyopel raskin ];
43− platforms = platforms.all;
53+ platforms = platforms.unix;
4454 };
4555}