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