gnu: Replace uses of 'libjpeg' with 'libjpeg-turbo'.
[jackhill/guix/guix.git] / gnu / packages / netpbm.scm
CommitLineData
05bf6f82 1;;; GNU Guix --- Functional package management for GNU
7d8379a7 2;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
61dc82d9 3;;; Copyright © 2015, 2016 Ludovic Courtès <ludo@gnu.org>
2a18b572 4;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
05bf6f82
AE
5;;;
6;;; This file is part of GNU Guix.
7;;;
8;;; GNU Guix is free software; you can redistribute it and/or modify it
9;;; under the terms of the GNU General Public License as published by
10;;; the Free Software Foundation; either version 3 of the License, or (at
11;;; your option) any later version.
12;;;
13;;; GNU Guix is distributed in the hope that it will be useful, but
14;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;;; GNU General Public License for more details.
17;;;
18;;; You should have received a copy of the GNU General Public License
19;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21(define-module (gnu packages netpbm)
22 #:use-module (gnu packages)
23 #:use-module (gnu packages compression)
24 #:use-module (gnu packages flex)
25 #:use-module (gnu packages ghostscript)
e55354b8 26 #:use-module (gnu packages image)
05bf6f82
AE
27 #:use-module (gnu packages perl)
28 #:use-module (gnu packages pkg-config)
29 #:use-module (gnu packages python)
30 #:use-module (gnu packages xml)
2492581f 31 #:use-module (gnu packages xorg)
7d8379a7 32 #:use-module (guix build-system gnu)
05bf6f82
AE
33 #:use-module ((guix licenses) #:select (gpl2))
34 #:use-module (guix packages)
7d8379a7 35 #:use-module (guix svn-download))
05bf6f82
AE
36
37(define-public netpbm
38 (package
39 (name "netpbm")
664ac384 40 (version "10.78.3")
05bf6f82 41 (source (origin
7d8379a7
AE
42 (method svn-fetch)
43 ;; At the time of first packaging, the "super-stable" and
44 ;; "stable" versions did not compile with newer libpng;
45 ;; we needed the "advanced" version.
836223f7
AE
46 ;; The currently highest stable version is 10.47.53,
47 ;; the currently highest advanced version is 10.69.4,
48 ;; svn release 2397.
7d8379a7
AE
49 ;; To determine the correct release: "svn log version.mk".
50 (uri (svn-reference
51 (url "http://svn.code.sf.net/p/netpbm/code/advanced")
664ac384 52 (revision 2965)))
7d8379a7
AE
53 (sha256
54 (base32
664ac384 55 "1k7as9qi1942wyjxpvbf02wg0h4braw44m3m3vvi8sm9y5z1m967"))
2a18b572
TGR
56 (patches (search-patches "netpbm-CVE-2017-2586.patch"
57 "netpbm-CVE-2017-2587.patch"))
713e0aa4
LC
58 (file-name (string-append name "-" version "-checkout"))
59 (modules '((guix build utils)))
60 (snippet
713e0aa4 61 '(begin
56501d3b 62 ;; Remove non-FSDG-compliant code.
713e0aa4
LC
63
64 (define-syntax drop
65 (syntax-rules (in)
66 ;; Remove PROGRAM from DIRECTORY/Makefile, and remove
67 ;; DIRECTORY/PROGRAM and DIRECTORY/PROGRAM.c.
68 ((_ program ... in directory)
69 (begin
70 (substitute* (string-append directory "/Makefile")
71 ((program) "") ...)
72
73 (let* ((subdir (string-append directory "/" program))
74 (dot-c (string-append subdir ".c")))
75 (when (file-exists? subdir)
76 (delete-file-recursively subdir))
77 (when (file-exists? dot-c)
78 (delete-file dot-c)))
79
80 ...))))
81
82 ;; Drop advertisement for non-free program.
83 (drop "hpcdtoppm" in "converter/ppm")
84
85 ;; Drop programs without a license, see
86 ;; <http://packages.debian.org/changelogs/pool/main/n/netpbm-free/netpbm-free_10.0-12.2/libnetpbm10.copyright>.
87 (drop "pbmto4425" "pbmtoln03" "pbmtolps" "pbmtopk" "pktopbm"
88 in "converter/pbm")
89 (drop "spottopgm" in "converter/pgm")
56501d3b
LC
90 (drop "ppmtopjxl" in "converter/ppm")
91
92 ;; Remove timestamps from the generated code.
5bc42e1a
DM
93 (substitute* "buildtools/makepointerman"
94 (("gmctime[(][)]")
95 "\"Thu Jan 1 00:00:00 1970\""))
56501d3b
LC
96 (substitute* "buildtools/stamp-date"
97 (("^DATE=.*")
98 "DATE=\"Thu Jan 01 00:00:00+0000 1970\"\n")
99 (("^USER=.*")
6cbee49d
MW
100 "USER=Guix\n"))
101 #t))))
56501d3b 102
05bf6f82 103 (build-system gnu-build-system)
c4c4cc05 104 (inputs `(("ghostscript" ,ghostscript)
4bd428a7 105 ("libjpeg" ,libjpeg-turbo)
05bf6f82
AE
106 ("libpng" ,libpng)
107 ("libtiff" ,libtiff)
108 ("libxml2" ,libxml2)
2492581f 109 ("xorg-rgb" ,xorg-rgb)
05bf6f82 110 ("zlib" ,zlib)))
c4c4cc05
JD
111 (native-inputs
112 `(("flex" ,flex)
113 ("perl" ,perl)
114 ("pkg-config" ,pkg-config)
115 ("python" ,python-wrapper)))
05bf6f82
AE
116 (arguments
117 `(#:phases
1de1c56d
FB
118 (modify-phases %standard-phases
119 (replace 'configure
120 (lambda* (#:key inputs outputs #:allow-other-keys)
121 (copy-file "config.mk.in" "config.mk")
122 (chmod "config.mk" #o664)
123 (let ((f (open-file "config.mk" "a")))
124 (display "CC=gcc\n" f)
125 (display "CFLAGS_SHLIB += -fPIC\n" f)
126 (display "TIFFLIB = libtiff.so\n" f)
127 (display "JPEGLIB = libjpeg.so\n" f)
128 (display "ZLIB = libz.so\n" f)
129 (display (string-append "LDFLAGS += -Wl,-rpath=" %output "/lib") f)
2492581f 130 (close-port f))
61dc82d9 131
2492581f
FB
132 (let ((rgb (string-append (assoc-ref inputs "xorg-rgb")
133 "/share/X11/rgb.txt")))
664ac384
LF
134 (substitute* "config.mk"
135 (("/usr/share/netpbm/rgb.txt") rgb))
61dc82d9
LC
136
137 ;; Our Ghostscript no longer provides the 'gs' command, only
138 ;; 'gsc', so look for that instead.
139 (substitute* "converter/other/pstopnm.c"
140 (("\"%s/gs\"")
344e0f56
LF
141 "\"%s/gsc\"")
142 (("/usr/bin/gs")
143 (string-append (assoc-ref inputs "ghostscript") "/bin/gsc"))))
9f9861d7 144 #t))
1de1c56d
FB
145 (add-before 'check 'setup-check
146 (lambda _
147 ;; install temporarily into /tmp/netpbm
148 (system* "make" "package")
149 ;; remove test requiring X
150 (substitute* "test/all-in-place.test" (("pamx") ""))
151 ;; do not worry about non-existing file
152 (substitute* "test/all-in-place.test" (("^rm ") "rm -f "))
153 ;; remove four tests that fail for unknown reasons
154 (substitute* "test/Test-Order"
155 (("all-in-place.test") "")
156 (("pnmpsnr.test") "")
157 (("pnmremap1.test") "")
664ac384
LF
158 (("gif-roundtrip.test") "")
159
160 ;; These two tests started failing in netpbm-10.78.3.
161 (("jpeg-roundtrip.test") "")
162 (("pbmtext.test") "")
163
164 ;; Skip tests that use nonfree programs that we don't build.
165 (("ps-alt-roundtrip.test") "" )
166 (("pbm-misc-converters.test") ""))
9f9861d7 167 #t))
1de1c56d
FB
168 (replace 'install
169 (lambda* (#:key outputs make-flags #:allow-other-keys)
170 (let ((out (assoc-ref outputs "out")))
171 (apply system* "make" "package"
172 (string-append "pkgdir=" out) make-flags)
173 ;; copy static library
174 (copy-file (string-append out "/link/libnetpbm.a")
175 (string-append out "/lib/libnetpbm.a"))
176 ;; remove superfluous folders and files
177 (system* "rm" "-r" (string-append out "/link"))
178 (system* "rm" "-r" (string-append out "/misc"))
179 (with-directory-excursion out
180 (for-each delete-file
181 '("config_template" "pkginfo" "README"
9f9861d7
FB
182 "VERSION")))
183 #t))))))
35b9e423 184 (synopsis "Toolkit for manipulation of images")
05bf6f82
AE
185 (description
186 "Netpbm is a toolkit for the manipulation of graphic images, including
187the conversion of images between a variety of different formats.
188There are over 300 separate tools in the package including converters for
189about 100 graphics formats.")
190 (license gpl2)
191 (home-page "http://netpbm.sourceforge.net/")))