Merge remote-tracking branch 'origin/master' into staging
[jackhill/guix/guix.git] / gnu / packages / ncurses.scm
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 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>
8 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
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.
15 ;;;
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.
20 ;;;
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/>.
23
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 swig)
34 #:use-module (guix utils))
35
36 (define-public ncurses
37 (package
38 (name "ncurses")
39 (version "6.0")
40 (source (origin
41 (method url-fetch)
42 (uri (string-append "mirror://gnu/ncurses/ncurses-"
43 version ".tar.gz"))
44 (sha256
45 (base32
46 "0q3jck7lna77z5r42f13c4xglc7azd19pxfrjrpgp2yf615w4lgm"))))
47 (build-system gnu-build-system)
48 (outputs '("out"
49 "doc")) ;1 MiB of man pages
50 (arguments
51 (let ((patch-makefile-phase
52 '(lambda _
53 (for-each patch-makefile-SHELL
54 (find-files "." "Makefile.in"))))
55 (configure-phase
56 ;; The 'configure' script does not understand '--docdir', so we must
57 ;; override that and use '--mandir' instead.
58 '(lambda* (#:key build target outputs configure-flags
59 #:allow-other-keys)
60 (let ((out (assoc-ref outputs "out"))
61 (doc (assoc-ref outputs "doc")))
62 (zero? (apply system* "./configure"
63 (string-append "SHELL=" (which "sh"))
64 (string-append "--build=" build)
65 (string-append "--prefix=" out)
66 (string-append "--mandir=" doc "/share/man")
67 (if target
68 (cons (string-append "--host=" target)
69 configure-flags)
70 configure-flags))))))
71 (remove-shebang-phase
72 '(lambda _
73 ;; To avoid retaining a reference to the bootstrap Bash via the
74 ;; shebang of the 'ncursesw6-config' script, simply remove that
75 ;; shebang: it'll work just as well without it. Likewise, do not
76 ;; retain a reference to the "doc" output.
77 (substitute* "misc/ncurses-config.in"
78 (("#!@SHELL@")
79 "# No shebang here, use /bin/sh!\n")
80 (("@SHELL@ \\$0")
81 "$0")
82 (("mandir=.*$")
83 "mandir=share/man"))
84 #t))
85 (post-install-phase
86 `(lambda* (#:key outputs #:allow-other-keys)
87 (let ((out (assoc-ref outputs "out")))
88 ;; When building a wide-character (Unicode) build, create backward
89 ;; compatibility links from the the "normal" libraries to the
90 ;; wide-character libraries (e.g. libncurses.so to libncursesw.so).
91 ,@(if (target-mingw?)
92 '( ;; TODO: create .la files to link to the .dll?
93 (with-directory-excursion (string-append out "/bin")
94 (for-each
95 (lambda (lib)
96 (define lib.dll
97 (string-append "lib" lib ".dll"))
98 (define libw6.dll
99 (string-append "lib" lib "w6.dll"))
100
101 (when (file-exists? libw6.dll)
102 (format #t "creating symlinks for `lib~a'~%" lib)
103 (symlink libw6.dll lib.dll)))
104 '("curses" "ncurses" "form" "panel" "menu"))))
105 '())
106 (with-directory-excursion (string-append out "/lib")
107 (for-each (lambda (lib)
108 (define libw.a
109 (string-append "lib" lib "w.a"))
110 (define lib.a
111 (string-append "lib" lib ".a"))
112
113 ,@(if (not (target-mingw?))
114 '((define libw.so.x
115 (string-append "lib" lib "w.so.6"))
116 (define lib.so.x
117 (string-append "lib" lib ".so.6"))
118 (define lib.so
119 (string-append "lib" lib ".so")))
120 '())
121
122 (when (file-exists? libw.a)
123 (format #t "creating symlinks for `lib~a'~%" lib)
124 (symlink libw.a lib.a)
125 ,@(if (not (target-mingw?))
126 '((symlink libw.so.x lib.so.x)
127 (false-if-exception (delete-file lib.so))
128 (call-with-output-file lib.so
129 (lambda (p)
130 (format p "INPUT (-l~aw)~%" lib))))
131 '())))
132 '("curses" "ncurses" "form" "panel" "menu")))))))
133 `(#:configure-flags
134 ,(cons*
135 'quasiquote
136 `(("--with-shared" "--without-debug" "--enable-widec"
137
138 ;; By default headers land in an `ncursesw' subdir, which is not
139 ;; what users expect.
140 ,(list 'unquote '(string-append "--includedir=" (assoc-ref %outputs "out")
141 "/include"))
142 "--enable-overwrite" ;really honor --includedir
143
144 ;; Make sure programs like 'tic', 'reset', and 'clear' have a
145 ;; correct RUNPATH.
146 ,(list 'unquote '(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out")
147 "/lib"))
148 ;; MinGW: Use term-driver created for the MinGW port.
149 ,@(if (target-mingw?) '("--enable-term-driver") '()))))
150 #:tests? #f ; no "check" target
151 #:phases (modify-phases %standard-phases
152 (replace 'configure ,configure-phase)
153 (add-after 'install 'post-install
154 ,post-install-phase)
155 (add-before 'configure 'patch-makefile-SHELL
156 ,patch-makefile-phase)
157 (add-after 'unpack 'remove-unneeded-shebang
158 ,remove-shebang-phase)))))
159 (self-native-input? #t) ; for `tic'
160 (native-search-paths
161 (list (search-path-specification
162 (variable "TERMINFO_DIRS")
163 (files '("share/terminfo")))))
164 (synopsis "Terminal emulation (termcap, terminfo) library")
165 (description
166 "GNU Ncurses is a library which provides capabilities to write text to
167 a terminal in a terminal-independent manner. It supports pads and color as
168 well as multiple highlights and forms characters. It is typically used to
169 implement user interfaces for command-line applications. The accompanying
170 ncursesw library provides wide character support.")
171 (license x11)
172 (home-page "http://www.gnu.org/software/ncurses/")))
173
174 (define-public dialog
175 (package
176 (name "dialog")
177 (version "1.2-20150920")
178 (source (origin
179 (method url-fetch)
180 (uri (string-append
181 "http://invisible-mirror.net/archives/dialog/dialog-"
182 version ".tgz"))
183 (sha256
184 (base32
185 "01ccd585c241nkj02n0zdbx8jqhylgcfpcmmshynh0c7fv2ixrn4"))))
186 (build-system gnu-build-system)
187 (arguments
188 `(#:tests? #f)) ; no test suite
189 (inputs
190 `(("ncurses" ,ncurses)))
191 (synopsis "Curses widgets")
192 (description "Dialog is a script-interpreter which provides a set of
193 curses widgets, such as dialog boxes.")
194 (home-page "http://invisible-island.net/dialog/dialog.html")
195 ;; Includes the gpl3 file "config.sub" from Automake.
196 (license (list lgpl2.1 gpl3))))
197
198 (define-public perl-curses
199 (package
200 (name "perl-curses")
201 (version "1.36")
202 (source
203 (origin
204 (method url-fetch)
205 (uri (string-append "mirror://cpan/authors/id/G/GI/GIRAFFED/"
206 "Curses-" version ".tar.gz"))
207 (sha256
208 (base32
209 "0r6xd9wr0c25rr28zixhqipak575zqsfb7r7f2693i9il1dpj554"))))
210 (build-system perl-build-system)
211 (inputs
212 `(("ncurses" ,ncurses)))
213 (arguments
214 `(#:make-maker-flags (list "PANELS" "MENUS")
215 #:phases
216 (modify-phases %standard-phases
217 (add-before
218 'configure 'set-curses-ldflags
219 (lambda* (#:key inputs #:allow-other-keys)
220 (let* ((ncurses (assoc-ref inputs "ncurses"))
221 (include (string-append ncurses "/include"))
222 (lib (string-append ncurses "/lib")))
223 (setenv "CURSES_LIBTYPE" "ncurses")
224 (setenv "CURSES_CFLAGS" (string-append "-I" include))
225 (setenv "CURSES_PANEL_CFLAGS" (string-append "-I" include))
226 (setenv "CURSES_MENU_CFLAGS" (string-append "-I" include))
227 (setenv "CURSES_FORM_CFLAGS" (string-append "-I" include))
228 (setenv "CURSES_LDFLAGS" (string-append "-L" lib " -lncurses"))
229 (setenv "CURSES_PANEL_LDFLAGS" (string-append "-L" lib " -lpanel"))
230 (setenv "CURSES_MENU_LDFLAGS" (string-append "-L" lib " -lmenu"))
231 (setenv "CURSES_FORM_LDFLAGS" (string-append "-L" lib " -lform"))
232 #t))))))
233 (home-page "http://search.cpan.org/dist/Curses")
234 (synopsis "Terminal screen handling and optimization")
235 (description
236 "@code{Curses} is the interface between Perl and the curses library
237 of your system.")
238 (license (package-license perl))))
239
240 (define-public stfl
241 (package
242 (name "stfl")
243 (version "0.24")
244 (source
245 (origin
246 (method url-fetch)
247 (uri (string-append "http://www.clifford.at/stfl/stfl-"
248 version ".tar.gz"))
249 (sha256
250 (base32
251 "1460d5lc780p3q38l3wc9jfr2a7zlyrcra0li65aynj738cam9yl"))))
252 (build-system gnu-build-system)
253 (arguments
254 '(#:tests? #f ; no test target
255 #:make-flags (list (string-append "prefix=" (assoc-ref %outputs "out")))
256 #:phases
257 (modify-phases %standard-phases
258 (delete 'configure) ; there is no configure script
259 ;; in our ncurses, the headers are in /include
260 (add-before 'build 'patch-ncursesw
261 (lambda _
262 (substitute* "stfl_internals.h"
263 (("ncursesw/") ""))
264 #t))
265 (add-after 'install 'install-missing-symlink
266 (lambda* (#:key outputs #:allow-other-keys)
267 (let* ((out (assoc-ref outputs "out"))
268 (lib (string-append out "/lib")))
269 ;; Some programs look for libstfl.so.0.
270 (symlink "libstfl.so" (string-append lib "/libstfl.so.0"))))))))
271 (inputs `(("ncurses" ,ncurses)))
272 (native-inputs `(("swig" ,swig)))
273 (home-page "http://www.clifford.at/stfl/")
274 (synopsis "Structured terminal forms library")
275 (description "Stfl is a library which implements a curses-based widget
276 set for text terminals.")
277 (license lgpl3+)))