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

Paul Eggert's avatar
Paul Eggert committed
3
# Copyright (C) 1992-2016 Free Software Foundation, Inc.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

# 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
# along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.

### 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
#
# make check  or  make check-expensive
#      Run Emacs test suite.  check-expensive runs also tests which
#      take more time to perform.
64

65
SHELL = @SHELL@
66

Glenn Morris's avatar
Glenn Morris committed
67 68
# This only matters when inheriting a CDPATH not starting with the
# current directory.
69 70 71 72 73
CDPATH=

# If Make doesn't predefine MAKE, set it here.
@SET_MAKE@

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

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

79 80 81 82
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
ACLOCAL = @ACLOCAL@
83
AWK = @AWK@
84

85 86 87 88 89 90
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,
91
### like '24.5' or '25.0.50'.
92 93 94
version=@version@

### This should be the name of the configuration we're building Emacs
95
### for, like 'x86_64-unknown-linux-gnu' or 'powerpc-ibm-aix7.1.2.0'.
96 97
configuration=@configuration@

98 99 100
### The nt/ subdirectory gets built only for MinGW
NTDIR=@NTDIR@

Paul Eggert's avatar
Paul Eggert committed
101 102 103 104 105 106 107 108 109 110 111 112 113
# '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 =

114 115
# ==================== Where To Install Things ====================

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

123 124 125 126 127 128
# 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@

129
# Like 'prefix', but used for architecture-specific files.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
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
150 151 152 153
# 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.
154 155
libexecdir=@libexecdir@

156 157 158
# Currently only used for the systemd service file.
libdir=@libdir@

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 200 201
# Where the etc/emacs.appdata.xml file is to be installed.
appdatadir=$(datarootdir)/appdata

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

# Where to install Emacs game score files.
gamedir=@gamedir@

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

# Allow the user to specify the install program.
278 279 280
# 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
281
# INSTALL-type commands from the directory containing the Makefile.
282
# This explains (I think) the cd thisdir seen in several install rules.
283 284 285 286 287 288
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 =
289
MKDIR_P = @MKDIR_P@
290 291
# Create a link to a file in the same directory as the target.
LN_S_FILEONLY = @LN_S_FILEONLY@
292

293
# We use gzip to compress installed .el and some .txt files.
294 295 296 297 298 299 300 301
GZIP_PROG = @GZIP_PROG@

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

# Program name transformation.
TRANSFORM = @program_transform_name@

# What emacs should be called when installed.
302 303
EMACS_NAME = `echo emacs | sed '$(TRANSFORM)'`
EMACS = ${EMACS_NAME}${EXEEXT}
304
EMACSFULL = `echo emacs-${version} | sed '$(TRANSFORM)'`${EXEEXT}
305

306
# Subdirectories to make recursively.
307
SUBDIR = $(NTDIR) lib lib-src src lisp
308 309

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

313 314 315
# 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
316 317 318
# separately.
COPYDIR = ${srcdir}/etc ${srcdir}/lisp
COPYDESTS = "$(DESTDIR)${etcdir}" "$(DESTDIR)${lispdir}"
319

320
all: ${SUBDIR} info
321

322 323 324 325 326 327 328 329 330 331 332 333
.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
334

335
# Generate epaths.h from epaths.in.  This target is invoked by 'configure'.
336
# See comments in configure.ac for why it is done this way, as opposed
337 338
# to just letting configure generate epaths.h from epaths.in in a
# similar way to how Makefile is made from Makefile.in.
Paul Eggert's avatar
Paul Eggert committed
339
epaths-force:
340 341 342
	@for dir in '$(abs_srcdir)' '$(lispdir)' '$(archlibdir)'; do \
	  case $$dir in \
	    *:*) \
343
	      printf >&2 "Build or installation directory '%s'\\n" "$$dir"; \
344 345 346 347
	      echo >&2 "cannot contain ':'."; \
	      exit 1;; \
	  esac; \
	done
348
	@(gamedir='${gamedir}'; \
349
	  sed < ${srcdir}/src/epaths.in > epaths.h.$$$$		\
350 351 352 353 354
	  -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/:"/"/'			\
355 356 357 358 359 360
	  -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}";' \
	  -e 's;\(#.*PATH_GAME\).*$$;\1 "${gamedir}";' \
361
	  -e 's;\(#.*PATH_DOC\).*$$;\1 "${etcdocdir}";') &&		\
362
	${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h
363

364 365
# The w32 build needs a slightly different editing, and it uses
# nt/epaths.nt as the template.
366
#
367
# Use the value of ${locallisppath} supplied by 'configure',
368
# to support the --enable-locallisppath argument.
369
#
370 371 372 373
# 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').
Paul Eggert's avatar
Paul Eggert committed
374
epaths-force-w32:
375
	@(w32srcdir=`${srcdir}/build-aux/msys-to-w32 "${abs_srcdir}"`; \
376
	  w32prefix=`${srcdir}/build-aux/msys-to-w32 "${prefix}"`; \
377 378
	  w32locallisppath=`${srcdir}/build-aux/msys-to-w32 "${locallisppath}"` ; \
	  w32locallisppath=$${w32locallisppath//$${w32prefix}/"%emacs_dir%"} ; \
379
	  sed < ${srcdir}/nt/epaths.nt > epaths.h.$$$$		\
380
	  -e 's;\(#.*PATH_SITELOADSEARCH\).*$$;\1 "'"$${w32locallisppath//;/\\;}"'";' \
381 382 383 384 385
	  -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

Paul Eggert's avatar
Paul Eggert committed
386 387 388 389
# If lib/Makefile would build files in '.', then build them before
# building 'lib', to avoid races with parallel makes.
lib: am--refresh

390
lib-src src: $(NTDIR) lib
Paul Eggert's avatar
Paul Eggert committed
391

Paul Eggert's avatar
Paul Eggert committed
392
src: lib-src
393

394
# We need to build 'emacs' in 'src' to compile the *.elc files in 'lisp'.
395
lisp: src
396

397
# These targets should be "${SUBDIR} without 'src'".
Paul Eggert's avatar
Paul Eggert committed
398
lib lib-src lisp nt: Makefile
399
	$(MAKE) -C $@ all
400

Eric S. Raymond's avatar
Eric S. Raymond committed
401 402 403 404 405
# 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.
#
406
# Pass an unexpanded $srcdir to src's Makefile, which then
Glenn Morris's avatar
Glenn Morris committed
407 408
# expands it using its own value of srcdir (which points to the
# source directory of src/).
409 410
dirstate = .git/logs/HEAD
VCSWITNESS = $(if $(wildcard $(srcdir)/$(dirstate)),$$(srcdir)/../$(dirstate))
Paul Eggert's avatar
Paul Eggert committed
411
src: Makefile
412
	$(MAKE) -C $@ VCSWITNESS='$(VCSWITNESS)' all
413

Paul Eggert's avatar
Paul Eggert committed
414
blessmail: Makefile src
415
	$(MAKE) -C lib-src maybe-blessmail
416 417 418 419

# We used to have one rule per */Makefile.in, but that leads to race
# conditions with parallel makes, so let's assume that the time stamp on
# ./Makefile is representative of the time stamp on all the other Makefiles.
420 421 422 423
#
# 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).
424 425 426 427
#
# '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.
428 429
MAKEFILE_NAME = Makefile
$(MAKEFILE_NAME): config.status $(srcdir)/src/config.in \
430
          $(srcdir)/Makefile.in $(SUBDIR_MAKEFILES_IN)
431
	MAKE='$(MAKE)' ./config.status
432

433 434
# Don't erase these files if make is interrupted while refreshing them.
.PRECIOUS: Makefile config.status
435

436
config.status: ${srcdir}/configure
437
	if [ -x ./config.status ]; then	\
438
	    $(CFG) ./config.status --recheck;	\
439
	else				\
440
	    $(CFG) $(srcdir)/configure $(CONFIGURE_FLAGS); \
441
	fi
442

443
AUTOCONF_INPUTS = $(srcdir)/configure.ac $(srcdir)/aclocal.m4
444 445

$(srcdir)/configure: $(AUTOCONF_INPUTS)
446
	cd ${srcdir} && ${AUTOCONF}
447

448
ACLOCAL_PATH = @ACLOCAL_PATH@
449
ACLOCAL_INPUTS = $(srcdir)/configure.ac $(srcdir)/m4/*.m4
Paul Eggert's avatar
Paul Eggert committed
450
$(srcdir)/aclocal.m4: $(ACLOCAL_INPUTS)
451
	cd $(srcdir) && ACLOCAL_PATH='$(ACLOCAL_PATH)' $(ACLOCAL) -I m4
Paul Eggert's avatar
Paul Eggert committed
452

453 454
AUTOMAKE_INPUTS = $(srcdir)/aclocal.m4 $(srcdir)/lib/Makefile.am \
  $(srcdir)/lib/gnulib.mk
Paul Eggert's avatar
Paul Eggert committed
455
$(srcdir)/lib/Makefile.in: $(AUTOMAKE_INPUTS)
456
	cd $(srcdir) && $(AUTOMAKE) --gnu -a -c lib/Makefile
457 458 459 460

# Regenerate files that this makefile would have made, if this makefile
# had been built by Automake.  The name 'am--refresh' is for
# compatibility with subsidiary Automake-generated makefiles.
461
am--refresh: $(srcdir)/aclocal.m4 $(srcdir)/configure $(srcdir)/src/config.in
462
.PHONY: am--refresh
Paul Eggert's avatar
Paul Eggert committed
463

464 465 466 467 468
$(srcdir)/src/config.in: $(srcdir)/src/stamp-h.in
	@ # Usually, there's no need to rebuild src/config.in just
	@ # because stamp-h.in has changed (since building stamp-h.in
	@ # refreshes config.in as well), but if config.in is missing
	@ # then we really need to do something more.
Paul Eggert's avatar
Paul Eggert committed
469
	$(if $(wildcard $@),,cd $(srcdir) && $(AUTOHEADER))
470
$(srcdir)/src/stamp-h.in: $(AUTOCONF_INPUTS)
471
	cd ${srcdir} && ${AUTOHEADER}
Paul Eggert's avatar
Paul Eggert committed
472 473
	rm -f $@
	echo timestamp > $@
474 475 476

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

477
.PHONY: install install-arch-dep install-arch-indep install-etcdoc install-info
478 479
.PHONY: install-man install-etc install-strip install-$(NTDIR)
.PHONY: uninstall uninstall-$(NTDIR)
480

481 482 483 484
## 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.

485
install: all install-arch-indep install-etcdoc install-arch-dep install-$(NTDIR) blessmail
486 487
	@true

488
## Ensure that $subdir contains a subdirs.el file.
489 490 491 492
## 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.
493
write_subdir=if [ -f "$${subdir}/subdirs.el" ]; \
494 495
	then true; \
	else \
496
	  umask 022; \
497
	  ${MKDIR_P} "$${subdir}"; \
498 499
	  (echo "(if (fboundp 'normal-top-level-add-subdirs-to-load-path)"; \
	   echo "    (normal-top-level-add-subdirs-to-load-path))") \
500
	    > "$${subdir}/subdirs.el"; \
501
	fi
502

503
### Install the executables that were compiled specifically for this machine.
504 505
### We do install-arch-indep first because the executable needs the
### Lisp files and DOC file to work properly.
506
install-arch-dep: src install-arch-indep install-etcdoc install-$(NTDIR)
507
	umask 022; ${MKDIR_P} "$(DESTDIR)${bindir}"
508
	$(MAKE) -C lib-src install
509 510
ifeq (${ns_self_contained},no)
	${INSTALL_PROGRAM} $(INSTALL_STRIP) src/emacs${EXEEXT} "$(DESTDIR)${bindir}/$(EMACSFULL)"
511
	-chmod 755 "$(DESTDIR)${bindir}/$(EMACSFULL)"
512 513 514 515 516 517 518 519
ifndef NO_BIN_LINK
	rm -f "$(DESTDIR)${bindir}/$(EMACS)"
	cd "$(DESTDIR)${bindir}" && $(LN_S_FILEONLY) $(EMACSFULL) $(EMACS)
endif
else
	subdir=${ns_appresdir}/site-lisp && ${write_subdir}
	rm -rf ${ns_appresdir}/share
endif
520 521 522 523 524

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

527
## In the share directory, we are deleting:
528 529
## applications (with emacs.desktop, also found in etc/)
## emacs (basically empty except for unneeded site-lisp directories)
530 531
## icons (duplicates etc/images/icons/hicolor)

Glenn Morris's avatar
Glenn Morris committed
532 533 534 535
## This is install-etc for everything except self-contained-ns builds.
## For them, it is empty.
INSTALL_ARCH_INDEP_EXTRA = @INSTALL_ARCH_INDEP_EXTRA@

536 537 538 539 540 541 542 543
## http://lists.gnu.org/archive/html/emacs-devel/2007-10/msg01672.html
## Needs to be the user running install, so configure can't set it.
set_installuser=for installuser in $${LOGNAME} $${USERNAME} $${USER} \
	  `id -un 2> /dev/null`; do \
	  [ -n "$${installuser}" ] && break ; \
	done

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

547 548 549 550 551
## 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.
552

553 554 555
## 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.
556
## install-etcdoc installs the relevant DOC.
557

558 559 560 561 562
## 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?).

563 564 565
## 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
566 567 568 569 570 571
## 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
572 573 574 575 576 577

## Note that we use tar instead of plain old cp -R/-r because the latter
## is apparently not portable (even in 2012!).
## http://lists.gnu.org/archive/html/emacs-devel/2012-05/msg00278.html
## 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
578 579
## See also these comments from 2004 about cp -r working fine:
## http://lists.gnu.org/archive/html/autoconf-patches/2004-11/msg00005.html
580
install-arch-indep: lisp install-info install-man ${INSTALL_ARCH_INDEP_EXTRA}
581 582 583 584
	-set ${COPYDESTS} ; \
	unset CDPATH; \
	$(set_installuser); \
	for dir in ${COPYDIR} ; do \
585
	  [ -d $${dir} ] || exit 1 ; \
586
	  dest="$$1" ; shift ; \
587 588 589 590 591
	  if [ -d "$${dest}" ]; then \
	    exp_dest=`cd "$${dest}" && /bin/pwd`; \
	    [ "$$exp_dest" = "`cd $${dir} && /bin/pwd`" ] && continue ; \
	  else true; \
	  fi; \
592 593
	  rm -rf "$${dest}" ; \
	  umask 022; ${MKDIR_P} "$${dest}" ; \
594
	  printf 'Copying %s to %s...\n' "$$dir" "$$dest" ; \
595
	  (cd $${dir}; tar -chf - . ) \
596
	    | (cd "$${dest}"; umask 022; \
597
	       tar -xvf - && cat > /dev/null) || exit 1; \
598
	  if [ "$${dir}" = "${srcdir}/etc" ]; then \
599 600
	      rm -f "$${dest}/DOC"* ; \
	      rm -f "$${dest}/refcards"/*.aux "$${dest}/refcards"/*.dvi; \
601
	      rm -f "$${dest}/refcards"/*.log "$${dest}/refcards"/*.in; \
602 603
	  else true; \
	  fi; \
604 605 606 607 608 609
	  (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 ; \
610 611
	      rm -f $${subdir}/#* ; \
	      rm -f $${subdir}/.#* ; \
612 613 614 615 616 617 618
	      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} {} ';' ;\
619
	done
620 621 622
	-rm -f "$(DESTDIR)${lispdir}/subdirs.el"
	umask 022; $(srcdir)/build-aux/update-subdirs "$(DESTDIR)${lispdir}"
	subdir="$(DESTDIR)${datadir}/emacs/${version}/site-lisp" ; \
623
	  ${write_subdir}
624
	subdir="$(DESTDIR)${datadir}/emacs/site-lisp" ; \
625
	  ${write_subdir} || true
626
	[ -z "${GZIP_PROG}" ] || { \
627
	  echo "Compressing *.el etc. ..." && \
628
	  cd "$(DESTDIR)${lispdir}" && \
629 630 631
	  for f in `find . -name "*.elc" -print | sed 's/.elc$$/.el/'`; do \
	    ${GZIP_PROG} -9n "$$f"; \
	  done; \
632
	  ${GZIP_PROG} -9n "../etc/publicsuffix.txt"; \
633
	}
634
	-chmod -R a+r "$(DESTDIR)${datadir}/emacs/${version}" ${COPYDESTS}
635

636 637 638
## 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.
639

640 641
## Note that install-arch-indep deletes and recreates the entire
## installed etc/ directory, so we need it to run before this does.
642
install-etcdoc: src install-arch-indep
643
	-unset CDPATH; \
644
	umask 022; ${MKDIR_P} "$(DESTDIR)${etcdocdir}" ; \
645 646
	exp_etcdocdir=`cd "$(DESTDIR)${etcdocdir}"; /bin/pwd`; \
	if [ "`cd ./etc; /bin/pwd`" != "$$exp_etcdocdir" ]; \
647
	then \
648
	   docfile="DOC"; \
649 650
	   printf 'Copying %s to %s ...\n' "etc/$$docfile" \
	     "$(DESTDIR)${etcdocdir}"; \
651
	   ${INSTALL_DATA} etc/$${docfile} "$(DESTDIR)${etcdocdir}/$${docfile}"; \
652
	   $(set_installuser); \
653
	     chown $${installuser} "$(DESTDIR)${etcdocdir}/$${docfile}" || true ; \
654
	else true; fi
655

656 657 658 659
## 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.
660 661 662
##
## FIXME:
## If HAVE_MAKEINFO = no and there are no info files, do not install info/dir.
663
install-info: info
664
	umask 022; ${MKDIR_P} "$(DESTDIR)${infodir}"
665 666
	-unset CDPATH; \
	thisdir=`/bin/pwd`; \
667 668
	exp_infodir=`cd "$(DESTDIR)${infodir}" && /bin/pwd`; \
	if [ "`cd ${srcdir}/info && /bin/pwd`" = "$$exp_infodir" ]; then \
669 670
	  true; \
	else \
671
	   [ -f "$(DESTDIR)${infodir}/dir" ] || \
672
	      [ ! -f ${srcdir}/info/dir ] || \
673
	      ${INSTALL_DATA} ${srcdir}/info/dir "$(DESTDIR)${infodir}/dir"; \
674
	   info_misc=`$(MAKE) --no-print-directory -s -C doc/misc echo-info`; \
675
	   cd ${srcdir}/info ; \
676
	   for elt in ${INFO_NONMISC} $${info_misc}; do \
677
	      test "$(HAVE_MAKEINFO)" = "no" && test ! -f $$elt && continue; \
678
	      for f in `ls $$elt $$elt-[1-9] $$elt-[1-9][0-9] 2>/dev/null`; do \
679
	       (cd "$${thisdir}"; \
680
	        ${INSTALL_DATA} ${srcdir}/info/$$f "$(DESTDIR)${infodir}/$$f"); \
681
	        [ -n "${GZIP_PROG}" ] || continue ; \
682 683
	        rm -f "$(DESTDIR)${infodir}/$$f.gz"; \
	        ${GZIP_PROG} -9n "$(DESTDIR)${infodir}/$$f"; \
684
	      done; \
685
	     (cd "$${thisdir}"; \
686
	      ${INSTALL_INFO} --info-dir="$(DESTDIR)${infodir}" "$(DESTDIR)${infodir}/$$elt"); \
687 688
	   done; \
	fi
689

690 691 692 693 694 695
## "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.
696
install-man:
697
	umask 022; ${MKDIR_P} "$(DESTDIR)${man1dir}"
698 699
	thisdir=`/bin/pwd`; \
	cd ${mansrcdir}; \
700
	for page in *.1; do \
701
	  test "$$page" = ChangeLog.1 && continue; \
702
	  dest=`echo "$${page}" | sed -e 's/\.1$$//' -e '$(TRANSFORM)'`.1; \
703
	  (cd "$${thisdir}"; \
704
	   ${INSTALL_DATA} ${mansrcdir}/$${page} "$(DESTDIR)${man1dir}/$${dest}"); \
705
	  [ -n "${GZIP_PROG}" ] || continue ; \
706 707
	  rm -f "$(DESTDIR)${man1dir}/$${dest}.gz"; \
	  ${GZIP_PROG} -9n "$(DESTDIR)${man1dir}/$${dest}" || true; \
708 709 710
	done

## Install those items from etc/ that need to end up elsewhere.
711 712 713 714 715

## 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
716
install-etc:
717
	umask 022; ${MKDIR_P} "$(DESTDIR)${desktopdir}"
718
	tmp=etc/emacs.tmpdesktop; rm -f $${tmp}; \
719 720 721
	emacs_name=`echo emacs | sed '$(TRANSFORM)'`; \
	sed -e "/^Exec=emacs/ s/emacs/$${emacs_name}/" \
	  -e "/^Icon=emacs/ s/emacs/$${emacs_name}/" \
722
	  ${srcdir}/etc/emacs.desktop > $${tmp}; \
723
	${INSTALL_DATA} $${tmp} "$(DESTDIR)${desktopdir}/${EMACS_NAME}.desktop"; \
724
	rm -f $${tmp}
725 726 727 728 729 730
	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}
731 732 733 734 735 736 737 738 739 740 741 742
	umask 022; $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)"
	tmp=etc/emacs.tmpservice; rm -f $${tmp}; \
	emacs_name=`echo emacs | sed '$(TRANSFORM)'`; \
	exe_name=$${emacs_name}${EXEEXT}; \
	client_name=`echo emacsclient | sed '$(TRANSFORM)'`${EXEEXT}; \
	sed -e '/^##/d' \
	  -e "/^Documentation/ s/emacs(1)/$${emacs_name}(1)/" \
	  -e "/^ExecStart/ s|emacs|$(DESTDIR)${bindir}/$${exe_name}|" \
	  -e "/^ExecStop/ s|emacsclient|$(DESTDIR)${bindir}/$${client_name}|" \
	  ${srcdir}/etc/emacs.service > $${tmp}; \
	$(INSTALL_DATA) $${tmp} "$(DESTDIR)$(systemdunitdir)/${EMACS_NAME}.service"; \
	rm -f $${tmp}
743
	thisdir=`/bin/pwd`; \
Glenn Morris's avatar
Glenn Morris committed
744 745 746
	cd ${iconsrcdir} || exit 1; umask 022 ; \
	for dir in */*/apps */*/mimetypes; do \
	  [ -d $${dir} ] || continue ; \
747
	  ( cd "$${thisdir}"; ${MKDIR_P} "$(DESTDIR)${icondir}/$${dir}" ) ; \
748
	  for icon in $${dir}/${EMACS_ICON}[.-]*; do \
Glenn Morris's avatar
Glenn Morris committed
749
	    [ -r $${icon} ] || continue ; \
750
	    ext=`echo "$${icon}" | sed -e 's|.*\.||'`; \
751
	    dest=`echo "$${icon}" | sed -e 's|.*/||' -e "s|\\.$${ext}\$$||" -e 's/$(EMACS_ICON)/emacs/' -e '$(TRANSFORM)'`.$${ext} ; \
752
	    ( cd "$${thisdir}"; \
753
	      ${INSTALL_DATA} ${iconsrcdir}/$${icon} "$(DESTDIR)${icondir}/$${dir}/$${dest}" ) \
754
	    || exit 1; \
Glenn Morris's avatar
Glenn Morris committed
755
	  done ; \
756 757 758 759
	done

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

762 763
### Delete all the installed files that the 'install' target would
### create (but not the noninstalled files such as 'make all' would create).
764 765
###
### Don't delete the lisp and etc directories if they're in the source tree.
766
uninstall: uninstall-$(NTDIR) uninstall-doc
767
	$(MAKE) -C lib-src uninstall
768
	-unset CDPATH; \
769 770
	for dir in "$(DESTDIR)${lispdir}" "$(DESTDIR)${etcdir}" ; do 	\
	  if [ -d "$${dir}" ]; then			\
771 772
	    case `cd "$${dir}" ; /bin/pwd` in		\
	      "`cd ${srcdir} ; /bin/pwd`"* ) ;;		\
773
	      * ) rm -rf "$${dir}" ;;			\
774
	    esac ;					\
775 776 777
	    case "$${dir}" in				\
	      "$(DESTDIR)${datadir}/emacs/${version}"/* )		\
	        rm -rf "$(DESTDIR)${datadir}/emacs/${version}"	\
778 779 780 781
	      ;;					\
	    esac ;					\
	  fi ;						\
	done
782
	-rm -rf "$(DESTDIR)${libexecdir}/emacs/${version}"
783
	thisdir=`/bin/pwd`; \
784
	(info_misc=`$(MAKE) --no-print-directory -s -C doc/misc echo-info`; \
785
	 if cd "$(DESTDIR)${infodir}"; then \
Glenn Morris's avatar
Glenn Morris committed
786
	   for elt in ${INFO_NONMISC} $${info_misc}; do \
787
	     (cd "$${thisdir}"; \
788
	      $(INSTALL_INFO) --remove --info-dir="$(DESTDIR)${infodir}" "$(DESTDIR)${infodir}/$$elt"); \
789
	     if [ -n "${GZIP_PROG}" ]; then \
Glenn Morris's avatar
Glenn Morris committed
790 791 792 793
	        ext=.gz; else ext=; fi; \
	     rm -f $$elt$$ext $$elt-[1-9]$$ext $$elt-[1-9][0-9]$$ext; \
	   done; \
	 fi)
794
	(if [ -n "${GZIP_PROG}" ]; then \
795
	    ext=.gz; else ext=; fi; \
Glenn Morris's avatar
Glenn Morris committed
796 797
	 if cd ${mansrcdir}; then \
	   for page in *.1; do \
798
	     rm -f "$(DESTDIR)${man1dir}"/`echo "$${page}" | sed -e 's/\.1$$//' -e '$(TRANSFORM)'`.1$$ext; done; \
Glenn Morris's avatar
Glenn Morris committed
799
	 fi)
800 801
	(cd "$(DESTDIR)${bindir}" && rm -f $(EMACSFULL) $(EMACS) || true)
	(if cd "$(DESTDIR)${icondir}"; then \
802 803
	   rm -f hicolor/*x*/apps/${EMACS_NAME}.png \
	     hicolor/scalable/apps/${EMACS_NAME}.svg \
Glenn Morris's avatar
Glenn Morris committed
804 805
	     hicolor/scalable/mimetypes/`echo emacs-document | sed '$(TRANSFORM)'`.svg; \
	fi)
806
	-rm -f "$(DESTDIR)${desktopdir}/${EMACS_NAME}.desktop"
807
	-rm -f "$(DESTDIR)${appdatadir}/${EMACS_NAME}.appdata.xml"
808
	-rm -f "$(DESTDIR)$(systemdunitdir)/${EMACS_NAME}.service"
809
	for file in snake-scores tetris-scores; do \
810 811
	  file="$(DESTDIR)${gamedir}/$${file}"; \
	  [ -s "$${file}" ] || rm -f "$$file"; \
812 813
	done

814 815 816 817
### Windows-specific uninstall target for removing programs produced
### in nt/, and its Posix do-nothing shadow.
uninstall-:
uninstall-nt:
818
	$(MAKE) -C $(NTDIR) uninstall
819

820 821
# ==================== Cleaning up and miscellanea ====================

822
.PHONY: mostlyclean clean distclean bootstrap-clean maintainer-clean extraclean
823

824 825 826 827 828 829 830 831 832
## Eg:
## src_clean:
##     make -C src clean
define submake_template
.PHONY: $(1)_$(2)
$(1)_$(2):
	$$(MAKE) -C $(1) $(2)
endef

833 834 835 836
### '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
837
###      is rarely necessary and takes a lot of time.
838 839 840 841 842 843
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)
844 845 846
	for dir in test/automated; do \
	  [ ! -d $$dir ] || $(MAKE) -C $$dir mostlyclean; \
	done
847

848
### 'clean'
849 850 851 852 853 854
###      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.
###
855
###      Delete '.dvi' files here if they are not part of the distribution.
856 857 858 859 860
clean_dirs = $(mostlyclean_dirs) nextstep

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

clean: $(clean_dirs:=_clean)
861
	for dir in test/automated admin/charsets; do \
862 863
	  [ ! -d $$dir ] || $(MAKE) -C $$dir clean; \
	done
864
	-rm -f *.tmp etc/*.tmp*
865
	-rm -rf info-dir.*
866

867
### 'bootclean'
868 869
###      Delete all files that need to be remade for a clean bootstrap.
top_bootclean=\
870
	rm -f config.cache config.log ${srcdir}/doc/man/emacs.1
871

872
### 'distclean'
873 874 875
###      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,
876
###      'make distclean' should leave only the files that were in the
877 878 879