doc: Fix minor typo in Programming Interface.
[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, 2018, 2019, 2020 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.de.texi \
26 %D%/guix.es.texi \
27 %D%/guix.fr.texi \
28 %D%/guix.ru.texi \
29 %D%/guix.zh_CN.texi \
30 %D%/guix-cookbook.texi \
31 %D%/guix-cookbook.de.texi
32
33 %C%_guix_TEXINFOS = \
34 %D%/contributing.texi \
35 %D%/fdl-1.3.texi
36
37 DOT_FILES = \
38 %D%/images/bootstrap-graph.dot \
39 %D%/images/bootstrap-packages.dot \
40 %D%/images/coreutils-graph.dot \
41 %D%/images/coreutils-bag-graph.dot \
42 %D%/images/gcc-core-mesboot0-graph.dot \
43 %D%/images/service-graph.dot \
44 %D%/images/shepherd-graph.dot
45
46 DOT_VECTOR_GRAPHICS = \
47 $(DOT_FILES:%.dot=%.eps) \
48 $(DOT_FILES:%.dot=%.pdf)
49
50 EXTRA_DIST += \
51 %D%/htmlxref.cnf \
52 $(DOT_FILES) \
53 $(DOT_VECTOR_GRAPHICS) \
54 %D%/images/coreutils-size-map.eps \
55 %D%/environment-gdb.scm \
56 %D%/package-hello.scm \
57 %D%/package-hello.json
58
59 OS_CONFIG_EXAMPLES_TEXI = \
60 %D%/os-config-bare-bones.texi \
61 %D%/os-config-desktop.texi \
62 %D%/os-config-lightweight-desktop.texi
63
64 TRANSLATED_INFO = \
65 %D%/guix.de.texi \
66 %D%/guix.es.texi \
67 %D%/guix.fr.texi \
68 %D%/guix.ru.texi \
69 %D%/guix.zh_CN.texi \
70 %D%/contributing.de.texi \
71 %D%/contributing.es.texi \
72 %D%/contributing.fr.texi \
73 %D%/contributing.ru.texi \
74 %D%/contributing.zh_CN.texi \
75 %D%/guix-cookbook.de.texi
76
77 # Bundle this file so that makeinfo finds it in out-of-source-tree builds.
78 BUILT_SOURCES += $(OS_CONFIG_EXAMPLES_TEXI) $(TRANSLATED_INFO)
79 EXTRA_DIST += $(OS_CONFIG_EXAMPLES_TEXI) $(TRANSLATED_INFO)
80 MAINTAINERCLEANFILES = $(OS_CONFIG_EXAMPLES_TEXI) $(TRANSLATED_INFO)
81
82 PO4A_PARAMS := -M UTF-8 -L UTF-8 #master and localized encoding
83 PO4A_PARAMS += -k 0 # produce an output even if the translation is not complete
84 PO4A_PARAMS += -f texinfo # texinfo format
85
86 # When a change to guix.texi occurs, it is not translated immediately.
87 # Because @pxref and @xref commands are reference to a section by name, they
88 # should be translated. If a modification adds a reference to a section, this
89 # reference is not translated, which means it references a section that does not
90 # exist.
91 # This command loops through the translated files looking for references. For
92 # each of these references, it tries to find the translation and replaces the
93 # reference name, even in untranslated strings.
94 # The last sed is a multiline sed because some references span multiple lines.
95 define xref_command
96 cat "$@.tmp" | egrep '@p?x?ref' -A1 | sed 'N;s|--\n||g;P;D' | sed 's|^| |g' | \
97 tr -d '\012' | sed 's|\(@p\?x\?ref\)|\n\1|g' | egrep '@p?x?ref' | \
98 sed 's|^.*@p\?x\?ref{\([^,}]*\).*$$|\1|g' | sort | uniq | while read e; do \
99 line=$$(grep -n "^msgid \"$$e\"" "$<" | cut -f1 --delimiter=":") ;\
100 ((line++)) ;\
101 if [ "$$line" != "1" ]; then \
102 translation=$$(head -n $$line "$<" | tail -1 | grep msgstr | sed 's|msgstr "\(.*\)"|\1|') ;\
103 if [ "$$translation" != "" ]; then \
104 sed "N;s@\(p\?x\?ref\){$$(echo $$e | sed 's| |[\\n ]|g')\(,\|}\)@\1{$$translation\2@g;P;D" -i "$@.tmp" ;\
105 fi ;\
106 fi ;\
107 done
108 endef
109
110 $(srcdir)/%D%/guix.%.texi: po/doc/guix-manual.%.po $(srcdir)/%D%/contributing.%.texi
111 -$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/guix.texi" -p "$<" -l "$@.tmp"
112 -sed -i "s|guix\.info|$$(basename "$@" | sed 's|texi$$|info|')|" "$@.tmp"
113 -$(AM_V_POXREF)$(xref_command)
114 -mv "$@.tmp" "$@"
115
116 $(srcdir)/%D%/guix-cookbook.%.texi: po/doc/guix-cookbook.%.po
117 -$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/guix-cookbook.texi" -p "$<" -l "$@.tmp"
118 -sed -i "s|guix-cookbook\.info|$$(basename "$@" | sed 's|texi$$|info|')|" "$@.tmp"
119 -$(AM_V_POXREF)$(xref_command)
120 -mv "$@.tmp" "$@"
121
122 $(srcdir)/%D%/contributing.%.texi: po/doc/guix-manual.%.po
123 -$(AM_V_PO4A)$(PO4A_TRANSLATE) $(PO4A_PARAMS) -m "%D%/contributing.texi" -p "$<" -l "$@.tmp"
124 -$(AM_V_POXREF)$(xref_command)
125 -mv "$@.tmp" "$@"
126
127 %D%/os-config-%.texi: gnu/system/examples/%.tmpl
128 $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
129 cp "$<" "$@"
130
131 infoimagedir = $(infodir)/images
132 dist_infoimage_DATA = \
133 $(DOT_FILES:%.dot=%.png) \
134 %D%/images/coreutils-size-map.png \
135 %D%/images/installer-network.png \
136 %D%/images/installer-partitions.png \
137 %D%/images/installer-resume.png
138
139 # Ask for warnings about cross-referenced manuals that are not listed in
140 # htmlxref.cnf.
141 AM_MAKEINFOHTMLFLAGS = --set-customization-variable CHECK_HTMLXREF=true
142
143 # Try hard to obtain an image size and aspect that's reasonable for inclusion
144 # in an Info or PDF document.
145 DOT_OPTIONS = \
146 -Gratio=.9 -Gnodesep=.005 -Granksep=.00005 \
147 -Nfontsize=9 -Nheight=.1 -Nwidth=.1
148
149 .dot.png:
150 $(AM_V_DOT)$(DOT) -Tpng $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \
151 mv "$(srcdir)/$@.tmp" "$(srcdir)/$@"
152
153 .dot.pdf:
154 $(AM_V_DOT)$(DOT) -Tpdf $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \
155 mv "$(srcdir)/$@.tmp" "$(srcdir)/$@"
156
157 .dot.eps:
158 $(AM_V_DOT)$(DOT) -Teps $(DOT_OPTIONS) < "$<" > "$(srcdir)/$@.tmp"; \
159 mv "$(srcdir)/$@.tmp" "$(srcdir)/$@"
160
161 .png.eps:
162 $(AM_V_GEN)convert "$<" "$@-tmp.eps"; \
163 mv "$@-tmp.eps" "$@"
164
165 # We cannot add new dependencies to `%D%/guix.pdf' & co. (info "(automake)
166 # Extending"). Using the `-local' rules is imperfect, because they may be
167 # triggered after the main rule. Oh, well.
168 pdf-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.pdf)
169 info-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.png)
170 ps-local: $(DOT_FILES=%.dot=$(top_srcdir)/%.eps) \
171 $(top_srcdir)/%D%/images/coreutils-size-map.eps
172 dvi-local: ps-local
173
174 ## ----------- ##
175 ## Man pages. ##
176 ## ----------- ##
177
178 # The man pages are generated using GNU Help2man. In makefiles rules they
179 # depend not on the binary, but on the source files. This usage allows a
180 # manual page to be generated by the maintainer and included in the
181 # distribution without requiring the end-user to have 'help2man' installed.
182 # They are built in $(srcdir) like info manuals.
183
184 sub_commands_mans = \
185 $(srcdir)/%D%/guix-archive.1 \
186 $(srcdir)/%D%/guix-build.1 \
187 $(srcdir)/%D%/guix-challenge.1 \
188 $(srcdir)/%D%/guix-deploy.1 \
189 $(srcdir)/%D%/guix-download.1 \
190 $(srcdir)/%D%/guix-edit.1 \
191 $(srcdir)/%D%/guix-environment.1 \
192 $(srcdir)/%D%/guix-gc.1 \
193 $(srcdir)/%D%/guix-hash.1 \
194 $(srcdir)/%D%/guix-import.1 \
195 $(srcdir)/%D%/guix-lint.1 \
196 $(srcdir)/%D%/guix-package.1 \
197 $(srcdir)/%D%/guix-publish.1 \
198 $(srcdir)/%D%/guix-pull.1 \
199 $(srcdir)/%D%/guix-refresh.1 \
200 $(srcdir)/%D%/guix-size.1 \
201 $(srcdir)/%D%/guix-system.1 \
202 $(srcdir)/%D%/guix-time-machine.1 \
203 $(srcdir)/%D%/guix-weather.1
204
205 # Assume that cross-compiled commands cannot be executed.
206 if !CROSS_COMPILING
207
208 dist_man1_MANS = \
209 $(srcdir)/%D%/guix.1 \
210 $(sub_commands_mans)
211
212 endif
213
214 gen_man = \
215 LANGUAGE= $(top_builddir)/pre-inst-env $(HELP2MAN) \
216 $(HELP2MANFLAGS)
217
218 HELP2MANFLAGS = --source=GNU --info-page=$(PACKAGE_TARNAME)
219
220 $(srcdir)/%D%/guix.1: scripts/guix.in $(sub_commands_mans)
221 -$(AM_V_HELP2MAN)$(gen_man) --output="$@" `basename "$@" .1`
222
223 # The 'case' ensures the man pages are only generated if the corresponding
224 # source script (the first prerequisite) has been changed. The $(GOBJECTS)
225 # prerequisite is solely meant to force these docs to be made only after all
226 # Guile modules have been compiled.
227 $(srcdir)/%D%/guix-%.1: guix/scripts/%.scm $(GOBJECTS)
228 -@case '$?' in \
229 *$<*) $(AM_V_P) && set -x || echo " HELP2MAN $@"; \
230 $(gen_man) --output="$@" "guix $*";; \
231 *) : ;; \
232 esac
233
234 if BUILD_DAEMON
235 if !CROSS_COMPILING
236
237 dist_man1_MANS += $(srcdir)/%D%/guix-daemon.1
238
239 $(srcdir)/%D%/guix-daemon.1: guix-daemon$(EXEEXT)
240 -$(AM_V_HELP2MAN)$(gen_man) --output="$@" `basename "$@" .1`
241
242 endif
243 endif