@@ -1,4 +1,6 @@
1−{ lib, stdenv, fetchurl, zlib }:
1+{ lib, stdenv, fetchurl, fetchpatch, autoreconfHook, giflib, libjpeg, libpng, libX11, zlib
2+, static ? stdenv.hostPlatform.isStatic
3+, withX ? !stdenv.isDarwin }:
24
35stdenv.mkDerivation {
46 pname = "libAfterImage";
@@ -13,7 +15,56 @@ stdenv.mkDerivation {
1315 sha256 = "0n74rxidwig3yhr6fzxsk7y19n1nq1f296lzrvgj5pfiyi9k48vf";
1416 };
1517
16− buildInputs = [ zlib ];
18+ patches = [
19+ # add back --with-gif option
20+ (fetchpatch {
21+ name = "libafterimage-gif.patch";
22+ url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/media-libs/libafterimage/files/libafterimage-gif.patch?id=4aa4fca00611b0b3a4007870da43cc5fd63f76c4";
23+ sha256 = "16pa94wlqpd7h6mzs4f0qm794yk1xczrwsgf93kdd3g0zbjq3rnr";
24+ })
25+
26+ # fix build with newer giflib
27+ (fetchpatch {
28+ name = "libafterimage-giflib5-v2.patch";
29+ url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/media-libs/libafterimage/files/libafterimage-giflib5-v2.patch?id=4aa4fca00611b0b3a4007870da43cc5fd63f76c4";
30+ sha256 = "0qwydqy9bm73cg5n3vm97aj4jfi70p7fxqmfbi54vi78z593brln";
31+ stripLen = 1;
32+ })
33+
34+ # fix build with newer libpng
35+ (fetchpatch {
36+ name = "libafterimage-libpng15.patch";
37+ url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/media-libs/libafterimage/files/libafterimage-libpng15.patch?id=4aa4fca00611b0b3a4007870da43cc5fd63f76c4";
38+ sha256 = "1qyvf7786hayasfnnilfbri3p99cfz5wjpbli3gdqj2cvk6mpydv";
39+ })
40+
41+ # fix an ldconfig problem
42+ (fetchpatch {
43+ name = "libafterimage-makefile.patch";
44+ url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/media-libs/libafterimage/files/libafterimage-makefile.in.patch?id=4aa4fca00611b0b3a4007870da43cc5fd63f76c4";
45+ sha256 = "1n6fniz6dldms615046yhc4mlg9gb53y4yfia8wfz6szgq5zicj4";
46+ })
47+ ];
48+ patchFlags = [ "-p0" ];
49+
50+ nativeBuildInputs = [ autoreconfHook ];
51+ buildInputs = [ giflib libjpeg libpng zlib ] ++ lib.optional withX libX11;
52+
53+ preConfigure = ''
54+ rm -rf {libjpeg,libpng,libungif,zlib}/
55+ substituteInPlace Makefile.in \
56+ --replace "include .depend" ""
57+ '' + lib.optionalString stdenv.isDarwin ''
58+ substituteInPlace Makefile.in \
59+ --replace "-soname," "-install_name,$out/lib/"
60+ '';
61+
62+ configureFlags = [
63+ "--with-gif"
64+ "--disable-mmx-optimization"
65+ "--${if static then "enable" else "disable"}-staticlibs"
66+ "--${if !static then "enable" else "disable"}-sharedlibs"
67+ ] ++ lib.optional withX "--with-x";
1768
1869 meta = with lib; {
1970 homepage = "http://www.afterstep.org/afterimage/";