Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / gettext.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
3 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages gettext)
22 #:use-module ((guix licenses) #:select (gpl2+ gpl3+))
23 #:use-module (gnu packages)
24 #:use-module (guix packages)
25 #:use-module (guix download)
26 #:use-module (guix build-system gnu)
27 #:use-module (guix build-system perl)
28 #:use-module (gnu packages docbook)
29 #:use-module (gnu packages perl)
30 #:use-module (gnu packages texlive)
31 #:use-module (gnu packages xml))
32
33 ;; Use that name to avoid clashes with Guile's 'gettext' procedure.
34 ;;
35 ;; We used to resort to #:renamer on the user side, but that prevented
36 ;; circular dependencies involving (gnu packages gettext). This is because
37 ;; 'resolve-interface' (as of Guile 2.0.9) iterates eagerly over the used
38 ;; module when there's a #:renamer, and that module may be empty at that point
39 ;; in case or circular dependencies.
40 (define-public gnu-gettext
41 (package
42 (name "gettext")
43 (version "0.19.6")
44 (source (origin
45 (method url-fetch)
46 (uri (string-append "mirror://gnu/gettext/gettext-"
47 version ".tar.gz"))
48 (sha256
49 (base32
50 "0pb9vp4ifymvdmc31ks3xxcnfqgzj8shll39czmk8c1splclqjzd"))))
51 (build-system gnu-build-system)
52 (inputs
53 `(("expat" ,expat)))
54 (arguments
55 `(#:phases (alist-cons-before
56 'check 'patch-tests
57 (lambda* (#:key inputs #:allow-other-keys)
58 (let* ((bash (which "sh")))
59 ;; Some of the files we're patching are
60 ;; ISO-8859-1-encoded, so choose it as the default
61 ;; encoding so the byte encoding is preserved.
62 (with-fluids ((%default-port-encoding #f))
63 (substitute*
64 (find-files "gettext-tools/tests"
65 "^(lang-sh|msg(exec|filter)-[0-9])")
66 (("#![[:blank:]]/bin/sh")
67 (format #f "#!~a" bash)))
68
69 (substitute* (cons "gettext-tools/src/msginit.c"
70 (find-files "gettext-tools/gnulib-tests"
71 "posix_spawn"))
72 (("/bin/sh")
73 bash))
74
75 (substitute* "gettext-tools/src/project-id"
76 (("/bin/pwd")
77 "pwd")))))
78 (alist-cons-before
79 'configure 'link-expat
80 (lambda _
81 ;; Gettext defaults to opening expat via dlopen on
82 ;; "Linux". Change to link directly.
83 (substitute* "gettext-tools/configure"
84 (("LIBEXPAT=\"-ldl\"") "LIBEXPAT=\"-ldl -lexpat\"")
85 (("LTLIBEXPAT=\"-ldl\"") "LTLIBEXPAT=\"-ldl -lexpat\"")))
86 %standard-phases))
87
88 ;; When tests fail, we want to know the details.
89 #:make-flags '("VERBOSE=yes")))
90 (home-page "http://www.gnu.org/software/gettext/")
91 (synopsis "Tools and documentation for translation")
92 (description
93 "GNU Gettext is a package providing a framework for translating the
94 textual output of programs into multiple languages. It provides translators
95 with the means to create message catalogs, as well as an Emacs mode to work
96 with them, and a runtime library to load translated messages from the
97 catalogs. Nearly all GNU packages use Gettext.")
98 (license gpl3+))) ;some files are under GPLv2+
99
100 (define-public po4a
101 (package
102 (name "po4a")
103 (version "0.47")
104 (source (origin
105 (method url-fetch)
106 (uri (string-append "https://alioth.debian.org/frs/download.php"
107 "/file/4142/po4a-" version ".tar.gz"))
108 (sha256
109 (base32
110 "01vm0750aq0h2lphrflv3wq9gz7y0py8frglfpacn58ivyvy242h"))))
111 (build-system perl-build-system)
112 (arguments
113 `(#:phases
114 (modify-phases %standard-phases
115 ;; FIXME: One test fails as we don't have SGMLS.pm
116 (add-before 'check 'disable-sgml-test
117 (lambda _
118 (delete-file "t/20-sgml.t")
119 #t))
120 (add-after 'unpack 'fix-builder
121 (lambda* (#:key inputs outputs #:allow-other-keys)
122 (substitute* "Po4aBuilder.pm"
123 ;; By default it tries to install into perl's manpath.
124 (("my \\$mandir = .*$")
125 (string-append "my $mandir = \"" (assoc-ref outputs "out")
126 "/share/man\";\n")))
127 #t))
128 (add-after 'install 'wrap-programs
129 (lambda* (#:key outputs #:allow-other-keys)
130 ;; Make sure all executables in "bin" find the Perl modules
131 ;; provided by this package at runtime.
132 (let* ((out (assoc-ref outputs "out"))
133 (bin (string-append out "/bin/"))
134 (path (string-append out "/lib/perl5/site_perl")))
135 (for-each (lambda (file)
136 (wrap-program file
137 `("PERL5LIB" ":" prefix (,path))))
138 (find-files bin "\\.*$"))
139 #t))))))
140 (native-inputs
141 `(("gettext" ,gnu-gettext)
142 ("perl-module-build" ,perl-module-build)
143 ("docbook-xsl" ,docbook-xsl)
144 ("docbook-xml" ,docbook-xml) ;for tests
145 ("texlive-bin" ,texlive-bin) ;for tests
146 ("libxml2" ,libxml2)
147 ("xsltproc" ,libxslt)))
148 (home-page "http://po4a.alioth.debian.org/")
149 (synopsis "Scripts to ease maintenance of translations")
150 (description
151 "The po4a (PO for anything) project goal is to ease translations (and
152 more interestingly, the maintenance of translations) using gettext tools on
153 areas where they were not expected like documentation.")
154 (license gpl2+)))