gnu: Use 'modify-phases' syntax.
[jackhill/guix/guix.git] / gnu / packages / lout.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 (gnu packages lout)
20 #:use-module (guix licenses)
21 #:use-module (guix packages)
22 #:use-module (guix download)
23 #:use-module (guix build-system gnu)
24 #:use-module (gnu packages ghostscript))
25
26 (define-public lout
27 ;; This one is a bit tricky, because it doesn't follow the GNU Build System
28 ;; rules. Instead, it has a makefile that has to be patched to set the
29 ;; prefix, etc., and it has no makefile rules to build its doc.
30 (let ((configure-phase
31 ')
32 (install-man-phase
33 ')
34 (doc-phase
35 '))
36 (package
37 (name "lout")
38 (version "3.40")
39 (source (origin
40 (method url-fetch)
41 (uri (string-append "mirror://savannah/lout/lout-"
42 version ".tar.gz"))
43 (sha256
44 (base32
45 "1gb8vb1wl7ikn269dd1c7ihqhkyrwk19jwx5kd0rdvbk6g7g25ix"))))
46 (build-system gnu-build-system) ; actually, just a makefile
47 (outputs '("out" "doc"))
48 (native-inputs
49 `(("ghostscript" ,ghostscript)))
50 (arguments
51 `(#:modules ((guix build utils)
52 (guix build gnu-build-system)
53 (srfi srfi-1)) ; we need SRFI-1
54 #:tests? #f ; no "check" target
55
56 ;; Customize the build phases.
57 #:phases
58 (modify-phases %standard-phases
59 (replace 'configure
60 (lambda* (#:key outputs #:allow-other-keys)
61 (let ((out (assoc-ref outputs "out"))
62 (doc (assoc-ref outputs "doc")))
63 (substitute* "makefile"
64 (("^PREFIX[[:blank:]]*=.*$")
65 (string-append "PREFIX = " out "\n"))
66 (("^LOUTLIBDIR[[:blank:]]*=.*$")
67 (string-append "LOUTLIBDIR = " out "/lib/lout\n"))
68 (("^LOUTDOCDIR[[:blank:]]*=.*$")
69 (string-append "LOUTDOCDIR = " doc "/share/doc/lout\n"))
70 (("^MANDIR[[:blank:]]*=.*$")
71 (string-append "MANDIR = " out "/man\n")))
72 (mkdir out)
73 (mkdir (string-append out "/bin"))
74 (mkdir (string-append out "/lib"))
75 (mkdir (string-append out "/man"))
76 (mkdir-p (string-append doc "/share/doc/lout")))
77 #t))
78 (add-after 'install 'install-man-pages
79 (lambda* (#:key outputs #:allow-other-keys)
80 (zero? (system* "make" "installman"))))
81 (add-after 'install 'install-doc
82 (lambda* (#:key outputs #:allow-other-keys)
83 (define out
84 (assoc-ref outputs "doc"))
85
86 (setenv "PATH"
87 (string-append (assoc-ref outputs "out")
88 "/bin:" (getenv "PATH")))
89 (chdir "doc")
90 (every (lambda (doc)
91 (format #t "doc: building `~a'...~%" doc)
92 (with-directory-excursion doc
93 (let ((file (string-append out "/share/doc/lout/"
94 doc ".ps")))
95 (and (or (file-exists? "outfile.ps")
96 (zero? (system* "lout" "-r4" "-o"
97 "outfile.ps" "all")))
98 (begin
99 (copy-file "outfile.ps" file)
100 #t)
101 (zero? (system* "ps2pdf"
102 "-dPDFSETTINGS=/prepress"
103 "-sPAPERSIZE=a4"
104 file
105 (string-append out "/share/doc/lout/"
106 doc ".pdf")))))))
107 '("design" "expert" "slides" "user")))))))
108 (synopsis "Document layout system")
109 (description
110 "The Lout document formatting system reads a high-level description of
111 a document similar in style to LaTeX and produces a PostScript or plain text
112 output file.
113
114 Lout offers an unprecedented range of advanced features, including optimal
115 paragraph and page breaking, automatic hyphenation, PostScript EPS file
116 inclusion and generation, equation formatting, tables, diagrams, rotation and
117 scaling, sorted indexes, bibliographic databases, running headers and
118 odd-even pages, automatic cross referencing, multilingual documents including
119 hyphenation (most European languages are supported), formatting of computer
120 programs, and much more, all ready to use. Furthermore, Lout is easily
121 extended with definitions which are very much easier to write than troff of
122 TeX macros because Lout is a high-level, purely functional language, the
123 outcome of an eight-year research project that went back to the
124 beginning.")
125 (license gpl3+)
126 (home-page "http://savannah.nongnu.org/projects/lout/"))))