guile-netlink/doc/build.scm

build.scm

1
;;;; This file is part of Guile Netlink
2
;;;;
3
;;;; Copyright (C) 2020 Julien Lepiller <julien@lepiller.eu>
4
;;;; 
5
;;;; This library is free software: you can redistribute it and/or modify
6
;;;; it under the terms of the GNU General Public License as published by
7
;;;; the Free Software Foundation, either version 3 of the License, or
8
;;;; (at your option) any later version.
9
;;;;
10
;;;; This library is distributed in the hope that it will be useful,
11
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
;;;; GNU General Public License for more details.
14
;;;;
15
;;;; You should have received a copy of the GNU General Public License
16
;;;; along with this library.  If not, see <https://www.gnu.org/licenses/>.
17
18
(use-modules (guix gexp)
19
             (guix utils)
20
             (git)
21
             (gnu packages base)
22
             (gnu packages texinfo))
23
24
(define %makeinfo-html-options
25
  ;; Options passed to 'makeinfo --html'.
26
  '("--css-ref=https://www.gnu.org/software/gnulib/manual.css"
27
    "-c" "EXTRA_HEAD=<meta name=\"viewport\" \
28
content=\"width=device-width, initial-scale=1\" />"))
29
30
(define* (texinfo-source source #:key (version "unknown"))
31
  (define texi-source
32
    (local-file
33
      (string-append (local-file-absolute-file-name source) "/doc/guile-netlink.texi")
34
      "guile-netlink.texi"))
35
36
  (define version.texi
37
    (plain-file
38
      "version.texi"
39
      (format #f "@set UPDATED unknown
40
@set UPDATED-MONTH unknown
41
@set EDITION unknown
42
@set VERSION ~a\n" version)))
43
44
  (define build
45
    (with-imported-modules '((guix build utils))
46
      #~(begin
47
          (use-modules (guix build utils))
48
          (mkdir-p #$output)
49
          (symlink #$version.texi (string-append #$output "/version.texi"))
50
          (symlink #$texi-source (string-append #$output "/guile-netlink.texi")))))
51
52
  (computed-file "texinfo-manual-source" build))
53
54
(define* (build-manual source #:key (version "unknown"))
55
  (define texi (texinfo-source source #:version version))
56
57
  (define build
58
    (with-imported-modules '((guix build utils))
59
      #~(begin
60
          (use-modules (guix build utils))
61
          (setenv "GUIX_LOCPATH"
62
                  #+(file-append glibc-utf8-locales "/lib/locale"))
63
          (setenv "LC_ALL" "en_US.utf8")
64
          (setlocale LC_ALL "en_US.utf8")
65
66
          (mkdir-p (string-append #$output "/html_node"))
67
68
          (apply invoke
69
                 #$(file-append texinfo "/bin/makeinfo")
70
                 "-o" (string-append #$output "/html_node")
71
                 "--html" "-c" "TOP_NODE_UP_URL=/guile-netlink/manual"
72
                 (string-append #$texi "/guile-netlink.texi")
73
                 '#$%makeinfo-html-options)
74
          (apply invoke
75
                 #$(file-append texinfo "/bin/makeinfo")
76
                 "--no-split"
77
                 "-o" (string-append #$output "/manual.html")
78
                 "--html" "-c" "TOP_NODE_UP_URL=/guile-netlink/manual"
79
                 (string-append #$texi "/guile-netlink.texi")
80
                 '#$%makeinfo-html-options))))
81
82
  (computed-file "manual" build))
83
84
(let* ((root (canonicalize-path
85
              (string-append (current-source-directory) "/..")))
86
       (source (local-file root "guix" #:recursive? #t)))
87
  (build-manual source))
88