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 (add-before 'configure 'link-expat
94 (lambda _
95 ;; Gettext defaults to opening expat via dlopen on
96 ;; "Linux". Change to link directly.
97 (substitute* "gettext-tools/configure"
98 (("LIBEXPAT=\"-ldl\"") "LIBEXPAT=\"-ldl -lexpat\"")
99 (("LTLIBEXPAT=\"-ldl\"") "LTLIBEXPAT=\"-ldl -lexpat\"")))))
100
101 ;; When tests fail, we want to know the details.
102 #:make-flags '("VERBOSE=yes")))
103 (home-page "https://www.gnu.org/software/gettext/")
104 (synopsis
105 "Tools and documentation for translation (used to build other packages)")
106 (description
107 "GNU Gettext is a package providing a framework for translating the
108 textual output of programs into multiple languages. It provides translators
109 with the means to create message catalogs, and a runtime library to load
110 translated messages from the catalogs. Nearly all GNU packages use Gettext.")
111 (license gpl3+))) ;some files are under GPLv2+
112
113 ;; Use that name to avoid clashes with Guile's 'gettext' procedure.
114 ;;
115 ;; We used to resort to #:renamer on the user side, but that prevented
116 ;; circular dependencies involving (gnu packages gettext). This is because
117 ;; 'resolve-interface' (as of Guile 2.0.9) iterates eagerly over the used
118 ;; module when there's a #:renamer, and that module may be empty at that point
119 ;; in case or circular dependencies.
120 (define-public gnu-gettext
121 (package
122 (inherit gettext-minimal)
123 (name "gettext")
124 (arguments
125 (substitute-keyword-arguments (package-arguments gettext-minimal)
126 ((#:phases phases)
127 `(modify-phases ,phases
128 (add-after 'install 'add-emacs-autoloads
129 (lambda* (#:key outputs #:allow-other-keys)
130 ;; Make 'po-mode' and other things available by default.
131 (with-directory-excursion
132 (string-append (assoc-ref outputs "out")
133 "/share/emacs/site-lisp")
134 (symlink "start-po.el" "gettext-autoloads.el")
135 #t)))))))
136 (native-inputs `(("emacs" ,emacs-minimal))) ; for Emacs tools
137 (synopsis "Tools and documentation for translation")))
138
139 (define-public po4a
140 (package
141 (name "po4a")
142 (version "0.47")
143 (source (origin
144 (method url-fetch)
145 (uri (string-append "https://alioth.debian.org/frs/download.php"
146 "/file/4142/po4a-" version ".tar.gz"))
147 (sha256
148 (base32
149 "01vm0750aq0h2lphrflv3wq9gz7y0py8frglfpacn58ivyvy242h"))))
150 (build-system perl-build-system)
151 (arguments
152 `(#:phases
153 (modify-phases %standard-phases
154 (add-before 'configure 'set-search-path
155 (lambda _
156 ;; Work around "dotless @INC" build failure.
157 (setenv "PERL5LIB"
158 (string-append (getcwd) ":"
159 (getenv "PERL5LIB")))
160 #t))
161 ;; FIXME: One test fails as we don't have SGMLS.pm
162 (add-before 'check 'disable-sgml-test
163 (lambda _
164 (delete-file "t/20-sgml.t")
165 #t))
166 (add-after 'unpack 'fix-builder
167 (lambda* (#:key inputs outputs #:allow-other-keys)
168 (substitute* "Po4aBuilder.pm"
169 ;; By default it tries to install into perl's manpath.
170 (("my \\$mandir = .*$")
171 (string-append "my $mandir = \"" (assoc-ref outputs "out")
172 "/share/man\";\n")))
173 #t))
174 (add-after 'install 'wrap-programs
175 (lambda* (#:key outputs #:allow-other-keys)
176 ;; Make sure all executables in "bin" find the Perl modules
177 ;; provided by this package at runtime.
178 (let* ((out (assoc-ref outputs "out"))
179 (bin (string-append out "/bin/"))
180 (path (string-append out "/lib/perl5/site_perl")))
181 (for-each (lambda (file)
182 (wrap-program file
183 `("PERL5LIB" ":" prefix (,path))))
184 (find-files bin "\\.*$"))
185 #t)))
186 (add-before 'reset-gzip-timestamps 'make-compressed-files-writable
187 (lambda* (#:key outputs #:allow-other-keys)
188 (for-each make-file-writable
189 (find-files (string-append (assoc-ref outputs "out")
190 "/share/man")
191 ".*\\.gz$"))
192 #t)))))
193 (native-inputs
194 `(("gettext" ,gettext-minimal)
195 ("perl-module-build" ,perl-module-build)
196 ("docbook-xsl" ,docbook-xsl)
197 ("docbook-xml" ,docbook-xml) ;for tests
198 ("texlive" ,texlive-tiny) ;for tests
199 ("libxml2" ,libxml2)
200 ("xsltproc" ,libxslt)))
201 (home-page "http://po4a.alioth.debian.org/")
202 (synopsis "Scripts to ease maintenance of translations")
203 (description
204 "The po4a (PO for anything) project goal is to ease translations (and
205 more interestingly, the maintenance of translations) using gettext tools on
206 areas where they were not expected like documentation.")
207 (license gpl2+)))