gnu: ncurses: Update to 6.1-20190909.
[jackhill/guix/guix.git] / gnu / packages / ncurses.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
528ea990 2;;; Copyright © 2012, 2013, 2014, 2015, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
d230cf61 3;;; Copyright © 2014, 2016 Mark H Weaver <mhw@netris.org>
625e7cd6 4;;; Copyright © 2015, 2017 Leo Famulari <leo@famulari.name>
47956fa0 5;;; Copyright © 2016 ng0 <ng0@n0.is>
c76dab7b 6;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
d230cf61 7;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
1bd36436 8;;; Copyright © 2017, 2019 Marius Bakke <mbakke@fastmail.com>
da71a77c 9;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
c44899a2 10;;;
233e7676 11;;; This file is part of GNU Guix.
c44899a2 12;;;
233e7676 13;;; GNU Guix is free software; you can redistribute it and/or modify it
c44899a2
LC
14;;; under the terms of the GNU General Public License as published by
15;;; the Free Software Foundation; either version 3 of the License, or (at
16;;; your option) any later version.
17;;;
233e7676 18;;; GNU Guix is distributed in the hope that it will be useful, but
c44899a2
LC
19;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;;; GNU General Public License for more details.
22;;;
23;;; You should have received a copy of the GNU General Public License
233e7676 24;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
c44899a2 25
1ffa7090 26(define-module (gnu packages ncurses)
d230cf61 27 #:use-module (gnu packages)
4a44e743 28 #:use-module (guix licenses)
c44899a2 29 #:use-module (guix packages)
87f5d366 30 #:use-module (guix download)
b393a44c 31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system perl)
33 #:use-module (gnu packages)
c76dab7b 34 #:use-module (gnu packages perl)
57742b35 35 #:use-module (gnu packages pkg-config)
d230cf61 36 #:use-module (gnu packages swig)
c67d8056 37 #:use-module (gnu packages linux)
d230cf61 38 #:use-module (guix utils))
c44899a2
LC
39
40(define-public ncurses
d230cf61
MW
41 (package
42 (name "ncurses")
1bd36436 43 (version "6.1-20190609")
d230cf61 44 (source (origin
87f5d366 45 (method url-fetch)
0db342a5 46 (uri (string-append "mirror://gnu/ncurses/ncurses-"
667082d5
MB
47 (car (string-split version #\-))
48 ".tar.gz"))
c44899a2
LC
49 (sha256
50 (base32
784d3b7e 51 "05qdmbmrrn88ii9f66rkcmcyzp1kb1ymkx7g040lfkd1nkp7w1da"))))
d230cf61
MW
52 (build-system gnu-build-system)
53 (outputs '("out"
54 "doc")) ;1 MiB of man pages
55 (arguments
56 (let ((patch-makefile-phase
57 '(lambda _
58 (for-each patch-makefile-SHELL
5170bbd5
TGR
59 (find-files "." "Makefile.in"))
60 #t))
d230cf61
MW
61 (configure-phase
62 ;; The 'configure' script does not understand '--docdir', so we must
63 ;; override that and use '--mandir' instead.
64 '(lambda* (#:key build target outputs configure-flags
65 #:allow-other-keys)
66 (let ((out (assoc-ref outputs "out"))
67 (doc (assoc-ref outputs "doc")))
5170bbd5
TGR
68 (apply invoke "./configure"
69 (string-append "SHELL=" (which "sh"))
70 (string-append "--build=" build)
71 (string-append "--prefix=" out)
72 (string-append "--mandir=" doc "/share/man")
73 (if target
74 (cons (string-append "--host=" target)
75 configure-flags)
76 configure-flags))
77 #t)))
667082d5 78 (apply-rollup-patch-phase
784d3b7e
MB
79 ;; Ncurses distributes "stable" patchsets to be applied on top
80 ;; of the release tarball. These are only available as shell
81 ;; scripts(!) so we decompress and apply them in a phase.
82 ;; See <https://invisible-mirror.net/archives/ncurses/6.1/README>.
11b9a223
LC
83 '(lambda* (#:key inputs native-inputs #:allow-other-keys)
84 (copy-file (assoc-ref (or native-inputs inputs) "rollup-patch")
667082d5 85 (string-append (getcwd) "/rollup-patch.sh.bz2"))
5170bbd5 86 (invoke "bzip2" "-d" "rollup-patch.sh.bz2")
1bd36436 87 (invoke "sh" "rollup-patch.sh")))
d230cf61
MW
88 (remove-shebang-phase
89 '(lambda _
90 ;; To avoid retaining a reference to the bootstrap Bash via the
91 ;; shebang of the 'ncursesw6-config' script, simply remove that
92 ;; shebang: it'll work just as well without it. Likewise, do not
93 ;; retain a reference to the "doc" output.
94 (substitute* "misc/ncurses-config.in"
95 (("#!@SHELL@")
96 "# No shebang here, use /bin/sh!\n")
97 (("@SHELL@ \\$0")
98 "$0")
99 (("mandir=.*$")
100 "mandir=share/man"))
101 #t))
102 (post-install-phase
103 `(lambda* (#:key outputs #:allow-other-keys)
104 (let ((out (assoc-ref outputs "out")))
105 ;; When building a wide-character (Unicode) build, create backward
106 ;; compatibility links from the the "normal" libraries to the
74288230 107 ;; wide-character ones (e.g. libncurses.so to libncursesw.so).
d230cf61
MW
108 ,@(if (target-mingw?)
109 '( ;; TODO: create .la files to link to the .dll?
110 (with-directory-excursion (string-append out "/bin")
111 (for-each
112 (lambda (lib)
113 (define lib.dll
114 (string-append "lib" lib ".dll"))
115 (define libw6.dll
116 (string-append "lib" lib "w6.dll"))
117
118 (when (file-exists? libw6.dll)
119 (format #t "creating symlinks for `lib~a'~%" lib)
120 (symlink libw6.dll lib.dll)))
121 '("curses" "ncurses" "form" "panel" "menu"))))
122 '())
123 (with-directory-excursion (string-append out "/lib")
124 (for-each (lambda (lib)
125 (define libw.a
126 (string-append "lib" lib "w.a"))
127 (define lib.a
128 (string-append "lib" lib ".a"))
129
130 ,@(if (not (target-mingw?))
131 '((define libw.so.x
132 (string-append "lib" lib "w.so.6"))
133 (define lib.so.x
134 (string-append "lib" lib ".so.6"))
135 (define lib.so
74288230
LF
136 (string-append "lib" lib ".so"))
137 (define packagew.pc
138 (string-append lib "w.pc"))
139 (define package.pc
140 (string-append lib ".pc")))
d230cf61 141 '())
c44899a2 142
d230cf61
MW
143 (when (file-exists? libw.a)
144 (format #t "creating symlinks for `lib~a'~%" lib)
145 (symlink libw.a lib.a)
146 ,@(if (not (target-mingw?))
147 '((symlink libw.so.x lib.so.x)
148 (false-if-exception (delete-file lib.so))
149 (call-with-output-file lib.so
150 (lambda (p)
74288230
LF
151 (format p "INPUT (-l~aw)~%" lib)))
152 (with-directory-excursion "pkgconfig"
153 (format #t "creating symlink for `~a'~%"
154 package.pc)
155 (when (file-exists? packagew.pc)
156 (symlink packagew.pc package.pc))))
d230cf61 157 '())))
5170bbd5
TGR
158 '("curses" "ncurses" "form" "panel" "menu")))
159 #t))))
d230cf61
MW
160 `(#:configure-flags
161 ,(cons*
162 'quasiquote
163 `(("--with-shared" "--without-debug" "--enable-widec"
164
74288230
LF
165 "--enable-pc-files"
166 ,(list 'unquote '(string-append "--with-pkg-config-libdir="
167 (assoc-ref %outputs "out")
168 "/lib/pkgconfig"))
57742b35 169
d230cf61
MW
170 ;; By default headers land in an `ncursesw' subdir, which is not
171 ;; what users expect.
172 ,(list 'unquote '(string-append "--includedir=" (assoc-ref %outputs "out")
173 "/include"))
174 "--enable-overwrite" ;really honor --includedir
c44899a2 175
d230cf61
MW
176 ;; Make sure programs like 'tic', 'reset', and 'clear' have a
177 ;; correct RUNPATH.
178 ,(list 'unquote '(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out")
179 "/lib"))
b0ff3606
LC
180
181 ;; Starting from ncurses 6.1, "make install" runs "install -s"
182 ;; by default, which doesn't work for cross-compiled binaries
183 ;; because it invokes 'strip' instead of 'TRIPLET-strip'. Work
184 ;; around this.
185 ,@(if (%current-target-system) '("--disable-stripping") '())
186
d230cf61
MW
187 ;; MinGW: Use term-driver created for the MinGW port.
188 ,@(if (target-mingw?) '("--enable-term-driver") '()))))
189 #:tests? #f ; no "check" target
190 #:phases (modify-phases %standard-phases
1bd36436
MB
191 (add-after 'unpack 'apply-rollup-patch
192 ,apply-rollup-patch-phase)
d230cf61
MW
193 (replace 'configure ,configure-phase)
194 (add-after 'install 'post-install
195 ,post-install-phase)
196 (add-before 'configure 'patch-makefile-SHELL
197 ,patch-makefile-phase)
1bd36436 198 (add-before 'patch-source-shebangs 'remove-unneeded-shebang
d230cf61 199 ,remove-shebang-phase)))))
667082d5 200 (native-inputs
528ea990
LC
201 `(,@(if (%current-target-system)
202 `(("self" ,this-package)) ;for `tic'
203 '())
1bd36436
MB
204
205 ("rollup-patch"
206 ,(origin
207 (method url-fetch)
208 (uri (string-append
209 "https://invisible-mirror.net/archives/ncurses/"
210 (car (string-split version #\-))
211 "/ncurses-" version "-patch.sh.bz2"))
212 (sha256
213 (base32
214 "0hqlqdqmh7lfs6dwj763qksb4j9nk0pv6crzx5gnp6n4caz3i46g"))))
215
528ea990 216 ("pkg-config" ,pkg-config)))
d230cf61
MW
217 (native-search-paths
218 (list (search-path-specification
219 (variable "TERMINFO_DIRS")
220 (files '("share/terminfo")))))
221 (synopsis "Terminal emulation (termcap, terminfo) library")
222 (description
223 "GNU Ncurses is a library which provides capabilities to write text to
79c311b8 224a terminal in a terminal-independent manner. It supports pads and color as
a22dc0c4 225well as multiple highlights and forms characters. It is typically used to
79c311b8
LC
226implement user interfaces for command-line applications. The accompanying
227ncursesw library provides wide character support.")
d230cf61 228 (license x11)
6fd52309 229 (home-page "https://www.gnu.org/software/ncurses/")))
44298269 230
c67d8056
MW
231(define-public ncurses/gpm
232 (package/inherit ncurses
233 (name "ncurses-with-gpm")
234 (arguments
235 (substitute-keyword-arguments (package-arguments ncurses)
236 ((#:configure-flags cf)
237 `(cons (string-append "--with-gpm="
238 (assoc-ref %build-inputs "gpm")
239 "/lib/libgpm.so.2")
240 ,cf))))
241 (inputs
242 `(("gpm" ,gpm)))))
243
44298269
LF
244(define-public dialog
245 (package
246 (name "dialog")
da71a77c 247 (version "1.3-20190211")
44298269
LF
248 (source (origin
249 (method url-fetch)
250 (uri (string-append
89e1b270 251 "https://invisible-mirror.net/archives/dialog/dialog-"
44298269
LF
252 version ".tgz"))
253 (sha256
254 (base32
da71a77c 255 "1lx0bvradzx1zl7znlrsnyljcs596r7wamkhyq37ikbxsy4y5h29"))))
44298269
LF
256 (build-system gnu-build-system)
257 (arguments
c327bb44 258 `(#:tests? #f)) ; no test suite
44298269
LF
259 (inputs
260 `(("ncurses" ,ncurses)))
261 (synopsis "Curses widgets")
262 (description "Dialog is a script-interpreter which provides a set of
263curses widgets, such as dialog boxes.")
432fd269 264 (home-page "https://invisible-island.net/dialog/dialog.html")
44298269
LF
265 ;; Includes the gpl3 file "config.sub" from Automake.
266 (license (list lgpl2.1 gpl3))))
b393a44c 267
268(define-public perl-curses
269 (package
270 (name "perl-curses")
271 (version "1.36")
272 (source
273 (origin
274 (method url-fetch)
275 (uri (string-append "mirror://cpan/authors/id/G/GI/GIRAFFED/"
276 "Curses-" version ".tar.gz"))
277 (sha256
278 (base32
279 "0r6xd9wr0c25rr28zixhqipak575zqsfb7r7f2693i9il1dpj554"))))
280 (build-system perl-build-system)
281 (inputs
282 `(("ncurses" ,ncurses)))
283 (arguments
284 `(#:make-maker-flags (list "PANELS" "MENUS")
285 #:phases
286 (modify-phases %standard-phases
287 (add-before
288 'configure 'set-curses-ldflags
289 (lambda* (#:key inputs #:allow-other-keys)
290 (let* ((ncurses (assoc-ref inputs "ncurses"))
291 (include (string-append ncurses "/include"))
292 (lib (string-append ncurses "/lib")))
293 (setenv "CURSES_LIBTYPE" "ncurses")
294 (setenv "CURSES_CFLAGS" (string-append "-I" include))
295 (setenv "CURSES_PANEL_CFLAGS" (string-append "-I" include))
296 (setenv "CURSES_MENU_CFLAGS" (string-append "-I" include))
297 (setenv "CURSES_FORM_CFLAGS" (string-append "-I" include))
298 (setenv "CURSES_LDFLAGS" (string-append "-L" lib " -lncurses"))
299 (setenv "CURSES_PANEL_LDFLAGS" (string-append "-L" lib " -lpanel"))
300 (setenv "CURSES_MENU_LDFLAGS" (string-append "-L" lib " -lmenu"))
301 (setenv "CURSES_FORM_LDFLAGS" (string-append "-L" lib " -lform"))
302 #t))))))
9aba9b12 303 (home-page "https://metacpan.org/release/Curses")
b393a44c 304 (synopsis "Terminal screen handling and optimization")
305 (description
306 "@code{Curses} is the interface between Perl and the curses library
307of your system.")
2f3108ad 308 (license perl-license)))
c76dab7b
EF
309
310(define-public stfl
311 (package
312 (name "stfl")
313 (version "0.24")
314 (source
315 (origin
316 (method url-fetch)
317 (uri (string-append "http://www.clifford.at/stfl/stfl-"
318 version ".tar.gz"))
319 (sha256
320 (base32
321 "1460d5lc780p3q38l3wc9jfr2a7zlyrcra0li65aynj738cam9yl"))))
322 (build-system gnu-build-system)
323 (arguments
324 '(#:tests? #f ; no test target
325 #:make-flags (list (string-append "prefix=" (assoc-ref %outputs "out")))
326 #:phases
327 (modify-phases %standard-phases
328 (delete 'configure) ; there is no configure script
329 ;; in our ncurses, the headers are in /include
330 (add-before 'build 'patch-ncursesw
331 (lambda _
332 (substitute* "stfl_internals.h"
333 (("ncursesw/") ""))
334 #t))
335 (add-after 'install 'install-missing-symlink
336 (lambda* (#:key outputs #:allow-other-keys)
337 (let* ((out (assoc-ref outputs "out"))
338 (lib (string-append out "/lib")))
339 ;; Some programs look for libstfl.so.0.
340 (symlink "libstfl.so" (string-append lib "/libstfl.so.0"))))))))
341 (inputs `(("ncurses" ,ncurses)))
342 (native-inputs `(("swig" ,swig)))
343 (home-page "http://www.clifford.at/stfl/")
344 (synopsis "Structured terminal forms library")
345 (description "Stfl is a library which implements a curses-based widget
346set for text terminals.")
347 (license lgpl3+)))