aboutsummaryrefslogtreecommitdiffstats
path: root/mk/texinfo.mk
blob: d08cb6b9a4e959f78de2a2a19cd426347995b83e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# 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.


# TODO ((support translations))
#=== 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 += $(v)doc/info/*.texinfo
endif
ifneq ($(_TEXINFO_DIRLEVELS),1)
ifeq ($(_TEXINFO_DIRLEVELS),2)
__TEXI_SRC += $(v)doc/info/*.texinfo
__TEXI_SRC += $(v)doc/info/*/*.texinfo
endif
ifneq ($(_TEXINFO_DIRLEVELS),2)
__TEXI_SRC += $(foreach W,$(shell $(SEQ) $(_TEXINFO_DIRLEVELS) | while read n; do $(ECHO) $$($(SEQ) $$n)" " | $(SED) 's/[^ ]* /\/\*/g'; done | $(XARGS) $(ECHO)),$(v)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.
aux/$(_LOGO).svg: $(v)doc/$(_LOGO).svg
	@$(PRINTF_INFO) '\e[00;01;31mCP\e[34m %s\e[00m$A\n' "$@"
	@$(MKDIR) -p aux
	$(Q)$(CP) $^ $@ #$Z
	@$(ECHO_EMPTY)

# Intermediate format for the logo for DVI and PostScript manuals.
aux/$(_LOGO).ps: $(v)doc/$(_LOGO).svg
	@$(PRINTF_INFO) '\e[00;01;31mPS\e[34m %s\e[00m$A\n' "$@"
	@$(MKDIR) -p aux
	$(Q)$(SVG2PS) $^ > $@ #$Z
	@$(ECHO_EMPTY)

# Logo for DVI and PostScript manuals.
aux/$(_LOGO).eps: aux/$(_LOGO).ps
	@$(PRINTF_INFO) '\e[00;01;31mEPS\e[34m %s\e[00m$A\n' "$@"
	$(Q)$(PS2EPS) $^ #$Z
	@$(ECHO_EMPTY)

# Logo for PDF manual.
aux/$(_LOGO).pdf: doc/$(_LOGO).svg
	@$(PRINTF_INFO) '\e[00;01;31mPDF\e[34m %s\e[00m$A\n' "$@"
	@$(MKDIR) -p aux
	$(Q)$(SVG2PDF) $^ > $@ #$Z
	@$(ECHO_EMPTY)
endif

# Build info manual.
.PHONY: info
info: bin/$(_PROJECT).info
bin/%.info $(foreach P,$(__INFOPARTS),bin/%.info-$(P)): $(v)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: $(v)doc/info/%.texinfo $(__TEXI_SRC) $(foreach L,$(_LOGO),aux/$(L).eps)
	@$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
	@! $(TEST) -d aux/dvi/$* || $(RM) -rf aux/dvi/$*
	@$(MKDIR) -p aux/dvi/$* bin
	$(Q)cd aux/dvi/$* && $(TEXI2DVI) $(__back3unless_v)$< $(__TEXINFO_FLAGS) < /dev/null #$Z
	@$(PRINTF_INFO) '$A'
	$(Q)$(MV) aux/dvi/$*/$*.dvi $@ #$Z
	@$(ECHO_EMPTY)

# Build PDF manual.
.PHONY: pdf
pdf: bin/$(_PROJECT).pdf
bin/%.pdf: $(v)doc/info/%.texinfo $(__TEXI_SRC) $(foreach L,$(_LOGO),aux/$(L).pdf)
	@$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
	@! $(TEST) -d aux/pdf/$* || $(RM) -rf aux/pdf/$*
	@$(MKDIR) -p aux/pdf/$* bin
	$(Q)cd aux/pdf/$* && $(TEXI2PDF) $(__back3unless_v)$< $(__TEXINFO_FLAGS) < /dev/null #$Z
	@$(PRINTF_INFO) '$A'
	$(Q)$(MV) aux/pdf/$*/$*.pdf $@ #$Z
	@$(ECHO_EMPTY)

# Build PostScript manual.
.PHONY: ps
ps: bin/$(_PROJECT).ps
bin/%.ps: $(v)doc/info/%.texinfo $(__TEXI_SRC) $(foreach L,$(_LOGO),aux/$(L).eps)
	@$(PRINTF_INFO) '\e[00;01;31mTEXI\e[34m %s\e[00m$A\n' "$@"
	@! $(TEST) -d aux/ps/$* || $(RM) -rf aux/ps/$*
	@$(MKDIR) -p aux/ps/$* bin
	$(Q)cd aux/ps/$* && $(TEXI2PS) $(__back3unless_v)$< $(__TEXINFO_FLAGS) < /dev/null #$Z
	@$(PRINTF_INFO) '$A'
	$(Q)$(MV) aux/ps/$*/$*.ps $@ #$Z
	@$(ECHO_EMPTY)

# Build HTML manual.
.PHONY: html
html: bin/html/$(_PROJECT)/index.html
bin/html/%/index.html: $(v)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) $(__back2unless_v)$< < /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) bin/$(_PROJECT).info -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info"
	$(Q)$(forearch P,$(__INFOPARTS),$(INSTALL_DATA) bin/$*.info-$(P) -- "$(DESTDIR)$(INFODIR)/$(PKGNAME).info-$(P)" &&) $(TRUE)
ifdef POST_INSTALL
	$(POST_INSTALL)
endif
	$(Q)if $(SHELL) -c '$(N) $(INSTALL_INFO) --version' > /dev/null 2>&1; then  \
	  $(N)$(z) $(INSTALL_INFO) -- "${DESTDIR}${INFODIR}/$(PKGNAME).info" "${DESTDIR}${INFODIR}/dir";  \
	else  \
	  $(TRUE);  \
	fi
ifdef POST_INSTALL
	$(NORMAL_INSTALL)
endif
	@$(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)"
	$(Q)$(INSTALL_DATA) $^ -- "$(DESTDIR)$(HTMLDIR)/$(PKGNAME)/"
	@$(ECHO_EMPTY)


# UNINSTALL RULES:

# Uninstall info manual.
.PHONY: uninstall-info
uninstall-info:
ifdef PRE_UNINSTALL
	$(PRE_UNINSTALL)
endif
	-$(Q)$(N)$(a) $(INSTALL_INFO) --delete -- "${DESTDIR}${INFODIR}/$(PKGNAME).info" "${DESTDIR}${INFODIR}/dir"
ifdef PRE_UNINSTALL
	$(NORMAL_UNINSTALL)
endif
	-$(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)/$(F)")
	-$(Q)$(RM) -- "$(DESTDIR)$(HTMLDIR)/$(PKGNAME)"


endif