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