aboutsummaryrefslogtreecommitdiffstats
path: root/mk/texinfo.mk
diff options
context:
space:
mode:
Diffstat (limited to 'mk/texinfo.mk')
-rw-r--r--mk/texinfo.mk256
1 files changed, 256 insertions, 0 deletions
diff --git a/mk/texinfo.mk b/mk/texinfo.mk
new file mode 100644
index 0000000..163b6e6
--- /dev/null
+++ b/mk/texinfo.mk
@@ -0,0 +1,256 @@
+# Copyright (C) 2015 Mattias Andrée <maandree@member.fsf.org>
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved. This file is offered as-is,
+# without any warranty.
+
+
+#=== These rules are used for Texinfo manuals. ===#
+
+
+# Enables the rules:
+# info Build info manual
+# dvi Build DVI manual
+# pdf Build PDF manual
+# ps Build PostScript manual
+# html Build HTML manual
+# install-info Install info manual
+# install-dvi Install DVI manual
+# install-pdf Install PDF manual
+# install-ps Install PostScript manual
+# install-html Install HTML manual
+#
+# This file is ignored unless
+# _HAVE_TEXINFO_MANUAL is defined.
+#
+# This file can only build output for
+# one Texinfo manual. This manual must
+# be named doc/info/$(_PROJECT).texinfo.
+# Additional sourced are set by specifing
+# how man directories deep doc/info nests
+# in the variable _TEXINFO_DIRLEVELS.
+#
+# If the info manual splits, specify the
+# split-number, of the file with the highest
+# split-number, in the variable _INFOPARTS.
+#
+# If the project has a logo, _LOGO should
+# name the suffixless basename of the SVG
+# files that contains the logo. This file
+# must be located in doc/.
+#
+# _HTML_FILES should the basename (with
+# suffix) of all files generated by `html`.
+
+
+ifdef _HAVE_TEXINFO_MANUAL
+
+
+# WHEN TO BUILD, INSTALL, AND UNINSTALL:
+
+all: info
+everything: info dvi pdf ps html
+doc: info dvi pdf ps html
+install: install-info
+install-everything: install-info install-dvi install-pdf install-ps install-html
+install-doc: install-info install-dvi install-pdf install-ps install-html
+uninstall: uninstall-info uninstall-dvi uninstall-pdf uninstall-ps uninstall-html
+
+
+# HELP VARIABLES:
+
+# Files from which the Texinfo manuals are built.
+__TEXI_SRC =
+ifdef _TEXINFO_DIRLEVELS
+ifeq ($(_TEXINFO_DIRLEVELS),1)
+__TEXI_SRC += doc/info/*.texinfo
+else
+ifeq ($(_TEXINFO_DIRLEVELS),2)
+__TEXI_SRC += doc/info/*.texinfo
+__TEXI_SRC += doc/info/*/*.texinfo
+else
+__TEXI_SRC += $(foreach W,$(shell $(SEQ) $(_TEXINFO_DIRLEVELS) | while read n; do $(ECHO) $$($(SEQ) $$n)" " | $(SED) 's/[^ ]* /\/\*/g'; done | $(XARGS) $(ECHO)),doc/info$(W).texinfo)
+endif
+endif
+endif
+
+# Split parts of the info manual.
+ifdef _INFOPARTS
+ifneq ($(_INFOPARTS),0)
+__INFOPARTS = $(shell $(SEQ))
+endif
+endif
+
+# Flags for TeX processed output.
+__TEXINFO_FLAGS = $(TEXINFO_FLAGS)
+ifdef _LOGO
+__TEXINFO_FLAGS += '--texinfo="@set LOGO $(_LOGO)"'
+endif
+
+
+# BUILD RULES:
+
+ifdef _LOGO
+# Prepare conversion of logo.
+obj/$(_LOGO).svg: doc/$(_LOGO).svg
+ @$(PRINTF_INFO) '\e[00;01;31mCP\e[34m %s\e[00m$A\n' "$@"
+ @$(MKDIR) -p obj
+ $(Q)$(CP) $< $@ #$Z
+ @$(ECHO_EMPTY)
+
+# Intermediate format for the logo for DVI and PostScript manuals.
+obj/$(_LOGO).ps: doc/$(_LOGO).svg
+ @$(PRINTF_INFO) '\e[00;01;31mPS\e[34m %s\e[00m$A\n' "$@"
+ @$(MKDIR) -p obj
+ $(Q)$(SVG2PS) $< > $@ #$Z
+ @$(ECHO_EMPTY)
+
+# Logo for DVI and PostScript manuals.
+obj/$(_LOGO).eps: obj/$(_LOGO).ps
+ @$(PRINTF_INFO) '\e[00;01;31mEPS\e[34m %s\e[00m$A\n' "$@"
+ $(Q)$(PS2EPS) $< #$Z
+ @$(ECHO_EMPTY)
+
+# Logo for PDF manual.
+obj/$(_LOGO).pdf: doc/$(_LOGO).svg
+ @$(PRINTF_INFO) '\e[00;01;31mPDF\e[34m %s\e[00m$A\n' "$@"
+ @$(MKDIR) -p obj
+ $(Q)$(SVG2PDF) $< > $@ #$Z
+ @$(ECHO_EMPTY)
+endif
+
+# Build info manual.
+.PHONY: info
+info: bin/$(_PROJECT).info
+bin/%.info $(foreach P,$(__INFOPARTS),bin/%.info-$(P)): doc/info/%.texinfo $(__TEXI_SRC)
+ @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
+ @$(MKDIR) -p bin
+ $(Q)$(MAKEINFO) $< #$Z
+ @$(PRINTF_INFO) '$A'
+ $(Q)$(MV) $*.info $@ #$Z
+ @$(ECHO_EMPTY)
+
+# Build DVI manual.
+.PHONY: dvi
+dvi: bin/$(_PROJECT).dvi
+bin/%.dvi: doc/info/%.texinfo $(__TEXI_SRC) $(foreach L,$(_LOGO),obj/$(L).eps)
+ @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
+ @! $(TEST) -d obj/dvi/$* || $(RM) -rf obj/dvi/$*
+ @$(MKDIR) -p obj/dvi/$* bin
+ $(Q)cd obj/dvi/$* && $(TEXI2DVI) ../../../$< $(__TEXINFO_FLAGS) < /dev/null #$Z
+ @$(PRINTF_INFO) '$A'
+ $(Q)$(MV) obj/dvi/$*/$*.dvi $@ #$Z
+ @$(ECHO_EMPTY)
+
+# Build PDF manual.
+.PHONY: pdf
+pdf: bin/$(_PROJECT).pdf
+bin/%.pdf: doc/info/%.texinfo $(__TEXI_SRC) $(foreach L,$(_LOGO),obj/$(L).pdf)
+ @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
+ @! $(TEST) -d obj/pdf/$* || $(RM) -rf obj/pdf/$*
+ @$(MKDIR) -p obj/pdf/$* bin
+ $(Q)cd obj/pdf/$* && $(TEXI2PDF) ../../../$< $(__TEXINFO_FLAGS) < /dev/null #$Z
+ @$(PRINTF_INFO) '$A'
+ $(Q)$(MV) obj/pdf/$*/$*.pdf $@ #$Z
+ @$(ECHO_EMPTY)
+
+# Build PostScript manual.
+.PHONY: ps
+ps: bin/$(_PROJECT).ps
+bin/%.ps: doc/info/%.texinfo $(__TEXI_SRC) $(foreach L,$(_LOGO),obj/$(L).eps)
+ @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
+ @! $(TEST) -d obj/ps/$* || $(RM) -rf obj/ps/$*
+ @$(MKDIR) -p obj/ps/$* bin
+ $(Q)cd obj/ps/$* && $(TEXI2PS) ../../../$< $(__TEXINFO_FLAGS) < /dev/null #$Z
+ @$(PRINTF_INFO) '$A'
+ $(Q)$(MV) obj/ps/$*/$*.ps $@ #$Z
+ @$(ECHO_EMPTY)
+
+# Build HTML manual.
+.PHONY: html
+html: bin/html/$(_PROJECT)/index.html
+bin/html/%/index.html: doc/info/%.texinfo $(__TEXI_SRC)
+ @$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
+ @! $(TEST) -d bin/html/$* || $(RM) -rf bin/html/$*
+ @$(MKDIR) -p bin/html
+ $(Q)cd bin/html && $(MAKEINFO_HTML) ../../$< < /dev/null #$Z
+ @$(ECHO_EMPTY)
+
+
+# INSTALL RULES:
+
+# Install info manual.
+.PHONY: install-info
+install-info: bin/$(_PROJECT).info $(foreach P,$(__INFOPARTS),bin/%.info-$(P))
+ @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
+ $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(INFODIR)"
+ $(Q)$(INSTALL_DATA) $< -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info"
+ $(Q)$(forearch P,$(__INFOPARTS),$(INSTALL_DATA) bin/$*.info-$(P) -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info-$(P)" &&) $(TRUE)
+ @$(ECHO_EMPTY)
+
+# Install DVI manual.
+.PHONY: install-dvi
+install-dvi: bin/$(_PROJECT).dvi
+ @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
+ $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(DVIDIR)"
+ $(Q)$(INSTALL_DATA) $< -- "$(DESTDIR)$(DVIDIR)/$(PKGNAME).dvi"
+ @$(ECHO_EMPTY)
+
+# Install PDF manual.
+.PHONY: install-pdf
+install-pdf: bin/$(_PROJECT).pdf
+ @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
+ $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(PDFDIR)"
+ $(Q)$(INSTALL_DATA) $< -- "$(DESTDIR)$(PDFDIR)/$(PKGNAME).pdf"
+ @$(ECHO_EMPTY)
+
+# Install PostScript manual.
+.PHONY: install-ps
+install-ps: bin/$(_PROJECT).ps
+ @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
+ $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(PSDIR)"
+ $(Q)$(INSTALL_DATA) $< -- "$(DESTDIR)$(PSDIR)/$(PKGNAME).ps"
+ @$(ECHO_EMPTY)
+
+# Install HTML manual.
+.PHONY: install-html
+install-html: $(foreach F,$(_HTML_FILES),bin/html/$(_PROJECT)/$(F))
+ @$(PRINTF_INFO) '\e[00;01;31mINSTALL\e[34m %s\e[00m\n' "$@"
+ $(Q)$(INSTALL_DIR) -- "$(DESTDIR)$(HTMLDIR)/$(PKGNAME)/html"
+ $(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(HTMLDIR)/$(PKGNAME)/html/"
+ @$(ECHO_EMPTY)
+
+
+# UNINSTALL RULES:
+
+# Uninstall info manual.
+.PHONY: uninstall-info
+uninstall-info:
+ -$(Q)$(RM) -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info" $(forearch P,$(__INFOPARTS),"$(DESTDIR)$(INFODIR)/$(PKGNAME).info-$(P)")
+
+# Uninstall DVI manual.
+.PHONY: uninstall-dvi
+uninstall-dvi:
+ -$(Q)$(RM) -- "$(DESTDIR)$(DVIDIR)/$(PKGNAME).dvi"
+
+# Uninstall PDF manual.
+.PHONY: uninstall-pdf
+uninstall-pdf:
+ -$(Q)$(RM) -- "$(DESTDIR)$(PDFDIR)/$(PKGNAME).pdf"
+
+# Uninstall PostScript manual.
+.PHONY: uninstall-ps
+uninstall-ps:
+ -$(Q)$(RM) -- "$(DESTDIR)$(PSDIR)/$(PKGNAME).ps"
+
+# Uninstall HTML manual.
+.PHONY: uninstall-html
+uninstall-html:
+ -$(Q)$(RM) -- $(foreach F,$(_HTML_FILES),"$(DESTDIR)$(HTMLDIR)/$(PKGNAME)/html/$(F)")
+ -$(Q)$(RM) -- "$(DESTDIR)$(HTMLDIR)/$(PKGNAME)/html"
+ -$(Q)$(RM) -- "$(DESTDIR)$(HTMLDIR)/$(PKGNAME)"
+
+
+endif
+