1### @configure_input@
2
3# Copyright (C) 1992-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
20### Commentary:
21
22# make all	to compile and build Emacs.
23# make install	to install it.
24# make TAGS	to update tags tables.
25#
26# make clean  or  make mostlyclean
27#      Delete all files from the current directory that are normally
28#      created by building the program.	 Don't delete the files that
29#      record the configuration.  Also preserve files that could be made
30#      by building, but normally aren't because the distribution comes
31#      with them.
32#
33#      Delete '.dvi' files here if they are not part of the distribution.
34#
35# make distclean
36#      Delete all files from the current directory that are created by
37#      configuring or building the program.  If you have unpacked the
38#      source and built the program without creating any other files,
39#      'make distclean' should leave only the files that were in the
40#      distribution.
41#
42# make maintainer-clean
43#      Delete everything from the current directory that can be
44#      reconstructed with this Makefile.  This typically includes
45#      everything deleted by distclean, plus more: .elc files,
46#      C source files produced by Bison, tags tables, info files,
47#      and so on.
48#
49# make extraclean
50#      Still more severe - delete backup and autosave files, too.
51#      Also generated files that do not normally change and can be slow
52#      to rebuild (eg leim/ja-dic).
53#
54# make bootstrap
55#      Removes all the compiled files to force a new bootstrap from a
56#      clean slate, and then build in the normal way.
57#
58# make docs
59#      Make Emacs documentation files from their sources; requires makeinfo.
60#
61# make check (or check-expensive or check-all)
62#      Run the Emacs test suite.
63#      check-expensive includes additional tests that can be slow.
64#      check-all runs all tests, including ones that can be slow, or
65#        fail unpredictably
66
67SHELL = @SHELL@
68
69DUMPING=@DUMPING@
70
71# This only matters when inheriting a CDPATH not starting with the
72# current directory.
73CDPATH=
74
75# ==================== Things 'configure' Might Edit ====================
76
77cache_file = @cache_file@
78CONFIGURE_FLAGS = --cache-file=$(cache_file)
79
80AWK = @AWK@
81
82EXEEXT=@EXEEXT@
83
84### These help us choose version- and architecture-specific directories
85### to install files in.
86
87### This should be the number of the Emacs version we're building,
88### like '24.5' or '25.0.50'.
89version=@version@
90
91### This should be the name of the configuration we're building Emacs
92### for, like 'x86_64-unknown-linux-gnu' or 'powerpc-ibm-aix7.1.2.0'.
93configuration=@configuration@
94
95### The nt/ subdirectory gets built only for MinGW
96NTDIR=@NTDIR@
97
98# 'make' verbosity.
99AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
100
101AM_V_GEN = $(am__v_GEN_@AM_V@)
102am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
103am__v_GEN_0 = @echo "  GEN     " $@;
104am__v_GEN_1 =
105
106AM_V_at = $(am__v_at_@AM_V@)
107am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
108am__v_at_0 = @
109am__v_at_1 =
110
111# ==================== Where To Install Things ====================
112
113# Location to install Emacs.app under GNUstep / macOS.
114# Later values may use these.
115ns_appbindir=@ns_appbindir@
116ns_appresdir=@ns_appresdir@
117# Either yes or no depending on whether this is a relocatable Emacs.app.
118ns_self_contained=@ns_self_contained@
119
120# The default location for installation.  Everything is placed in
121# subdirectories of this directory.  The default values for many of
122# the variables below are expressed in terms of this one, so you may
123# not need to change them.  This defaults to /usr/local.
124prefix=@prefix@
125
126# Like 'prefix', but used for architecture-specific files.
127exec_prefix=@exec_prefix@
128
129# Where to install Emacs and other binaries that people will want to
130# run directly (like etags).
131bindir=@bindir@
132
133# The root of the directory tree for read-only architecture-independent
134# data files.  ${datadir}, ${infodir} and ${mandir} are based on this.
135datarootdir=@datarootdir@
136
137# Where to install architecture-independent data files.	 ${lispdir}
138# and ${etcdir} are subdirectories of this.
139datadir=@datadir@
140
141# Where to install and expect the files that Emacs modifies as it
142# runs.  These files are all architecture-independent.
143# Right now, this is not used.
144sharedstatedir=@sharedstatedir@
145
146# Where to install and expect executable files to be run by Emacs
147# rather than directly by users (and other architecture-dependent
148# data, although Emacs does not have any).  The executables
149# are actually installed in ${archlibdir}, which is (normally)
150# a subdirectory of this.
151libexecdir=@libexecdir@
152
153# Currently only used for the systemd service file.
154libdir=@libdir@
155
156# Where to install emacs-module.h.
157includedir=@includedir@
158
159# Where to install Emacs's man pages.
160# Note they contain cross-references that expect them to be in section 1.
161mandir=@mandir@
162man1dir=$(mandir)/man1
163
164# Where to install and expect the info files describing Emacs.
165infodir=@infodir@
166# Info files not in the doc/misc directory (we get those via make echo-info).
167INFO_NONMISC=emacs.info eintr.info elisp.info
168
169# If no makeinfo was found and configured --without-makeinfo, "no"; else "yes".
170HAVE_MAKEINFO=@HAVE_MAKEINFO@
171
172# Directory for local state files for all programs.
173localstatedir=@localstatedir@
174
175# Where to look for bitmap files.
176bitmapdir=@bitmapdir@
177
178# Where to find the source code.  The source code for Emacs's C kernel is
179# expected to be in ${srcdir}/src, and the source code for Emacs's
180# utility programs is expected to be in ${srcdir}/lib-src.  This is
181# set by the configure script's '--srcdir' option.
182
183# We use $(srcdir) explicitly in dependencies so as not to depend on VPATH.
184srcdir=@srcdir@
185abs_srcdir=@abs_srcdir@
186
187# Where the manpage source files are kept.
188mansrcdir=$(srcdir)/doc/man
189
190# Tell make where to find source files; this is needed for the makefiles.
191VPATH=@srcdir@
192
193# Where to find the application default.
194x_default_search_path=@x_default_search_path@
195
196# Where the etc/emacs.desktop file is to be installed.
197desktopdir=$(datarootdir)/applications
198
199# Where the etc/emacs.appdata.xml file is to be installed.
200appdatadir=$(datarootdir)/metainfo
201
202# Where the etc/emacs.service file is to be installed.
203# The system value (typically /usr/lib/systemd/user) can be
204# obtained with: pkg-config --variable=systemduserunitdir systemd
205# but that does not respect configure's prefix.
206# It is not clear where we should install this file when
207# prefix != /usr (or /usr/local?) (eg for non-root installs).
208# Other options include ~/.config/systemd/user/,
209# $XDG_RUNTIME_DIR/systemd/user/
210# It seems the user may end up having to make a manual link...
211systemdunitdir=$(libdir)/systemd/user
212
213# Where the etc/images/icons/hicolor directory is to be installed.
214icondir=$(datarootdir)/icons
215
216# The source directory for the icon files.
217iconsrcdir=$(srcdir)/etc/images/icons
218
219# ==================== Emacs-specific directories ====================
220
221# These variables hold the values Emacs will actually use.  They are
222# based on the values of the standard Make variables above.
223
224# Where to install the lisp files distributed with Emacs.
225# This includes the Emacs version, so that the lisp files for different
226# versions of Emacs will install themselves in separate directories.
227lispdir=@lispdir@
228
229# Directories Emacs should search for standard lisp files.
230# The default is ${lispdir}.
231standardlisppath=@standardlisppath@
232
233# Directories Emacs should search for lisp files specific to this
234# site (i.e. customizations), before consulting ${standardlisppath}.
235# This should be a colon-separated list of directories.
236locallisppath=@locallisppath@
237
238# Where Emacs will search to find its lisp files.  Before
239# changing this, check to see if your purpose wouldn't
240# better be served by changing locallisppath.  This
241# should be a colon-separated list of directories.
242# The default is ${locallisppath}:${standardlisppath}.
243lisppath=@lisppath@
244
245# Where Emacs will search for its lisp files while building.
246# This is only used during the process of compiling Emacs,
247# to help Emacs find its lisp files before they've been installed
248# in their final location.
249# This should be a colon-separated list of directories.
250# Normally it points to the lisp/ directory in the sources.
251# NB lread.c relies on lisp/ being first here.
252buildlisppath=${abs_srcdir}/lisp
253
254# Where to install the other architecture-independent
255# data files distributed with Emacs (like the tutorial,
256# the cookie recipes and the Zippy database). This path
257# usually contains the Emacs version number, so the data
258# files for multiple versions of Emacs may be installed
259# at once.
260etcdir=@etcdir@
261
262# Where to put executables to be run by Emacs rather than
263# the user.  This path usually includes the Emacs version
264# and configuration name, so that multiple configurations
265# for multiple versions of Emacs may be installed at
266# once.
267archlibdir=@archlibdir@
268
269# Where to put the etc/DOC file.
270etcdocdir=@etcdocdir@
271
272# User or group of the auxiliary program update-game-score, which is
273# installed on platforms with a game directory shared by multiple users.
274# On other platforms Emacs can update the score files itself.
275gameuser=@gameuser@
276gamegroup=@gamegroup@
277# Where to install game score files, if gameuser or gamegroup is nonempty.
278gamedir=@gamedir@
279# Nonempty if and only if a shared gamedir is used.
280use_gamedir=$(gameuser)$(gamegroup)
281
282# ==================== Utility Programs for the Build ====================
283
284# Allow the user to specify the install program.
285# Note that if the system does not provide a suitable install,
286# configure will use build-aux/install-sh.  Annoyingly, it does
287# not use an absolute path.  So we must take care to always run
288# INSTALL-type commands from the directory containing the Makefile.
289# This explains (I think) the cd thisdir seen in several install rules.
290INSTALL = @INSTALL@
291INSTALL_PROGRAM = @INSTALL_PROGRAM@
292INSTALL_DATA = @INSTALL_DATA@
293INSTALL_INFO = @INSTALL_INFO@
294# By default, we uphold the dignity of our programs.
295INSTALL_STRIP =
296MKDIR_P = @MKDIR_P@
297# Create a link to a file in the same directory as the target.
298LN_S_FILEONLY = @LN_S_FILEONLY@
299
300# We use gzip to compress installed .el and some .txt files.
301GZIP_PROG = @GZIP_PROG@
302
303# ============================= Targets ==============================
304
305# Program name transformation.
306TRANSFORM = @program_transform_name@
307
308# What emacs should be called when installed.
309EMACS_NAME = `echo emacs | sed '$(TRANSFORM)'`
310EMACS = ${EMACS_NAME}${EXEEXT}
311EMACSFULL = `echo emacs-${version} | sed '$(TRANSFORM)'`${EXEEXT}
312
313# Subdirectories to make recursively.
314SUBDIR = $(NTDIR) lib lib-src src lisp
315
316# The subdir makefiles created by config.status.
317SUBDIR_MAKEFILES_IN = @SUBDIR_MAKEFILES_IN@
318SUBDIR_MAKEFILES = $(patsubst ${srcdir}/%,%,${SUBDIR_MAKEFILES_IN:.in=})
319
320# Non-makefile files created by config.status.
321CONFIG_STATUS_FILES_IN = \
322 ${srcdir}/nt/emacs.rc.in ${srcdir}/nt/emacsclient.rc.in \
323 ${srcdir}/doc/man/emacs.1.in ${srcdir}/src/emacs-module.h.in \
324 ${srcdir}/src/module-env-*.h
325
326# Subdirectories to install, and where they'll go.  lib-src's and nt's
327# makefiles know how to install them, so we don't do that here.
328# Directories that cannot simply be copied, eg info, are treated
329# separately.
330COPYDIR = ${srcdir}/etc ${srcdir}/lisp
331COPYDESTS = "$(DESTDIR)${etcdir}" "$(DESTDIR)${lispdir}"
332
333all: ${SUBDIR} info
334
335.PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 etc-emacsver
336
337# If configure were to just generate emacsver.tex from emacsver.tex.in
338# in the normal way, the timestamp of emacsver.tex would always be
339# newer than that of the pdf files, which are prebuilt in release tarfiles.
340# So we use this rule, and move-if-change, to avoid that.
341etc-emacsver:
342	majorversion=`echo ${version} | sed 's/\..*//'`; \
343	sed "s/[@]majorversion@/$${majorversion}/" \
344	  ${srcdir}/etc/refcards/emacsver.tex.in > emacsver.tex.$$$$ && \
345	  ${srcdir}/build-aux/move-if-change emacsver.tex.$$$$ \
346	  ${srcdir}/etc/refcards/emacsver.tex
347
348# The shared gamedir name as a C string literal, or a null ptr if not in use.
349PATH_GAME = $(if $(use_gamedir),"$(gamedir)",((char const *) 0))
350
351# Generate epaths.h from epaths.in.  This target is invoked by 'configure'.
352# See comments in configure.ac for why it is done this way, as opposed
353# to just letting configure generate epaths.h from epaths.in in a
354# similar way to how Makefile is made from Makefile.in.
355epaths-force:
356	@for dir in '$(abs_srcdir)' '$(lispdir)' '$(archlibdir)'; do \
357	  case $$dir in \
358	    *:*) \
359	      printf >&2 "Build or installation directory '%s'\\n" "$$dir"; \
360	      echo >&2 "cannot contain ':'."; \
361	      exit 1;; \
362	  esac; \
363	done
364	@(gamedir='${gamedir}'; \
365	  sed < ${srcdir}/src/epaths.in > epaths.h.$$$$		\
366	  -e 's;\(#.*PATH_LOADSEARCH\).*$$;\1 "${standardlisppath}";' \
367	  -e 's;\(#.*PATH_SITELOADSEARCH\).*$$;\1 "${locallisppath}";' \
368	  -e 's;\(#.*PATH_DUMPLOADSEARCH\).*$$;\1 "${buildlisppath}";' \
369	  -e '/^#define PATH_[^ ]*SEARCH /s/\([":]\):*/\1/g'		\
370	  -e '/^#define PATH_[^ ]*SEARCH /s/:"/"/'			\
371	  -e 's;\(#.*PATH_EXEC\).*$$;\1 "${archlibdir}";'		\
372	  -e 's;\(#.*PATH_INFO\).*$$;\1 "${infodir}";'			\
373	  -e 's;\(#.*PATH_DATA\).*$$;\1 "${etcdir}";'			\
374	  -e 's;\(#.*PATH_BITMAPS\).*$$;\1 "${bitmapdir}";'		\
375	  -e 's;\(#.*PATH_X_DEFAULTS\).*$$;\1 "${x_default_search_path}";' \
376	  -e 's;\(#.*PATH_GAME\).*$$;\1 $(PATH_GAME);'			\
377	  -e 's;\(#.*PATH_DOC\).*$$;\1 "${etcdocdir}";') &&		\
378	${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h
379
380# The w32 build needs a slightly different editing, and it uses
381# nt/epaths.nt as the template.
382#
383# Use the value of ${locallisppath} supplied by 'configure',
384# to support the --enable-locallisppath argument.
385#
386# In this case, the paths written to 'src/epaths.h' must be in native
387# MS-Windows format (e.g. 'c:/foo/bar'), because temacs is a MinGW
388# program that doesn't support MSYS-style paths (e.g. '/c/foo/bar' or
389# '/foo/bar').
390epaths-force-w32:
391	@(w32srcdir=`${srcdir}/build-aux/msys-to-w32 "${abs_srcdir}"`; \
392	  w32prefix=`${srcdir}/build-aux/msys-to-w32 "${prefix}"`; \
393	  w32locallisppath=`${srcdir}/build-aux/msys-to-w32 "${locallisppath}"` ; \
394	  w32locallisppath=$${w32locallisppath//$${w32prefix}/"%emacs_dir%"} ; \
395	  sed < ${srcdir}/nt/epaths.nt > epaths.h.$$$$		\
396	  -e 's;\(#.*PATH_SITELOADSEARCH\).*$$;\1 "'"$${w32locallisppath//;/\\;}"'";' \
397	  -e '/^.*#/s/@VER@/${version}/g' 			\
398	  -e '/^.*#/s/@CFG@/${configuration}/g' 		\
399	  -e "/^.*#/s|@SRC@|$${w32srcdir}|g") &&		\
400	${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h
401
402lib-src src: $(NTDIR) lib
403
404src: lib-src
405
406# We need to build 'emacs' in 'src' to compile the *.elc files in 'lisp'.
407lisp: src
408
409# These targets should be "${SUBDIR} without 'src'".
410lib lib-src lisp nt: Makefile
411	$(MAKE) -C $@ all
412
413# Ideally, VCSWITNESS should be a file that is modified whenever the
414# repository registers a commit from either a local checkin or a
415# repository pull. In git there is no single file that guarantees
416# this, but the local log for the current head should be close enough.
417#
418# Pass an unexpanded $srcdir to src's Makefile, which then
419# expands it using its own value of srcdir (which points to the
420# source directory of src/).
421dirstate = .git/logs/HEAD
422VCSWITNESS = $(if $(wildcard $(srcdir)/$(dirstate)),$$(srcdir)/../$(dirstate))
423src: Makefile
424	$(MAKE) -C $@ VCSWITNESS='$(VCSWITNESS)' all
425
426blessmail: Makefile src
427	$(MAKE) -C lib-src maybe-blessmail
428
429# We used to have one rule per */Makefile.in, but that leads to race
430# conditions with parallel makes, so assume that the timestamp on
431# ./Makefile represents the timestamp on all the other Makefiles.
432# Similarly, assume the timestamp on ./configure represents the
433# timestamp on src/config.in.
434#
435# config.status overrides MAKEFILE_NAME with a bogus name when creating
436# src/epaths.h, so that 'make epaths-force' does not recursively invoke
437# config.status and overwrite config.status while executing it (Bug#11214).
438#
439# 'make bootstrap' overrides MAKEFILE_NAME to a nonexistent file but
440# then attempts to build that file.  This forces 'Makefile', 'lib/Makefile',
441# etc. to be built without running into similar recursion problems.
442MAKEFILE_NAME = Makefile
443$(MAKEFILE_NAME): config.status $(srcdir)/configure \
444	 $(srcdir)/lib/gnulib.mk.in \
445         $(srcdir)/Makefile.in $(SUBDIR_MAKEFILES_IN) $(CONFIG_STATUS_FILES_IN)
446	MAKE='$(MAKE)' ./config.status
447
448# Don't erase these files if make is interrupted while refreshing them.
449.PRECIOUS: Makefile config.status
450
451config.status: ${srcdir}/configure
452	if [ -x ./config.status ]; then	\
453	    $(CFG) ./config.status --recheck;	\
454	else				\
455	    $(CFG) $(srcdir)/configure $(CONFIGURE_FLAGS); \
456	fi
457
458$(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/m4/*.m4
459	cd $(srcdir) && ./autogen.sh autoconf
460
461# ==================== Installation ====================
462
463.PHONY: install install-arch-dep install-arch-indep install-etcdoc install-info
464.PHONY: install-man install-etc install-strip install-$(NTDIR)
465.PHONY: uninstall uninstall-$(NTDIR)
466
467## If we let lib-src do its own installation, that means we
468## don't have to duplicate the list of utilities to install in
469## this Makefile as well.
470
471install: all install-arch-indep install-etcdoc install-arch-dep install-$(NTDIR) blessmail
472	@true
473
474## Ensure that $subdir contains a subdirs.el file.
475## Here and elsewhere, we set the umask so that any created files are
476## world-readable.
477## TODO it might be good to warn about non-standard permissions of
478## pre-existing directories, but that does not seem easy.
479write_subdir=if [ -f "$${subdir}/subdirs.el" ]; \
480	then true; \
481	else \
482	  umask 022; \
483	  ${MKDIR_P} "$${subdir}"; \
484	  (echo "(if (fboundp 'normal-top-level-add-subdirs-to-load-path)"; \
485	   echo "    (normal-top-level-add-subdirs-to-load-path))") \
486	    > "$${subdir}/subdirs.el"; \
487	fi
488
489### Install the executables that were compiled specifically for this machine.
490### We do install-arch-indep first because the executable needs the
491### Lisp files and DOC file to work properly.
492install-arch-dep: src install-arch-indep install-etcdoc install-$(NTDIR)
493	umask 022; ${MKDIR_P} "$(DESTDIR)${bindir}"
494	$(MAKE) -C lib-src install
495ifeq (${ns_self_contained},no)
496	${INSTALL_PROGRAM} $(INSTALL_STRIP) src/emacs${EXEEXT} "$(DESTDIR)${bindir}/$(EMACSFULL)"
497ifeq (${DUMPING},pdumper)
498	${INSTALL_DATA} src/emacs.pdmp "$(DESTDIR)${libexecdir}/emacs/${version}/${configuration}"/emacs.pdmp
499endif
500	-chmod 755 "$(DESTDIR)${bindir}/$(EMACSFULL)"
501ifndef NO_BIN_LINK
502	rm -f "$(DESTDIR)${bindir}/$(EMACS)"
503	cd "$(DESTDIR)${bindir}" && $(LN_S_FILEONLY) "$(EMACSFULL)" "$(EMACS)"
504endif
505else
506	subdir=${ns_appresdir}/site-lisp && ${write_subdir}
507	rm -rf ${ns_appresdir}/share
508endif
509
510### Windows-specific install target for installing programs produced
511### in nt/, and its Posix do-nothing shadow.
512install-:
513install-nt:
514	$(MAKE) -C $(NTDIR) install
515
516## In the share directory, we are deleting:
517## applications (with emacs.desktop, also found in etc/)
518## emacs (basically empty except for unneeded site-lisp directories)
519## icons (duplicates etc/images/icons/hicolor)
520
521## This is install-etc for everything except self-contained-ns builds.
522## For them, it is empty.
523INSTALL_ARCH_INDEP_EXTRA = @INSTALL_ARCH_INDEP_EXTRA@
524
525## https://lists.gnu.org/r/emacs-devel/2007-10/msg01672.html
526## Needs to be the user running install, so configure can't set it.
527set_installuser=for installuser in $${LOGNAME} $${USERNAME} $${USER} \
528	  `(id -u) 2> /dev/null`; do \
529	  [ -n "$${installuser}" ] && break ; \
530	done; \
531	installgroup=`(id -g) 2>/dev/null` && [ -n "$$installgroup" ] && \
532	  installuser=$$installuser:$$installgroup
533
534### Install the files that are machine-independent.
535### Most of them come straight from the distribution; the exception is
536### the DOC file, which is copied from the build directory.
537
538## We delete each directory in ${COPYDESTS} before we copy into it;
539## that way, we can reinstall over directories that have been put in
540## place with their files read-only (perhaps because they are checked
541## into RCS).  In order to make this safe, we make sure that the
542## source exists and is distinct from the destination.
543
544## We delete etc/DOC* because there may be irrelevant DOC files from
545## other builds in the source directory.  This is ok because we just
546## deleted the entire installed etc/ directory and recreated it.
547## install-etcdoc installs the relevant DOC.
548
549## Note that we install etc/refcards/*.ps if present.
550## TODO we should compress these if GZIP_PROG is set.
551## It would be simpler to have a separate install rule for etc/refcards
552## (maybe move it to doc/refcards?).
553
554## Note that the Makefiles in the etc directory are potentially useful
555## in an installed Emacs, so should not be excluded.
556
557## We always create the _default_ locallisppath directories, and
558## ensure that they contain a subdirs.el file (via write_subdir).
559## This is true even if locallisppath has a non-default value.
560## In case of non-default value, we used to create the specified directories,
561## but not add subdirs.el to them.  This was a strange halfway house.
562## Nowadays we do not create non-default directories.
563
564## Note that we use tar instead of plain old cp -R/-r because the latter
565## is apparently not portable (even in 2012!).
566## https://lists.gnu.org/r/emacs-devel/2012-05/msg00278.html
567## I have no idea which platforms Emacs supports where cp -R does not
568## work correctly, and therefore no idea when tar can be replaced.
569## See also these comments from 2004 about cp -r working fine:
570## https://lists.gnu.org/r/autoconf-patches/2004-11/msg00005.html
571install-arch-indep: lisp install-info install-man ${INSTALL_ARCH_INDEP_EXTRA}
572	umask 022 && $(MKDIR_P) "$(DESTDIR)$(includedir)"
573	$(INSTALL_DATA) src/emacs-module.h "$(DESTDIR)$(includedir)/emacs-module.h"
574	-set ${COPYDESTS} ; \
575	unset CDPATH; \
576	$(set_installuser); \
577	for dir in ${COPYDIR} ; do \
578	  [ -d $${dir} ] || exit 1 ; \
579	  dest="$$1" ; shift ; \
580	  if [ -d "$${dest}" ]; then \
581	    exp_dest=`cd "$${dest}" && /bin/pwd`; \
582	    [ "$$exp_dest" = "`cd $${dir} && /bin/pwd`" ] && continue ; \
583	  else true; \
584	  fi; \
585	  rm -rf "$${dest}" ; \
586	  umask 022; ${MKDIR_P} "$${dest}" ; \
587	  printf 'Copying %s to %s...\n' "$$dir" "$$dest" ; \
588	  (cd $${dir}; tar -chf - . ) \
589	    | (cd "$${dest}"; umask 022; \
590	       tar -xvf - && cat > /dev/null) || exit 1; \
591	  if [ "$${dir}" = "${srcdir}/etc" ]; then \
592	      rm -f "$${dest}/DOC"* ; \
593	      rm -f "$${dest}/refcards"/*.aux "$${dest}/refcards"/*.dvi; \
594	      rm -f "$${dest}/refcards"/*.log "$${dest}/refcards"/*.in; \
595	  else true; \
596	  fi; \
597	  (cd "$${dest}" || exit 1; \
598	    for subdir in `find . -type d -print` ; do \
599	      chmod a+rx $${subdir} ; \
600	      rm -f $${subdir}/.gitignore ; \
601	      rm -f $${subdir}/.arch-inventory ; \
602	      rm -f $${subdir}/.DS_Store ; \
603	      rm -f $${subdir}/#* ; \
604	      rm -f $${subdir}/.#* ; \
605	      rm -f $${subdir}/*~ ; \
606	      rm -f $${subdir}/*.orig ; \
607	      rm -f $${subdir}/ChangeLog* ; \
608	      [ "$${dir}" != "${srcdir}/etc" ] && \
609	        rm -f $${subdir}/[mM]akefile*[.-]in $${subdir}/[mM]akefile ; \
610	    done ); \
611	  find "$${dest}" -exec chown $${installuser} {} ';' ;\
612	done
613	-rm -f "$(DESTDIR)${lispdir}/subdirs.el"
614	umask 022; $(srcdir)/build-aux/update-subdirs "$(DESTDIR)${lispdir}"
615	subdir="$(DESTDIR)${datadir}/emacs/${version}/site-lisp" ; \
616	  ${write_subdir}
617	subdir="$(DESTDIR)${datadir}/emacs/site-lisp" ; \
618	  ${write_subdir} || true
619	[ -z "${GZIP_PROG}" ] || { \
620	  echo "Compressing *.el etc. ..." && \
621	  cd "$(DESTDIR)${lispdir}" && \
622	  for f in `find . -name "*.elc" -print | sed 's/.elc$$/.el/'`; do \
623	    ${GZIP_PROG} -9n "$$f"; \
624	  done; \
625	  ${GZIP_PROG} -9n "../etc/publicsuffix.txt"; \
626	}
627	-chmod -R a+r "$(DESTDIR)${datadir}/emacs/${version}" ${COPYDESTS}
628
629## The above chmods are needed because "umask 022; tar ..." is not
630## guaranteed to do the right thing; eg if we are root and tar is
631## preserving source permissions.
632
633## Note that install-arch-indep deletes and recreates the entire
634## installed etc/ directory, so we need it to run before this does.
635install-etcdoc: src install-arch-indep
636	-unset CDPATH; \
637	umask 022; ${MKDIR_P} "$(DESTDIR)${etcdocdir}" ; \
638	exp_etcdocdir=`cd "$(DESTDIR)${etcdocdir}"; /bin/pwd`; \
639	if [ "`cd ./etc; /bin/pwd`" != "$$exp_etcdocdir" ]; \
640	then \
641	   docfile="DOC"; \
642	   printf 'Copying %s to %s ...\n' "etc/$$docfile" \
643	     "$(DESTDIR)${etcdocdir}"; \
644	   ${INSTALL_DATA} etc/$${docfile} "$(DESTDIR)${etcdocdir}/$${docfile}"; \
645	   $(set_installuser); \
646	     chown $${installuser} "$(DESTDIR)${etcdocdir}/$${docfile}" || true ; \
647	else true; fi
648
649## FIXME:
650## If info/dir is missing, but we have install-info, we should let
651## that handle it.  If info/dir is present and we do not have install-info,
652## we should check for missing entries and add them by hand.
653##
654## FIXME:
655## If HAVE_MAKEINFO = no and there are no info files, do not install info/dir.
656install-info: info
657	umask 022; ${MKDIR_P} "$(DESTDIR)${infodir}"
658	-unset CDPATH; \
659	thisdir=`/bin/pwd`; \
660	exp_infodir=`cd "$(DESTDIR)${infodir}" && /bin/pwd`; \
661	if [ "`cd ${srcdir}/info && /bin/pwd`" = "$$exp_infodir" ]; then \
662	  true; \
663	else \
664	   [ -f "$(DESTDIR)${infodir}/dir" ] || \
665	      [ ! -f ${srcdir}/info/dir ] || \
666	      ${INSTALL_DATA} ${srcdir}/info/dir "$(DESTDIR)${infodir}/dir"; \
667	   info_misc=`$(MAKE) --no-print-directory -s -C doc/misc echo-info`; \
668	   cd ${srcdir}/info ; \
669	   for elt in ${INFO_NONMISC} $${info_misc}; do \
670	      test "$(HAVE_MAKEINFO)" = "no" && test ! -f $$elt && continue; \
671	      for f in `ls $$elt $$elt-[1-9] $$elt-[1-9][0-9] 2>/dev/null`; do \
672	       (cd "$${thisdir}"; \
673	        ${INSTALL_DATA} ${srcdir}/info/$$f "$(DESTDIR)${infodir}/$$f"); \
674	        [ -n "${GZIP_PROG}" ] || continue ; \
675	        rm -f "$(DESTDIR)${infodir}/$$f.gz"; \
676	        ${GZIP_PROG} -9n "$(DESTDIR)${infodir}/$$f"; \
677	      done; \
678	     (cd "$${thisdir}"; \
679	      ${INSTALL_INFO} --info-dir="$(DESTDIR)${infodir}" "$(DESTDIR)${infodir}/$$elt"); \
680	   done; \
681	fi
682
683## "gzip || true" is because some gzips exit with non-zero status
684## if compression would not reduce the file size.  Eg, the gzip in
685## OpenBSD 4.9 seems to do this (2013/03).  In Emacs, this can
686## only happen with the tiny ctags.1 manpage.  We don't really care if
687## ctags.1 is compressed or not.  "gzip -f" is another option here,
688## but not sure if portable.
689install-man:
690	umask 022; ${MKDIR_P} "$(DESTDIR)${man1dir}"
691	thisdir=`/bin/pwd`; \
692	cd ${mansrcdir}; \
693	for page in *.1; do \
694	  test "$$page" = ChangeLog.1 && continue; \
695	  dest=`echo "$${page}" | sed -e 's/\.1$$//' -e '$(TRANSFORM)'`.1; \
696	  (cd "$${thisdir}"; \
697	   ${INSTALL_DATA} ${mansrcdir}/$${page} "$(DESTDIR)${man1dir}/$${dest}"); \
698	  [ -n "${GZIP_PROG}" ] || continue ; \
699	  rm -f "$(DESTDIR)${man1dir}/$${dest}.gz"; \
700	  ${GZIP_PROG} -9n "$(DESTDIR)${man1dir}/$${dest}" || true; \
701	done
702
703## Install those items from etc/ that need to end up elsewhere.
704
705## If you prefer, choose "emacs22" at installation time.
706## Note: emacs22 does not have all the resolutions.
707EMACS_ICON=emacs
708
709install-etc:
710	umask 022; ${MKDIR_P} "$(DESTDIR)${desktopdir}"
711	tmp=etc/emacs.tmpdesktop; rm -f $${tmp}; \
712	sed -e "/^Exec=emacs/ s/emacs/${EMACS_NAME}/" \
713	  -e "/^Icon=emacs/ s/emacs/${EMACS_NAME}/" \
714	  ${srcdir}/etc/emacs.desktop > $${tmp}; \
715	${INSTALL_DATA} $${tmp} "$(DESTDIR)${desktopdir}/${EMACS_NAME}.desktop"; \
716	rm -f $${tmp}
717	umask 022; ${MKDIR_P} "$(DESTDIR)${appdatadir}"
718	tmp=etc/emacs.tmpappdata; rm -f $${tmp}; \
719	sed -e "s/emacs\.desktop/${EMACS_NAME}.desktop/" \
720	  ${srcdir}/etc/emacs.appdata.xml > $${tmp}; \
721	${INSTALL_DATA} $${tmp} "$(DESTDIR)${appdatadir}/${EMACS_NAME}.appdata.xml"; \
722	rm -f $${tmp}
723	umask 022; $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)"
724	tmp=etc/emacs.tmpservice; rm -f $${tmp}; \
725	client_name=`echo emacsclient | sed '$(TRANSFORM)'`${EXEEXT}; \
726	sed -e '/^##/d' \
727	  -e "/^Documentation/ s/emacs(1)/${EMACS_NAME}(1)/" \
728	  -e "/^ExecStart/ s|emacs|${bindir}/${EMACS}|" \
729	  -e "/^ExecStop/ s|emacsclient|${bindir}/$${client_name}|" \
730	  ${srcdir}/etc/emacs.service > $${tmp}; \
731	$(INSTALL_DATA) $${tmp} "$(DESTDIR)$(systemdunitdir)/${EMACS_NAME}.service"; \
732	rm -f $${tmp}
733	thisdir=`/bin/pwd`; \
734	cd ${iconsrcdir} || exit 1; umask 022 ; \
735	for dir in */*/apps */*/mimetypes; do \
736	  [ -d $${dir} ] || continue ; \
737	  ( cd "$${thisdir}"; ${MKDIR_P} "$(DESTDIR)${icondir}/$${dir}" ) ; \
738	  for icon in $${dir}/${EMACS_ICON}[.-]*; do \
739	    [ -r $${icon} ] || continue ; \
740	    ext=`echo "$${icon}" | sed -e 's|.*\.||'`; \
741	    dest=`echo "$${icon}" | sed -e 's|.*/||' -e "s|\\.$${ext}\$$||" -e 's/$(EMACS_ICON)/emacs/' -e '$(TRANSFORM)'`.$${ext} ; \
742	    ( cd "$${thisdir}"; \
743	      ${INSTALL_DATA} ${iconsrcdir}/$${icon} "$(DESTDIR)${icondir}/$${dir}/$${dest}" ) \
744	    || exit 1; \
745	  done ; \
746	done
747
748### Build Emacs and install it, stripping binaries while installing them.
749install-strip:
750	$(MAKE) INSTALL_STRIP=-s install
751
752### Delete all the installed files that the 'install' target would
753### create (but not the noninstalled files such as 'make all' would create).
754###
755### Don't delete the lisp and etc directories if they're in the source tree.
756uninstall: uninstall-$(NTDIR) uninstall-doc
757	rm -f "$(DESTDIR)$(includedir)/emacs-module.h"
758	$(MAKE) -C lib-src uninstall
759	-unset CDPATH; \
760	for dir in "$(DESTDIR)${lispdir}" "$(DESTDIR)${etcdir}" ; do 	\
761	  if [ -d "$${dir}" ]; then			\
762	    case `cd "$${dir}" ; /bin/pwd` in		\
763	      "`cd ${srcdir} ; /bin/pwd`"* ) ;;		\
764	      * ) rm -rf "$${dir}" ;;			\
765	    esac ;					\
766	    case "$${dir}" in				\
767	      "$(DESTDIR)${datadir}/emacs/${version}"/* )		\
768	        rm -rf "$(DESTDIR)${datadir}/emacs/${version}"	\
769	      ;;					\
770	    esac ;					\
771	  fi ;						\
772	done
773	-rm -rf "$(DESTDIR)${libexecdir}/emacs/${version}"
774	thisdir=`/bin/pwd`; \
775	(info_misc=`$(MAKE) --no-print-directory -s -C doc/misc echo-info`; \
776	 if cd "$(DESTDIR)${infodir}"; then \
777	   for elt in ${INFO_NONMISC} $${info_misc}; do \
778	     (cd "$${thisdir}"; \
779	      $(INSTALL_INFO) --remove --info-dir="$(DESTDIR)${infodir}" "$(DESTDIR)${infodir}/$$elt"); \
780	     if [ -n "${GZIP_PROG}" ]; then \
781	        ext=.gz; else ext=; fi; \
782	     rm -f $$elt$$ext $$elt-[1-9]$$ext $$elt-[1-9][0-9]$$ext; \
783	   done; \
784	 fi)
785	(if [ -n "${GZIP_PROG}" ]; then \
786	    ext=.gz; else ext=; fi; \
787	 if cd ${mansrcdir}; then \
788	   for page in *.1; do \
789	     rm -f "$(DESTDIR)${man1dir}"/`echo "$${page}" | sed -e 's/\.1$$//' -e '$(TRANSFORM)'`.1$$ext; done; \
790	 fi)
791	rm -f "$(DESTDIR)${bindir}/$(EMACS)" "$(DESTDIR)${bindir}/$(EMACSFULL)"
792	(if cd "$(DESTDIR)${icondir}"; then \
793	   rm -f hicolor/*x*/apps/"${EMACS_NAME}.png" \
794	     "hicolor/scalable/apps/${EMACS_NAME}.svg" \
795	     "hicolor/scalable/apps/${EMACS_NAME}.ico" \
796	     "hicolor/scalable/mimetypes/${EMACS_NAME}-document.svg" \
797	     "hicolor/scalable/mimetypes/${EMACS_NAME}-document23.svg"; \
798	fi)
799	-rm -f "$(DESTDIR)${desktopdir}/${EMACS_NAME}.desktop"
800	-rm -f "$(DESTDIR)${appdatadir}/${EMACS_NAME}.appdata.xml"
801	-rm -f "$(DESTDIR)$(systemdunitdir)/${EMACS_NAME}.service"
802  ifneq (,$(use_gamedir))
803	for file in snake-scores tetris-scores; do \
804	  file="$(DESTDIR)${gamedir}/$${file}"; \
805	  [ -s "$${file}" ] || rm -f "$$file"; \
806	done
807  endif
808
809### Windows-specific uninstall target for removing programs produced
810### in nt/, and its Posix do-nothing shadow.
811uninstall-:
812uninstall-nt:
813	$(MAKE) -C $(NTDIR) uninstall
814
815# ==================== Cleaning up and miscellanea ====================
816
817.PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean extraclean
818
819## Eg:
820## src_clean:
821##     make -C src clean
822define submake_template
823.PHONY: $(1)_$(2)
824$(1)_$(2):
825	$$(MAKE) -C $(1) $(2)
826endef
827
828### 'mostlyclean'
829###      Like 'clean', but may refrain from deleting a few files that people
830###      normally don't want to recompile.  For example, the 'mostlyclean'
831###      target for GCC does not delete 'libgcc.a', because recompiling it
832###      is rarely necessary and takes a lot of time.
833mostlyclean_dirs = src oldXMenu lwlib lib lib-src nt doc/emacs doc/misc \
834  doc/lispref doc/lispintro
835
836$(foreach dir,$(mostlyclean_dirs),$(eval $(call submake_template,$(dir),mostlyclean)))
837
838mostlyclean: $(mostlyclean_dirs:=_mostlyclean)
839	[ ! -d test ] || $(MAKE) -C test $@
840
841### 'clean'
842###      Delete all files from the current directory that are normally
843###      created by building the program.  Don't delete the files that
844###      record the configuration.  Also preserve files that could be made
845###      by building, but normally aren't because the distribution comes
846###      with them.
847###
848###      Delete '.dvi' files here if they are not part of the distribution.
849clean_dirs = $(mostlyclean_dirs) nextstep
850
851$(foreach dir,$(clean_dirs),$(eval $(call submake_template,$(dir),clean)))
852
853clean: $(clean_dirs:=_clean)
854	$(MAKE) -C admin/charsets $@
855	[ ! -d test ] || $(MAKE) -C test $@
856	-rm -f ./*.tmp etc/*.tmp*
857	-rm -rf info-dir.*
858
859### 'bootclean'
860###      Delete all files that need to be remade for a clean bootstrap.
861top_bootclean=\
862	rm -f config.cache config.log ${srcdir}/doc/man/emacs.1
863
864### 'distclean'
865###      Delete all files from the current directory that are created by
866###      configuring or building the program.  If you have unpacked the
867###      source and built the program without creating any other files,
868###      'make distclean' should leave only the files that were in the
869###      distribution.
870top_distclean=\
871	${top_bootclean}; \
872	rm -f config.status config.log~ \
873	  Makefile makefile lib/gnulib.mk ${SUBDIR_MAKEFILES}
874
875distclean_dirs = $(clean_dirs) leim lisp
876
877$(foreach dir,$(distclean_dirs),$(eval $(call submake_template,$(dir),distclean)))
878
879maybeclean_dirs = test admin/grammars admin/unidata admin/charsets
880
881distclean: $(distclean_dirs:=_distclean)
882	for dir in $(filter-out test,$(maybeclean_dirs)); do \
883	  $(MAKE) -C $$dir $@ || exit; \
884	done
885	[ ! -d test ] || $(MAKE) -C test $@
886	${top_distclean}
887
888### 'bootstrap-clean'
889###      Delete everything that can be reconstructed by 'make' and that
890###      needs to be deleted in order to force a bootstrap from a clean state.
891$(foreach dir,$(distclean_dirs),$(eval $(call submake_template,$(dir),bootstrap-clean)))
892
893bootstrap-clean: $(distclean_dirs:=_bootstrap-clean)
894	for dir in $(filter-out test,$(maybeclean_dirs)); do \
895	  $(MAKE) -C $$dir $@ || exit; \
896	done
897	[ ! -d test ] || $(MAKE) -C test $@
898	[ ! -f config.log ] || mv -f config.log config.log~
899	rm -rf ${srcdir}/info
900	rm -f ${srcdir}/etc/refcards/emacsver.tex
901	${top_bootclean}
902
903### 'maintainer-clean'
904###      Delete everything from the current directory that can be
905###      reconstructed with this Makefile.  This typically includes
906###      everything deleted by distclean, plus more: C source files
907###      produced by Bison, tags tables, info files, and so on.
908###
909###      One exception, however: 'make maintainer-clean' should not delete
910###      'configure' even if 'configure' can be remade using a rule in the
911###      Makefile.  More generally, 'make maintainer-clean' should not delete
912###      anything that needs to exist in order to run 'configure' and then
913###      begin to build the program.
914top_maintainer_clean=\
915	${top_distclean}; \
916	rm -fr autom4te.cache
917
918maintainer_clean_dirs = src leim lisp
919
920$(foreach dir,$(maintainer_clean_dirs),$(eval $(call submake_template,$(dir),maintainer-clean)))
921
922maintainer-clean: bootstrap-clean $(maintainer_clean_dirs:=_maintainer-clean)
923	for dir in $(filter-out test,$(maybeclean_dirs)); do \
924	  $(MAKE) -C $$dir $@ || exit; \
925	done
926	[ ! -d test ] || $(MAKE) -C test $@
927	${top_maintainer_clean}
928
929### This doesn't actually appear in the coding standards, but Karl
930### says GCC supports it, and that's where the configuration part of
931### the coding standards seem to come from.  It's like distclean, but
932### it deletes backup and autosave files too.
933### Note that we abuse this in some subdirectories (eg leim),
934### to delete some generated files that are slow to rebuild.
935extraclean_dirs = ${NTDIR} lib-src src leim \
936  admin/charsets admin/grammars admin/unidata lisp lib
937
938$(foreach dir,$(extraclean_dirs),$(eval $(call submake_template,$(dir),extraclean)))
939
940extraclean: $(extraclean_dirs:=_extraclean)
941	${top_maintainer_clean}
942	-rm -f config-tmp-* aclocal.m4 configure
943	-rm -f ./*~ \#* etc/refcards/emacsver.tex doc/emacs/emacsver.texi
944	-rm -f info/*.info info/dir
945	-rmdir info 2>/dev/null
946
947# The src subdir knows how to do the right thing
948# even when the build directory and source dir are different.
949.PHONY: TAGS tags
950# FIXME: We used to include `src` in the dependencies, not sure why.
951# I removed it because it causes `make tags` to build Emacs.
952TAGS tags: lib lib-src # src
953	$(MAKE) -C src tags
954
955CHECK_TARGETS = check check-maybe check-expensive check-all
956.PHONY: $(CHECK_TARGETS)
957$(CHECK_TARGETS): all
958ifeq ($(wildcard test),test)
959	$(MAKE) -C test $@
960else
961	@echo "You do not seem to have the test/ directory."
962	@echo "Maybe you used a release tarfile that lacks tests."
963endif
964
965dist:
966	cd ${srcdir}; ./make-dist
967
968DVIS  = lispref-dvi  lispintro-dvi  emacs-dvi  misc-dvi
969HTMLS = lispref-html lispintro-html emacs-html misc-html
970INFOS = lispref-info lispintro-info emacs-info misc-info
971PDFS  = lispref-pdf  lispintro-pdf  emacs-pdf  misc-pdf
972PSS   = lispref-ps   lispintro-ps   emacs-ps   misc-ps
973
974DOCS = $(DVIS) $(HTMLS) $(INFOS) $(PDFS) $(PSS)
975$(DOCS):
976	$(MAKE) -C doc/$(subst -, ,$@)
977
978.PHONY: $(DOCS) docs pdf ps
979.PHONY: info dvi dist html info-real info-dir check-info
980
981## TODO add etc/refcards.
982docs: $(DOCS)
983dvi: $(DVIS)
984html: $(HTMLS)
985info-real: $(INFOS)
986pdf: $(PDFS)
987ps: $(PSS)
988
989info-dir: ${srcdir}/info/dir
990
991## Hopefully doc/misc/*.texi is not too long for some systems?
992srcdir_doc_info_dir_inputs = \
993  ${srcdir}/doc/emacs/emacs.texi \
994  ${srcdir}/doc/lispintro/emacs-lisp-intro.texi \
995  ${srcdir}/doc/lispref/elisp.texi \
996  $(sort $(wildcard ${srcdir}/doc/misc/*.texi))
997info_dir_inputs = \
998  ../build-aux/dir_top \
999  $(subst ${srcdir}/doc/,,${srcdir_doc_info_dir_inputs})
1000info_dir_deps = \
1001  ${srcdir}/build-aux/make-info-dir \
1002  ${srcdir}/build-aux/dir_top \
1003  ${srcdir_doc_info_dir_inputs}
1004
1005## It would be much simpler if info/dir was only created in the
1006## installation location by the install-info rule, but we also
1007## need one in the source directory for people running uninstalled.
1008## FIXME it would be faster to use the install-info program if we have it,
1009## but then we would need to depend on info-real, which would
1010## slow down parallelization.
1011${srcdir}/info/dir: ${info_dir_deps}
1012	$(AM_V_at)${MKDIR_P} ${srcdir}/info
1013	$(AM_V_GEN)(cd ${srcdir}/doc && \
1014	 AWK='${AWK}' ../build-aux/make-info-dir ${info_dir_inputs} \
1015	) >$@.tmp && mv $@.tmp $@
1016
1017INSTALL_DVI = install-emacs-dvi install-lispref-dvi \
1018	install-lispintro-dvi install-misc-dvi
1019INSTALL_HTML = install-emacs-html install-lispref-html \
1020	install-lispintro-html install-misc-html
1021INSTALL_PDF = install-emacs-pdf install-lispref-pdf \
1022	install-lispintro-pdf install-misc-pdf
1023INSTALL_PS = install-emacs-ps install-lispref-ps \
1024	install-lispintro-ps install-misc-ps
1025INSTALL_DOC = $(INSTALL_DVI) $(INSTALL_HTML) $(INSTALL_PDF) $(INSTALL_PS)
1026
1027## Install non .info forms of the documentation.
1028## TODO add etc/refcards.
1029$(INSTALL_DOC):
1030	$(MAKE) -C doc/$(subst -, install-,$(subst install-,,$@))
1031
1032.PHONY: $(INSTALL_DOC) install-doc
1033.PHONY: install-dvi install-html install-pdf install-ps
1034
1035install-doc: $(INSTALL_DOC)
1036install-dvi: $(INSTALL_DVI)
1037install-html: $(INSTALL_HTML)
1038install-pdf: $(INSTALL_PDF)
1039install-ps: $(INSTALL_PS)
1040
1041
1042UNINSTALL_DVI = uninstall-emacs-dvi uninstall-lispref-dvi \
1043	uninstall-lispintro-dvi uninstall-misc-dvi
1044UNINSTALL_HTML = uninstall-emacs-html uninstall-lispref-html \
1045	uninstall-lispintro-html uninstall-misc-html
1046UNINSTALL_PDF = uninstall-emacs-pdf uninstall-lispref-pdf \
1047	uninstall-lispintro-pdf uninstall-misc-pdf
1048UNINSTALL_PS = uninstall-emacs-ps uninstall-lispref-ps \
1049	uninstall-lispintro-ps uninstall-misc-ps
1050UNINSTALL_DOC = $(UNINSTALL_DVI) $(UNINSTALL_HTML) $(UNINSTALL_PDF) $(UNINSTALL_PS)
1051
1052$(UNINSTALL_DOC):
1053	$(MAKE) -C doc/$(subst -, uninstall-,$(subst uninstall-,,$@))
1054
1055.PHONY: $(UNINSTALL_DOC) uninstall-doc
1056.PHONY: uninstall-dvi uninstall-html uninstall-pdf uninstall-ps
1057
1058uninstall-doc: $(UNINSTALL_DOC)
1059uninstall-dvi: $(UNINSTALL_DVI)
1060uninstall-html: $(UNINSTALL_HTML)
1061uninstall-pdf: $(UNINSTALL_PDF)
1062uninstall-ps: $(UNINSTALL_PS)
1063
1064
1065# Note that man/Makefile knows how to put the info files in $(srcdir),
1066# so we can do ok running make in the build dir.
1067# This used to have a clause that exited with an error if MAKEINFO = no.
1068# But it is inappropriate to do so without checking if makeinfo is
1069# actually needed - it is not if the info files are up-to-date.  (Bug#3982)
1070# Only the doc/*/Makefiles can decide that, so we let those rules run
1071# and give a standard error if makeinfo is needed but missing.
1072# While it would be nice to give a more detailed error message, that
1073# would require changing every rule in doc/ that builds an info file,
1074# and it's not worth it.  This case is only relevant if you download a
1075# release, then change the .texi files.
1076info:
1077  ifneq ($(HAVE_MAKEINFO),no)
1078	$(MAKE) info-real info-dir
1079  endif
1080
1081## build-aux/make-info-dir expects only certain dircategories.
1082check-info: info
1083	cd info ; \
1084	bad= ; \
1085	for file in *; do \
1086	  test -f "$${file}" || continue ; \
1087	  case $${file} in \
1088	    *-[0-9]*|COPYING|dir) continue ;; \
1089	  esac ; \
1090	  cat=`sed -n 's/^INFO-DIR-SECTION //p' $${file}`; \
1091	  case $${cat} in \
1092	   "Texinfo documentation system" | "Emacs"| "Emacs lisp" | \
1093           "Emacs editing modes" | "Emacs network features" | \
1094	   "Emacs misc features" | "Emacs lisp libraries" ) : ;; \
1095	   *)  bad="$${bad} $${file}" ;; \
1096	  esac; \
1097	done ; \
1098	if test -n "$${bad}"; then \
1099	  echo "Unexpected dircategory in: $${bad}" ; \
1100	  exit 1 ; \
1101	fi ; \
1102	echo "info files are OK"
1103
1104#### Bootstrapping.
1105
1106### This first cleans the lisp subdirectory, removing all compiled
1107### Lisp files.  Then re-run make to build all the files anew.
1108
1109.PHONY: bootstrap
1110
1111# Bootstrapping does the following:
1112#  * Remove files to start from a bootstrap-clean slate.
1113#  * Run autogen.sh.
1114#  * Rebuild Makefile, to update the build procedure itself.
1115#  * Do the actual build.
1116bootstrap: bootstrap-clean
1117	cd $(srcdir) && ./autogen.sh autoconf
1118	$(MAKE) MAKEFILE_NAME=force-Makefile force-Makefile
1119	$(MAKE) all
1120
1121.PHONY: ChangeLog change-history change-history-commit change-history-nocommit
1122.PHONY: preferred-branch-is-current unchanged-history-files
1123
1124CHANGELOG = ChangeLog
1125emacslog = build-aux/gitlog-to-emacslog
1126# The ChangeLog history files are called ChangeLog.1, ChangeLog.2, ...,
1127# ChangeLog.$(CHANGELOG_HISTORY_INDEX_MAX).  $(CHANGELOG_N) stands for
1128# the newest (highest-numbered) ChangeLog history file.
1129CHANGELOG_HISTORY_INDEX_MAX = 3
1130CHANGELOG_N = ChangeLog.$(CHANGELOG_HISTORY_INDEX_MAX)
1131
1132# Convert git commit log to ChangeLog file.  make-dist uses this.
1133# I guess this is PHONY so it always updates?
1134ChangeLog:
1135	$(AM_V_GEN)cd $(srcdir) && \
1136	  ./$(emacslog) -o $(CHANGELOG) -n $(CHANGELOG_HISTORY_INDEX_MAX)
1137
1138# Check that we are in a good state for changing history.
1139PREFERRED_BRANCH = emacs-27
1140preferred-branch-is-current:
1141	git branch | grep -q '^\* $(PREFERRED_BRANCH)$$'
1142unchanged-history-files:
1143	x=$$(git diff-files --name-only $(CHANGELOG_N) $(emacslog)) && \
1144	  test -z "$$x"
1145
1146# Regular expression that matches the newest commit covered by a ChangeLog.
1147new_commit_regexp = ^commit [0123456789abcdef]* (inclusive)
1148
1149# Copy newer commit messages to the start of the ChangeLog history file,
1150# and consider them to be older.
1151change-history-nocommit: preferred-branch-is-current unchanged-history-files
1152	-rm -f ChangeLog.tmp
1153	$(MAKE) ChangeLog CHANGELOG=ChangeLog.tmp
1154	sed '/^This file records repository revisions/,$$d' \
1155	  ChangeLog.tmp >$(CHANGELOG_N).tmp
1156	new_commit_line=`grep '$(new_commit_regexp)' ChangeLog.tmp` && \
1157	sed 's/$(new_commit_regexp).*/'"$$new_commit_line/" \
1158	  $(CHANGELOG_N) >>$(CHANGELOG_N).tmp
1159	rm ChangeLog.tmp
1160	mv $(CHANGELOG_N).tmp $(CHANGELOG_N)
1161
1162change-history: change-history-nocommit
1163	$(MAKE) $@-commit
1164
1165# If 'make change-history' fails because the newest ChangeLog history
1166# file contains invalid text, fix the file by hand and then run
1167# 'make change-history-commit'.
1168change-history-commit:
1169	git commit -m'; make $@' $(CHANGELOG_N) $(emacslog)
1170
1171.PHONY: check-declare
1172
1173check-declare:
1174	@if [ ! -f $(srcdir)/src/emacs ]; then \
1175	  echo "You must build Emacs to use this command"; \
1176	  exit 1; \
1177	fi
1178	$(MAKE) -C lisp $@
1179	$(MAKE) -C test $@
1180
1181.PHONY: gitmerge
1182
1183GITMERGE_EMACS = ./src/emacs${EXEEXT}
1184GITMERGE_NMIN = 10
1185
1186gitmerge:
1187	${GITMERGE_EMACS} -batch --no-site-file --no-site-lisp \
1188	  -l ${srcdir}/admin/gitmerge.el \
1189	  --eval '(setq gitmerge-minimum-missing ${GITMERGE_NMIN})' -f gitmerge
1190