build.scm
1 | ;;;; Copyright (C) 2020 Julien Lepiller <julien@lepiller.eu> |
2 | ;;;; |
3 | ;;;; This library is free software; you can redistribute it and/or |
4 | ;;;; modify it under the terms of the GNU Lesser General Public |
5 | ;;;; License as published by the Free Software Foundation; either |
6 | ;;;; version 3 of the License, or (at your option) any later version. |
7 | ;;;; |
8 | ;;;; This library is distributed in the hope that it will be useful, |
9 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 | ;;;; Lesser General Public License for more details. |
12 | ;;;; |
13 | ;;;; You should have received a copy of the GNU Lesser General Public |
14 | ;;;; License along with this library; if not, write to the Free Software |
15 | ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
16 | ;;;; |
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 |