Makefile.in 44.3 KB
Newer Older
1
### @configure_input@
2

3
# Copyright (C) 1992-2019 Free Software Foundation, Inc.
4 5 6 7 8 9 10 11 12 13 14 15 16 17

# This file is part of GNU Emacs.

# GNU Emacs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# GNU Emacs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# 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 21 22 23 24 25 26 27 28 29 30 31 32

### Commentary:

# make all	to compile and build Emacs.
# make install	to install it.
# make TAGS	to update tags tables.
#
# make clean  or  make mostlyclean
#      Delete all files from the current directory that are normally
#      created by building the program.	 Don't delete the files that
#      record the configuration.  Also preserve files that could be made
#      by building, but normally aren't because the distribution comes
#      with them.
#
33
#      Delete '.dvi' files here if they are not part of the distribution.
34 35 36 37 38
#
# make distclean
#      Delete all files from the current directory that are created by
#      configuring or building the program.  If you have unpacked the
#      source and built the program without creating any other files,
39
#      'make distclean' should leave only the files that were in the
40 41 42 43 44 45 46 47 48 49 50
#      distribution.
#
# make maintainer-clean
#      Delete everything from the current directory that can be
#      reconstructed with this Makefile.  This typically includes
#      everything deleted by distclean, plus more: .elc files,
#      C source files produced by Bison, tags tables, info files,
#      and so on.
#
# make extraclean
#      Still more severe - delete backup and autosave files, too.
51 52
#      Also generated files that do not normally change and can be slow
#      to rebuild (eg leim/ja-dic).
53 54 55 56
#
# make bootstrap
#      Removes all the compiled files to force a new bootstrap from a
#      clean slate, and then build in the normal way.
57 58 59
#
# make docs
#      Make Emacs documentation files from their sources; requires makeinfo.
60
#
61 62 63 64 65
# make check (or check-expensive or check-all)
#      Run the Emacs test suite.
#      check-expensive includes additional tests that can be slow.
#      check-all runs all tests, including ones that can be slow, or
#        fail unpredictably
66

67
SHELL = @SHELL@
68

Daniel Colascione's avatar
Daniel Colascione committed
69 70
DUMPING=@DUMPING@

71 72
# This only matters when inheriting a CDPATH not starting with the
# current directory.
73 74
CDPATH=

75
# ==================== Things 'configure' Might Edit ====================
76

77
cache_file = @cache_file@
78
CONFIGURE_FLAGS = --cache-file=$(cache_file)
79

80
AWK = @AWK@
81

82 83 84 85 86 87
EXEEXT=@EXEEXT@

### These help us choose version- and architecture-specific directories
### to install files in.

### This should be the number of the Emacs version we're building,
88
### like '24.5' or '25.0.50'.
89 90 91
version=@version@

### 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'.
93 94
configuration=@configuration@

95 96 97
### The nt/ subdirectory gets built only for MinGW
NTDIR=@NTDIR@

98 99 100 101 102 103 104 105 106 107 108 109 110
# 'make' verbosity.
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@

AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo "  GEN     " $@;
am__v_GEN_1 =

AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =

111 112
# ==================== Where To Install Things ====================

113
# Location to install Emacs.app under GNUstep / macOS.
114 115 116
# Later values may use these.
ns_appbindir=@ns_appbindir@
ns_appresdir=@ns_appresdir@
117 118
# Either yes or no depending on whether this is a relocatable Emacs.app.
ns_self_contained=@ns_self_contained@
119

120 121 122 123 124 125
# The default location for installation.  Everything is placed in
# subdirectories of this directory.  The default values for many of
# the variables below are expressed in terms of this one, so you may
# not need to change them.  This defaults to /usr/local.
prefix=@prefix@

126
# Like 'prefix', but used for architecture-specific files.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
exec_prefix=@exec_prefix@

# Where to install Emacs and other binaries that people will want to
# run directly (like etags).
bindir=@bindir@

# The root of the directory tree for read-only architecture-independent
# data files.  ${datadir}, ${infodir} and ${mandir} are based on this.
datarootdir=@datarootdir@

# Where to install architecture-independent data files.	 ${lispdir}
# and ${etcdir} are subdirectories of this.
datadir=@datadir@

# Where to install and expect the files that Emacs modifies as it
# runs.  These files are all architecture-independent.
# Right now, this is not used.
sharedstatedir=@sharedstatedir@

# Where to install and expect executable files to be run by Emacs
147 148 149 150
# rather than directly by users (and other architecture-dependent
# data, although Emacs does not have any).  The executables
# are actually installed in ${archlibdir}, which is (normally)
# a subdirectory of this.
151 152
libexecdir=@libexecdir@

153 154 155
# Currently only used for the systemd service file.
libdir=@libdir@

156 157 158
# Where to install emacs-module.h.
includedir=@includedir@

159
# Where to install Emacs's man pages.
160
# Note they contain cross-references that expect them to be in section 1.
161 162 163
mandir=@mandir@
man1dir=$(mandir)/man1

164
# Where to install and expect the info files describing Emacs.
165
infodir=@infodir@
166
# Info files not in the doc/misc directory (we get those via make echo-info).
167
INFO_NONMISC=emacs.info eintr.info elisp.info
168

169 170 171
# If no makeinfo was found and configured --without-makeinfo, "no"; else "yes".
HAVE_MAKEINFO=@HAVE_MAKEINFO@

172 173 174 175 176 177 178 179 180
# Directory for local state files for all programs.
localstatedir=@localstatedir@

# Where to look for bitmap files.
bitmapdir=@bitmapdir@

# Where to find the source code.  The source code for Emacs's C kernel is
# expected to be in ${srcdir}/src, and the source code for Emacs's
# utility programs is expected to be in ${srcdir}/lib-src.  This is
181
# set by the configure script's '--srcdir' option.
182 183 184

# We use $(srcdir) explicitly in dependencies so as not to depend on VPATH.
srcdir=@srcdir@
185
abs_srcdir=@abs_srcdir@
186 187 188 189 190 191 192 193 194 195 196 197 198

# Where the manpage source files are kept.
mansrcdir=$(srcdir)/doc/man

# Tell make where to find source files; this is needed for the makefiles.
VPATH=@srcdir@

# Where to find the application default.
x_default_search_path=@x_default_search_path@

# Where the etc/emacs.desktop file is to be installed.
desktopdir=$(datarootdir)/applications

199
# Where the etc/emacs.appdata.xml file is to be installed.
200
appdatadir=$(datarootdir)/metainfo
201

202 203 204 205 206 207 208 209 210 211 212
# Where the etc/emacs.service file is to be installed.
# The system value (typically /usr/lib/systemd/user) can be
# obtained with: pkg-config --variable=systemduserunitdir systemd
# but that does not respect configure's prefix.
# It is not clear where we should install this file when
# prefix != /usr (or /usr/local?) (eg for non-root installs).
# Other options include ~/.config/systemd/user/,
# $XDG_RUNTIME_DIR/systemd/user/
# It seems the user may end up having to make a manual link...
systemdunitdir=$(libdir)/systemd/user

213 214 215 216 217 218 219 220 221 222 223
# Where the etc/images/icons/hicolor directory is to be installed.
icondir=$(datarootdir)/icons

# The source directory for the icon files.
iconsrcdir=$(srcdir)/etc/images/icons

# ==================== Emacs-specific directories ====================

# These variables hold the values Emacs will actually use.  They are
# based on the values of the standard Make variables above.

224 225 226
# Where to install the lisp files distributed with Emacs.
# This includes the Emacs version, so that the lisp files for different
# versions of Emacs will install themselves in separate directories.
227 228
lispdir=@lispdir@

229
# Directories Emacs should search for standard lisp files.
230
# The default is ${lispdir}.
231 232 233 234 235
standardlisppath=@standardlisppath@

# Directories Emacs should search for lisp files specific to this
# site (i.e. customizations), before consulting ${standardlisppath}.
# This should be a colon-separated list of directories.
236 237 238 239 240 241
locallisppath=@locallisppath@

# Where Emacs will search to find its lisp files.  Before
# changing this, check to see if your purpose wouldn't
# better be served by changing locallisppath.  This
# should be a colon-separated list of directories.
242
# The default is ${locallisppath}:${standardlisppath}.
243 244
lisppath=@lisppath@

Glenn Morris's avatar
Glenn Morris committed
245 246 247 248
# Where Emacs will search for its lisp files while building.
# This is only used during the process of compiling Emacs,
# to help Emacs find its lisp files before they've been installed
# 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.
Glenn Morris's avatar
Glenn Morris committed
251
# NB lread.c relies on lisp/ being first here.
252
buildlisppath=${abs_srcdir}/lisp
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268

# Where to install the other architecture-independent
# data files distributed with Emacs (like the tutorial,
# the cookie recipes and the Zippy database). This path
# usually contains the Emacs version number, so the data
# files for multiple versions of Emacs may be installed
# at once.
etcdir=@etcdir@

# Where to put executables to be run by Emacs rather than
# the user.  This path usually includes the Emacs version
# and configuration name, so that multiple configurations
# for multiple versions of Emacs may be installed at
# once.
archlibdir=@archlibdir@

269 270
# Where to put the etc/DOC file.
etcdocdir=@etcdocdir@
271

272 273 274 275 276 277
# User or group of the auxiliary program update-game-score, which is
# installed on platforms with a game directory shared by multiple users.
# On other platforms Emacs can update the score files itself.
gameuser=@gameuser@
gamegroup=@gamegroup@
# Where to install game score files, if gameuser or gamegroup is nonempty.
278
gamedir=@gamedir@
279 280
# Nonempty if and only if a shared gamedir is used.
use_gamedir=$(gameuser)$(gamegroup)
281 282 283 284

# ==================== Utility Programs for the Build ====================

# Allow the user to specify the install program.
285 286 287
# Note that if the system does not provide a suitable install,
# configure will use build-aux/install-sh.  Annoyingly, it does
# 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.
290 291 292 293 294 295
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_INFO = @INSTALL_INFO@
# By default, we uphold the dignity of our programs.
INSTALL_STRIP =
296
MKDIR_P = @MKDIR_P@
297 298
# Create a link to a file in the same directory as the target.
LN_S_FILEONLY = @LN_S_FILEONLY@
299

300
# We use gzip to compress installed .el and some .txt files.
301 302 303 304 305 306 307 308
GZIP_PROG = @GZIP_PROG@

# ============================= Targets ==============================

# Program name transformation.
TRANSFORM = @program_transform_name@

# What emacs should be called when installed.
309 310
EMACS_NAME = `echo emacs | sed '$(TRANSFORM)'`
EMACS = ${EMACS_NAME}${EXEEXT}
311
EMACSFULL = `echo emacs-${version} | sed '$(TRANSFORM)'`${EXEEXT}
312

313
# Subdirectories to make recursively.
314
SUBDIR = $(NTDIR) lib lib-src src lisp
315 316

# The subdir makefiles created by config.status.
317
SUBDIR_MAKEFILES_IN = @SUBDIR_MAKEFILES_IN@
318
SUBDIR_MAKEFILES = $(patsubst ${srcdir}/%,%,${SUBDIR_MAKEFILES_IN:.in=})
319

320 321 322
# Non-makefile files created by config.status.
CONFIG_STATUS_FILES_IN = \
 ${srcdir}/nt/emacs.rc.in ${srcdir}/nt/emacsclient.rc.in \
323 324
 ${srcdir}/doc/man/emacs.1.in ${srcdir}/src/emacs-module.h.in \
 ${srcdir}/src/module-env-*.h
325

326 327 328
# Subdirectories to install, and where they'll go.  lib-src's and nt's
# makefiles know how to install them, so we don't do that here.
# Directories that cannot simply be copied, eg info, are treated
329 330 331
# separately.
COPYDIR = ${srcdir}/etc ${srcdir}/lisp
COPYDESTS = "$(DESTDIR)${etcdir}" "$(DESTDIR)${lispdir}"
332

333
all: ${SUBDIR} info
334

335 336 337 338 339 340 341 342 343 344 345 346
.PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 etc-emacsver

# If configure were to just generate emacsver.tex from emacsver.tex.in
# in the normal way, the timestamp of emacsver.tex would always be
# newer than that of the pdf files, which are prebuilt in release tarfiles.
# So we use this rule, and move-if-change, to avoid that.
etc-emacsver:
	majorversion=`echo ${version} | sed 's/\..*//'`; \
	sed "s/[@]majorversion@/$${majorversion}/" \
	  ${srcdir}/etc/refcards/emacsver.tex.in > emacsver.tex.$$$$ && \
	  ${srcdir}/build-aux/move-if-change emacsver.tex.$$$$ \
	  ${srcdir}/etc/refcards/emacsver.tex
347

348 349 350
# The shared gamedir name as a C string literal, or a null ptr if not in use.
PATH_GAME = $(if $(use_gamedir),"$(gamedir)",((char const *) 0))

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 354
# to just letting configure generate epaths.h from epaths.in in a
# similar way to how Makefile is made from Makefile.in.
355
epaths-force:
356 357 358
	@for dir in '$(abs_srcdir)' '$(lispdir)' '$(archlibdir)'; do \
	  case $$dir in \
	    *:*) \
359
	      printf >&2 "Build or installation directory '%s'\\n" "$$dir"; \
360 361 362 363
	      echo >&2 "cannot contain ':'."; \
	      exit 1;; \
	  esac; \
	done
364
	@(gamedir='${gamedir}'; \
365
	  sed < ${srcdir}/src/epaths.in > epaths.h.$$$$		\
366 367 368 369 370
	  -e 's;\(#.*PATH_LOADSEARCH\).*$$;\1 "${standardlisppath}";' \
	  -e 's;\(#.*PATH_SITELOADSEARCH\).*$$;\1 "${locallisppath}";' \
	  -e 's;\(#.*PATH_DUMPLOADSEARCH\).*$$;\1 "${buildlisppath}";' \
	  -e '/^#define PATH_[^ ]*SEARCH /s/\([":]\):*/\1/g'		\
	  -e '/^#define PATH_[^ ]*SEARCH /s/:"/"/'			\
371 372 373 374 375
	  -e 's;\(#.*PATH_EXEC\).*$$;\1 "${archlibdir}";'		\
	  -e 's;\(#.*PATH_INFO\).*$$;\1 "${infodir}";'			\
	  -e 's;\(#.*PATH_DATA\).*$$;\1 "${etcdir}";'			\
	  -e 's;\(#.*PATH_BITMAPS\).*$$;\1 "${bitmapdir}";'		\
	  -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 381
# The w32 build needs a slightly different editing, and it uses
# 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 387 388 389
# In this case, the paths written to 'src/epaths.h' must be in native
# MS-Windows format (e.g. 'c:/foo/bar'), because temacs is a MinGW
# program that doesn't support MSYS-style paths (e.g. '/c/foo/bar' or
# '/foo/bar').
390
epaths-force-w32:
391
	@(w32srcdir=`${srcdir}/build-aux/msys-to-w32 "${abs_srcdir}"`; \
392
	  w32prefix=`${srcdir}/build-aux/msys-to-w32 "${prefix}"`; \
393 394
	  w32locallisppath=`${srcdir}/build-aux/msys-to-w32 "${locallisppath}"` ; \
	  w32locallisppath=$${w32locallisppath//$${w32prefix}/"%emacs_dir%"} ; \
395
	  sed < ${srcdir}/nt/epaths.nt > epaths.h.$$$$		\
396
	  -e 's;\(#.*PATH_SITELOADSEARCH\).*$$;\1 "'"$${w32locallisppath//;/\\;}"'";' \
397 398 399 400 401
	  -e '/^.*#/s/@VER@/${version}/g' 			\
	  -e '/^.*#/s/@CFG@/${configuration}/g' 		\
	  -e "/^.*#/s|@SRC@|$${w32srcdir}|g") &&		\
	${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h

402
lib-src src: $(NTDIR) lib
403

Paul Eggert's avatar
Paul Eggert committed
404
src: lib-src
405

406
# We need to build 'emacs' in 'src' to compile the *.elc files in 'lisp'.
407
lisp: src
408

409
# These targets should be "${SUBDIR} without 'src'".
410
lib lib-src lisp nt: Makefile
411
	$(MAKE) -C $@ all
412

Eric S. Raymond's avatar
Eric S. Raymond committed
413 414 415 416 417
# Ideally, VCSWITNESS should be a file that is modified whenever the
# repository registers a commit from either a local checkin or a
# repository pull. In git there is no single file that guarantees
# this, but the local log for the current head should be close enough.
#
418
# Pass an unexpanded $srcdir to src's Makefile, which then
Glenn Morris's avatar
Glenn Morris committed
419 420
# expands it using its own value of srcdir (which points to the
# source directory of src/).
421 422
dirstate = .git/logs/HEAD
VCSWITNESS = $(if $(wildcard $(srcdir)/$(dirstate)),$$(srcdir)/../$(dirstate))
423
src: Makefile
424
	$(MAKE) -C $@ VCSWITNESS='$(VCSWITNESS)' all
425

426
blessmail: 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 431 432 433
# conditions with parallel makes, so assume that the timestamp on
# ./Makefile represents the timestamp on all the other Makefiles.
# Similarly, assume the timestamp on ./configure represents the
# timestamp on src/config.in.
434 435 436 437
#
# config.status overrides MAKEFILE_NAME with a bogus name when creating
# src/epaths.h, so that 'make epaths-force' does not recursively invoke
# config.status and overwrite config.status while executing it (Bug#11214).
438 439 440 441
#
# 'make bootstrap' overrides MAKEFILE_NAME to a nonexistent file but
# then attempts to build that file.  This forces 'Makefile', 'lib/Makefile',
# etc. to be built without running into similar recursion problems.
442
MAKEFILE_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 449
# Don't erase these files if make is interrupted while refreshing them.
.PRECIOUS: Makefile config.status
450

451
config.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 462

# ==================== Installation ====================

463
.PHONY: install install-arch-dep install-arch-indep install-etcdoc install-info
464 465
.PHONY: install-man install-etc install-strip install-$(NTDIR)
.PHONY: uninstall uninstall-$(NTDIR)
466

467 468 469 470
## If we let lib-src do its own installation, that means we
## don't have to duplicate the list of utilities to install in
## this Makefile as well.

471
install: all install-arch-indep install-etcdoc install-arch-dep install-$(NTDIR) blessmail
472 473
	@true

474
## Ensure that $subdir contains a subdirs.el file.
475 476 477 478
## Here and elsewhere, we set the umask so that any created files are
## world-readable.
## TODO it might be good to warn about non-standard permissions of
## pre-existing directories, but that does not seem easy.
479
write_subdir=if [ -f "$${subdir}/subdirs.el" ]; \
480 481
	then true; \
	else \
482
	  umask 022; \
483
	  ${MKDIR_P} "$${subdir}"; \
484 485
	  (echo "(if (fboundp 'normal-top-level-add-subdirs-to-load-path)"; \
	   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 491
### We do install-arch-indep first because the executable needs the
### Lisp files and DOC file to work properly.
492
install-arch-dep: src install-arch-indep install-etcdoc install-$(NTDIR)
493
	umask 022; ${MKDIR_P} "$(DESTDIR)${bindir}"
494
	$(MAKE) -C lib-src install
495 496
ifeq (${ns_self_contained},no)
	${INSTALL_PROGRAM} $(INSTALL_STRIP) src/emacs${EXEEXT} "$(DESTDIR)${bindir}/$(EMACSFULL)"
Daniel Colascione's avatar
Daniel Colascione committed
497 498 499
ifeq (${DUMPING},pdumper)
	${INSTALL_DATA} src/emacs.pdmp "$(DESTDIR)${libexecdir}/emacs/${version}/${configuration}"/emacs.pdmp
endif
500
	-chmod 755 "$(DESTDIR)${bindir}/$(EMACSFULL)"
501 502
ifndef NO_BIN_LINK
	rm -f "$(DESTDIR)${bindir}/$(EMACS)"
503
	cd "$(DESTDIR)${bindir}" && $(LN_S_FILEONLY) "$(EMACSFULL)" "$(EMACS)"
504 505 506 507 508
endif
else
	subdir=${ns_appresdir}/site-lisp && ${write_subdir}
	rm -rf ${ns_appresdir}/share
endif
509 510 511 512 513

### Windows-specific install target for installing programs produced
### in nt/, and its Posix do-nothing shadow.
install-:
install-nt:
514
	$(MAKE) -C $(NTDIR) install
515

516
## In the share directory, we are deleting:
517 518
## applications (with emacs.desktop, also found in etc/)
## emacs (basically empty except for unneeded site-lisp directories)
519 520
## icons (duplicates etc/images/icons/hicolor)

521 522 523 524
## This is install-etc for everything except self-contained-ns builds.
## For them, it is empty.
INSTALL_ARCH_INDEP_EXTRA = @INSTALL_ARCH_INDEP_EXTRA@

525
## https://lists.gnu.org/r/emacs-devel/2007-10/msg01672.html
526 527
## Needs to be the user running install, so configure can't set it.
set_installuser=for installuser in $${LOGNAME} $${USERNAME} $${USER} \
528
	  `(id -u) 2> /dev/null`; do \
529
	  [ -n "$${installuser}" ] && break ; \
530 531 532
	done; \
	installgroup=`(id -g) 2>/dev/null` && [ -n "$$installgroup" ] && \
	  installuser=$$installuser:$$installgroup
533 534

### Install the files that are machine-independent.
535 536
### Most of them come straight from the distribution; the exception is
### the DOC file, which is copied from the build directory.
537

538 539 540 541 542
## We delete each directory in ${COPYDESTS} before we copy into it;
## that way, we can reinstall over directories that have been put in
## place with their files read-only (perhaps because they are checked
## into RCS).  In order to make this safe, we make sure that the
## source exists and is distinct from the destination.
543

544 545 546
## We delete etc/DOC* because there may be irrelevant DOC files from
## other builds in the source directory.  This is ok because we just
## deleted the entire installed etc/ directory and recreated it.
547
## install-etcdoc installs the relevant DOC.
548

549 550 551 552 553
## Note that we install etc/refcards/*.ps if present.
## TODO we should compress these if GZIP_PROG is set.
## It would be simpler to have a separate install rule for etc/refcards
## (maybe move it to doc/refcards?).

554 555 556
## Note that the Makefiles in the etc directory are potentially useful
## in an installed Emacs, so should not be excluded.

Glenn Morris's avatar
Glenn Morris committed
557 558 559 560 561 562
## We always create the _default_ locallisppath directories, and
## ensure that they contain a subdirs.el file (via write_subdir).
## This is true even if locallisppath has a non-default value.
## In case of non-default value, we used to create the specified directories,
## but not add subdirs.el to them.  This was a strange halfway house.
## Nowadays we do not create non-default directories.
Glenn Morris's avatar
Glenn Morris committed
563 564 565

## Note that we use tar instead of plain old cp -R/-r because the latter
## is apparently not portable (even in 2012!).
566
## https://lists.gnu.org/r/emacs-devel/2012-05/msg00278.html
Glenn Morris's avatar
Glenn Morris committed
567 568
## I have no idea which platforms Emacs supports where cp -R does not
## work correctly, and therefore no idea when tar can be replaced.
Glenn Morris's avatar
Glenn Morris committed
569
## See also these comments from 2004 about cp -r working fine:
570
## https://lists.gnu.org/r/autoconf-patches/2004-11/msg00005.html
571
install-arch-indep: lisp install-info install-man ${INSTALL_ARCH_INDEP_EXTRA}
572 573
	umask 022 && $(MKDIR_P) "$(DESTDIR)$(includedir)"
	$(INSTALL_DATA) src/emacs-module.h "$(DESTDIR)$(includedir)/emacs-module.h"
574 575 576 577
	-set ${COPYDESTS} ; \
	unset CDPATH; \
	$(set_installuser); \
	for dir in ${COPYDIR} ; do \
578
	  [ -d $${dir} ] || exit 1 ; \
579
	  dest="$$1" ; shift ; \
580 581 582 583 584
	  if [ -d "$${dest}" ]; then \
	    exp_dest=`cd "$${dest}" && /bin/pwd`; \
	    [ "$$exp_dest" = "`cd $${dir} && /bin/pwd`" ] && continue ; \
	  else true; \
	  fi; \
585 586
	  rm -rf "$${dest}" ; \
	  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 593
	      rm -f "$${dest}/DOC"* ; \
	      rm -f "$${dest}/refcards"/*.aux "$${dest}/refcards"/*.dvi; \
594
	      rm -f "$${dest}/refcards"/*.log "$${dest}/refcards"/*.in; \
595 596
	  else true; \
	  fi; \
597 598 599 600 601 602
	  (cd "$${dest}" || exit 1; \
	    for subdir in `find . -type d -print` ; do \
	      chmod a+rx $${subdir} ; \
	      rm -f $${subdir}/.gitignore ; \
	      rm -f $${subdir}/.arch-inventory ; \
	      rm -f $${subdir}/.DS_Store ; \
603 604
	      rm -f $${subdir}/#* ; \
	      rm -f $${subdir}/.#* ; \
605 606 607 608 609 610 611
	      rm -f $${subdir}/*~ ; \
	      rm -f $${subdir}/*.orig ; \
	      rm -f $${subdir}/ChangeLog* ; \
	      [ "$${dir}" != "${srcdir}/etc" ] && \
	        rm -f $${subdir}/[mM]akefile*[.-]in $${subdir}/[mM]akefile ; \
	    done ); \
	  find "$${dest}" -exec chown $${installuser} {} ';' ;\
612
	done
613 614 615
	-rm -f "$(DESTDIR)${lispdir}/subdirs.el"
	umask 022; $(srcdir)/build-aux/update-subdirs "$(DESTDIR)${lispdir}"
	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 623 624
	  for f in `find . -name "*.elc" -print | sed 's/.elc$$/.el/'`; do \
	    ${GZIP_PROG} -9n "$$f"; \
	  done; \
625
	  ${GZIP_PROG} -9n "../etc/publicsuffix.txt"; \
626
	}
627
	-chmod -R a+r "$(DESTDIR)${datadir}/emacs/${version}" ${COPYDESTS}
628

629 630 631
## The above chmods are needed because "umask 022; tar ..." is not
## guaranteed to do the right thing; eg if we are root and tar is
## preserving source permissions.
632

633 634
## Note that install-arch-indep deletes and recreates the entire
## installed etc/ directory, so we need it to run before this does.
635
install-etcdoc: src install-arch-indep
636
	-unset CDPATH; \
637
	umask 022; ${MKDIR_P} "$(DESTDIR)${etcdocdir}" ; \
638 639
	exp_etcdocdir=`cd "$(DESTDIR)${etcdocdir}"; /bin/pwd`; \
	if [ "`cd ./etc; /bin/pwd`" != "$$exp_etcdocdir" ]; \
640
	then \
641
	   docfile="DOC"; \
642 643
	   printf 'Copying %s to %s ...\n' "etc/$$docfile" \
	     "$(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 650 651 652
## FIXME:
## If info/dir is missing, but we have install-info, we should let
## that handle it.  If info/dir is present and we do not have install-info,
## we should check for missing entries and add them by hand.
653 654 655
##
## FIXME:
## If HAVE_MAKEINFO = no and there are no info files, do not install info/dir.
656
install-info: info
657
	umask 022; ${MKDIR_P} "$(DESTDIR)${infodir}"
658 659
	-unset CDPATH; \
	thisdir=`/bin/pwd`; \
660 661
	exp_infodir=`cd "$(DESTDIR)${infodir}" && /bin/pwd`; \
	if [ "`cd ${srcdir}/info && /bin/pwd`" = "$$exp_infodir" ]; then \
662 663
	  true; \
	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 676
	        rm -f "$(DESTDIR)${infodir}/$$f.gz"; \
	        ${GZIP_PROG} -9n "$(DESTDIR)${infodir}/$$f"; \
677
	      done; \
678
	     (cd "$${thisdir}"; \
679
	      ${INSTALL_INFO} --info-dir="$(DESTDIR)${infodir}" "$(DESTDIR)${infodir}/$$elt"); \
680 681
	   done; \
	fi
682

683 684 685 686 687 688
## "gzip || true" is because some gzips exit with non-zero status
## if compression would not reduce the file size.  Eg, the gzip in
## OpenBSD 4.9 seems to do this (2013/03).  In Emacs, this can
## only happen with the tiny ctags.1 manpage.  We don't really care if
## ctags.1 is compressed or not.  "gzip -f" is another option here,
## but not sure if portable.
689
install-man:
690
	umask 022; ${MKDIR_P} "$(DESTDIR)${man1dir}"
691 692
	thisdir=`/bin/pwd`; \
	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 700
	  rm -f "$(DESTDIR)${man1dir}/$${dest}.gz"; \
	  ${GZIP_PROG} -9n "$(DESTDIR)${man1dir}/$${dest}" || true; \
701 702 703
	done

## Install those items from etc/ that need to end up elsewhere.
704 705 706 707 708

## If you prefer, choose "emacs22" at installation time.
## Note: emacs22 does not have all the resolutions.
EMACS_ICON=emacs

Glenn Morris's avatar
Glenn Morris committed
709
install-etc:
710
	umask 022; ${MKDIR_P} "$(DESTDIR)${desktopdir}"
711
	tmp=etc/emacs.tmpdesktop; rm -f $${tmp}; \
712 713
	sed -e "/^Exec=emacs/ s/emacs/${EMACS_NAME}/" \
	  -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 718 719 720 721 722
	umask 022; ${MKDIR_P} "$(DESTDIR)${appdatadir}"
	tmp=etc/emacs.tmpappdata; rm -f $${tmp}; \
	sed -e "s/emacs\.desktop/${EMACS_NAME}.desktop/" \
	  ${srcdir}/etc/emacs.appdata.xml > $${tmp}; \
	${INSTALL_DATA} $${tmp} "$(DESTDIR)${appdatadir}/${EMACS_NAME}.appdata.xml"; \
	rm -f $${tmp}
723 724 725 726
	umask 022; $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)"
	tmp=etc/emacs.tmpservice; rm -f $${tmp}; \
	client_name=`echo emacsclient | sed '$(TRANSFORM)'`${EXEEXT}; \
	sed -e '/^##/d' \
727 728
	  -e "/^Documentation/ s/emacs(1)/${EMACS_NAME}(1)/" \
	  -e "/^ExecStart/ s|emacs|${bindir}/${EMACS}|" \
729
	  -e "/^ExecStop/ s|emacsclient|${bindir}/$${client_name}|" \
730 731 732
	  ${srcdir}/etc/emacs.service > $${tmp}; \
	$(INSTALL_DATA) $${tmp} "$(DESTDIR)$(systemdunitdir)/${EMACS_NAME}.service"; \
	rm -f $${tmp}
733
	thisdir=`/bin/pwd`; \
Glenn Morris's avatar
Glenn Morris committed
734 735 736
	cd ${iconsrcdir} || exit 1; umask 022 ; \
	for dir in */*/apps */*/mimetypes; do \
	  [ -d $${dir} ] || continue ; \
737
	  ( cd "$${thisdir}"; ${MKDIR_P} "$(DESTDIR)${icondir}/$${dir}" ) ; \
738
	  for icon in $${dir}/${EMACS_ICON}[.-]*; do \
Glenn Morris's avatar
Glenn Morris committed
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; \
Glenn Morris's avatar
Glenn Morris committed
745
	  done ; \
746 747 748 749
	done

### Build Emacs and install it, stripping binaries while installing them.
install-strip:
750
	$(MAKE) INSTALL_STRIP=-s install
751

752 753
### Delete all the installed files that the 'install' target would
### 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.
756
uninstall: uninstall-$(NTDIR) uninstall-doc
757
	rm -f "$(DESTDIR)$(includedir)/emacs-module.h"
758
	$(MAKE) -C lib-src uninstall
759
	-unset CDPATH; \
760 761
	for dir in "$(DESTDIR)${lispdir}" "$(DESTDIR)${etcdir}" ; do 	\
	  if [ -d "$${dir}" ]; then			\
762 763
	    case `cd "$${dir}" ; /bin/pwd` in		\
	      "`cd ${srcdir} ; /bin/pwd`"* ) ;;		\
764
	      * ) rm -rf "$${dir}" ;;			\
765
	    esac ;					\
766 767 768
	    case "$${dir}" in				\
	      "$(DESTDIR)${datadir}/emacs/${version}"/* )		\
	        rm -rf "$(DESTDIR)${datadir}/emacs/${version}"	\
769 770 771 772
	      ;;					\
	    esac ;					\
	  fi ;						\
	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 782 783 784
	        ext=.gz; else ext=; fi; \
	     rm -f $$elt$$ext $$elt-[1-9]$$ext $$elt-[1-9][0-9]$$ext; \
	   done; \
	 fi)
785
	(if [ -n "${GZIP_PROG}" ]; then \
786
	    ext=.gz; else ext=; fi; \
787 788
	 if cd ${mansrcdir}; then \
	   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 794
	   rm -f hicolor/*x*/apps/"${EMACS_NAME}.png" \
	     "hicolor/scalable/apps/${EMACS_NAME}.svg" \
795 796 797
	     "hicolor/scalable/apps/${EMACS_NAME}.ico" \
	     "hicolor/scalable/mimetypes/${EMACS_NAME}-document.svg" \
	     "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 805
	  file="$(DESTDIR)${gamedir}/$${file}"; \
	  [ -s "$${file}" ] || rm -f "$$file"; \
806
	done
807
  endif
808

809 810 811 812
### Windows-specific uninstall target for removing programs produced
### in nt/, and its Posix do-nothing shadow.
uninstall-:
uninstall-nt:
813
	$(MAKE) -C $(NTDIR) uninstall
814

815 816
# ==================== Cleaning up and miscellanea ====================

817
.PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean extraclean
818

819 820 821 822 823 824 825 826 827
## Eg:
## src_clean:
##     make -C src clean
define submake_template
.PHONY: $(1)_$(2)
$(1)_$(2):
	$$(MAKE) -C $(1) $(2)
endef

828 829 830 831
### 'mostlyclean'
###      Like 'clean', but may refrain from deleting a few files that people
###      normally don't want to recompile.  For example, the 'mostlyclean'
###      target for GCC does not delete 'libgcc.a', because recompiling it
832
###      is rarely necessary and takes a lot of time.
833 834 835 836 837 838
mostlyclean_dirs = src oldXMenu lwlib lib lib-src nt doc/emacs doc/misc \
  doc/lispref doc/lispintro

$(foreach dir,$(mostlyclean_dirs),$(eval $(call submake_template,$(dir),mostlyclean)))

mostlyclean: $(mostlyclean_dirs:=_mostlyclean)
839
	[ ! -d test ] || $(MAKE) -C test $@
840

841
### 'clean'
842 843 844 845 846 847
###      Delete all files from the current directory that are normally
###      created by building the program.  Don't delete the files that
###      record the configuration.  Also preserve files that could be made
###      by building, but normally aren't because the distribution comes
###      with them.
###
848
###      Delete '.dvi' files here if they are not part of the distribution.
849 850 851 852 853
clean_dirs = $(mostlyclean_dirs) nextstep

$(foreach dir,$(clean_dirs),$(eval $(call submake_template,$(dir),clean)))

clean: $(clean_dirs:=_clean)
854 855
	$(MAKE) -C admin/charsets $@
	[ ! -d test ] || $(MAKE) -C test $@
856
	-rm -f ./*.tmp etc/*.tmp*
857
	-rm -rf info-dir.*
858

859
### 'bootclean'
860 861
###      Delete all files that need to be remade for a clean bootstrap.
top_bootclean=\
862
	rm -f config.cache config.log ${srcdir}/doc/man/emacs.1
863

864
### 'distclean'
865 866 867
###      Delete all files from the current directory that are created by
###      configuring or building the program.  If you have unpacked the
###      source and built the program without creating any other files,
868
###      'make distclean' should leave only the files that were in the
869 870 871
###      distribution.
top_distclean=\
	${top_bootclean}; \
872
	rm -f config.status config.log~ \
873
	  Makefile makefile lib/gnulib.mk ${SUBDIR_MAKEFILES}
874 875 876 877 878

distclean_dirs = $(clean_dirs) leim lisp

$(foreach dir,$(distclean_dirs),$(eval $(call submake_template,$(dir),distclean)))

879
maybeclean_dirs = test admin/grammars admin/unidata admin/charsets
880

881
distclean: $(distclean_dirs:=_distclean)
882 883
	for dir in $(filter-out test,$(maybeclean_dirs)); do \
	  $(MAKE) -C $$dir $@ || exit; \
884
	done
885
	[ ! -d test ] || $(MAKE) -C test $@
886 887
	${top_distclean}

888 889
### 'bootstrap-clean'
###      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 892 893
$(foreach dir,$(distclean_dirs),$(eval $(call submake_template,$(dir),bootstrap-clean)))

bootstrap-clean: $(distclean_dirs:=_bootstrap-clean)
894 895
	for dir in $(filter-out test,$(maybeclean_dirs)); do \
	  $(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 902
	${top_bootclean}

903
### 'maintainer-clean'
904 905 906 907 908
###      Delete everything from the current directory that can be
###      reconstructed with this Makefile.  This typically includes
###      everything deleted by distclean, plus more: C source files
###      produced by Bison, tags tables, info files, and so on.
###
909 910 911 912
###      One exception, however: 'make maintainer-clean' should not delete
###      'configure' even if 'configure' can be remade using a rule in the
###      Makefile.  More generally, 'make maintainer-clean' should not delete
###      anything that needs to exist in order to run 'configure' and then
913
###      begin to build the program.
914 915
top_maintainer_clean=\
	${top_distclean}; \
916
	rm -fr autom4te.cache
917 918 919 920 921 922

maintainer_clean_dirs = src leim lisp

$(foreach dir,$(maintainer_clean_dirs),$(eval $(call submake_template,$(dir),maintainer-clean)))

maintainer-clean: bootstrap-clean $(maintainer_clean_dirs:=_maintainer-clean)
923 924
	for dir in $(filter-out test,$(maybeclean_dirs)); do \
	  $(MAKE) -C $$dir $@ || exit; \
925
	done
926
	[ ! -d test ] || $(MAKE) -C test $@
927
	${top_maintainer_clean}
928 929 930 931 932

### This doesn't actually appear in the coding standards, but Karl
### says GCC supports it, and that's where the configuration part of
### the coding standards seem to come from.  It's like distclean, but
### it deletes backup and autosave files too.
933 934
### Note that we abuse this in some subdirectories (eg leim),
### to delete some generated files that are slow to rebuild.
935
extraclean_dirs = ${NTDIR} lib-src src leim \
936
  admin/charsets admin/grammars admin/unidata lisp lib
937

938 939 940
$(foreach dir,$(extraclean_dirs),$(eval $(call submake_template,$(dir),extraclean)))

extraclean: $(extraclean_dirs:=_extraclean)
941
	${top_maintainer_clean}
942 943 944
	-rm -f config-tmp-* aclocal.m4 configure
	-rm -f ./*~ \#* etc/refcards/emacsver.tex doc/emacs/emacsver.texi
	-rm -f info/*.info info/dir
945
	-rmdir info 2>/dev/null
946 947 948

# The src subdir knows how to do the right thing
# even when the build directory and source dir are different.
949
.PHONY: TAGS tags
950 951 952
# FIXME: We used to include `src` in the dependencies, not sure why.
# I removed it because it causes `make tags` to build Emacs.
TAGS tags: lib lib-src # src
953
	$(MAKE) -C src tags
954

955 956 957 958
CHECK_TARGETS = check check-maybe check-expensive check-all
.PHONY: $(CHECK_TARGETS)
$(CHECK_TARGETS): all
ifeq ($(wildcard test),test)
959
	$(MAKE) -C test $@
960 961 962 963
else
	@echo "You do not seem to have the test/ directory."
	@echo "Maybe you used a release tarfile that lacks tests."
endif
964 965 966 967

dist:
	cd ${srcdir}; ./make-dist

968 969 970 971
DVIS  = lispref-dvi  lispintro-dvi  emacs-dvi  misc-dvi
HTMLS = lispref-html lispintro-html emacs-html misc-html
INFOS = lispref-info lispintro-info emacs-info misc-info
PDFS  = lispref-pdf  lispintro-pdf  emacs-pdf  misc-pdf
972
PSS   = lispref-ps   lispintro-ps   emacs-ps   misc-ps
973 974 975

DOCS = $(DVIS) $(HTMLS) $(INFOS) $(PDFS) $(PSS)
$(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.
982 983 984 985 986 987
docs: $(DOCS)
dvi: $(DVIS)
html: $(HTMLS)
info-real: $(INFOS)
pdf: $(PDFS)
ps: $(PSS)
988

989 990
info-dir: ${srcdir}/info/dir

991
## Hopefully doc/misc/*.texi is not too long for some systems?
992 993 994 995 996 997 998 999 1000 1001 1002 1003
srcdir_doc_info_dir_inputs = \
  ${srcdir}/doc/emacs/emacs.texi \
  ${srcdir}/doc/lispintro/emacs-lisp-intro.texi \
  ${srcdir}/doc/lispref/elisp.texi \
  $(sort $(wildcard ${srcdir}/doc/misc/*.texi))
info_dir_inputs = \
  ../build-aux/dir_top \
  $(subst ${srcdir}/doc/,,${srcdir_doc_info_dir_inputs})
info_dir_deps = \
  ${srcdir}/build-aux/make-info-dir \
  ${srcdir}/build-aux/dir_top \
  ${srcdir_doc_info_dir_inputs}
1004

1005 1006 1007
## It would be much simpler if info/dir was only created in the
## installation location by the install-info rule, but we also
## need one in the source directory for people running uninstalled.
1008 1009 1010 1011
## FIXME it would be faster to use the install-info program if we have it,
## but then we would need to depend on info-real, which would
## slow down parallelization.
${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 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029

INSTALL_DVI = install-emacs-dvi install-lispref-dvi \
	install-lispintro-dvi install-misc-dvi
INSTALL_HTML = install-emacs-html install-lispref-html \
	install-lispintro-html install-misc-html
INSTALL_PDF = install-emacs-pdf install-lispref-pdf \
	install-lispintro-pdf install-misc-pdf
INSTALL_PS = install-emacs-ps install-lispref-ps \
	install-lispintro-ps install-misc-ps
INSTALL_DOC = $(INSTALL_DVI) $(INSTALL_HTML) $(INSTALL_PDF) $(INSTALL_PS)

## Install non .info forms of the documentation.
## TODO add etc/refcards.
$(INSTALL_DOC):
1030
	$(MAKE) -C doc/$(subst -, install-,$(subst install-,,$@))
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052

.PHONY: $(INSTALL_DOC) install-doc
.PHONY: install-dvi install-html install-pdf install-ps

install-doc: $(INSTALL_DOC)
install-dvi: $(INSTALL_DVI)
install-html: $(INSTALL_HTML)
install-pdf: $(INSTALL_PDF)
install-ps: $(INSTALL_PS)


UNINSTALL_DVI = uninstall-emacs-dvi uninstall-lispref-dvi \
	uninstall-lispintro-dvi uninstall-misc-dvi
UNINSTALL_HTML = uninstall-emacs-html uninstall-lispref-html \
	uninstall-lispintro-html uninstall-misc-html
UNINSTALL_PDF = uninstall-emacs-pdf uninstall-lispref-pdf \
	uninstall-lispintro-pdf uninstall-misc-pdf
UNINSTALL_PS = uninstall-emacs-ps uninstall-lispref-ps \
	uninstall-lispintro-ps uninstall-misc-ps
UNINSTALL_DOC = $(UNINSTALL_DVI) $(UNINSTALL_HTML) $(UNINSTALL_PDF) $(UNINSTALL_PS)

$(UNINSTALL_DOC):
1053
	$(MAKE) -C doc/$(subst -, uninstall-,$(subst uninstall-,,$@))
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064

.PHONY: $(UNINSTALL_DOC) uninstall-doc
.PHONY: uninstall-dvi uninstall-html uninstall-pdf uninstall-ps

uninstall-doc: $(UNINSTALL_DOC)
uninstall-dvi: $(UNINSTALL_DVI)
uninstall-html: $(UNINSTALL_HTML)
uninstall-pdf: $(UNINSTALL_PDF)
uninstall-ps: $(UNINSTALL_PS)


1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075
# Note that man/Makefile knows how to put the info files in $(srcdir),
# so we can do ok running make in the build dir.
# This used to have a clause that exited with an error if MAKEINFO = no.
# But it is inappropriate to do so without checking if makeinfo is
# actually needed - it is not if the info files are up-to-date.  (Bug#3982)
# Only the doc/*/Makefiles can decide that, so we let those rules run
# and give a standard error if makeinfo is needed but missing.
# While it would be nice to give a more detailed error message, that
# would require changing every rule in doc/ that builds an info file,
# and it's not worth it.  This case is only relevant if you download a
# release, then change the .texi files.
1076
info:
Paul Eggert's avatar
Paul Eggert committed
1077 1078 1079
  ifneq ($(HAVE_MAKEINFO),no)
	$(MAKE) info-real info-dir
  endif
1080

1081 1082
## build-aux/make-info-dir expects only certain dircategories.
check-info: info
1083
	cd info ; \
1084
	bad= ; \
1085 1086 1087
	for file in *; do \
	  test -f "$${file}" || continue ; \
	  case $${file} in \
1088
	    *-[0-9]*|COPYING|dir) continue ;; \
1089
	  esac ; \
1090 1091
	  cat=`sed -n 's/^INFO-DIR-SECTION //p' $${file}`; \
	  case $${cat} in \
1092
	   "Texinfo documentation system" | "Emacs"| "Emacs lisp" | \
1093 1094 1095 1096
           "Emacs editing modes" | "Emacs network features" | \
	   "Emacs misc features" | "Emacs lisp libraries" ) : ;; \
	   *)  bad="$${bad} $${file}" ;; \
	  esac; \
1097
	done ; \
1098 1099
	if test -n "$${bad}"; then \
	  echo "Unexpected dircategory in: $${bad}" ; \
1100 1101
	  exit 1 ; \
	fi ; \
1102
	echo "info files are OK"
1103 1104 1105 1106 1107 1108 1109 1110

#### Bootstrapping.

### This first cleans the lisp subdirectory, removing all compiled
### Lisp files.  Then re-run make to build all the files anew.

.PHONY: bootstrap

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.
1116
bootstrap: bootstrap-clean
1117
	cd $(srcdir) && ./autogen.sh autoconf
1118 1119
	$(MAKE) MAKEFILE_NAME=force-Makefile force-Makefile
	$(MAKE) all
1120

1121
.PHONY: ChangeLog change-history change-history-commit change-history-nocommit
1122
.PHONY: preferred-branch-is-current unchanged-history-files
1123

1124
CHANGELOG = ChangeLog
1125
emacslog = build-aux/gitlog-to-emacslog
1126 1127 1128
# The ChangeLog history files are called ChangeLog.1, ChangeLog.2, ...,
# ChangeLog.$(CHANGELOG_HISTORY_INDEX_MAX).  $(CHANGELOG_N) stands for
# the newest (highest-numbered) ChangeLog history file.
1129
CHANGELOG_HISTORY_INDEX_MAX = 3
1130
CHANGELOG_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?
1134
ChangeLog:
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.
1139
PREFERRED_BRANCH = emacs-26
1140 1141
preferred-branch-is-current:
	git branch | grep -q '^\* $(PREFERRED_BRANCH)$$'
1142
unchanged-history-files:
1143
	x=$$(git diff-files --name-only $(CHANGELOG_N) $(emacslog)) && \
1144 1145
	  test -z "$$x"

1146 1147 1148
# Regular expression that matches the newest commit covered by a ChangeLog.
new_commit_regexp = ^commit [0123456789abcdef]* (inclusive)

1149 1150
# Copy newer commit messages to the start of the ChangeLog history file,
# and consider them to be older.
1151
change-history-nocommit: preferred-branch-is-current unchanged-history-files
1152
	-rm -f ChangeLog.tmp
1153
	$(MAKE) ChangeLog CHANGELOG=ChangeLog.tmp
1154 1155 1156 1157 1158
	sed '/^This file records repository revisions/,$$d' \
	  ChangeLog.tmp >$(CHANGELOG_N).tmp
	new_commit_line=`grep '$(new_commit_regexp)' ChangeLog.tmp` && \
	sed 's/$(new_commit_regexp).*/'"$$new_commit_line/" \
	  $(CHANGELOG_N) >>$(CHANGELOG_N).tmp
1159
	rm ChangeLog.tmp
1160
	mv $(CHANGELOG_N).tmp $(CHANGELOG_N)
1161 1162

change-history: change-history-nocommit
1163 1164 1165 1166 1167 1168
	$(MAKE) $@-commit

# If 'make change-history' fails because the newest ChangeLog history
# file contains invalid text, fix the file by hand and then run
# 'make change-history-commit'.
change-history-commit:
1169
	git commit -m'; make $@' $(CHANGELOG_N) $(emacslog)
1170

1171 1172 1173
.PHONY: check-declare

check-declare:
1174
	@if [ ! -f $(srcdir)/src/emacs ]; then \
1175 1176 1177
	  echo "You must build Emacs to use this command"; \
	  exit 1; \
	fi
1178
	$(MAKE) -C lisp $@
1179
	$(MAKE) -C test $@
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189

.PHONY: gitmerge

GITMERGE_EMACS = ./src/emacs${EXEEXT}
GITMERGE_NMIN = 10

gitmerge:
	${GITMERGE_EMACS} -batch --no-site-file --no-site-lisp \
	  -l ${srcdir}/admin/gitmerge.el \
	  --eval '(setq gitmerge-minimum-missing ${GITMERGE_NMIN})' -f gitmerge