1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014, 2015 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@we.make.ritual.n0.is>
6 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
7 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages ncurses)
25 #:use-module (gnu packages)
26 #:use-module (guix licenses)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix build-system perl)
31 #:use-module (gnu packages)
32 #:use-module (gnu packages perl)
33 #:use-module (gnu packages pkg-config)
34 #:use-module (gnu packages swig)
35 #:use-module (gnu packages linux)
36 #:use-module (guix utils))
38 (define-public ncurses
44 (uri (string-append "mirror://gnu/ncurses/ncurses-"
46 (patches (search-patches "ncurses-CVE-2017-10684-10685.patch"))
49 "0q3jck7lna77z5r42f13c4xglc7azd19pxfrjrpgp2yf615w4lgm"))))
50 (build-system gnu-build-system)
52 "doc")) ;1 MiB of man pages
54 (let ((patch-makefile-phase
56 (for-each patch-makefile-SHELL
57 (find-files "." "Makefile.in"))))
59 ;; The 'configure' script does not understand '--docdir', so we must
60 ;; override that and use '--mandir' instead.
61 '(lambda* (#:key build target outputs configure-flags
63 (let ((out (assoc-ref outputs "out"))
64 (doc (assoc-ref outputs "doc")))
65 (zero? (apply system* "./configure"
66 (string-append "SHELL=" (which "sh"))
67 (string-append "--build=" build)
68 (string-append "--prefix=" out)
69 (string-append "--mandir=" doc "/share/man")
71 (cons (string-append "--host=" target)
76 ;; To avoid retaining a reference to the bootstrap Bash via the
77 ;; shebang of the 'ncursesw6-config' script, simply remove that
78 ;; shebang: it'll work just as well without it. Likewise, do not
79 ;; retain a reference to the "doc" output.
80 (substitute* "misc/ncurses-config.in"
82 "# No shebang here, use /bin/sh!\n")
89 `(lambda* (#:key outputs #:allow-other-keys)
90 (let ((out (assoc-ref outputs "out")))
91 ;; When building a wide-character (Unicode) build, create backward
92 ;; compatibility links from the the "normal" libraries to the
93 ;; wide-character ones (e.g. libncurses.so to libncursesw.so).
95 '( ;; TODO: create .la files to link to the .dll?
96 (with-directory-excursion (string-append out "/bin")
100 (string-append "lib" lib ".dll"))
102 (string-append "lib" lib "w6.dll"))
104 (when (file-exists? libw6.dll)
105 (format #t "creating symlinks for `lib~a'~%" lib)
106 (symlink libw6.dll lib.dll)))
107 '("curses" "ncurses" "form" "panel" "menu"))))
109 (with-directory-excursion (string-append out "/lib")
110 (for-each (lambda (lib)
112 (string-append "lib" lib "w.a"))
114 (string-append "lib" lib ".a"))
116 ,@(if (not (target-mingw?))
118 (string-append "lib" lib "w.so.6"))
120 (string-append "lib" lib ".so.6"))
122 (string-append "lib" lib ".so"))
124 (string-append lib "w.pc"))
126 (string-append lib ".pc")))
129 (when (file-exists? libw.a)
130 (format #t "creating symlinks for `lib~a'~%" lib)
131 (symlink libw.a lib.a)
132 ,@(if (not (target-mingw?))
133 '((symlink libw.so.x lib.so.x)
134 (false-if-exception (delete-file lib.so))
135 (call-with-output-file lib.so
137 (format p "INPUT (-l~aw)~%" lib)))
138 (with-directory-excursion "pkgconfig"
139 (format #t "creating symlink for `~a'~%"
141 (when (file-exists? packagew.pc)
142 (symlink packagew.pc package.pc))))
144 '("curses" "ncurses" "form" "panel" "menu")))))))
148 `(("--with-shared" "--without-debug" "--enable-widec"
151 ,(list 'unquote '(string-append "--with-pkg-config-libdir="
152 (assoc-ref %outputs "out")
155 ;; By default headers land in an `ncursesw' subdir, which is not
156 ;; what users expect.
157 ,(list 'unquote '(string-append "--includedir=" (assoc-ref %outputs "out")
159 "--enable-overwrite" ;really honor --includedir
161 ;; Make sure programs like 'tic', 'reset', and 'clear' have a
163 ,(list 'unquote '(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out")
165 ;; MinGW: Use term-driver created for the MinGW port.
166 ,@(if (target-mingw?) '("--enable-term-driver") '()))))
167 #:tests? #f ; no "check" target
168 #:phases (modify-phases %standard-phases
169 (replace 'configure ,configure-phase)
170 (add-after 'install 'post-install
172 (add-before 'configure 'patch-makefile-SHELL
173 ,patch-makefile-phase)
174 (add-after 'unpack 'remove-unneeded-shebang
175 ,remove-shebang-phase)))))
176 (self-native-input? #t) ; for `tic'
178 `(("pkg-config" ,pkg-config)))
180 (list (search-path-specification
181 (variable "TERMINFO_DIRS")
182 (files '("share/terminfo")))))
183 (synopsis "Terminal emulation (termcap, terminfo) library")
185 "GNU Ncurses is a library which provides capabilities to write text to
186 a terminal in a terminal-independent manner. It supports pads and color as
187 well as multiple highlights and forms characters. It is typically used to
188 implement user interfaces for command-line applications. The accompanying
189 ncursesw library provides wide character support.")
191 (home-page "https://www.gnu.org/software/ncurses/")))
193 (define-public ncurses/gpm
194 (package/inherit ncurses
195 (name "ncurses-with-gpm")
197 (substitute-keyword-arguments (package-arguments ncurses)
198 ((#:configure-flags cf)
199 `(cons (string-append "--with-gpm="
200 (assoc-ref %build-inputs "gpm")
206 (define-public dialog
209 (version "1.3-20170509")
213 "http://invisible-mirror.net/archives/dialog/dialog-"
217 "0mj7rl5psilaj3bxxvjfd44qjknxjli98b0d1lxd3f9jqrsbmw9g"))))
218 (build-system gnu-build-system)
220 `(#:tests? #f)) ; no test suite
222 `(("ncurses" ,ncurses)))
223 (synopsis "Curses widgets")
224 (description "Dialog is a script-interpreter which provides a set of
225 curses widgets, such as dialog boxes.")
226 (home-page "http://invisible-island.net/dialog/dialog.html")
227 ;; Includes the gpl3 file "config.sub" from Automake.
228 (license (list lgpl2.1 gpl3))))
230 (define-public perl-curses
237 (uri (string-append "mirror://cpan/authors/id/G/GI/GIRAFFED/"
238 "Curses-" version ".tar.gz"))
241 "0r6xd9wr0c25rr28zixhqipak575zqsfb7r7f2693i9il1dpj554"))))
242 (build-system perl-build-system)
244 `(("ncurses" ,ncurses)))
246 `(#:make-maker-flags (list "PANELS" "MENUS")
248 (modify-phases %standard-phases
250 'configure 'set-curses-ldflags
251 (lambda* (#:key inputs #:allow-other-keys)
252 (let* ((ncurses (assoc-ref inputs "ncurses"))
253 (include (string-append ncurses "/include"))
254 (lib (string-append ncurses "/lib")))
255 (setenv "CURSES_LIBTYPE" "ncurses")
256 (setenv "CURSES_CFLAGS" (string-append "-I" include))
257 (setenv "CURSES_PANEL_CFLAGS" (string-append "-I" include))
258 (setenv "CURSES_MENU_CFLAGS" (string-append "-I" include))
259 (setenv "CURSES_FORM_CFLAGS" (string-append "-I" include))
260 (setenv "CURSES_LDFLAGS" (string-append "-L" lib " -lncurses"))
261 (setenv "CURSES_PANEL_LDFLAGS" (string-append "-L" lib " -lpanel"))
262 (setenv "CURSES_MENU_LDFLAGS" (string-append "-L" lib " -lmenu"))
263 (setenv "CURSES_FORM_LDFLAGS" (string-append "-L" lib " -lform"))
265 (home-page "http://search.cpan.org/dist/Curses")
266 (synopsis "Terminal screen handling and optimization")
268 "@code{Curses} is the interface between Perl and the curses library
270 (license perl-license)))
279 (uri (string-append "http://www.clifford.at/stfl/stfl-"
283 "1460d5lc780p3q38l3wc9jfr2a7zlyrcra0li65aynj738cam9yl"))))
284 (build-system gnu-build-system)
286 '(#:tests? #f ; no test target
287 #:make-flags (list (string-append "prefix=" (assoc-ref %outputs "out")))
289 (modify-phases %standard-phases
290 (delete 'configure) ; there is no configure script
291 ;; in our ncurses, the headers are in /include
292 (add-before 'build 'patch-ncursesw
294 (substitute* "stfl_internals.h"
297 (add-after 'install 'install-missing-symlink
298 (lambda* (#:key outputs #:allow-other-keys)
299 (let* ((out (assoc-ref outputs "out"))
300 (lib (string-append out "/lib")))
301 ;; Some programs look for libstfl.so.0.
302 (symlink "libstfl.so" (string-append lib "/libstfl.so.0"))))))))
303 (inputs `(("ncurses" ,ncurses)))
304 (native-inputs `(("swig" ,swig)))
305 (home-page "http://www.clifford.at/stfl/")
306 (synopsis "Structured terminal forms library")
307 (description "Stfl is a library which implements a curses-based widget
308 set for text terminals.")