Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / doc / local.mk
1 # GNU Guix --- Functional package management for GNU
2 # Copyright © 2016 Eric Bavier <bavier@member.fsf.org>
3 # Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
4 # Copyright © 2013 Andreas Enge <andreas@enge.fr>
5 # Copyright © 2016 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
6 # Copyright © 2016, 2018 Mathieu Lirzin <mthl@gnu.org>
7 # Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
8 #
9 # This file is part of GNU Guix.
10 #
11 # GNU Guix is free software; you can redistribute it and/or modify it
12 # under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or (at
14 # your option) any later version.
15 #
16 # GNU Guix is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 info_TEXINFOS = %D%/guix.texi \
25 %D%/guix.fr.texi
26
27 %C%_guix_TEXINFOS = \
28 %D%/contributing.texi \
29 %D%/fdl-1.3.texi
30
31 DOT_FILES = \
32 %D%/images/bootstrap-graph.dot \
33 %D%/images/bootstrap-packages.dot \
34 %D%/images/coreutils-graph.dot \
35 %D%/images/coreutils-bag-graph.dot \
36 %D%/images/service-graph.dot \
37 %D%/images/shepherd-graph.dot
38
39 DOT_VECTOR_GRAPHICS = \
40 $(DOT_FILES:%.dot=%.eps) \
41 $(DOT_FILES:%.dot=%.pdf)
42
43 EXTRA_DIST += \
44 %D%/htmlxref.cnf \
45 $(DOT_FILES) \
46 $(DOT_VECTOR_GRAPHICS) \
47 %D%/images/coreutils-size-map.eps \
48 %D%/environment-gdb.scm \
49 %D%/package-hello.scm
50
51 OS_CONFIG_EXAMPLES_TEXI = \
52 %D%/os-config-bare-bones.texi \
53 %D%/os-config-desktop.texi \
54 %D%/os-config-lightweight-desktop.texi
55
56 TRANSLATED_INFO = \
57 %D%/guix.fr.texi \
58 %D%/contributing.fr.texi
59
60 # Bundle this file so that makeinfo finds it in out-of-source-tree builds.
61 BUILT_SOURCES += $(OS_CONFIG_EXAMPLES_TEXI) $(TRANSLATED_INFO)
62 EXTRA_DIST += $(OS_CONFIG_EXAMPLES_TEXI) $(TRANSLATED_INFO)
63 MAINTAINERCLEANFILES = $(OS_CONFIG_EXAMPLES_TEXI) $(TRANSLATED_INFO)
64
65 PO4A_PARAMS := -M UTF-8 -L UTF-8 #master and localized encoding
66 PO4A_PARAMS += -k 0 # produce an output even if the translation is not complete
67 PO4A_PARAMS += -f texinfo # texinfo format
68
69 # When a change to guix.texi occurs, it is not translated immediately.
70 # Because @pxref and @xref commands are reference to a section by name, they
71 # should be translated. If a modification adds a reference to a section, this
72 # reference is not translated, which means it references a section that does not
73 # exist.
74 # This command loops through the translated files looking for references. For
75 # each of these references, it tries to find the translation and replaces the
76 # reference name, even in untranslated strings.
77 # The last sed is a multiline sed because some references span multiple lines.
78 define xref_command
79 cat "$@.tmp" | egrep '@p?x?ref' -A1 | sed 'N;s|--\n||g;P;D' | sed 's|^| |g' | \
80 tr -d '\012' | sed 's|\(@p\?x\?ref\)|\n\1|g' | egrep '@p?x?ref' | \
81 sed 's|^.*@p\?x\?ref{\([^,}]*\).*$$|\1|g' | sort | uniq | while read e; do \
82 line=$$(grep -n "^msgid \"$$e\"" "$<" | cut -f1 --delimiter=":") ;\
83 ((line++)) ;\
84 if [ "$$line" != "1" ]; then \
85 translation=$$(head -n $$line "$<" | tail -1 | grep msgstr | sed 's|msgstr "\(.*\)"|\1|') ;\
86 if [ "$$translation" != "" ]; then \
87 sed "N;s@\(p\?x\?ref\){$$(echo $$e | sed 's| |[\\n ]|g')\(,\|}\)@\1{$$translation\2@g;P;D" -i "$@.tmp" ;\
88 fi ;\
89 fi ;\
90 done
91 endef
92
93 $(srcdir)/%D%/guix.%.texi: po/doc/guix.%.po $(srcdir)/%D%/contributing.%.texi
94 -$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/guix.texi" -p "$<" -l "$@.tmp"
95 -sed -i "s|guix\.info|$$(basename "$@" | sed 's|texi$$|info|')|" "$@.tmp"
96 -$(xref_command)
97 -mv "$@.tmp" "$@"
98
99 $(srcdir)/%D%/contributing.%.texi: po/doc/guix.%.po po/doc/contributing.%.po
100 -$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/contributing.texi" -p "$(word 2,$^)" -l "$@.tmp"
101 -$(xref_command)
102 -mv "$@.tmp" "$@"
103
104 %D%/os-config-%.texi: gnu/system/examples/%.tmpl
105 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
106 cp "$<" "$@"
107
108 infoimagedir = $(infodir)/images
109 dist_infoimage_DATA = \
110 $(DOT_FILES:%.dot=%.png) \
111 %D%/images/coreutils-size-map.png
112
113 # Try hard to obtain an image size and aspect that's reasonable for inclusion
114 # in an Info or PDF document.
115 DOT_OPTIONS = \
116 -Gratio=.9 -Gnodesep=.005 -Granksep=.00005 \
117 -Nfontsize=9 -Nheight=.1 -Nwidth=.1
118
119 .dot.png:
120 $(AM_V_DOT)$(DOT) -Tpng $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \
121 mv "$(srcdir)/$@.tmp" "$(srcdir)/$@"
122
123 .dot.pdf:
124 $(AM_V_DOT)$(DOT) -Tpdf $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \
125 mv "$(srcdir)/$@.tmp" "$(srcdir)/$@"
126
127 .dot.eps:
128 $(AM_V_DOT)$(DOT) -Teps $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \
129 mv "$(srcdir)/$@.tmp" "$(srcdir)/$@"
130
131 .png.eps:
132 $(AM_V_GEN)convert "$<" "$@-tmp.eps"; \
133 mv "$@-tmp.eps" "$@"
134
135 # We cannot add new dependencies to `%D%/guix.pdf' & co. (info "(automake)
136 # Extending"). Using the `-local' rules is imperfect, because they may be
137 # triggered after the main rule. Oh, well.
138 pdf-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.pdf)
139 info-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.png)
140 ps-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.eps) \
141 $(top_srcdir)/%D%/images/coreutils-size-map.eps
142 dvi-local: ps-local
143
144 ## ----------- ##
145 ## Man pages. ##
146 ## ----------- ##
147
148 # The man pages are generated using GNU Help2man. In makefiles rules they
149 # depend not on the binary, but on the source files. This usage allows a
150 # manual page to be generated by the maintainer and included in the
151 # distribution without requiring the end-user to have 'help2man' installed.
152 # They are built in $(srcdir) like info manuals.
153
154 sub_commands_mans = \
155 $(srcdir)/%D%/guix-archive.1 \
156 $(srcdir)/%D%/guix-build.1 \
157 $(srcdir)/%D%/guix-challenge.1 \
158 $(srcdir)/%D%/guix-download.1 \
159 $(srcdir)/%D%/guix-edit.1 \
160 $(srcdir)/%D%/guix-environment.1 \
161 $(srcdir)/%D%/guix-gc.1 \
162 $(srcdir)/%D%/guix-hash.1 \
163 $(srcdir)/%D%/guix-import.1 \
164 $(srcdir)/%D%/guix-lint.1 \
165 $(srcdir)/%D%/guix-package.1 \
166 $(srcdir)/%D%/guix-publish.1 \
167 $(srcdir)/%D%/guix-pull.1 \
168 $(srcdir)/%D%/guix-refresh.1 \
169 $(srcdir)/%D%/guix-size.1 \
170 $(srcdir)/%D%/guix-system.1
171
172 dist_man1_MANS = \
173 $(srcdir)/%D%/guix.1 \
174 $(sub_commands_mans)
175
176 gen_man = \
177 LANGUAGE= $(top_builddir)/pre-inst-env $(HELP2MAN) \
178 $(HELP2MANFLAGS)
179
180 HELP2MANFLAGS = --source=GNU --info-page=$(PACKAGE_TARNAME)
181
182 $(srcdir)/%D%/guix.1: scripts/guix.in $(sub_commands_mans)
183 -$(AM_V_HELP2MAN)$(gen_man) --output="$@" `basename "$@" .1`
184
185 # The 'case' ensures the man pages are only generated if the corresponding
186 # source script (the first prerequisite) has been changed. The $(GOBJECTS)
187 # prerequisite is solely meant to force these docs to be made only after all
188 # Guile modules have been compiled.
189 $(srcdir)/%D%/guix-%.1: guix/scripts/%.scm $(GOBJECTS)
190 -@case '$?' in \
191 *$<*) $(AM_V_P) && set -x || echo " HELP2MAN $@"; \
192 $(gen_man) --output="$@" "guix $*";; \
193 *) : ;; \
194 esac
195
196 if BUILD_DAEMON
197
198 dist_man1_MANS += $(srcdir)/%D%/guix-daemon.1
199
200 $(srcdir)/%D%/guix-daemon.1: nix/nix-daemon/guix-daemon.cc
201 -$(AM_V_HELP2MAN)$(gen_man) --output="$@" `basename "$@" .1`
202
203 endif