Makefile.in 32.6 KB
Newer Older
Jim Blandy's avatar
Jim Blandy committed
1 2 3
# DIST: This is the distribution Makefile for Emacs.  configure can
# DIST: make most of the changes to this file you might want, so try
# DIST: that first.
Jim Blandy's avatar
Jim Blandy committed
4

Glenn Morris's avatar
Glenn Morris committed
5
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
Glenn Morris's avatar
Glenn Morris committed
6
#   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Glenn Morris's avatar
Glenn Morris committed
7
#   Free Software Foundation, Inc.
Gerd Moellmann's avatar
Gerd Moellmann committed
8 9 10

# This file is part of GNU Emacs.

11
# GNU Emacs is free software: you can redistribute it and/or modify
Gerd Moellmann's avatar
Gerd Moellmann committed
12
# it under the terms of the GNU General Public License as published by
13 14
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
Gerd Moellmann's avatar
Gerd Moellmann committed
15 16 17 18 19 20 21

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

### Commentary:
Gerd Moellmann's avatar
Gerd Moellmann committed
25

Jim Blandy's avatar
Jim Blandy committed
26 27
# make all	to compile and build Emacs.
# make install	to install it.
28
# make TAGS	to update tags tables.
Jim Blandy's avatar
Jim Blandy committed
29
#
30 31
# make clean  or  make mostlyclean
#      Delete all files from the current directory that are normally
32
#      created by building the program.	 Don't delete the files that
33 34 35 36 37
#      record the configuration.  Also preserve files that could be made
#      by building, but normally aren't because the distribution comes
#      with them.
#
#      Delete `.dvi' files here if they are not part of the distribution.
38
#
39 40 41 42 43 44
# 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,
#      `make distclean' should leave only the files that were in the
#      distribution.
45
#
46
# make maintainer-clean
47 48
#      Delete everything from the current directory that can be
#      reconstructed with this Makefile.  This typically includes
49 50 51
#      everything deleted by distclean, plus more: .elc files,
#      C source files produced by Bison, tags tables, info files,
#      and so on.
52 53 54
#
# make extraclean
#      Still more severe - delete backup and autosave files, too.
Richard M. Stallman's avatar
Richard M. Stallman committed
55
#
Richard M. Stallman's avatar
Richard M. Stallman committed
56
# make bootstrap
57 58
#      Removes all the compiled files to force a new bootstrap from a
#      clean slate, and then build in the normal way.
Jim Blandy's avatar
Jim Blandy committed
59 60

SHELL = /bin/sh
61

Luc Teirlinck's avatar
Luc Teirlinck committed
62 63 64 65
# This may not work with certain non-GNU make's.  It only matters when
# inheriting a CDPATH not starting with the current directory.
CDPATH=

66 67
# If Make doesn't predefine MAKE, set it here.
@SET_MAKE@
Jim Blandy's avatar
Jim Blandy committed
68

69
# ==================== Things `configure' Might Edit ====================
Jim Blandy's avatar
Jim Blandy committed
70

71
CC=@CC@
72
CPP=@CPP@
73
C_SWITCH_SYSTEM=@c_switch_system@
74
ALLOCA=@ALLOCA@
75 76
LN_S=@LN_S@
CFLAGS=@CFLAGS@
77
LDFLAGS=@LDFLAGS@
78
CPPFLAGS=@CPPFLAGS@
79
C_SWITCH_X_SITE=@C_SWITCH_X_SITE@
Jim Blandy's avatar
Jim Blandy committed
80
LD_SWITCH_X_SITE=@LD_SWITCH_X_SITE@
81
EXEEXT=@EXEEXT@
82
MAKEINFO=@MAKEINFO@
83 84 85 86 87 88

### 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,
### like `18.59' or `19.0'.
89
version=@version@
90 91 92

### This should be the name of the configuration we're building Emacs
### for, like `mips-dec-ultrix' or `sparc-sun-sunos'.
93 94
configuration=@configuration@

95 96
# ==================== Where To Install Things ====================

Jim Blandy's avatar
Jim Blandy committed
97
# The default location for installation.  Everything is placed in
98 99
# subdirectories of this directory.  The default values for many of
# the variables below are expressed in terms of this one, so you may
100 101
# not need to change them.  This defaults to /usr/local.
prefix=@prefix@
Jim Blandy's avatar
Jim Blandy committed
102

103
# Like `prefix', but used for architecture-specific files.
104
exec_prefix=@exec_prefix@
105

Jim Blandy's avatar
Jim Blandy committed
106 107
# Where to install Emacs and other binaries that people will want to
# run directly (like etags).
108
bindir=@bindir@
Jim Blandy's avatar
Jim Blandy committed
109

Andreas Schwab's avatar
Andreas Schwab committed
110 111 112 113
# The root of the directory tree for read-only architecture-independent
# data files.  ${datadir}, ${infodir} and ${mandir} are based on this.
datarootdir=@datarootdir@

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

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

# Where to install and expect executable files to be run by Emacs
# rather than directly by users, and other architecture-dependent
125
# data.	 ${archlibdir} is a subdirectory of this.
126
libexecdir=@libexecdir@
127

Glenn Morris's avatar
Glenn Morris committed
128 129 130 131
# Where to install Emacs's man pages.
# This used to allow choice of the numeric extension, but this made
# little sense since the files were always installed in man1/
# (and they contain cross-references that expect them to be there).
132
mandir=@mandir@
133
man1dir=$(mandir)/man1
Glenn Morris's avatar
Glenn Morris committed
134 135
MAN_PAGES=b2m.1 ctags.1 ebrowse.1 emacs.1 emacsclient.1 etags.1 \
          grep-changelog.1 rcs-checkin.1
136 137 138 139 140

# Where to install and expect the info files describing Emacs.	In the
# past, this defaulted to a subdirectory of ${prefix}/lib/emacs, but
# since there are now many packages documented with the texinfo
# system, it is inappropriate to imply that it is part of Emacs.
141
infodir=@infodir@
142
INFO_FILES=ada-mode autotype calc ccmode cl dbus dired-x ebrowse ediff	\
143
           efaq eintr elisp emacs emacs-mime epa erc eshell eudc	\
144
           flymake forms gnus idlwave info mairix-el message mh-e	\
Eli Zaretskii's avatar
Eli Zaretskii committed
145 146 147
           newsticker nxml-mode org pcl-cvs pgg rcirc reftex remember	\
           sasl sc ses sieve speedbar tramp vip viper widget woman	\
           smtpmail url
Jim Blandy's avatar
Jim Blandy committed
148

149 150 151
# Directory for local state files for all programs.
localstatedir=@localstatedir@

152 153 154
# Where to look for bitmap files.
bitmapdir=@bitmapdir@

155
# Where to find the source code.  The source code for Emacs's C kernel is
156 157 158
# 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
# set by the configure script's `--srcdir' option.
Richard M. Stallman's avatar
Richard M. Stallman committed
159 160

# We use $(srcdir) explicitly in dependencies so as not to depend on VPATH.
161
srcdir=@srcdir@
Jim Blandy's avatar
Jim Blandy committed
162

Glenn Morris's avatar
Glenn Morris committed
163 164 165
# Where the manpage source files are kept.
mansrcdir=$(srcdir)/doc/man

Roland McGrath's avatar
Roland McGrath committed
166 167 168
# Tell make where to find source files; this is needed for the makefiles.
VPATH=@srcdir@

169 170 171
# Where to find the application default.
x_default_search_path=@x_default_search_path@

172 173
# Location to install Emacs.app under NeXT/Open/GNUstep / Cocoa
ns_appdir=@ns_appdir@
174 175
ns_appbindir=@ns_appbindir@
ns_appresdir=@ns_appresdir@
176

177 178 179 180 181 182
# Where the etc/emacs.desktop file is to be installed.
desktopdir=$(datarootdir)/applications

# Where the etc/images/icons/hicolor directory is to be installed.
icondir=$(datarootdir)/icons

Glenn Morris's avatar
Glenn Morris committed
183 184 185
# The source directory for the icon files.
iconsrcdir=$(srcdir)/etc/images/icons

186 187
# ==================== Emacs-specific directories ====================

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

191 192 193 194 195
# 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.
lispdir=@lispdir@
196

197 198 199 200 201
# Directories Emacs should search for lisp files specific
# to this site (i.e. customizations), before consulting
# ${lispdir}.  This should be a colon-separated list of
# directories.
locallisppath=@locallisppath@
202 203 204 205

# 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
Jim Blandy's avatar
Jim Blandy committed
206
# should be a colon-separated list of directories.
207
lisppath=@lisppath@
Jim Blandy's avatar
Jim Blandy committed
208

209 210 211 212
# 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.
213
# It's usually identical to lisppath, except that
Richard M. Stallman's avatar
Richard M. Stallman committed
214
# it does not include locallisppath, and the
215 216 217
# entry for the directory containing the installed lisp
# files has been replaced with ../lisp.  This should be a
# colon-separated list of directories.
218
buildlisppath=${srcdir}/lisp
Jim Blandy's avatar
Jim Blandy committed
219

220 221 222 223 224 225 226 227 228 229 230 231 232 233
# 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@
234

235 236 237
# Where to put the docstring file.
docdir=@docdir@

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

Jim Blandy's avatar
Jim Blandy committed
241 242 243
# ==================== Utility Programs for the Build ====================

# Allow the user to specify the install program.
244
INSTALL = @INSTALL@
245 246
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
247
INSTALL_INFO = @INSTALL_INFO@
248 249
# By default, we uphold the dignity of our programs.
INSTALL_STRIP =
Jim Blandy's avatar
Jim Blandy committed
250

251
# We use gzip to compress installed .el files.
252
GZIP_PROG = @GZIP_PROG@
253

Jim Blandy's avatar
Jim Blandy committed
254
# ============================= Targets ==============================
Jim Blandy's avatar
Jim Blandy committed
255

256 257 258
# Program name transformation.
TRANSFORM = @program_transform_name@

259
# What emacs should be called when installed.
260 261
EMACS = `echo emacs${EXEEXT} | sed '$(TRANSFORM)'`
EMACSFULL = `echo emacs-${version}${EXEEXT} | sed '$(TRANSFORM)'`
262

Jim Blandy's avatar
Jim Blandy committed
263
# Subdirectories to make recursively.  `lisp' is not included
264
# because the compiled lisp files are part of the distribution.
Gerd Moellmann's avatar
Gerd Moellmann committed
265
# leim is not included because it needs special handling.
266 267 268 269 270
# 
# Actually, we now include `lisp' as well, since the compiled files
# are not included any more in case of bootstrap or in case Emacs was
# checked out from a VCS.
SUBDIR = lib-src src lisp
Jim Blandy's avatar
Jim Blandy committed
271

272 273
# The subdir makefiles created by config.status.
SUBDIR_MAKEFILES = lib-src/Makefile doc/emacs/Makefile doc/misc/Makefile doc/lispref/Makefile doc/lispintro/Makefile src/Makefile oldXMenu/Makefile lwlib/Makefile leim/Makefile lisp/Makefile
274

275 276
# Subdirectories to install, and where they'll go.
# lib-src's makefile knows how to install it, so we don't do that here.
Kenichi Handa's avatar
Kenichi Handa committed
277
# leim's makefile also knows how to install it, so we don't do that here.
278 279 280
# When installing the info files, we need to do special things to
# avoid nuking an existing dir file, so we don't do that here;
# instead, we have written out explicit code in the `install' targets.
281
COPYDIR = ${srcdir}/etc ${srcdir}/lisp
282
COPYDESTS = $(DESTDIR)${etcdir} $(DESTDIR)${lispdir}
Jim Blandy's avatar
Jim Blandy committed
283

284
all: ${SUBDIR} leim
Jim Blandy's avatar
Jim Blandy committed
285

286
removenullpaths=sed -e 's/^://g' -e 's/:$$//g' -e 's/::/:/g'
Jim Blandy's avatar
Jim Blandy committed
287

288 289
# Generate epaths.h from epaths.in.  This target is invoked by `configure'.
epaths-force: FRC
290 291
	@(lisppath=`echo ${lisppath} | ${removenullpaths}` ;		\
	  buildlisppath=`echo ${buildlisppath} | ${removenullpaths}` ;	\
292
	  x_default_search_path=`echo ${x_default_search_path}`; \
293
	  gamedir=`echo ${gamedir}`; \
294
	  sed < ${srcdir}/src/epaths.in > epaths.h.$$$$		\
295 296
	  -e 's;\(#.*PATH_LOADSEARCH\).*$$;\1 "'"$${lisppath}"'";'	\
	  -e 's;\(#.*PATH_DUMPLOADSEARCH\).*$$;\1 "'"$${buildlisppath}"'";' \
297 298 299
	  -e 's;\(#.*PATH_EXEC\).*$$;\1 "${archlibdir}";'		\
	  -e 's;\(#.*PATH_INFO\).*$$;\1 "${infodir}";'			\
	  -e 's;\(#.*PATH_DATA\).*$$;\1 "${etcdir}";'			\
300
	  -e 's;\(#.*PATH_BITMAPS\).*$$;\1 "${bitmapdir}";'		\
301
	  -e 's;\(#.*PATH_X_DEFAULTS\).*$$;\1 "${x_default_search_path}";' \
302
	  -e 's;\(#.*PATH_GAME\).*$$;\1 "${gamedir}";' \
303 304
	  -e 's;\(#.*PATH_DOC\).*$$;\1 "${docdir}";' \
	  -e 's;/[*] *arch-tag:.*;/*;') &&		\
305
	${srcdir}/move-if-change epaths.h.$$$$ src/epaths.h
306

Romain Francoise's avatar
Romain Francoise committed
307
# For parallel make, src should be built before leim.
Gerd Moellmann's avatar
Gerd Moellmann committed
308 309 310
# "export PARALLEL=0" is for SGI's Make, to prevent it from
# running more than 1 process in the leim directory, especially for
# the $TIT files there.
311
leim:   src Makefile FRC
Gerd Moellmann's avatar
Gerd Moellmann committed
312 313 314
	(export PARALLEL; PARALLEL=0; cd $@; $(MAKE) all $(MFLAGS) \
	  CC='${CC}' CFLAGS='${CFLAGS}' CPPFLAGS='${CPPFLAGS}' \
	  LDFLAGS='${LDFLAGS}' MAKE='${MAKE}')
315

316
src:	lib-src FRC
317

Gerd Moellmann's avatar
Gerd Moellmann committed
318
.RECURSIVE: ${SUBDIR} leim
Jim Blandy's avatar
Jim Blandy committed
319

320 321 322
# We need to build `emacs' in `src' to compile the *.elc files in `lisp'.
lisp: src

323 324 325 326 327 328
# These targets should be "${SUBDIR} without `src'".
lib-src lisp: Makefile FRC
	cd $@; $(MAKE) all $(MFLAGS)                           \
	  CC='${CC}' CFLAGS='${CFLAGS}' CPPFLAGS='${CPPFLAGS}' \
	  LDFLAGS='${LDFLAGS}' MAKE='${MAKE}'

329 330 331 332 333 334 335 336 337
# Pass to src/Makefile.in an additional BOOTSTRAPEMACS variable which
# is either set to bootstrap-emacs (in case bootstrap-emacs has not been
# constructed yet) or the empty string (otherwise).
# src/Makefile.in uses it to implement conditional dependencies, so that
# files that need bootstrap-emacs to be built do not additionally need
# to be kept fresher than bootstrap-emacs.  Otherwise changing a single
# file src/foo.c forces dumping a new bootstrap-emacs, then re-byte-compiling
# all preloaded elisp files, and only then dump the actual src/emacs, which
# is not wrong, but is overkill in 99.99% of the cases.
338
src: Makefile FRC
339
	boot=bootstrap-emacs$(EXEEXT);                         \
340 341 342 343
	if [ ! -x "src/$$boot" ]; then                                     \
	    cd $@; $(MAKE) all $(MFLAGS)                                   \
	      CC='${CC}' CFLAGS='${CFLAGS}' CPPFLAGS='${CPPFLAGS}'         \
	      LDFLAGS='${LDFLAGS}' MAKE='${MAKE}' BOOTSTRAPEMACS="$$boot"; \
344
	fi;
345
	cd $@; $(MAKE) all $(MFLAGS)                           \
346
	  CC='${CC}' CFLAGS='${CFLAGS}' CPPFLAGS='${CPPFLAGS}' \
347
	  LDFLAGS='${LDFLAGS}' MAKE='${MAKE}' BOOTSTRAPEMACS=""
348

349
blessmail: Makefile src FRC
350 351
	cd lib-src; $(MAKE) maybe-blessmail $(MFLAGS) \
	  MAKE='${MAKE}' archlibdir='$(archlibdir)'
352

353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
# 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.
Makefile: config.status $(srcdir)/src/config.in \
          $(srcdir)/Makefile.in \
          $(srcdir)/src/Makefile.in \
          $(srcdir)/lib-src/Makefile.in \
          $(srcdir)/doc/emacs/Makefile.in \
          $(srcdir)/doc/misc/Makefile.in \
          $(srcdir)/doc/lispref/Makefile.in \
          $(srcdir)/doc/lispintro/Makefile.in \
          $(srcdir)/oldXMenu/Makefile.in \
          $(srcdir)/lwlib/Makefile.in \
          $(srcdir)/leim/Makefile.in \
          $(srcdir)/lisp/Makefile.in
368 369
	./config.status

370
config.status: ${srcdir}/configure ${srcdir}/lisp/version.el
371 372
	./config.status --recheck

373 374 375
AUTOCONF_INPUTS = @MAINT@ $(srcdir)/configure.in $(srcdir)/m4/getopt.m4

$(srcdir)/configure: $(AUTOCONF_INPUTS)
376 377
	cd ${srcdir} && autoconf

378 379
$(srcdir)/src/config.in: $(srcdir)/src/stamp-h.in
	@true
380
$(srcdir)/src/stamp-h.in: $(AUTOCONF_INPUTS)
381 382 383 384
	cd ${srcdir} && autoheader
	rm -f $(srcdir)/src/stamp-h.in
	echo timestamp > $(srcdir)/src/stamp-h.in

385 386
# ==================== Installation ====================

Jim Blandy's avatar
Jim Blandy committed
387 388 389
## 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.
390

391 392 393
## On AIX, use tar xBf.
## On Xenix, use tar xpf.

394
.PHONY: install mkdir
395

396 397 398 399 400
## 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.
401 402
### We do install-arch-indep first because
### the executable needs the Lisp files and DOC file to work properly.
Karl Heuer's avatar
Karl Heuer committed
403
install: all install-arch-indep install-arch-dep install-leim blessmail
404
	@true
405

406 407
MV_DIRS = for i in $$dir; do rm -fr $$(basename "$$i") ; mv "$$i" . ; done

408
### Install the executables that were compiled specifically for this machine.
409 410 411
### It would be nice to do something for a parallel make
### to ensure that install-arch-indep finishes before this starts.
install-arch-dep: mkdir
412
	(cd lib-src; \
413
	  $(MAKE) install $(MFLAGS) prefix=${prefix} \
414
	    exec_prefix=${exec_prefix} bindir=${bindir} \
415 416
	    libexecdir=${libexecdir} archlibdir=${archlibdir} \
	    INSTALL_STRIP=${INSTALL_STRIP})
417 418 419 420
	${INSTALL_PROGRAM} $(INSTALL_STRIP) src/emacs${EXEEXT} $(DESTDIR)${bindir}/$(EMACSFULL)
	-chmod 1755 $(DESTDIR)${bindir}/$(EMACSFULL)
	rm -f $(DESTDIR)${bindir}/$(EMACS)
	-ln $(DESTDIR)${bindir}/$(EMACSFULL) $(DESTDIR)${bindir}/$(EMACS)
421
	-unset CDPATH; \
422
	for f in `cd lib-src && echo fns-*.el`; do \
423
	  if test -r lib-src/$$f ; then \
424
	    ${INSTALL_DATA} lib-src/$$f $(DESTDIR)${archlibdir}/$$f; \
425
	  else true; fi ; \
426
	done
427
	if test "${ns_appdir}" != ""; then \
428
	  ( cd ${ns_appresdir} ; \
429 430
	    if test -d share/emacs ; then dir=share/emacs/*/*; $(MV_DIRS); fi;\
	    if test -d share/info ; then dir=share/info; $(MV_DIRS) ; fi ; \
431
	    rm -fr share ) ; \
432 433
	  ( cd ${ns_appbindir}/libexec ; dir=emacs/*/*/* ; $(MV_DIRS); \
	    rm -fr emacs ) ; \
434 435 436
	  ( cd ${ns_appbindir}/bin ; rm -f emacs emacs-23* ; \
	    ln -sf ../libexec/* .) ; \
	else true ; fi
437

Glenn Morris's avatar
Glenn Morris committed
438 439 440 441 442 443 444
## 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

445 446 447
### Install the files that are machine-independent.
### Most of them come straight from the distribution;
### the exception is the DOC-* files, which are copied
Glenn Morris's avatar
Glenn Morris committed
448
### from the build directory.
449

Kenichi Handa's avatar
Kenichi Handa committed
450 451
## Note that we copy DOC* and then delete DOC
## as a workaround for a bug in tar on Ultrix 4.2.
452

453 454 455
## We install only the relevant DOC file if possible
## (ie DOC-${version}.buildnumber), otherwise DOC-${version}*.

456 457
## If people complain about the h flag in tar command, take that out.
## That flag is also used in leim/Makefile.in
458 459 460

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

462
install-arch-indep: mkdir info install-etc
Jim Blandy's avatar
Jim Blandy committed
463
	-set ${COPYDESTS} ; \
464
	unset CDPATH; \
465 466 467 468 469 470
	for dir in ${COPYDIR} ; do \
	  if [ `(cd $$1 && /bin/pwd)` != `(cd $${dir} && /bin/pwd)` ] ; then \
	    rm -rf $$1 ; \
	  fi ; \
	  shift ; \
	done
471
	-set ${COPYDESTS} ; \
472 473
	mkdir ${COPYDESTS} ; \
	chmod ugo+rx ${COPYDESTS} ; \
474
	unset CDPATH; \
Glenn Morris's avatar
Glenn Morris committed
475
	$(set_installuser); \
476 477 478 479 480
	for dir in ${COPYDIR} ; do \
	  dest=$$1 ; shift ; \
	  [ -d $${dir} ] \
	  && [ `(cd $${dir} && /bin/pwd)` != `(cd $${dest} && /bin/pwd)` ] \
	  && (echo "Copying $${dir} to $${dest}..." ; \
481
	      (cd $${dir}; tar -chf - . ) \
482 483
		| (cd $${dest}; umask 022; \
                   tar -xvf - && cat > /dev/null) || exit 1; \
484
	      find $${dest} -exec chown $${installuser} {} ';' ;\
485
	      for subdir in `find $${dest} -type d ! -name RCS ! -name CVS -print` ; do \
486
		chmod a+rx $${subdir} ; \
487 488
		rm -rf $${subdir}/RCS ; \
		rm -rf $${subdir}/CVS ; \
489
		rm -f  $${subdir}/.cvsignore ; \
490
		rm -f  $${subdir}/.arch-inventory ; \
491 492 493 494
		rm -f  $${subdir}/\#* ; \
		rm -f  $${subdir}/.\#* ; \
		rm -f  $${subdir}/*~ ; \
		rm -f  $${subdir}/*.orig ; \
495 496
		[ "$${dir}" != "${srcdir}/etc" ] && \
			rm -f  $${subdir}/[mM]akefile* ; \
497 498 499 500
		rm -f  $${subdir}/ChangeLog* ; \
		rm -f  $${subdir}/dired.todo ; \
	      done) ; \
	done
501 502 503
	-rm -f $(DESTDIR)${lispdir}/subdirs.el
	$(srcdir)/update-subdirs $(DESTDIR)${lispdir}
	if [ -f $(DESTDIR)${datadir}/emacs/${version}/site-lisp/subdirs.el ]; \
504 505 506 507
	then true; \
	else \
	  (echo "(if (fboundp 'normal-top-level-add-subdirs-to-load-path)"; \
	   echo "    (normal-top-level-add-subdirs-to-load-path))") \
508
	    > $(DESTDIR)${datadir}/emacs/${version}/site-lisp/subdirs.el; \
509
	fi
510 511
	chmod a+r $(DESTDIR)${datadir}/emacs/${version}/site-lisp/subdirs.el
	-if [ -f $(DESTDIR)${datadir}/emacs/site-lisp/subdirs.el ]; \
512 513 514 515
	then true; \
	else \
	  (echo "(if (fboundp 'normal-top-level-add-subdirs-to-load-path)"; \
	   echo "    (normal-top-level-add-subdirs-to-load-path))") \
516
	    > $(DESTDIR)${datadir}/emacs/site-lisp/subdirs.el; \
517
	fi
518
	-chmod a+r $(DESTDIR)${datadir}/emacs/site-lisp/subdirs.el
519
	-unset CDPATH; \
520
	if [ `(cd ./etc; /bin/pwd)` != `(cd $(DESTDIR)${docdir}; /bin/pwd)` ]; \
521
	then \
522 523 524 525 526 527 528 529 530
	   fullversion=`./src/emacs --version | sed -n '1 s/GNU Emacs *//p'`; \
	   if [ -f "./etc/DOC-$${fullversion}" ]; \
	   then \
	     docfile="DOC-$${fullversion}"; \
	   else \
	     docfile="DOC-${version}*"; \
	   fi; \
	   echo "Copying etc/$${docfile} to $(DESTDIR)${docdir} ..." ; \
	   (cd ./etc; tar -chf - $${docfile}) \
531
	     |(cd $(DESTDIR)${docdir}; umask 022; tar -xvf - && cat > /dev/null) || exit 1; \
532
	   (cd $(DESTDIR)$(docdir); \
Glenn Morris's avatar
Glenn Morris committed
533
	    $(set_installuser); \
534
	    chown $${installuser} DOC*; chmod a+r DOC*; \
535
	    if test "`echo DOC-*`" != "DOC-*"; then rm -f DOC; fi); \
536
	else true; fi
537
	-unset CDPATH; \
538 539
	if [ -r ./lisp ] \
	   && [ -r ./lisp/simple.el ] \
540
	   && [ x`(cd ./lisp; /bin/pwd)` != x`(cd $(DESTDIR)${lispdir}; /bin/pwd)` ] \
541
	   && [ x`(cd ${srcdir}/lisp; /bin/pwd)` != x`(cd ./lisp; /bin/pwd)` ]; \
542
	then \
543
	   echo "Copying lisp/*.el and lisp/*.elc to $(DESTDIR)${lispdir} ..." ; \
544
	   (cd lisp; tar -chf - *.el *.elc) \
545
	     |(cd $(DESTDIR)${lispdir}; umask 022; tar -xvf - && cat > /dev/null) || exit 1; \
546
	   (cd $(DESTDIR)${lispdir}; \
Glenn Morris's avatar
Glenn Morris committed
547
	    $(set_installuser); \
548
	    find . -exec chown $${installuser} {} ';') ; \
549
	else true; fi
550
	-unset CDPATH; \
551
	if [ -n "${GZIP_PROG}" ]; \
552 553
	then \
	   echo "Compressing *.el ..." ; \
554
	   (cd $(DESTDIR)${lispdir}; for f in `find . -name "*.elc" -print`; do \
555
		${GZIP_PROG} -9n `echo $$f|sed 's/.elc$$/.el/'` ; \
556 557 558
	    done) \
	else true; fi
	-unset CDPATH; \
559
	thisdir=`/bin/pwd`; \
560
	if [ `(cd ${srcdir}/info && /bin/pwd)` != `(cd $(DESTDIR)${infodir} && /bin/pwd)` ]; \
561
	then \
562
	  (cd $(DESTDIR)${infodir};  \
563 564 565
	   if [ -f dir ]; then true; \
	   else	\
	     (cd $${thisdir}; \
566 567
	      ${INSTALL_DATA} ${srcdir}/info/dir $(DESTDIR)${infodir}/dir; \
	      chmod a+r $(DESTDIR)${infodir}/dir); \
568
	   fi; \
569
	   cd ${srcdir}/info ; \
570
	   for elt in $(INFO_FILES); do \
571
	      test "$(MAKEINFO)" = "off" && ! test -e $$elt && continue; \
572 573 574 575
	      for f in `ls $$elt $$elt-[1-9] $$elt-[1-9][0-9] 2>/dev/null`; do \
	        ${INSTALL_DATA} $$f $(DESTDIR)${infodir}/$$f; \
	        chmod a+r $(DESTDIR)${infodir}/$$f; \
	      done; \
Richard M. Stallman's avatar
Richard M. Stallman committed
576
	   done); \
577
	else true; fi
578 579
	-unset CDPATH; \
	thisdir=`/bin/pwd`; \
580
	if [ `(cd ${srcdir}/info && /bin/pwd)` != `(cd $(DESTDIR)${infodir} && /bin/pwd)` ]; \
581
	then \
582
	  for elt in $(INFO_FILES); do \
583
	    test "$(MAKEINFO)" = "off" && ! test -e $$elt && continue; \
584
	    (cd $${thisdir}; \
585
	     ${INSTALL_INFO} --info-dir=$(DESTDIR)${infodir} $(DESTDIR)${infodir}/$$elt); \
586 587
	  done; \
	else true; fi
588
	-chmod -R a+r $(DESTDIR)${datadir}/emacs/${version} $(DESTDIR)${datadir}/emacs/site-lisp ${COPYDESTS} $(DESTDIR)${infodir}
589
	thisdir=`/bin/pwd`; \
Glenn Morris's avatar
Glenn Morris committed
590
	cd ${mansrcdir}; \
Glenn Morris's avatar
Glenn Morris committed
591
	for page in ${MAN_PAGES}; do \
592
	  (cd $${thisdir}; \
Glenn Morris's avatar
Glenn Morris committed
593 594
	   ${INSTALL_DATA} ${mansrcdir}/$${page} $(DESTDIR)${man1dir}/$${page}; \
	   chmod a+r $(DESTDIR)${man1dir}/$${page}); \
595
	done
Jim Blandy's avatar
Jim Blandy committed
596

597 598 599 600
## Install those items from etc/ that need to end up elsewhere.
install-etc: mkdir
	${INSTALL_DATA} ${srcdir}/etc/emacs.desktop \
	  $(DESTDIR)${desktopdir}/emacs.desktop
601 602
	for icon in $(iconsrcdir)/*/*/apps/*.* \
	  $(iconsrcdir)/*/*/mimetypes/*.*; do \
603 604 605 606 607 608
	  if [ -r $${icon} ]; then \
	    iicon=`echo "$${icon}" | sed 's,$(srcdir)/etc/images/icons,$(DESTDIR)${icondir},'` ; \
	    ${INSTALL_DATA} $${icon} $${iicon} ; \
	  fi ; \
	done

Kenichi Handa's avatar
Kenichi Handa committed
609 610 611 612
### Install LEIM files.  Although they are machine-independent, we
### have separate target here instead of including it in
### `install-arch-indep'.  People who extracted LEIM files after they
### insalled Emacs itself can install only LEIM files by this target.
613
install-leim: leim/Makefile mkdir
614
	cd leim; $(MAKE) install
Kenichi Handa's avatar
Kenichi Handa committed
615

616 617
### Build Emacs and install it, stripping binaries while installing them.
install-strip:
618
	$(MAKE) INSTALL_STRIP=-s install
619

620
### Build all the directories we're going to install Emacs in.	Since
621
### we may be creating several layers of directories (for example,
622
### /usr/local/lib/emacs/19.0/mips-dec-ultrix4.2), we use mkinstalldirs
623
### instead of mkdir.  Not all systems' mkdir programs have the `-p' flag.
Richard M. Stallman's avatar
Richard M. Stallman committed
624
mkdir: FRC
625 626 627
	if [ -d $(DESTDIR)${datadir} ]; then true; else \
	  $(srcdir)/mkinstalldirs $(DESTDIR)${datadir}; \
	  chmod a+r $(DESTDIR)${datadir};\
628
	fi
629
	icondirs= ; \
630
	for dir in $(iconsrcdir)/*/*/apps $(iconsrcdir)/*/*/mimetypes; do \
631 632 633 634 635
	  if [ -d $${dir} ]; then \
	    icondirs="$${icondirs} $${dir}" ; \
	  fi ; \
	done ; \
	icondirs=`echo "$${icondirs}" | sed 's,$(srcdir)/etc/images/icons,$(DESTDIR)${icondir},g'` ; \
636 637 638 639
	$(srcdir)/mkinstalldirs ${COPYDESTS} $(DESTDIR)${infodir} $(DESTDIR)${man1dir} \
	  $(DESTDIR)${bindir} $(DESTDIR)${docdir} $(DESTDIR)${libexecdir} \
	  $(DESTDIR)${datadir}/emacs/site-lisp \
	  $(DESTDIR)${datadir}/emacs/${version}/site-lisp \
640 641
	  $(DESTDIR)`echo ${locallisppath} | sed 's,:, $(DESTDIR),g'` \
	  $(DESTDIR)${desktopdir} $${icondirs}
Jim Blandy's avatar
Jim Blandy committed
642

643 644 645
### Delete all the installed files that the `install' target would
### create (but not the noninstalled files such as `make all' would
### create).
646 647
###
### Don't delete the lisp and etc directories if they're in the source tree.
648
uninstall:
649
	(cd lib-src; 					\
650
	 $(MAKE) $(MFLAGS) uninstall			\
651
	    prefix=${prefix} exec_prefix=${exec_prefix}	\
652
	    bindir=${bindir} libexecdir=${libexecdir} archlibdir=${archlibdir})
653
	-unset CDPATH; \
654
	for dir in $(DESTDIR)${lispdir} $(DESTDIR)${etcdir} ; do 	\
655
	  if [ -d $${dir} ]; then			\
656 657
	    case `(cd $${dir} ; /bin/pwd)` in		\
	      `(cd ${srcdir} ; /bin/pwd)`* ) ;;		\
658 659 660
	      * ) rm -rf $${dir} ;;			\
	    esac ;					\
	    case $${dir} in				\
661 662
	      $(DESTDIR)${datadir}/emacs/${version}/* )		\
	        rm -rf $(DESTDIR)${datadir}/emacs/${version}	\
663 664 665
	      ;;					\
	    esac ;					\
	  fi ;						\
666
	done
667 668
	(cd $(DESTDIR)${archlibdir} && rm -f fns-*)
	-rm -rf $(DESTDIR)${libexecdir}/emacs/${version}
669 670 671 672 673 674 675
	(cd $(DESTDIR)${infodir} && \
	  for elt in $(INFO_FILES); do \
	    $(INSTALL_INFO) --remove --info-dir=. $$elt; \
	    for f in `ls $$elt $$elt-[1-9] $$elt-[1-9][0-9] 2>/dev/null`; do \
	      rm -f $$f; \
	    done; \
	  done;)
Glenn Morris's avatar
Glenn Morris committed
676
	(cd $(DESTDIR)${man1dir}  && rm -f $(MAN_PAGES))
677
	(cd $(DESTDIR)${bindir}  && rm -f $(EMACSFULL) $(EMACS))
678
	(cd $(DESTDIR)${icondir} && rm -f hicolor/*x*/apps/emacs.png hicolor/*x*/apps/emacs22.png hicolor/scalable/apps/emacs.svg hicolor/scalable/mimetypes/emacs-document.svg )
679 680 681 682 683
	-rm -f $(DESTDIR)${desktopdir}/emacs.desktop
	for file in snake-scores tetris-scores; do \
	  file=$(DESTDIR)${gamedir}/$${file}; \
	  [ -s $${file} ] || rm -f $$file; \
	done
684

Richard M. Stallman's avatar
Richard M. Stallman committed
685
FRC:
686 687 688

# ==================== Cleaning up and miscellanea ====================

689
.PHONY: mostlyclean clean distclean maintainer-clean extraclean
690

691
### `mostlyclean'
692 693 694 695
###      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
###      is rarely necessary and takes a lot of time.
Richard M. Stallman's avatar
Richard M. Stallman committed
696
mostlyclean: FRC
697 698
	(cd src;      $(MAKE) $(MFLAGS) mostlyclean)
	(cd oldXMenu; $(MAKE) $(MFLAGS) mostlyclean)
699
	(cd lwlib;    $(MAKE) $(MFLAGS) mostlyclean)
700
	(cd lib-src;  $(MAKE) $(MFLAGS) mostlyclean)
Glenn Morris's avatar
Glenn Morris committed
701 702 703 704
	-(cd doc/emacs &&   $(MAKE) $(MFLAGS) mostlyclean)
	-(cd doc/misc &&   $(MAKE) $(MFLAGS) mostlyclean)
	-(cd doc/lispref &&   $(MAKE) $(MFLAGS) mostlyclean)
	-(cd doc/lispintro &&   $(MAKE) $(MFLAGS) mostlyclean)
705
	(cd leim;     $(MAKE) $(MFLAGS) mostlyclean)
706 707 708 709 710 711 712

### `clean'
###      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.
713
###
714
###      Delete `.dvi' files here if they are not part of the distribution.
Richard M. Stallman's avatar
Richard M. Stallman committed
715
clean: FRC
716 717
	(cd src;      $(MAKE) $(MFLAGS) clean)
	(cd oldXMenu; $(MAKE) $(MFLAGS) clean)
718
	(cd lwlib;    $(MAKE) $(MFLAGS) clean)
719
	(cd lib-src;  $(MAKE) $(MFLAGS) clean)
Glenn Morris's avatar
Glenn Morris committed
720 721 722 723
	-(cd doc/emacs &&   $(MAKE) $(MFLAGS) clean)
	-(cd doc/misc &&   $(MAKE) $(MFLAGS) clean)
	-(cd doc/lispref &&   $(MAKE) $(MFLAGS) clean)
	-(cd doc/lispintro &&   $(MAKE) $(MFLAGS) clean)
724
	(cd leim;     $(MAKE) $(MFLAGS) clean)
Jim Blandy's avatar
Jim Blandy committed
725

726 727 728
### `bootclean'
###      Delete all files that need to be remade for a clean bootstrap.
top_bootclean=\
729
	rm -f config.cache config.log
730
### `distclean'
731 732 733 734 735 736
###      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,
###      `make distclean' should leave only the files that were in the
###      distribution.
top_distclean=\
737 738
	${top_bootclean}; \
	rm -f config.status Makefile ${SUBDIR_MAKEFILES}
Richard M. Stallman's avatar
Richard M. Stallman committed
739
distclean: FRC
740 741
	(cd src;      $(MAKE) $(MFLAGS) distclean)
	(cd oldXMenu; $(MAKE) $(MFLAGS) distclean)
742
	(cd lwlib;    $(MAKE) $(MFLAGS) distclean)
743
	(cd lib-src;  $(MAKE) $(MFLAGS) distclean)
Glenn Morris's avatar
Glenn Morris committed
744 745 746 747
	(cd doc/emacs &&    $(MAKE) $(MFLAGS) distclean)
	(cd doc/misc &&    $(MAKE) $(MFLAGS) distclean)
	(cd doc/lispref &&    $(MAKE) $(MFLAGS) distclean)
	(cd doc/lispintro &&    $(MAKE) $(MFLAGS) distclean)
748
	(cd leim;     $(MAKE) $(MFLAGS) distclean)
749
	(cd lisp;     $(MAKE) $(MFLAGS) distclean)
750
	${top_distclean}
Jim Blandy's avatar
Jim Blandy committed
751

752 753 754 755 756 757 758 759 760 761 762 763 764
### `bootstrap-clean'
###      Delete everything that can be reconstructed by `make' and that
###      needs to be deleted in order to force a bootstrap from a clean state.
bootstrap-clean: FRC
	(cd src;      $(MAKE) $(MFLAGS) bootstrap-clean)
	(cd oldXMenu; $(MAKE) $(MFLAGS) maintainer-clean)
	(cd lwlib;    $(MAKE) $(MFLAGS) maintainer-clean)
	(cd lib-src;  $(MAKE) $(MFLAGS) maintainer-clean)
	-(cd doc/emacs &&   $(MAKE) $(MFLAGS) maintainer-clean)
	-(cd doc/misc &&   $(MAKE) $(MFLAGS) maintainer-clean)
	-(cd doc/lispref &&   $(MAKE) $(MFLAGS) maintainer-clean)
	-(cd doc/lispintro &&   $(MAKE) $(MFLAGS) maintainer-clean)
	(cd leim;     $(MAKE) $(MFLAGS) maintainer-clean)
765 766
	(cd lisp;     $(MAKE) $(MFLAGS) bootstrap-clean)
	${top_bootclean}
767

768
### `maintainer-clean'
769 770 771 772
###      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.
773
###
774
###      One exception, however: `make maintainer-clean' should not delete
775
###      `configure' even if `configure' can be remade using a rule in the
776
###      Makefile.  More generally, `make maintainer-clean' should not delete
777 778
###      anything that needs to exist in order to run `configure' and then
###      begin to build the program.
779
maintainer-clean: bootstrap-clean FRC
780
	(cd src;      $(MAKE) $(MFLAGS) maintainer-clean)
781 782
	(cd lisp;     $(MAKE) $(MFLAGS) maintainer-clean)
	${top_distclean}
Jim Blandy's avatar
Jim Blandy committed
783

784 785 786 787 788
### 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.
extraclean:
Gerd Moellmann's avatar
Gerd Moellmann committed
789
	for i in ${SUBDIR} leim; do (cd $$i; $(MAKE) $(MFLAGS) extraclean); done
790
	${top_distclean}
791
	-rm -f config-tmp-*
792 793
	-rm -f *~ \#*