1### @configure_input@
2
3# Copyright (C) 1994, 1996-2021 Free Software Foundation, Inc.
4
5# This file is part of GNU Emacs.
6
7# GNU Emacs is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11
12# GNU Emacs is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16
17# You should have received a copy of the GNU General Public License
18# along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
19
20SHELL = @SHELL@
21
22# Where to find the source code.  $(srcdir) will be the doc/misc subdirectory
23# of the source tree.  This is set by configure's '--srcdir' option.
24srcdir=@srcdir@
25top_srcdir = @top_srcdir@
26top_builddir = @top_builddir@
27
28## Where the output files go.
29## Note that all the Info targets build the Info files in srcdir.
30## There is no provision for Info files to exist in the build directory.
31## In a tarfile of Emacs, the Info files should be up to date.
32buildinfodir = $(srcdir)/../../info
33
34## Directory with docstyle.texi and emacsver.texi.
35emacsdir = $(srcdir)/../emacs
36
37prefix = @prefix@
38datarootdir = @datarootdir@
39datadir = @datadir@
40PACKAGE_TARNAME = @PACKAGE_TARNAME@
41docdir = @docdir@
42dvidir = @dvidir@
43htmldir = @htmldir@
44pdfdir = @pdfdir@
45psdir = @psdir@
46
47MKDIR_P = @MKDIR_P@
48
49GZIP_PROG = @GZIP_PROG@
50
51HTML_OPTS = --no-split --html
52
53# Options used only when making info output.
54# (Note that idlwave, info used --nosplit even without the .info extension.)
55INFO_OPTS= --no-split
56
57INSTALL = @INSTALL@
58INSTALL_DATA = @INSTALL_DATA@
59
60# The makeinfo program is part of the Texinfo distribution.
61# Use --force so that it generates output even if there are errors.
62# (TODO?  Why is this appropriate?)
63MAKEINFO = @MAKEINFO@
64MAKEINFO_OPTS = --force -I$(emacsdir)
65
66## On MS Windows, efaq-w32; otherwise blank.
67DOCMISC_W32 = @DOCMISC_W32@
68
69## Info files to build and install on all platforms.
70INFO_COMMON = auth autotype bovine calc ccmode cl \
71	dbus dired-x ebrowse ede ediff edt eieio \
72	emacs-mime epa erc ert eshell eudc efaq eww \
73	flymake forms gnus emacs-gnutls htmlfontify idlwave ido info.info \
74	mairix-el message mh-e modus-themes newsticker nxml-mode octave-mode \
75	org pcl-cvs pgg rcirc remember reftex sasl \
76	sc semantic ses sieve smtpmail speedbar srecode todo-mode tramp \
77	url vhdl-mode vip viper widget wisent woman
78
79## Info files to install on current platform.
80INFO_INSTALL = $(INFO_COMMON) $(DOCMISC_W32)
81
82## Info files to build on current platform.
83## This is all of them, even though they might not all get installed,
84## because the info files are pre-built in release tarfiles.
85INFO_TARGETS = $(INFO_COMMON) efaq-w32
86
87## Some manuals have their source in .org format.
88## This is discouraged because the .texi files it generates
89## are not as well formatted as handwritten ones.
90ORG_SETUP = $(wildcard ${srcdir}/*-setup.org)
91ORG_SRC = $(filter-out ${ORG_SETUP},$(wildcard ${srcdir}/*.org))
92TEXI_FROM_ORG = ${ORG_SRC:.org=.texi}
93
94# There are some naming differences between the info targets and the other
95# targets, so let's resolve them here.
96TARGETS_1 = $(INFO_INSTALL:ccmode=cc-mode)
97TARGETS = $(TARGETS_1:info.info=info)
98
99texi_sources = $(addsuffix .texi,${TARGETS})
100texi_notgen = $(filter-out $(notdir ${TEXI_FROM_ORG}),${texi_sources})
101texi_and_org = $(notdir ${ORG_SRC}) ${texi_notgen}
102SOURCES = $(sort ${texi_and_org})
103
104DVI_TARGETS  = $(TARGETS:=.dvi)
105HTML_TARGETS = $(TARGETS:=.html)
106PDF_TARGETS  = $(TARGETS:=.pdf)
107PS_TARGETS   = $(TARGETS:=.ps)
108
109TEXI2DVI = texi2dvi
110TEXI2PDF = texi2pdf
111DVIPS = dvips
112
113-include ${top_builddir}/src/verbose.mk
114
115ENVADD = $(AM_V_GEN)TEXINPUTS="$(srcdir):$(emacsdir):$(TEXINPUTS)" \
116         MAKEINFO="$(MAKEINFO) $(MAKEINFO_OPTS)"
117
118gfdl = ${srcdir}/doclicense.texi
119style = ${emacsdir}/docstyle.texi
120
121.PHONY: info dvi html pdf ps echo-info echo-sources $(INFO_TARGETS)
122## Prevent implicit rule triggering for foo.info.
123.SUFFIXES:
124
125## Disable implicit rules.
126%.texi: ;
127
128# Default.
129info: $(INFO_TARGETS)
130
131## Used by top-level Makefile.
132## Base file names of output info files.
133INFO_BASES = $(patsubst %.info,%,$(notdir $(INFO_INSTALL)))
134echo-info:
135	@: $(info $(addsuffix .info,$(INFO_BASES)))
136
137echo-sources:
138	@: $(info $(SOURCES))
139
140dvi: $(DVI_TARGETS)
141
142html: $(HTML_TARGETS)
143
144pdf: $(PDF_TARGETS)
145
146ps: $(PS_TARGETS)
147
148${buildinfodir}:
149	${MKDIR_P} $@
150
151### The general case.
152
153EXTRA_OPTS =
154
155${buildinfodir}/%.info: ${srcdir}/%.texi ${gfdl} ${style} | ${buildinfodir}
156	$(AM_V_GEN)$(MAKEINFO) $(MAKEINFO_OPTS) $(INFO_OPTS) $(EXTRA_OPTS) \
157	  -o $@ $<
158
159## The short aliases, eg efaq = $(buildinfodir)/efaq.info.
160define info_template
161 $(1): $$(buildinfodir)/$(1).info
162endef
163
164## "info" is already taken.
165info.info: $(buildinfodir)/info.info
166
167$(foreach ifile,$(filter-out info.info,$(INFO_TARGETS)),$(eval $(call info_template,$(ifile))))
168
169
170%.dvi: ${srcdir}/%.texi ${gfdl} ${style}
171	$(ENVADD) $(TEXI2DVI) $<
172
173%.pdf: ${srcdir}/%.texi ${gfdl} ${style}
174	$(ENVADD) $(TEXI2PDF) $<
175
176%.html: ${srcdir}/%.texi ${gfdl} ${style}
177	$(AM_V_GEN)$(MAKEINFO) $(MAKEINFO_OPTS) $(HTML_OPTS) $(EXTRA_OPTS) \
178	  -o $@ $<
179
180%.ps: %.dvi
181	$(DVIPS) -o $@ $<
182
183
184### The exceptions.
185
186## Extra dependencies.
187
188## FIXME Updating this list manually is unreliable.
189need_emacsver = calc cl dired-x efaq efaq-w32 erc forms ido newsticker reftex remember woman
190need_emacsver_prefix = $(addprefix ${buildinfodir}/,${need_emacsver})
191
192$(need_emacsver_prefix:=.info) $(need_emacsver:=.dvi) $(need_emacsver:=.pdf) $(need_emacsver:=.html) : ${emacsdir}/emacsver.texi
193
194$(buildinfodir)/gnus.info gnus.html: ${srcdir}/gnus-faq.texi
195
196$(buildinfodir)/semantic.info semantic.dvi semantic.pdf semantic.html: ${srcdir}/sem-user.texi
197
198
199## Please can we just rename cc-mode.texi to ccmode.texi...
200${buildinfodir}/ccmode.info: \
201  ${srcdir}/cc-mode.texi ${gfdl} ${style} | ${buildinfodir}
202	$(AM_V_GEN)$(MAKEINFO) $(MAKEINFO_OPTS) $(INFO_OPTS) -o $@ $<
203
204## efaq, efaq_w32 do not depend on gfdl.
205## Maybe we can use .SECONDEXPANSION for this.
206${buildinfodir}/efaq%.info: ${srcdir}/efaq%.texi ${style} | ${buildinfodir}
207	$(AM_V_GEN)$(MAKEINFO) $(MAKEINFO_OPTS) $(INFO_OPTS) -o $@ $<
208
209efaq%.dvi: ${srcdir}/efaq%.texi
210	$(ENVADD) $(TEXI2DVI) $<
211
212efaq%.pdf: ${srcdir}/efaq%.texi
213	$(ENVADD) $(TEXI2PDF) $<
214
215efaq%.html: ${srcdir}/efaq%.texi
216	$(AM_V_GEN)$(MAKEINFO) $(MAKEINFO_OPTS) $(HTML_OPTS) -o $@ $<
217
218${buildinfodir}/emacs-mime.info emacs-mime.html: EXTRA_OPTS = --enable-encoding
219
220gnus_deps = ${srcdir}/gnus.texi ${srcdir}/gnus-faq.texi ${gfdl} ${style}
221gnus.dvi: $(gnus_deps)
222	sed -e '/@iflatex/,/@end iflatex/d' $< > gnustmpdvi.texi
223	$(ENVADD) $(TEXI2DVI) gnustmpdvi.texi
224	cp gnustmpdvi.dvi $@
225	rm gnustmpdvi.*
226
227gnus.pdf: $(gnus_deps)
228	sed -e '/@iflatex/,/@end iflatex/d' $< > gnustmppdf.texi
229	$(ENVADD) $(TEXI2PDF) gnustmppdf.texi
230	cp gnustmppdf.pdf $@
231	rm gnustmppdf.*
232
233${buildinfodir}/tramp.info tramp.html: ${srcdir}/trampver.texi
234
235
236abs_top_builddir = @abs_top_builddir@
237EMACS = ${abs_top_builddir}/src/emacs
238emacs = "${EMACS}" -batch --no-site-file --no-site-lisp --eval '(setq load-prefer-newer t)'
239
240# Generated .texi files go in srcdir so they can be included in the
241# release tarfile along with the others.
242# Work in srcdir (and use abs_top_builddir) so that +setupfile and
243# things like org-setup's "version" macro work.  Sigh.
244define org_template
245 $(1:.org=.texi): $(1) ${top_srcdir}/lisp/org/ox-texinfo.el
246	$${AM_V_GEN}cd "$${srcdir}" && $${emacs} -l ox-texinfo \
247	  -f org-texinfo-export-to-texinfo-batch $$(notdir $$<) $$(notdir $$@)
248endef
249
250$(foreach orgfile,${ORG_SRC},$(eval $(call org_template,$(orgfile))))
251
252## foo.org depends on foo-setup.org, if the latter exists.
253define org_setup_template
254  $(1:-setup.org=.texi): $(1)
255endef
256
257$(foreach orgfile,${ORG_SETUP},$(eval $(call org_setup_template,$(orgfile))))
258
259
260.PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean
261
262mostlyclean:
263	rm -f ./*.aux ./*.log ./*.toc ./*.c[mp] ./*.c[mp]s ./*.fn ./*.fns \
264	  ./*.ky ./*.kys ./*.op ./*.ops ./*.p[gj] ./*.p[gj]s ./*.sc ./*.scs ./*.ss \
265	  ./*.t[gp] ./*.t[gp]s ./*.vr ./*.vrs
266	rm -f gnustmp*
267
268clean: mostlyclean
269	rm -f ./*.dvi ./*.html ./*.pdf ./*.ps
270
271distclean: clean
272	rm -f Makefile
273
274## buildinfodir is relative to srcdir.
275infoclean:
276	for file in $(INFO_TARGETS); do \
277	  file=`echo $${file} | sed 's/\.info$$//'`.info; \
278	  rm -f \
279	    $(buildinfodir)/$${file} \
280	    $(buildinfodir)/$${file}-[1-9] \
281	    $(buildinfodir)/$${file}-[1-9][0-9]; \
282	done
283
284.PHONY: orgclean
285
286orgclean:
287	rm -f ${TEXI_FROM_ORG}
288
289bootstrap-clean maintainer-clean: distclean infoclean orgclean
290	rm -f TAGS
291
292.PHONY: install-dvi install-html install-pdf install-ps install-doc
293
294install-dvi: dvi
295	umask 022; $(MKDIR_P) "$(DESTDIR)$(dvidir)"
296	$(INSTALL_DATA) $(DVI_TARGETS) "$(DESTDIR)$(dvidir)"
297install-html: html
298	umask 022; $(MKDIR_P) "$(DESTDIR)$(htmldir)"
299	$(INSTALL_DATA) $(HTML_TARGETS) "$(DESTDIR)$(htmldir)"
300install-pdf: pdf
301	 umask 022;$(MKDIR_P) "$(DESTDIR)$(pdfdir)"
302	$(INSTALL_DATA) $(PDF_TARGETS) "$(DESTDIR)$(pdfdir)"
303install-ps: ps
304	umask 022; $(MKDIR_P) "$(DESTDIR)$(psdir)"
305	for file in $(PS_TARGETS); do \
306	  $(INSTALL_DATA) $${file} "$(DESTDIR)$(psdir)"; \
307	  [ -n "${GZIP_PROG}" ] || continue; \
308	  rm -f "$(DESTDIR)$(psdir)/$${file}.gz"; \
309	  ${GZIP_PROG} -9n "$(DESTDIR)$(psdir)/$${file}"; \
310	done
311
312## Top-level Makefile installs the Info manuals.
313install-doc: install-dvi install-html install-pdf install-ps
314
315
316
317.PHONY: uninstall-dvi uninstall-html uninstall-pdf uninstall-ps uninstall-doc
318
319uninstall-dvi:
320	for file in $(DVI_TARGETS); do \
321	  rm -f "$(DESTDIR)$(dvidir)/$${file}"; \
322	done
323uninstall-html:
324	for file in $(HTML_TARGETS); do \
325	  rm -f "$(DESTDIR)$(htmldir)/$${file}"; \
326	done
327uninstall-ps:
328	ext= ; [ -n "${GZIP_PROG}" ] && ext=.gz; \
329	for file in $(PS_TARGETS); do \
330	  rm -f "$(DESTDIR)$(psdir)/$${file}$${ext}"; \
331	done
332uninstall-pdf:
333	for file in $(PDF_TARGETS); do \
334	  rm -f "$(DESTDIR)$(pdfdir)/$${file}"; \
335	done
336
337uninstall-doc: uninstall-dvi uninstall-html uninstall-pdf uninstall-ps
338
339
340ETAGS = ../../lib-src/etags${EXEEXT}
341
342${ETAGS}: FORCE
343	$(MAKE) -C $(dir $@) $(notdir $@)
344
345texifiles = $(wildcard ${srcdir}/*.texi)
346
347TAGS: ${ETAGS} $(texifiles)
348	$(AM_V_GEN)${ETAGS} $(texifiles)
349
350tags: TAGS
351.PHONY: tags
352
353FORCE:
354.PHONY: FORCE
355
356### Makefile ends here
357