about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/giflib/default.nix
blob: a73d12061250ed1e9a4100a2f1f7173e97080f36 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{ stdenv
, lib
, fetchurl
, fetchpatch
, fixDarwinDylibNames
, pkgsStatic
, imagemagick_light
}:

stdenv.mkDerivation rec {
  pname = "giflib";
  version = "5.2.2";

  src = fetchurl {
    url = "mirror://sourceforge/giflib/giflib-${version}.tar.gz";
    hash = "sha256-vn/70FfK3r4qoURUL9kMaDjGoIO16KkEi47jtmsp1fs=";
  };

  patches = [
    ./CVE-2021-40633.patch
  ] ++ lib.optionals stdenv.hostPlatform.isMinGW [
    # Build dll libraries.
    (fetchurl {
      url = "https://aur.archlinux.org/cgit/aur.git/plain/001-mingw-build.patch?h=mingw-w64-giflib&id=4cf1e519bcf51338dc607d23388fca47d71790c0";
      sha256 = "KyJi3eqH/Ae+guEK6znraZI5+IPImaoYoW5NTkCvjsg=";
    })

    # Install executables.
    ./mingw-install-exes.patch
  ];

  nativeBuildInputs = [
    imagemagick_light
  ] ++ lib.optionals stdenv.isDarwin [
    fixDarwinDylibNames
  ];

  makeFlags = [
    "PREFIX=${builtins.placeholder "out"}"
  ];

  postPatch = lib.optionalString stdenv.hostPlatform.isStatic ''
    # Upstream build system does not support NOT building shared libraries.
    sed -i '/all:/ s/$(LIBGIFSO)//' Makefile
    sed -i '/all:/ s/$(LIBUTILSO)//' Makefile
    sed -i '/-m 755 $(LIBGIFSO)/ d' Makefile
    sed -i '/ln -sf $(LIBGIFSOVER)/ d' Makefile
    sed -i '/ln -sf $(LIBGIFSOMAJOR)/ d' Makefile
  '';

  passthru.tests = {
    static = pkgsStatic.giflib;
  };

  meta = {
    description = "A library for reading and writing gif images";
    homepage = "https://giflib.sourceforge.net/";
    platforms = lib.platforms.unix ++ lib.platforms.windows;
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ ];
    branch = "5.2";
  };
}