local.mk 9.2 KB

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