lout.scm 5.8 KB

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