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, 2017 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
7 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
8 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
9 ;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
10 ;;;
11 ;;; This file is part of GNU Guix.
12 ;;;
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
17 ;;;
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
22 ;;;
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25
26 (define-module (gnu packages gettext)
27 #:use-module ((guix licenses) #:select (gpl2+ gpl3+))
28 #:use-module (gnu packages)
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system perl)
33 #:use-module (gnu packages docbook)
34 #:use-module (gnu packages emacs)
35 #:use-module (gnu packages perl)
36 #:use-module (gnu packages tex)
37 #:use-module (gnu packages xml)
38 #:use-module (guix utils))
39
40 (define-public gettext-minimal
41 (package
42 (name "gettext-minimal")
43 (version "0.19.8.1")
44 (source (origin
45 (method url-fetch)
46 (uri (string-append "mirror://gnu/gettext/gettext-"
47 version ".tar.gz"))
48 (sha256
49 (base32
50 "0hsw28f9q9xaggjlsdp2qmbp2rbd1mp0njzan2ld9kiqwkq2m57z"))
51 (modules '((guix build utils)))
52 (snippet
53 '(begin
54 ;; The gnulib test-lock test is prone to writer starvation
55 ;; with our glibc@2.25, which prefers readers, so disable it.
56 ;; The gnulib commit b20e8afb0b2 should fix this once
57 ;; incorporated here.
58 (substitute* "gettext-runtime/tests/Makefile.in"
59 (("TESTS = test-lock\\$\\(EXEEXT\\)") "TESTS ="))
60 (substitute* "gettext-tools/gnulib-tests/Makefile.in"
61 (("test-lock\\$\\(EXEEXT\\) ") ""))
62 #t))))
63 (build-system gnu-build-system)
64 (outputs '("out"
65 "doc")) ;8 MiB of HTML
66 (inputs
67 `(("expat" ,expat)))
68 (arguments
69 `(#:phases
70 (modify-phases %standard-phases
71 (add-before 'check 'patch-tests
72 (lambda* (#:key inputs #:allow-other-keys)
73 (let* ((bash (which "sh")))
74 ;; Some of the files we're patching are
75 ;; ISO-8859-1-encoded, so choose it as the default
76 ;; encoding so the byte encoding is preserved.
77 (with-fluids ((%default-port-encoding #f))
78 (substitute*
79 (find-files "gettext-tools/tests"
80 "^(lang-sh|msg(exec|filter)-[0-9])")
81 (("#![[:blank:]]/bin/sh")
82 (format #f "#!~a" bash)))
83
84 (substitute* (cons "gettext-tools/src/msginit.c"
85 (find-files "gettext-tools/gnulib-tests"
86 "posix_spawn"))
87 (("/bin/sh")
88 bash))
89
90 (substitute* "gettext-tools/src/project-id"
91 (("/bin/pwd")
92 "pwd"))
93
94 #t))))
95 (add-before 'configure 'link-expat
96 (lambda _
97 ;; Gettext defaults to opening expat via dlopen on
98 ;; "Linux". Change to link directly.
99 (substitute* "gettext-tools/configure"
100 (("LIBEXPAT=\"-ldl\"") "LIBEXPAT=\"-ldl -lexpat\"")
101 (("LTLIBEXPAT=\"-ldl\"") "LTLIBEXPAT=\"-ldl -lexpat\""))
102 #t)))
103
104 ;; When tests fail, we want to know the details.
105 #:make-flags '("VERBOSE=yes")))
106 (home-page "https://www.gnu.org/software/gettext/")
107 (synopsis
108 "Tools and documentation for translation (used to build other packages)")
109 (description
110 "GNU Gettext is a package providing a framework for translating the
111 textual output of programs into multiple languages. It provides translators
112 with the means to create message catalogs, and a runtime library to load
113 translated messages from the catalogs. Nearly all GNU packages use Gettext.")
114 (license gpl3+))) ;some files are under GPLv2+
115
116 ;; Use that name to avoid clashes with Guile's 'gettext' procedure.
117 ;;
118 ;; We used to resort to #:renamer on the user side, but that prevented
119 ;; circular dependencies involving (gnu packages gettext). This is because
120 ;; 'resolve-interface' (as of Guile 2.0.9) iterates eagerly over the used
121 ;; module when there's a #:renamer, and that module may be empty at that point
122 ;; in case or circular dependencies.
123 (define-public gnu-gettext
124 (package
125 (inherit gettext-minimal)
126 (name "gettext")
127 (arguments
128 (substitute-keyword-arguments (package-arguments gettext-minimal)
129 ((#:phases phases)
130 `(modify-phases ,phases
131 (add-after 'install 'add-emacs-autoloads
132 (lambda* (#:key outputs #:allow-other-keys)
133 ;; Make 'po-mode' and other things available by default.
134 (with-directory-excursion
135 (string-append (assoc-ref outputs "out")
136 "/share/emacs/site-lisp")
137 (symlink "start-po.el" "gettext-autoloads.el")
138 #t)))))))
139 (native-inputs `(("emacs" ,emacs-minimal))) ; for Emacs tools
140 (synopsis "Tools and documentation for translation")))
141
142 (define-public po4a
143 (package
144 (name "po4a")
145 (version "0.47")
146 (source (origin
147 (method url-fetch)
148 (uri (string-append "https://alioth.debian.org/frs/download.php"
149 "/file/4142/po4a-" version ".tar.gz"))
150 (sha256
151 (base32
152 "01vm0750aq0h2lphrflv3wq9gz7y0py8frglfpacn58ivyvy242h"))))
153 (build-system perl-build-system)
154 (arguments
155 `(#:phases
156 (modify-phases %standard-phases
157 (add-before 'configure 'set-search-path
158 (lambda _
159 ;; Work around "dotless @INC" build failure.
160 (setenv "PERL5LIB"
161 (string-append (getcwd) ":"
162 (getenv "PERL5LIB")))
163 #t))
164 ;; FIXME: One test fails as we don't have SGMLS.pm
165 (add-before 'check 'disable-sgml-test
166 (lambda _
167 (delete-file "t/20-sgml.t")
168 #t))
169 (add-after 'unpack 'fix-builder
170 (lambda* (#:key inputs outputs #:allow-other-keys)
171 (substitute* "Po4aBuilder.pm"
172 ;; By default it tries to install into perl's manpath.
173 (("my \\$mandir = .*$")
174 (string-append "my $mandir = \"" (assoc-ref outputs "out")
175 "/share/man\";\n")))
176 #t))
177 (add-after 'install 'wrap-programs
178 (lambda* (#:key outputs #:allow-other-keys)
179 ;; Make sure all executables in "bin" find the Perl modules
180 ;; provided by this package at runtime.
181 (let* ((out (assoc-ref outputs "out"))
182 (bin (string-append out "/bin/"))
183 (path (string-append out "/lib/perl5/site_perl")))
184 (for-each (lambda (file)
185 (wrap-program file
186 `("PERL5LIB" ":" prefix (,path))))
187 (find-files bin "\\.*$"))
188 #t)))
189 (add-before 'reset-gzip-timestamps 'make-compressed-files-writable
190 (lambda* (#:key outputs #:allow-other-keys)
191 (for-each make-file-writable
192 (find-files (string-append (assoc-ref outputs "out")
193 "/share/man")
194 ".*\\.gz$"))
195 #t)))))
196 (native-inputs
197 `(("gettext" ,gettext-minimal)
198 ("perl-module-build" ,perl-module-build)
199 ("docbook-xsl" ,docbook-xsl)
200 ("docbook-xml" ,docbook-xml) ;for tests
201 ("texlive" ,texlive-tiny) ;for tests
202 ("libxml2" ,libxml2)
203 ("xsltproc" ,libxslt)))
204 (home-page "https://po4a.org/")
205 (synopsis "Scripts to ease maintenance of translations")
206 (description
207 "The po4a (PO for anything) project goal is to ease translations (and
208 more interestingly, the maintenance of translations) using gettext tools on
209 areas where they were not expected like documentation.")
210 (license gpl2+)))