1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2016 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015, 2017 Leo Famulari <leo@famulari.name>
5 ;;; Copyright © 2016 ng0 <ng0@n0.is>
6 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
8 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
9 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
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.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
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.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu packages ncurses)
27 #:use-module (gnu packages)
28 #:use-module (guix licenses)
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system perl)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages pkg-config)
36 #:use-module (gnu packages swig)
37 #:use-module (gnu packages linux)
38 #:use-module (guix utils))
40 (define-public ncurses
46 (uri (string-append "mirror://gnu/ncurses/ncurses-"
47 (car (string-split version #\-))
51 "05qdmbmrrn88ii9f66rkcmcyzp1kb1ymkx7g040lfkd1nkp7w1da"))))
52 (build-system gnu-build-system)
54 "doc")) ;1 MiB of man pages
56 (let ((patch-makefile-phase
58 (for-each patch-makefile-SHELL
59 (find-files "." "Makefile.in"))
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
66 (let ((out (assoc-ref outputs "out"))
67 (doc (assoc-ref outputs "doc")))
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")
74 (cons (string-append "--host=" target)
78 (apply-rollup-patch-phase
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>.
83 '(lambda* (#:key inputs native-inputs #:allow-other-keys)
84 (copy-file (assoc-ref (or native-inputs inputs) "rollup-patch")
85 (string-append (getcwd) "/rollup-patch.sh.bz2"))
86 (invoke "bzip2" "-d" "rollup-patch.sh.bz2")
87 (invoke "sh" "rollup-patch.sh")
91 ;; To avoid retaining a reference to the bootstrap Bash via the
92 ;; shebang of the 'ncursesw6-config' script, simply remove that
93 ;; shebang: it'll work just as well without it. Likewise, do not
94 ;; retain a reference to the "doc" output.
95 (substitute* "misc/ncurses-config.in"
97 "# No shebang here, use /bin/sh!\n")
104 `(lambda* (#:key outputs #:allow-other-keys)
105 (let ((out (assoc-ref outputs "out")))
106 ;; When building a wide-character (Unicode) build, create backward
107 ;; compatibility links from the the "normal" libraries to the
108 ;; wide-character ones (e.g. libncurses.so to libncursesw.so).
109 ,@(if (target-mingw?)
110 '( ;; TODO: create .la files to link to the .dll?
111 (with-directory-excursion (string-append out "/bin")
115 (string-append "lib" lib ".dll"))
117 (string-append "lib" lib "w6.dll"))
119 (when (file-exists? libw6.dll)
120 (format #t "creating symlinks for `lib~a'~%" lib)
121 (symlink libw6.dll lib.dll)))
122 '("curses" "ncurses" "form" "panel" "menu"))))
124 (with-directory-excursion (string-append out "/lib")
125 (for-each (lambda (lib)
127 (string-append "lib" lib "w.a"))
129 (string-append "lib" lib ".a"))
131 ,@(if (not (target-mingw?))
133 (string-append "lib" lib "w.so.6"))
135 (string-append "lib" lib ".so.6"))
137 (string-append "lib" lib ".so"))
139 (string-append lib "w.pc"))
141 (string-append lib ".pc")))
144 (when (file-exists? libw.a)
145 (format #t "creating symlinks for `lib~a'~%" lib)
146 (symlink libw.a lib.a)
147 ,@(if (not (target-mingw?))
148 '((symlink libw.so.x lib.so.x)
149 (false-if-exception (delete-file lib.so))
150 (call-with-output-file lib.so
152 (format p "INPUT (-l~aw)~%" lib)))
153 (with-directory-excursion "pkgconfig"
154 (format #t "creating symlink for `~a'~%"
156 (when (file-exists? packagew.pc)
157 (symlink packagew.pc package.pc))))
159 '("curses" "ncurses" "form" "panel" "menu")))
164 `(("--with-shared" "--without-debug" "--enable-widec"
167 ,(list 'unquote '(string-append "--with-pkg-config-libdir="
168 (assoc-ref %outputs "out")
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")
175 "--enable-overwrite" ;really honor --includedir
177 ;; Make sure programs like 'tic', 'reset', and 'clear' have a
179 ,(list 'unquote '(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out")
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
186 ,@(if (%current-target-system) '("--disable-stripping") '())
188 ;; MinGW: Use term-driver created for the MinGW port.
189 ,@(if (target-mingw?) '("--enable-term-driver") '()))))
190 #:tests? #f ; no "check" target
191 #:phases (modify-phases %standard-phases
192 (replace 'configure ,configure-phase)
193 (add-after 'install 'post-install
195 (add-before 'configure 'patch-makefile-SHELL
196 ,patch-makefile-phase)
197 (add-after 'unpack 'remove-unneeded-shebang
198 ,remove-shebang-phase)))))
200 `(,@(if (%current-target-system)
201 `(("self" ,this-package)) ;for `tic'
203 ("pkg-config" ,pkg-config)))
205 (list (search-path-specification
206 (variable "TERMINFO_DIRS")
207 (files '("share/terminfo")))))
208 (synopsis "Terminal emulation (termcap, terminfo) library")
210 "GNU Ncurses is a library which provides capabilities to write text to
211 a terminal in a terminal-independent manner. It supports pads and color as
212 well as multiple highlights and forms characters. It is typically used to
213 implement user interfaces for command-line applications. The accompanying
214 ncursesw library provides wide character support.")
216 (home-page "https://www.gnu.org/software/ncurses/")))
218 (define-public ncurses/gpm
219 (package/inherit ncurses
220 (name "ncurses-with-gpm")
222 (substitute-keyword-arguments (package-arguments ncurses)
223 ((#:configure-flags cf)
224 `(cons (string-append "--with-gpm="
225 (assoc-ref %build-inputs "gpm")
231 (define-public dialog
234 (version "1.3-20190211")
238 "https://invisible-mirror.net/archives/dialog/dialog-"
242 "1lx0bvradzx1zl7znlrsnyljcs596r7wamkhyq37ikbxsy4y5h29"))))
243 (build-system gnu-build-system)
245 `(#:tests? #f)) ; no test suite
247 `(("ncurses" ,ncurses)))
248 (synopsis "Curses widgets")
249 (description "Dialog is a script-interpreter which provides a set of
250 curses widgets, such as dialog boxes.")
251 (home-page "https://invisible-island.net/dialog/dialog.html")
252 ;; Includes the gpl3 file "config.sub" from Automake.
253 (license (list lgpl2.1 gpl3))))
255 (define-public perl-curses
262 (uri (string-append "mirror://cpan/authors/id/G/GI/GIRAFFED/"
263 "Curses-" version ".tar.gz"))
266 "0r6xd9wr0c25rr28zixhqipak575zqsfb7r7f2693i9il1dpj554"))))
267 (build-system perl-build-system)
269 `(("ncurses" ,ncurses)))
271 `(#:make-maker-flags (list "PANELS" "MENUS")
273 (modify-phases %standard-phases
275 'configure 'set-curses-ldflags
276 (lambda* (#:key inputs #:allow-other-keys)
277 (let* ((ncurses (assoc-ref inputs "ncurses"))
278 (include (string-append ncurses "/include"))
279 (lib (string-append ncurses "/lib")))
280 (setenv "CURSES_LIBTYPE" "ncurses")
281 (setenv "CURSES_CFLAGS" (string-append "-I" include))
282 (setenv "CURSES_PANEL_CFLAGS" (string-append "-I" include))
283 (setenv "CURSES_MENU_CFLAGS" (string-append "-I" include))
284 (setenv "CURSES_FORM_CFLAGS" (string-append "-I" include))
285 (setenv "CURSES_LDFLAGS" (string-append "-L" lib " -lncurses"))
286 (setenv "CURSES_PANEL_LDFLAGS" (string-append "-L" lib " -lpanel"))
287 (setenv "CURSES_MENU_LDFLAGS" (string-append "-L" lib " -lmenu"))
288 (setenv "CURSES_FORM_LDFLAGS" (string-append "-L" lib " -lform"))
290 (home-page "https://metacpan.org/release/Curses")
291 (synopsis "Terminal screen handling and optimization")
293 "@code{Curses} is the interface between Perl and the curses library
295 (license perl-license)))
304 (uri (string-append "http://www.clifford.at/stfl/stfl-"
308 "1460d5lc780p3q38l3wc9jfr2a7zlyrcra0li65aynj738cam9yl"))))
309 (build-system gnu-build-system)
311 '(#:tests? #f ; no test target
312 #:make-flags (list (string-append "prefix=" (assoc-ref %outputs "out")))
314 (modify-phases %standard-phases
315 (delete 'configure) ; there is no configure script
316 ;; in our ncurses, the headers are in /include
317 (add-before 'build 'patch-ncursesw
319 (substitute* "stfl_internals.h"
322 (add-after 'install 'install-missing-symlink
323 (lambda* (#:key outputs #:allow-other-keys)
324 (let* ((out (assoc-ref outputs "out"))
325 (lib (string-append out "/lib")))
326 ;; Some programs look for libstfl.so.0.
327 (symlink "libstfl.so" (string-append lib "/libstfl.so.0"))))))))
328 (inputs `(("ncurses" ,ncurses)))
329 (native-inputs `(("swig" ,swig)))
330 (home-page "http://www.clifford.at/stfl/")
331 (synopsis "Structured terminal forms library")
332 (description "Stfl is a library which implements a curses-based widget
333 set for text terminals.")