* Makefile.in (lib, lib-src, lisp): Check cd return value.
[bpt/emacs.git] / Makefile.in
CommitLineData
067d23c9
KY
1# DIST: This is the distribution Makefile for Emacs. configure can
2# DIST: make most of the changes to this file you might want, so try
3# DIST: that first.
4
fd9d85c2 5# Copyright (C) 1992-2012 Free Software Foundation, Inc.
067d23c9
KY
6
7# This file is part of GNU Emacs.
8
9# GNU Emacs is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13
14# GNU Emacs is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18
19# You should have received a copy of the GNU General Public License
20# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22### Commentary:
23
24# make all to compile and build Emacs.
25# make install to install it.
26# make TAGS to update tags tables.
27#
28# make clean or make mostlyclean
29# Delete all files from the current directory that are normally
30# created by building the program. Don't delete the files that
31# record the configuration. Also preserve files that could be made
32# by building, but normally aren't because the distribution comes
33# with them.
34#
35# Delete `.dvi' files here if they are not part of the distribution.
36#
37# make distclean
38# Delete all files from the current directory that are created by
39# configuring or building the program. If you have unpacked the
40# source and built the program without creating any other files,
41# `make distclean' should leave only the files that were in the
42# distribution.
43#
44# make maintainer-clean
45# Delete everything from the current directory that can be
46# reconstructed with this Makefile. This typically includes
47# everything deleted by distclean, plus more: .elc files,
48# C source files produced by Bison, tags tables, info files,
49# and so on.
50#
51# make extraclean
52# Still more severe - delete backup and autosave files, too.
53#
54# make bootstrap
55# Removes all the compiled files to force a new bootstrap from a
56# clean slate, and then build in the normal way.
57
58SHELL = /bin/sh
59
60# This may not work with certain non-GNU make's. It only matters when
61# inheriting a CDPATH not starting with the current directory.
62CDPATH=
63
64# If Make doesn't predefine MAKE, set it here.
65@SET_MAKE@
66
67# ==================== Things `configure' Might Edit ====================
68
6c269a38
PE
69MAINTAINER_MODE_FLAG = --disable-maintainer-mode
70@MAINT@MAINTAINER_MODE_FLAG = --enable-maintainer-mode
71cache_file = @cache_file@
72CONFIGURE_FLAGS = --cache-file=$(cache_file) $(MAINTAINER_MODE_FLAG)
73
067d23c9
KY
74CC=@CC@
75CFLAGS=@CFLAGS@
76LDFLAGS=@LDFLAGS@
77CPPFLAGS=@CPPFLAGS@
78EXEEXT=@EXEEXT@
067d23c9
KY
79
80### These help us choose version- and architecture-specific directories
81### to install files in.
82
83### This should be the number of the Emacs version we're building,
84### like `18.59' or `19.0'.
85version=@version@
86
87### This should be the name of the configuration we're building Emacs
88### for, like `mips-dec-ultrix' or `sparc-sun-sunos'.
89configuration=@configuration@
90
91# ==================== Where To Install Things ====================
92
3a4155de
GM
93# Location to install Emacs.app under GNUstep / Mac OS X.
94# Later values may use these.
95ns_appbindir=@ns_appbindir@
96ns_appresdir=@ns_appresdir@
b4a36200
GM
97# Either yes or no depending on whether this is a relocatable Emacs.app.
98ns_self_contained=@ns_self_contained@
3a4155de 99
067d23c9
KY
100# The default location for installation. Everything is placed in
101# subdirectories of this directory. The default values for many of
102# the variables below are expressed in terms of this one, so you may
103# not need to change them. This defaults to /usr/local.
104prefix=@prefix@
105
106# Like `prefix', but used for architecture-specific files.
107exec_prefix=@exec_prefix@
108
109# Where to install Emacs and other binaries that people will want to
110# run directly (like etags).
111bindir=@bindir@
112
113# The root of the directory tree for read-only architecture-independent
114# data files. ${datadir}, ${infodir} and ${mandir} are based on this.
115datarootdir=@datarootdir@
116
117# Where to install architecture-independent data files. ${lispdir}
118# and ${etcdir} are subdirectories of this.
119datadir=@datadir@
120
121# Where to install and expect the files that Emacs modifies as it
122# runs. These files are all architecture-independent.
123# Right now, this is not used.
124sharedstatedir=@sharedstatedir@
125
126# Where to install and expect executable files to be run by Emacs
3a4155de
GM
127# rather than directly by users (and other architecture-dependent
128# data, although Emacs does not have any). The executables
129# are actually installed in ${archlibdir}, which is (normally)
130# a subdirectory of this.
067d23c9
KY
131libexecdir=@libexecdir@
132
133# Where to install Emacs's man pages.
ab1121bd 134# Note they contain cross-references that expect them to be in section 1.
067d23c9
KY
135mandir=@mandir@
136man1dir=$(mandir)/man1
067d23c9 137
9aa071df 138# Where to install and expect the info files describing Emacs.
067d23c9 139infodir=@infodir@
9aa071df 140# Info files not in the doc/misc directory (we get those via make echo-info).
8045b906
GM
141INFO_EXT=@INFO_EXT@
142INFO_NONMISC=emacs$(INFO_EXT) eintr$(INFO_EXT) elisp$(INFO_EXT)
067d23c9 143
e5365138
GM
144# If no makeinfo was found and configured --without-makeinfo, "no"; else "yes".
145HAVE_MAKEINFO=@HAVE_MAKEINFO@
146
067d23c9
KY
147# Directory for local state files for all programs.
148localstatedir=@localstatedir@
149
150# Where to look for bitmap files.
151bitmapdir=@bitmapdir@
152
153# Where to find the source code. The source code for Emacs's C kernel is
154# expected to be in ${srcdir}/src, and the source code for Emacs's
155# utility programs is expected to be in ${srcdir}/lib-src. This is
156# set by the configure script's `--srcdir' option.
157
158# We use $(srcdir) explicitly in dependencies so as not to depend on VPATH.
159srcdir=@srcdir@
160
161# Where the manpage source files are kept.
162mansrcdir=$(srcdir)/doc/man
163
164# Tell make where to find source files; this is needed for the makefiles.
165VPATH=@srcdir@
166
167# Where to find the application default.
168x_default_search_path=@x_default_search_path@
169
067d23c9
KY
170# Where the etc/emacs.desktop file is to be installed.
171desktopdir=$(datarootdir)/applications
172
173# Where the etc/images/icons/hicolor directory is to be installed.
174icondir=$(datarootdir)/icons
175
176# The source directory for the icon files.
177iconsrcdir=$(srcdir)/etc/images/icons
178
179# ==================== Emacs-specific directories ====================
180
181# These variables hold the values Emacs will actually use. They are
182# based on the values of the standard Make variables above.
183
184# Where to install the lisp files distributed with
185# Emacs. This includes the Emacs version, so that the
186# lisp files for different versions of Emacs will install
187# themselves in separate directories.
188lispdir=@lispdir@
189
190# Directories Emacs should search for lisp files specific
191# to this site (i.e. customizations), before consulting
192# ${lispdir}. This should be a colon-separated list of
193# directories.
194locallisppath=@locallisppath@
195
196# Where Emacs will search to find its lisp files. Before
197# changing this, check to see if your purpose wouldn't
198# better be served by changing locallisppath. This
199# should be a colon-separated list of directories.
200lisppath=@lisppath@
201
202# Where Emacs will search for its lisp files while
203# building. This is only used during the process of
204# compiling Emacs, to help Emacs find its lisp files
205# before they've been installed in their final location.
5b43da69
GM
206# This should be a colon-separated list of directories.
207# Normally it points to the lisp/ directory in the sources.
067d23c9
KY
208buildlisppath=${srcdir}/lisp
209
210# Where to install the other architecture-independent
211# data files distributed with Emacs (like the tutorial,
212# the cookie recipes and the Zippy database). This path
213# usually contains the Emacs version number, so the data
214# files for multiple versions of Emacs may be installed
215# at once.
216etcdir=@etcdir@
217
218# Where to put executables to be run by Emacs rather than
219# the user. This path usually includes the Emacs version
220# and configuration name, so that multiple configurations
221# for multiple versions of Emacs may be installed at
222# once.
223archlibdir=@archlibdir@
224
225# Where to put the docstring file.
226docdir=@docdir@
227
228# Where to install Emacs game score files.
229gamedir=@gamedir@
230
231# ==================== Utility Programs for the Build ====================
232
233# Allow the user to specify the install program.
a36e64d0
GM
234# Note that if the system does not provide a suitable install,
235# configure will use build-aux/install-sh. Annoyingly, it does
236# not use an absolute path. So we must take care to always run
3fe7cdc8 237# INSTALL-type commands from the directory containing the Makefile.
a36e64d0 238# This explains (I think) the cd thisdir seen in several install rules.
067d23c9
KY
239INSTALL = @INSTALL@
240INSTALL_PROGRAM = @INSTALL_PROGRAM@
241INSTALL_DATA = @INSTALL_DATA@
242INSTALL_INFO = @INSTALL_INFO@
243# By default, we uphold the dignity of our programs.
244INSTALL_STRIP =
3fe7cdc8 245MKDIR_P = @MKDIR_P@
067d23c9
KY
246
247# We use gzip to compress installed .el files.
248GZIP_PROG = @GZIP_PROG@
249# If non-nil, gzip the installed Info and man pages.
250GZIP_INFO = @GZIP_INFO@
251
252# ============================= Targets ==============================
253
254# Program name transformation.
255TRANSFORM = @program_transform_name@
256
257# What emacs should be called when installed.
258EMACS = `echo emacs${EXEEXT} | sed '$(TRANSFORM)'`
259EMACSFULL = `echo emacs-${version}${EXEEXT} | sed '$(TRANSFORM)'`
260
261# Subdirectories to make recursively. `lisp' is not included
262# because the compiled lisp files are part of the distribution.
263# leim is not included because it needs special handling.
925e561d 264#
067d23c9
KY
265# Actually, we now include `lisp' as well, since the compiled files
266# are not included any more in case of bootstrap or in case Emacs was
267# checked out from a VCS.
9a514d4a 268SUBDIR = lib lib-src src lisp
067d23c9
KY
269
270# The subdir makefiles created by config.status.
70716b1d 271SUBDIR_MAKEFILES_IN = @SUBDIR_MAKEFILES_IN@
cee4acda 272SUBDIR_MAKEFILES = `echo $(SUBDIR_MAKEFILES_IN:.in=) | sed 's|$(srcdir)/||g'`
067d23c9
KY
273
274# Subdirectories to install, and where they'll go.
275# lib-src's makefile knows how to install it, so we don't do that here.
276# leim's makefile also knows how to install it, so we don't do that here.
277# When installing the info files, we need to do special things to
278# avoid nuking an existing dir file, so we don't do that here;
279# instead, we have written out explicit code in the `install' targets.
280COPYDIR = ${srcdir}/etc ${srcdir}/lisp
281COPYDESTS = $(DESTDIR)${etcdir} $(DESTDIR)${lispdir}
282
283all: ${SUBDIR} leim
284
285removenullpaths=sed -e 's/^://g' -e 's/:$$//g' -e 's/::/:/g'
286
287# Generate epaths.h from epaths.in. This target is invoked by `configure'.
288# See comments in configure.in for why it is done this way, as opposed
289# to just letting configure generate epaths.h from epaths.in in a
290# similar way to how Makefile is made from Makefile.in.
291epaths-force: FRC
292 @(lisppath=`echo ${lisppath} | ${removenullpaths}` ; \
293 buildlisppath=`echo ${buildlisppath} | ${removenullpaths}` ; \
294 x_default_search_path=`echo ${x_default_search_path}`; \
295 gamedir=`echo ${gamedir}`; \
296 sed < ${srcdir}/src/epaths.in > epaths.h.$$$$ \
297 -e 's;\(#.*PATH_LOADSEARCH\).*$$;\1 "'"$${lisppath}"'";' \
298 -e 's;\(#.*PATH_DUMPLOADSEARCH\).*$$;\1 "'"$${buildlisppath}"'";' \
299 -e 's;\(#.*PATH_EXEC\).*$$;\1 "${archlibdir}";' \
300 -e 's;\(#.*PATH_INFO\).*$$;\1 "${infodir}";' \
301 -e 's;\(#.*PATH_DATA\).*$$;\1 "${etcdir}";' \
302 -e 's;\(#.*PATH_BITMAPS\).*$$;\1 "${bitmapdir}";' \
303 -e 's;\(#.*PATH_X_DEFAULTS\).*$$;\1 "${x_default_search_path}";' \
304 -e 's;\(#.*PATH_GAME\).*$$;\1 "${gamedir}";' \
dc3e3e7b 305 -e 's;\(#.*PATH_DOC\).*$$;\1 "${docdir}";') && \
24e0f6b1 306 ${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h
067d23c9
KY
307
308# For parallel make, src should be built before leim.
067d23c9 309leim: src Makefile FRC
e7333757 310 cd leim && $(MAKE) all $(MFLAGS)
067d23c9 311
9a514d4a
PE
312lib-src src: lib
313
067d23c9
KY
314src: lib-src FRC
315
316.RECURSIVE: ${SUBDIR} leim
317
318# We need to build `emacs' in `src' to compile the *.elc files in `lisp'.
319lisp: src
320
9a514d4a
PE
321# Maintainers can put a copy of gnulib into $(gnulib_srcdir).
322gnulib_srcdir = ../gnulib
323$(gnulib_srcdir):
324 git clone git://git.savannah.gnu.org/gnulib.git $@
325
125c3718 326# A shorter name that satisfies MS-DOS 8+3 constraints.
c7e95b91 327DOS_gnulib_comp.m4 = gl-comp.m4
125c3718 328
9a514d4a
PE
329# Update modules from gnulib, for maintainers, who should have it in
330# $(gnulib_srcdir) (relative to $(srcdir) and should have build tools
331# as per $(gnulib_srcdir)/DEPENDENCIES.
942f733f 332GNULIB_MODULES = \
fa23e171 333 alloca-opt \
3ce9d0d4 334 careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr \
7a7ef429 335 dup2 \
6db30f83 336 filemode getloadavg getopt-gnu ignore-value intprops lstat \
b8df54ff
PE
337 manywarnings mktime pthread_sigmask readlink \
338 socklen stdarg stdio strftime strtoimax strtoumax symlink sys_stat \
339 warnings
9a514d4a 340GNULIB_TOOL_FLAGS = \
6df37268 341 --avoid=msvc-inval --avoid=msvc-nothrow \
316f8af0 342 --avoid=raise --avoid=threadlib \
19548d08
PE
343 --conditional-dependencies --import --no-changelog --no-vc-files \
344 --makefile-name=gnulib.mk
9a514d4a 345sync-from-gnulib: $(gnulib_srcdir)
c7e95b91 346 -cd $(srcdir)/m4 && cp $(DOS_gnulib_comp.m4) gnulib-comp.m4
9a514d4a
PE
347 cd $(srcdir) && \
348 $(gnulib_srcdir)/gnulib-tool $(GNULIB_TOOL_FLAGS) $(GNULIB_MODULES)
125c3718 349 cd $(srcdir)/m4 && rm gnulib-cache.m4 warn-on-use.m4
c7e95b91 350 cd $(srcdir)/m4 && mv gnulib-comp.m4 $(DOS_gnulib_comp.m4)
9a514d4a
PE
351 cp $(gnulib_srcdir)/build-aux/texinfo.tex $(srcdir)/doc/misc
352 cp \
9a514d4a 353 $(gnulib_srcdir)/build-aux/move-if-change \
24e0f6b1 354 $(srcdir)/build-aux
f6ca84c0 355 cd $(srcdir) && autoreconf -i -I m4
9a514d4a
PE
356.PHONY: sync-from-gnulib
357
067d23c9 358# These targets should be "${SUBDIR} without `src'".
9a514d4a 359lib lib-src lisp: Makefile FRC
2e5d41e4 360 cd $@ && $(MAKE) all $(MFLAGS) \
067d23c9
KY
361 CC='${CC}' CFLAGS='${CFLAGS}' CPPFLAGS='${CPPFLAGS}' \
362 LDFLAGS='${LDFLAGS}' MAKE='${MAKE}'
363
364# Pass to src/Makefile.in an additional BOOTSTRAPEMACS variable which
365# is either set to bootstrap-emacs (in case bootstrap-emacs has not been
366# constructed yet) or the empty string (otherwise).
367# src/Makefile.in uses it to implement conditional dependencies, so that
368# files that need bootstrap-emacs to be built do not additionally need
369# to be kept fresher than bootstrap-emacs. Otherwise changing a single
370# file src/foo.c forces dumping a new bootstrap-emacs, then re-byte-compiling
371# all preloaded elisp files, and only then dump the actual src/emacs, which
372# is not wrong, but is overkill in 99.99% of the cases.
373src: Makefile FRC
374 boot=bootstrap-emacs$(EXEEXT); \
375 if [ ! -x "src/$$boot" ]; then \
376 cd $@; $(MAKE) all $(MFLAGS) \
377 CC='${CC}' CFLAGS='${CFLAGS}' CPPFLAGS='${CPPFLAGS}' \
378 LDFLAGS='${LDFLAGS}' MAKE='${MAKE}' BOOTSTRAPEMACS="$$boot"; \
379 fi;
380 if [ -r .bzr/checkout/dirstate ]; then \
4f8c52a9 381 vcswitness="`pwd`/.bzr/checkout/dirstate"; \
067d23c9
KY
382 fi; \
383 cd $@; $(MAKE) all $(MFLAGS) \
384 CC='${CC}' CFLAGS='${CFLAGS}' CPPFLAGS='${CPPFLAGS}' \
385 LDFLAGS='${LDFLAGS}' MAKE='${MAKE}' BOOTSTRAPEMACS="" \
386 VCSWITNESS="$$vcswitness"
387
388blessmail: Makefile src FRC
389 cd lib-src; $(MAKE) maybe-blessmail $(MFLAGS) \
390 MAKE='${MAKE}' archlibdir='$(archlibdir)'
391
392# We used to have one rule per */Makefile.in, but that leads to race
393# conditions with parallel makes, so let's assume that the time stamp on
394# ./Makefile is representative of the time stamp on all the other Makefiles.
395Makefile: config.status $(srcdir)/src/config.in \
fa5d79db 396 $(srcdir)/Makefile.in $(SUBDIR_MAKEFILES_IN)
067d23c9
KY
397 ./config.status
398
bfab7d85
SM
399# Don't erase config.status if make is interrupted while refreshing it.
400.PRECIOUS: config.status
401
067d23c9 402config.status: ${srcdir}/configure ${srcdir}/lisp/version.el
bfab7d85
SM
403 if [ -x ./config.status ]; then \
404 ./config.status --recheck; \
405 else \
6c269a38 406 ./configure $(CONFIGURE_FLAGS); \
bfab7d85 407 fi
067d23c9 408
84bbb1ad 409AUTOCONF_INPUTS = @MAINT@ $(srcdir)/configure.in $(srcdir)/aclocal.m4
067d23c9
KY
410
411$(srcdir)/configure: $(AUTOCONF_INPUTS)
412 cd ${srcdir} && autoconf
413
c7e95b91 414ACLOCAL_INPUTS = @MAINT@ $(srcdir)/m4/$(DOS_gnulib_comp.m4)
9a514d4a
PE
415$(srcdir)/aclocal.m4: $(ACLOCAL_INPUTS)
416 cd $(srcdir) && aclocal -I m4
417
16b71f3a 418AUTOMAKE_INPUTS = @MAINT@ $(srcdir)/aclocal.m4 $(srcdir)/lib/Makefile.am $(srcdir)/lib/gnulib.mk
9a514d4a
PE
419$(srcdir)/lib/Makefile.in: $(AUTOMAKE_INPUTS)
420 cd $(srcdir) && automake --gnu -a -c lib/Makefile
925e561d 421am--refresh: $(srcdir)/aclocal.m4 $(srcdir)/configure $(srcdir)/src/config.in
3cbecb8f 422.PHONY: am--refresh
9a514d4a 423
067d23c9
KY
424$(srcdir)/src/config.in: $(srcdir)/src/stamp-h.in
425 @ # Usually, there's no need to rebuild src/config.in just
426 @ # because stamp-h.in has changed (since building stamp-h.in
427 @ # refreshes config.in as well), but if config.in is missing
428 @ # then we really need to do something more.
429 [ -r "$@" ] || ( cd ${srcdir} && autoheader )
430$(srcdir)/src/stamp-h.in: $(AUTOCONF_INPUTS)
431 cd ${srcdir} && autoheader
432 rm -f $(srcdir)/src/stamp-h.in
433 echo timestamp > $(srcdir)/src/stamp-h.in
434
435# ==================== Installation ====================
436
437## If we let lib-src do its own installation, that means we
438## don't have to duplicate the list of utilities to install in
439## this Makefile as well.
440
62061397 441.PHONY: install
067d23c9 442
bfed8334 443install: all install-arch-indep install-doc install-arch-dep blessmail
067d23c9
KY
444 @true
445
53a84f3c 446## Ensure that $subdir contains a subdirs.el file.
7606c360
GM
447## Here and elsewhere, we set the umask so that any created files are
448## world-readable.
449## TODO it might be good to warn about non-standard permissions of
450## pre-existing directories, but that does not seem easy.
53a84f3c
GM
451write_subdir=if [ -f $${subdir}/subdirs.el ]; \
452 then true; \
453 else \
4c54abe1
GM
454 umask 022; \
455 ${MKDIR_P} $${subdir}; \
53a84f3c
GM
456 (echo "(if (fboundp 'normal-top-level-add-subdirs-to-load-path)"; \
457 echo " (normal-top-level-add-subdirs-to-load-path))") \
458 > $${subdir}/subdirs.el; \
4c54abe1 459 fi
53a84f3c 460
067d23c9 461### Install the executables that were compiled specifically for this machine.
ed0ba302
GM
462### We do install-arch-indep first because the executable needs the
463### Lisp files and DOC file to work properly.
bfed8334 464install-arch-dep: install-arch-indep install-doc
b533f05e 465 umask 022; ${MKDIR_P} $(DESTDIR)${bindir}
067d23c9
KY
466 (cd lib-src; \
467 $(MAKE) install $(MFLAGS) prefix=${prefix} \
468 exec_prefix=${exec_prefix} bindir=${bindir} \
469 libexecdir=${libexecdir} archlibdir=${archlibdir} \
470 INSTALL_STRIP=${INSTALL_STRIP})
b4a36200 471 if test "${ns_self_contained}" = "no"; then \
96182ae6
GM
472 ${INSTALL_PROGRAM} $(INSTALL_STRIP) src/emacs${EXEEXT} $(DESTDIR)${bindir}/$(EMACSFULL) || exit 1 ; \
473 chmod 1755 $(DESTDIR)${bindir}/$(EMACSFULL) ; \
474 rm -f $(DESTDIR)${bindir}/$(EMACS) ; \
475 ln $(DESTDIR)${bindir}/$(EMACSFULL) $(DESTDIR)${bindir}/$(EMACS) || true ; \
476 else \
05f3d308 477 subdir=${ns_appresdir}/site-lisp; \
05f3d308
GM
478 ${write_subdir} || exit 1; \
479 rm -rf ${ns_appresdir}/share; \
96182ae6 480 fi
067d23c9 481
05f3d308 482## In the share directory, we are deleting:
660c8c1e
GM
483## applications (with emacs.desktop, also found in etc/)
484## emacs (basically empty except for unneeded site-lisp directories)
05f3d308 485## icons (duplicates etc/images/icons/hicolor)
05f3d308 486
6b3868cb
GM
487## This is install-etc for everything except self-contained-ns builds.
488## For them, it is empty.
489INSTALL_ARCH_INDEP_EXTRA = @INSTALL_ARCH_INDEP_EXTRA@
490
067d23c9
KY
491## http://lists.gnu.org/archive/html/emacs-devel/2007-10/msg01672.html
492## Needs to be the user running install, so configure can't set it.
493set_installuser=for installuser in $${LOGNAME} $${USERNAME} $${USER} \
494 `id -un 2> /dev/null`; do \
495 [ -n "$${installuser}" ] && break ; \
496 done
497
498### Install the files that are machine-independent.
29473393
GM
499### Most of them come straight from the distribution; the exception is
500### the DOC file, which is copied from the build directory.
067d23c9 501
7606c360
GM
502## We delete each directory in ${COPYDESTS} before we copy into it;
503## that way, we can reinstall over directories that have been put in
504## place with their files read-only (perhaps because they are checked
505## into RCS). In order to make this safe, we make sure that the
506## source exists and is distinct from the destination.
62061397 507
29473393
GM
508## We delete etc/DOC* because there may be irrelevant DOC files from
509## other builds in the source directory. This is ok because we just
510## deleted the entire installed etc/ directory and recreated it.
511## install-doc installs the relevant DOC.
512
513## Note that the Makefiles in the etc directory are potentially useful
514## in an installed Emacs, so should not be excluded.
515
62061397
GM
516## I'm not sure creating locallisppath here serves any useful purpose.
517## If it has the default value, then the later write_subdir commands
518## will ensure all these components exist.
519## This will only do something if locallisppath has a non-standard value.
520## Is it really Emacs's job to create those directories?
521## Should we also be ensuring they contain subdirs.el files?
522## It would be easy to do, just use write_subdir.
bfed8334 523install-arch-indep: install-leim install-info install-man ${INSTALL_ARCH_INDEP_EXTRA}
62061397
GM
524 umask 022 ; \
525 $(MKDIR_P) $(DESTDIR)`echo ${locallisppath} | sed 's,:, $(DESTDIR),g'`
067d23c9
KY
526 -set ${COPYDESTS} ; \
527 unset CDPATH; \
067d23c9
KY
528 $(set_installuser); \
529 for dir in ${COPYDIR} ; do \
7606c360 530 [ -d $${dir} ] || exit 1 ; \
067d23c9 531 dest=$$1 ; shift ; \
b7e1feea
GM
532 [ -d $${dest} ] && \
533 [ `(cd $${dest} && /bin/pwd)` = `(cd $${dir} && /bin/pwd)` ] && \
7606c360
GM
534 continue ; \
535 rm -rf $${dest} ; \
536 umask 022; ${MKDIR_P} $${dest} ; \
537 (echo "Copying $${dir} to $${dest}..." ; \
538 (cd $${dir}; tar -chf - . ) \
539 | (cd $${dest}; umask 022; \
540 tar -xvf - && cat > /dev/null) || exit 1; \
29473393 541 [ "$${dir}" != "${srcdir}/etc" ] || rm -f $${dest}/DOC* ; \
7606c360
GM
542 find $${dest} -exec chown $${installuser} {} ';' ;\
543 for subdir in `find $${dest} -type d -print` ; do \
544 chmod a+rx $${subdir} ; \
545 rm -f $${subdir}/.gitignore ; \
546 rm -f $${subdir}/.arch-inventory ; \
547 rm -f $${subdir}/.DS_Store ; \
548 rm -f $${subdir}/\#* ; \
549 rm -f $${subdir}/.\#* ; \
550 rm -f $${subdir}/*~ ; \
551 rm -f $${subdir}/*.orig ; \
552 [ "$${dir}" != "${srcdir}/etc" ] && \
553 rm -f $${subdir}/[mM]akefile*[.-]in $${subdir}/[mM]akefile ; \
554 rm -f $${subdir}/ChangeLog* ; \
555 done) ; \
067d23c9
KY
556 done
557 -rm -f $(DESTDIR)${lispdir}/subdirs.el
558 $(srcdir)/update-subdirs $(DESTDIR)${lispdir}
9f1ea7dc
GM
559 subdir=$(DESTDIR)${datadir}/emacs/${version}/site-lisp ; \
560 ${write_subdir}
561 subdir=$(DESTDIR)${datadir}/emacs/site-lisp ; \
562 ${write_subdir} || true
6d1a623e
GM
563 [ -z "${GZIP_PROG}" ] || \
564 ( echo "Compressing *.el ..." ; \
565 unset CDPATH; \
566 cd $(DESTDIR)${lispdir}; \
567 for f in `find . -name "*.elc" -print`; do \
568 ${GZIP_PROG} -9n `echo $$f|sed 's/.elc$$/.el/'` ; \
569 done )
660c8c1e
GM
570 -chmod -R a+r $(DESTDIR)${datadir}/emacs/${version} ${COPYDESTS}
571
572## We install only the relevant DOC file if possible
573## (ie DOC-${version}.buildnumber), otherwise DOC-${version}*.
574## (Note "otherwise" is inaccurate since 2009-08-23.)
575
bfed8334
GM
576## Note that install-arch-indep deletes and recreates the entire
577## installed etc/ directory, so we need it to run before this does.
578install-doc: install-arch-indep
660c8c1e 579 -unset CDPATH; \
568c6157 580 umask 022; ${MKDIR_P} $(DESTDIR)${docdir} ; \
067d23c9
KY
581 if [ `(cd ./etc; /bin/pwd)` != `(cd $(DESTDIR)${docdir}; /bin/pwd)` ]; \
582 then \
583 fullversion=`./src/emacs --version | sed -n '1 s/GNU Emacs *//p'`; \
584 if [ -f "./etc/DOC-$${fullversion}" ]; \
585 then \
586 docfile="DOC-$${fullversion}"; \
587 else \
588 docfile="DOC"; \
589 fi; \
590 echo "Copying etc/$${docfile} to $(DESTDIR)${docdir} ..." ; \
e6124927 591 ${INSTALL_DATA} etc/$${docfile} $(DESTDIR)${docdir}/$${docfile}; \
29473393
GM
592 $(set_installuser); \
593 chown $${installuser} $(DESTDIR)${docdir}/$${docfile} || true ; \
067d23c9 594 else true; fi
660c8c1e
GM
595
596install-info: info
b533f05e 597 umask 022; ${MKDIR_P} $(DESTDIR)${infodir}
067d23c9
KY
598 -unset CDPATH; \
599 thisdir=`/bin/pwd`; \
6d1a623e 600 [ `(cd ${srcdir}/info && /bin/pwd)` = `(cd $(DESTDIR)${infodir} && /bin/pwd)` ] || \
067d23c9 601 (cd $(DESTDIR)${infodir}; \
6d1a623e 602 [ -f dir ] || \
067d23c9 603 (cd $${thisdir}; \
37baa3c8 604 ${INSTALL_DATA} ${srcdir}/info/dir $(DESTDIR)${infodir}/dir) ; \
9aa071df 605 info_misc=`cd $${thisdir}/doc/misc; ${MAKE} echo-info | sed '/ing directory/d'`; \
067d23c9 606 cd ${srcdir}/info ; \
9aa071df 607 for elt in ${INFO_NONMISC} $${info_misc}; do \
4f8c52a9 608 test "$(HAVE_MAKEINFO)" = "no" && test ! -f $$elt && continue; \
067d23c9 609 for f in `ls $$elt $$elt-[1-9] $$elt-[1-9][0-9] 2>/dev/null`; do \
a36e64d0
GM
610 (cd $${thisdir}; \
611 ${INSTALL_DATA} ${srcdir}/info/$$f $(DESTDIR)${infodir}/$$f); \
6d1a623e
GM
612 ( [ -n "${GZIP_INFO}" ] && [ -n "${GZIP_PROG}" ] ) || continue ; \
613 rm -f $(DESTDIR)${infodir}/$$f.gz; \
614 ${GZIP_PROG} -9n $(DESTDIR)${infodir}/$$f; \
067d23c9 615 done; \
7adecb99
GM
616 (cd $${thisdir}; \
617 ${INSTALL_INFO} --info-dir=$(DESTDIR)${infodir} $(DESTDIR)${infodir}/$$elt); \
6d1a623e 618 done)
660c8c1e
GM
619
620install-man:
b533f05e 621 umask 022; ${MKDIR_P} $(DESTDIR)${man1dir}
067d23c9
KY
622 thisdir=`/bin/pwd`; \
623 cd ${mansrcdir}; \
ab1121bd 624 for page in *.1; do \
067d23c9 625 (cd $${thisdir}; \
6d1a623e
GM
626 ${INSTALL_DATA} ${mansrcdir}/$${page} $(DESTDIR)${man1dir}/$${page}); \
627 ( [ -n "${GZIP_INFO}" ] && [ -n "${GZIP_PROG}" ] ) || continue ; \
628 rm -f $(DESTDIR)${man1dir}/$${page}.gz; \
629 ${GZIP_PROG} -9n $(DESTDIR)${man1dir}/$${page}; \
067d23c9
KY
630 done
631
632## Install those items from etc/ that need to end up elsewhere.
d9a1e2c2
GM
633install-etc:
634 umask 022; ${MKDIR_P} $(DESTDIR)${desktopdir}
067d23c9
KY
635 ${INSTALL_DATA} ${srcdir}/etc/emacs.desktop \
636 $(DESTDIR)${desktopdir}/emacs.desktop
7606c360 637 thisdir=`/bin/pwd`; \
d9a1e2c2
GM
638 cd ${iconsrcdir} || exit 1; umask 022 ; \
639 for dir in */*/apps */*/mimetypes; do \
640 [ -d $${dir} ] || continue ; \
904769ba 641 ( cd $${thisdir}; ${MKDIR_P} ${icondir}/$${dir} ) ; \
d9a1e2c2
GM
642 for icon in $${dir}/*.*; do \
643 [ -r $${icon} ] || continue ; \
7606c360 644 ( cd $${thisdir}; \
904769ba 645 ${INSTALL_DATA} ${iconsrcdir}/$${icon} ${icondir}/$${icon} ) \
7606c360 646 || exit 1; \
d9a1e2c2 647 done ; \
067d23c9
KY
648 done
649
650### Install LEIM files. Although they are machine-independent, we
651### have separate target here instead of including it in
652### `install-arch-indep'. People who extracted LEIM files after they
53964682 653### installed Emacs itself can install only LEIM files by this target.
b533f05e 654install-leim: leim/Makefile
fd9d85c2 655 cd leim && $(MAKE) $(MFLAGS) install
067d23c9
KY
656
657### Build Emacs and install it, stripping binaries while installing them.
658install-strip:
fd9d85c2 659 $(MAKE) $(MFLAGS) INSTALL_STRIP=-s install
067d23c9 660
067d23c9
KY
661### Delete all the installed files that the `install' target would
662### create (but not the noninstalled files such as `make all' would create).
663###
664### Don't delete the lisp and etc directories if they're in the source tree.
665uninstall:
666 (cd lib-src; \
667 $(MAKE) $(MFLAGS) uninstall \
668 prefix=${prefix} exec_prefix=${exec_prefix} \
669 bindir=${bindir} libexecdir=${libexecdir} archlibdir=${archlibdir})
670 -unset CDPATH; \
671 for dir in $(DESTDIR)${lispdir} $(DESTDIR)${etcdir} ; do \
672 if [ -d $${dir} ]; then \
673 case `(cd $${dir} ; /bin/pwd)` in \
674 `(cd ${srcdir} ; /bin/pwd)`* ) ;; \
675 * ) rm -rf $${dir} ;; \
676 esac ; \
677 case $${dir} in \
678 $(DESTDIR)${datadir}/emacs/${version}/* ) \
679 rm -rf $(DESTDIR)${datadir}/emacs/${version} \
680 ;; \
681 esac ; \
682 fi ; \
683 done
067d23c9 684 -rm -rf $(DESTDIR)${libexecdir}/emacs/${version}
a36e64d0 685 thisdir=`/bin/pwd`; \
9aa071df
GM
686 (info_misc=`cd doc/misc; ${MAKE} echo-info | sed '/ing directory/d'`; \
687 cd $(DESTDIR)${infodir} && \
688 for elt in ${INFO_NONMISC} $${info_misc}; do \
a36e64d0
GM
689 (cd $${thisdir}; \
690 $(INSTALL_INFO) --remove --info-dir=$(DESTDIR)${infodir} $(DESTDIR)${infodir}/$$elt); \
7eb21b49
GM
691 if [ -n "${GZIP_INFO}" ] && [ -n "${GZIP_PROG}" ]; then \
692 ext=.gz; else ext=; fi; \
cd3771a0 693 rm -f $$elt$$ext $$elt-[1-9]$$ext $$elt-[1-9][0-9]$$ext; \
067d23c9 694 done;)
7eb21b49
GM
695 (if [ -n "${GZIP_INFO}" ] && [ -n "${GZIP_PROG}" ]; then \
696 ext=.gz; else ext=; fi; \
ab1121bd
GM
697 cd ${mansrcdir} && for page in *.1; do \
698 rm -f $(DESTDIR)${man1dir}/$$page$$ext; done )
067d23c9
KY
699 (cd $(DESTDIR)${bindir} && rm -f $(EMACSFULL) $(EMACS))
700 (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 )
701 -rm -f $(DESTDIR)${desktopdir}/emacs.desktop
702 for file in snake-scores tetris-scores; do \
703 file=$(DESTDIR)${gamedir}/$${file}; \
704 [ -s $${file} ] || rm -f $$file; \
705 done
706
707FRC:
708
709# ==================== Cleaning up and miscellanea ====================
710
711.PHONY: mostlyclean clean distclean maintainer-clean extraclean
712
713### `mostlyclean'
714### Like `clean', but may refrain from deleting a few files that people
715### normally don't want to recompile. For example, the `mostlyclean'
716### target for GCC does not delete `libgcc.a', because recompiling it
717### is rarely necessary and takes a lot of time.
718mostlyclean: FRC
719 (cd src; $(MAKE) $(MFLAGS) mostlyclean)
720 (cd oldXMenu; $(MAKE) $(MFLAGS) mostlyclean)
721 (cd lwlib; $(MAKE) $(MFLAGS) mostlyclean)
9a514d4a 722 (cd lib; $(MAKE) $(MFLAGS) mostlyclean)
067d23c9
KY
723 (cd lib-src; $(MAKE) $(MFLAGS) mostlyclean)
724 -(cd doc/emacs && $(MAKE) $(MFLAGS) mostlyclean)
725 -(cd doc/misc && $(MAKE) $(MFLAGS) mostlyclean)
726 -(cd doc/lispref && $(MAKE) $(MFLAGS) mostlyclean)
727 -(cd doc/lispintro && $(MAKE) $(MFLAGS) mostlyclean)
728 (cd leim; $(MAKE) $(MFLAGS) mostlyclean)
729
730### `clean'
731### Delete all files from the current directory that are normally
732### created by building the program. Don't delete the files that
733### record the configuration. Also preserve files that could be made
734### by building, but normally aren't because the distribution comes
735### with them.
736###
737### Delete `.dvi' files here if they are not part of the distribution.
738clean: FRC
739 (cd src; $(MAKE) $(MFLAGS) clean)
740 (cd oldXMenu; $(MAKE) $(MFLAGS) clean)
741 (cd lwlib; $(MAKE) $(MFLAGS) clean)
9a514d4a 742 (cd lib; $(MAKE) $(MFLAGS) clean)
067d23c9
KY
743 (cd lib-src; $(MAKE) $(MFLAGS) clean)
744 -(cd doc/emacs && $(MAKE) $(MFLAGS) clean)
745 -(cd doc/misc && $(MAKE) $(MFLAGS) clean)
746 -(cd doc/lispref && $(MAKE) $(MFLAGS) clean)
747 -(cd doc/lispintro && $(MAKE) $(MFLAGS) clean)
748 (cd leim; $(MAKE) $(MFLAGS) clean)
749
750### `bootclean'
751### Delete all files that need to be remade for a clean bootstrap.
752top_bootclean=\
753 rm -f config.cache config.log
754### `distclean'
755### Delete all files from the current directory that are created by
756### configuring or building the program. If you have unpacked the
757### source and built the program without creating any other files,
758### `make distclean' should leave only the files that were in the
759### distribution.
760top_distclean=\
761 ${top_bootclean}; \
773233f8 762 rm -f config.status config.log~ Makefile stamp-h1 ${SUBDIR_MAKEFILES}
067d23c9
KY
763distclean: FRC
764 (cd src; $(MAKE) $(MFLAGS) distclean)
765 (cd oldXMenu; $(MAKE) $(MFLAGS) distclean)
766 (cd lwlib; $(MAKE) $(MFLAGS) distclean)
9a514d4a 767 (cd lib; $(MAKE) $(MFLAGS) distclean)
067d23c9
KY
768 (cd lib-src; $(MAKE) $(MFLAGS) distclean)
769 (cd doc/emacs && $(MAKE) $(MFLAGS) distclean)
770 (cd doc/misc && $(MAKE) $(MFLAGS) distclean)
771 (cd doc/lispref && $(MAKE) $(MFLAGS) distclean)
772 (cd doc/lispintro && $(MAKE) $(MFLAGS) distclean)
773 (cd leim; $(MAKE) $(MFLAGS) distclean)
774 (cd lisp; $(MAKE) $(MFLAGS) distclean)
775 ${top_distclean}
776
777### `bootstrap-clean'
778### Delete everything that can be reconstructed by `make' and that
779### needs to be deleted in order to force a bootstrap from a clean state.
780bootstrap-clean: FRC
781 (cd src; $(MAKE) $(MFLAGS) bootstrap-clean)
782 (cd oldXMenu; $(MAKE) $(MFLAGS) maintainer-clean)
783 (cd lwlib; $(MAKE) $(MFLAGS) maintainer-clean)
9a514d4a 784 (cd lib; $(MAKE) $(MFLAGS) maintainer-clean)
067d23c9
KY
785 (cd lib-src; $(MAKE) $(MFLAGS) maintainer-clean)
786 -(cd doc/emacs && $(MAKE) $(MFLAGS) maintainer-clean)
787 -(cd doc/misc && $(MAKE) $(MFLAGS) maintainer-clean)
788 -(cd doc/lispref && $(MAKE) $(MFLAGS) maintainer-clean)
789 -(cd doc/lispintro && $(MAKE) $(MFLAGS) maintainer-clean)
790 (cd leim; $(MAKE) $(MFLAGS) maintainer-clean)
791 (cd lisp; $(MAKE) $(MFLAGS) bootstrap-clean)
4f8c52a9 792 [ ! -f config.log ] || mv -f config.log config.log~
067d23c9 793 ${top_bootclean}
773233f8
GM
794## configure; make bootstrap replaces the real config.log from configure
795## with the truncated one from config.status. The former is more useful.
067d23c9
KY
796
797### `maintainer-clean'
798### Delete everything from the current directory that can be
799### reconstructed with this Makefile. This typically includes
800### everything deleted by distclean, plus more: C source files
801### produced by Bison, tags tables, info files, and so on.
802###
803### One exception, however: `make maintainer-clean' should not delete
804### `configure' even if `configure' can be remade using a rule in the
805### Makefile. More generally, `make maintainer-clean' should not delete
806### anything that needs to exist in order to run `configure' and then
807### begin to build the program.
9a514d4a
PE
808top_maintainer_clean=\
809 ${top_distclean}; \
e02ea74b 810 rm -fr autom4te.cache
067d23c9
KY
811maintainer-clean: bootstrap-clean FRC
812 (cd src; $(MAKE) $(MFLAGS) maintainer-clean)
813 (cd lisp; $(MAKE) $(MFLAGS) maintainer-clean)
9a514d4a 814 ${top_maintainer_clean}
067d23c9
KY
815
816### This doesn't actually appear in the coding standards, but Karl
817### says GCC supports it, and that's where the configuration part of
818### the coding standards seem to come from. It's like distclean, but
819### it deletes backup and autosave files too.
820extraclean:
821 for i in ${SUBDIR} leim; do (cd $$i; $(MAKE) $(MFLAGS) extraclean); done
9a514d4a 822 ${top_maintainer_clean}
067d23c9
KY
823 -rm -f config-tmp-*
824 -rm -f *~ \#*
825
826# The src subdir knows how to do the right thing
827# even when the build directory and source dir are different.
9a514d4a 828TAGS tags: lib lib-src src
5a95c002 829 cd src; $(MAKE) $(MFLAGS) tags
067d23c9
KY
830
831check:
6c7e099d 832 @if test ! -d test/automated; then \
a22d9d2c
GM
833 echo "You do not seem to have the test/ directory."; \
834 echo "Maybe you are using a release tarfile, rather than a repository checkout."; \
835 else \
836 cd test/automated && $(MAKE) $(MFLAGS) check; \
837 fi
067d23c9
KY
838
839dist:
840 cd ${srcdir}; ./make-dist
841
842.PHONY: info dvi dist check html
843
925e561d 844info-real:
067d23c9
KY
845 (cd doc/emacs; $(MAKE) $(MFLAGS) info)
846 (cd doc/misc; $(MAKE) $(MFLAGS) info)
847 (cd doc/lispref; $(MAKE) $(MFLAGS) info)
848 (cd doc/lispintro; $(MAKE) $(MFLAGS) info)
849
850force-info:
851# Note that man/Makefile knows how to put the info files in $(srcdir),
852# so we can do ok running make in the build dir.
853# This used to have a clause that exited with an error if MAKEINFO = no.
854# But it is inappropriate to do so without checking if makeinfo is
855# actually needed - it is not if the info files are up-to-date. (Bug#3982)
856# Only the doc/*/Makefiles can decide that, so we let those rules run
857# and give a standard error if makeinfo is needed but missing.
858# While it would be nice to give a more detailed error message, that
859# would require changing every rule in doc/ that builds an info file,
860# and it's not worth it. This case is only relevant if you download a
861# release, then change the .texi files.
862info: force-info
e5365138 863 @if test "$(HAVE_MAKEINFO)" = "no"; then \
067d23c9
KY
864 echo "Configured --without-makeinfo, not building manuals" ; \
865 else \
866 $(MAKE) $(MFLAGS) info-real ; \
867 fi
868
869# The info/dir file must be updated by hand when new manuals are added.
870check-info-dir: info
871 cd info ; \
872 missing= ; \
873 for file in *; do \
874 test -f "$${file}" || continue ; \
875 case $${file} in \
876 *-[0-9]*|COPYING|dir) continue ;; \
877 esac ; \
8045b906 878 file=`echo $${file} | sed 's/\.info//'` ; \
067d23c9
KY
879 grep -q -F ": ($${file})." dir || missing="$${missing} $${file}" ; \
880 done ; \
881 if test -n "$${missing}"; then \
882 echo "Missing info/dir entries: $${missing}" ; \
883 exit 1 ; \
884 fi ; \
885 echo "info/dir is OK"
886
887dvi:
888 (cd doc/emacs; $(MAKE) $(MFLAGS) dvi)
889 (cd doc/misc; $(MAKE) $(MFLAGS) dvi)
890 (cd doc/lispref; $(MAKE) $(MFLAGS) elisp.dvi)
891 (cd doc/lispintro; $(MAKE) $(MFLAGS) emacs-lisp-intro.dvi)
892
893#### Bootstrapping.
894
895### This first cleans the lisp subdirectory, removing all compiled
896### Lisp files. Then re-run make to build all the files anew.
897
898.PHONY: bootstrap
899
000d802e 900## configure; make bootstrap replaces the real config.log from configure
773233f8 901## with the truncated one from config.status. The former is more useful.
067d23c9
KY
902bootstrap: bootstrap-clean FRC
903 if [ -x ./config.status ]; then \
904 ./config.status; \
905 else \
6c269a38 906 ./configure $(CONFIGURE_FLAGS); \
067d23c9
KY
907 fi
908 $(MAKE) $(MFLAGS) info all
909
910.PHONY: check-declare
911
912check-declare:
4f8c52a9 913 @if [ ! -f $(srcdir)/src/emacs ]; then \
067d23c9
KY
914 echo "You must build Emacs to use this command"; \
915 exit 1; \
916 fi
917 (cd leim; $(MAKE) $(MFLAGS) $@)
918 (cd lisp; $(MAKE) $(MFLAGS) $@)