From c3524a8dd6cb3cc03a65a486290b29f97ba469d0 Mon Sep 17 00:00:00 2001 From: Jaka Hudoklin Date: Tue, 1 Apr 2014 01:37:10 +0200 Subject: [PATCH] optipng: use system libpng & zlib, fix cross builds and add support for static builds --- pkgs/development/libraries/libpng/12.nix | 2 ++ pkgs/tools/graphics/optipng/default.nix | 22 +++++++++++++++++++++- pkgs/top-level/all-packages.nix | 4 +++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/libpng/12.nix b/pkgs/development/libraries/libpng/12.nix index b7fad76acaa3..7c9ef3d20b18 100644 --- a/pkgs/development/libraries/libpng/12.nix +++ b/pkgs/development/libraries/libpng/12.nix @@ -21,6 +21,8 @@ stdenv.mkDerivation rec { passthru = {}; }; + configureFlags = "--enable-static"; + meta = { description = "The official reference implementation for the PNG file format"; homepage = http://www.libpng.org/pub/png/libpng.html; diff --git a/pkgs/tools/graphics/optipng/default.nix b/pkgs/tools/graphics/optipng/default.nix index 1b2fc6dbb90c..1984ab7b1de8 100644 --- a/pkgs/tools/graphics/optipng/default.nix +++ b/pkgs/tools/graphics/optipng/default.nix @@ -1,7 +1,9 @@ -{ stdenv, fetchurl }: +{ stdenv, fetchurl, libpng, static ? false }: # This package comes with its own copy of zlib, libpng and pngxtern +with stdenv.lib; + stdenv.mkDerivation rec { name = "optipng-0.7.4"; @@ -10,6 +12,24 @@ stdenv.mkDerivation rec { sha256 = "1zrphbz17rhhfl1l95q5s979rrhifbwczl2xj1fdrnq5jid5s2sj"; }; + buildInputs = [ libpng ]; + + LDFLAGS = optional static "-static"; + configureFlags = "--with-system-zlib --with-system-libpng"; + + crossAttrs = { + CC="${stdenv.cross.config}-gcc"; + LD="${stdenv.cross.config}-gcc"; + AR="${stdenv.cross.config}-ar"; + RANLIB="${stdenv.cross.config}-ranlib"; + configurePhase = '' + ./configure -prefix="$out" --with-system-zlib --with-system-libpng + ''; + postInstall = optional (stdenv.cross.libc == "msvcrt") '' + mv "$out"/bin/optipng "$out"/bin/optipng.exe + ''; + }; + meta = { homepage = http://optipng.sourceforge.net/; description = "A PNG optimizer"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c959f2c6b655..3dad42210bd0 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1596,7 +1596,9 @@ let openvpn = callPackage ../tools/networking/openvpn { }; - optipng = callPackage ../tools/graphics/optipng { }; + optipng = callPackage ../tools/graphics/optipng { + libpng = libpng12; + }; oslrd = callPackage ../tools/networking/oslrd { };