Update `HACKING'.
[jackhill/guix/guix.git] / distro / packages / ncurses.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (distro packages ncurses)
20 #:use-module (guix licenses)
21 #:use-module (guix packages)
22 #:use-module (guix download)
23 #:use-module (guix utils)
24 #:use-module (guix build-system gnu))
25
26 (define-public ncurses
27 (let ((patch-makefile-phase
28 '(lambda _
29 (for-each patch-makefile-SHELL
30 (find-files "." "Makefile.in"))))
31 (configure-phase
32 '(lambda* (#:key inputs outputs configure-flags
33 #:allow-other-keys)
34 ;; The `ncursesw5-config' has a #!/bin/sh. We want to patch
35 ;; it to point to libc's embedded Bash, to avoid retaining a
36 ;; reference to the bootstrap Bash.
37 (let* ((libc (assoc-ref inputs "libc"))
38 (bash (string-append libc "/bin/bash"))
39 (out (assoc-ref outputs "out")))
40 (format #t "configure flags: ~s~%" configure-flags)
41 (zero? (apply system* bash "./configure"
42 (string-append "SHELL=" bash)
43 (string-append "CONFIG_SHELL=" bash)
44 (string-append "--prefix=" out)
45 configure-flags)))))
46 (post-install-phase
47 '(lambda* (#:key outputs #:allow-other-keys)
48 (let ((out (assoc-ref outputs "out")))
49 ;; When building a wide-character (Unicode) build, create backward
50 ;; compatibility links from the the "normal" libraries to the
51 ;; wide-character libraries (e.g. libncurses.so to libncursesw.so).
52 (with-directory-excursion (string-append out "/lib")
53 (for-each (lambda (lib)
54 (define libw.a
55 (string-append "lib" lib "w.a"))
56 (define lib.a
57 (string-append "lib" lib ".a"))
58 (define libw.so.x
59 (string-append "lib" lib "w.so.5"))
60 (define lib.so.x
61 (string-append "lib" lib ".so.5"))
62 (define lib.so
63 (string-append "lib" lib ".so"))
64
65 (when (file-exists? libw.a)
66 (format #t "creating symlinks for `lib~a'~%" lib)
67 (symlink libw.a lib.a)
68 (symlink libw.so.x lib.so.x)
69 (false-if-exception (delete-file lib.so))
70 (call-with-output-file lib.so
71 (lambda (p)
72 (format p "INPUT (-l~aw)~%" lib)))))
73 '("curses" "ncurses" "form" "panel" "menu")))))))
74 (package
75 (name "ncurses")
76 (version "5.9")
77 (source (origin
78 (method url-fetch)
79 (uri (string-append "mirror://gnu/ncurses/ncurses-"
80 version ".tar.gz"))
81 (sha256
82 (base32
83 "0fsn7xis81za62afan0vvm38bvgzg5wfmv1m86flqcj0nj7jjilh"))))
84 (build-system gnu-build-system)
85 (arguments
86 (case-lambda
87 ((system)
88 `(#:configure-flags
89 `("--with-shared" "--without-debug" "--enable-widec"
90
91 ;; By default headers land in an `ncursesw' subdir, which is not
92 ;; what users expect.
93 ,(string-append "--includedir=" (assoc-ref %outputs "out")
94 "/include")
95
96 ;; C++ bindings fail to build on
97 ;; `i386-pc-solaris2.11' with GCC 3.4.3:
98 ;; <http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6395191>.
99 ,,@(if (string=? system "i686-solaris")
100 '("--without-cxx-binding")
101 '()))
102 #:tests? #f ; no "check" target
103 #:phases (alist-cons-after
104 'install 'post-install ,post-install-phase
105 (alist-cons-before
106 'configure 'patch-makefile-SHELL
107 ,patch-makefile-phase
108 (alist-replace
109 'configure
110 ,configure-phase
111 %standard-phases)))))
112 ((system cross-system)
113 (arguments cross-system))))
114 (self-native-input? #t)
115 (synopsis
116 "GNU Ncurses, a free software emulation of curses in SVR4 and more")
117 (description
118 "The Ncurses (new curses) library is a free software emulation of curses
119 in System V Release 4.0, and more. It uses Terminfo format, supports pads
120 and color and multiple highlights and forms characters and function-key
121 mapping, and has all the other SYSV-curses enhancements over BSD Curses.
122
123 The ncurses code was developed under GNU/Linux. It has been in use for some
124 time with OpenBSD as the system curses library, and on FreeBSD and NetBSD as
125 an external package. It should port easily to any ANSI/POSIX-conforming
126 UNIX. It has even been ported to OS/2 Warp!")
127 (license x11)
128 (home-page "http://www.gnu.org/software/ncurses/"))))