about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/freeimage
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/freeimage')
-rw-r--r--nixpkgs/pkgs/development/libraries/freeimage/default.nix54
-rw-r--r--nixpkgs/pkgs/development/libraries/freeimage/dylib.patch16
2 files changed, 70 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/freeimage/default.nix b/nixpkgs/pkgs/development/libraries/freeimage/default.nix
new file mode 100644
index 000000000000..188543bf7bf7
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/freeimage/default.nix
@@ -0,0 +1,54 @@
+{ lib, stdenv, fetchurl, unzip, darwin }:
+
+stdenv.mkDerivation {
+  name = "freeimage-3.18.0";
+
+  src = fetchurl {
+    url = mirror://sourceforge/freeimage/FreeImage3180.zip;
+    sha256 = "1z9qwi9mlq69d5jipr3v2jika2g0kszqdzilggm99nls5xl7j4zl";
+  };
+
+  patches = lib.optional stdenv.isDarwin ./dylib.patch;
+
+  buildInputs = [ unzip ] ++ lib.optional stdenv.isDarwin darwin.cctools;
+
+  prePatch = if stdenv.isDarwin then ''
+    sed -e 's/$(shell xcrun -find clang)/clang/g' \
+        -e 's/$(shell xcrun -find clang++)/clang++/g' \
+        -e "s|PREFIX = /usr/local|PREFIX = $out|" \
+        -e 's|-Wl,-syslibroot $(MACOSX_SYSROOT)||g' \
+        -e 's|-isysroot $(MACOSX_SYSROOT)||g' \
+        -e 's|	install -d -m 755 -o root -g wheel $(INCDIR) $(INSTALLDIR)||' \
+        -e 's| -m 644 -o root -g wheel||g' \
+        -i ./Makefile.osx
+    # Fix LibJXR performance timers
+    sed 's|^SRCS = \(.*\)$|SRCS = \1 Source/LibJXR/image/sys/perfTimerANSI.c|' -i ./Makefile.srcs
+  '' else ''
+    sed -e s@/usr/@$out/@ \
+        -e 's@-o root -g root@@' \
+        -e 's@ldconfig@echo not running ldconfig@' \
+        -i Makefile.gnu Makefile.fip
+  '';
+
+  postBuild = lib.optionalString (!stdenv.isDarwin) ''
+    make -f Makefile.fip
+  '';
+
+  preInstall = ''
+    mkdir -p $out/include $out/lib
+  '';
+
+  postInstall = lib.optionalString (!stdenv.isDarwin) ''
+    make -f Makefile.fip install
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "Open Source library for accessing popular graphics image file formats";
+    homepage = http://freeimage.sourceforge.net/;
+    license = "GPL";
+    maintainers = with lib.maintainers; [viric];
+    platforms = with lib.platforms; unix;
+  };
+}
diff --git a/nixpkgs/pkgs/development/libraries/freeimage/dylib.patch b/nixpkgs/pkgs/development/libraries/freeimage/dylib.patch
new file mode 100644
index 000000000000..0d8188aca707
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/freeimage/dylib.patch
@@ -0,0 +1,16 @@
+--- a/Makefile.osx
++++ b/Makefile.osx
+@@ -60,1 +60,1 @@
+-FreeImage: $(STATICLIB)
++FreeImage: $(STATICLIB) $(SHAREDLIB)
+@@ -87,7 +87,7 @@
+-$(SHAREDLIB): $(SHAREDLIB)-i386 $(SHAREDLIB)-x86_64
+-	$(LIPO) -create $(SHAREDLIB)-i386 $(SHAREDLIB)-x86_64 -output $(SHAREDLIB)
++#$(SHAREDLIB): $(SHAREDLIB)-i386 $(SHAREDLIB)-x86_64
++#	$(LIPO) -create $(SHAREDLIB)-i386 $(SHAREDLIB)-x86_64 -output $(SHAREDLIB)
+ 
+ $(SHAREDLIB)-i386: $(MODULES_I386)
+ 	$(CPP_I386) -arch i386 -dynamiclib $(LIBRARIES_I386) -o $@ $(MODULES_I386)
+ 
+-$(SHAREDLIB)-x86_64: $(MODULES_X86_64)
++$(SHAREDLIB): $(MODULES_X86_64)