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