(custom-make-dependencies): Simplify.
[bpt/emacs.git] / lisp / Makefile.in
CommitLineData
c7685c8d 1# Maintenance productions for the Lisp directory
92b47a4a 2# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
b3ae7a0a
GM
3
4# This file is part of GNU Emacs.
5
6# GNU Emacs is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2, or (at your option)
9# any later version.
10
11# GNU Emacs is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15
16# You should have received a copy of the GNU General Public License
17# along with GNU Emacs; see the file COPYING. If not, write to
086add15
LK
18# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19# Boston, MA 02110-1301, USA.
7ec641b8 20
261f3289
EZ
21SHELL = /bin/sh
22
dce6b995
GM
23lisp=@srcdir@
24VPATH=@srcdir@
0df68e9f 25srcdir=@srcdir@/..
dce6b995 26
7ec641b8
GM
27# You can specify a different executable on the make command line,
28# e.g. "make EMACS=../src/emacs ...".
29
e3384ae7 30EMACS = ../src/emacs
7ec641b8
GM
31
32# Command line flags for Emacs. This must include --multibyte,
33# otherwise some files will not compile.
34
1499d2dd 35EMACSOPT = -batch --no-site-file --multibyte
7ec641b8 36
c7685c8d 37SOURCES = *.el COPYING Makefile
dce6b995
GM
38lisptagsfiles1 = $(lisp)/[a-zA-Z]*.el
39lisptagsfiles2 = $(lisp)/[a-zA-Z]*/[a-zA-Z]*.el
3975988b 40ETAGS = ../lib-src/etags
c7685c8d 41
36801f7f
SM
42# Elisp files auto-generated.
43AUTOGENEL = loaddefs.el \
44 cus-load.el \
45 finder-inf.el \
46 subdirs.el \
1eee3de4
BW
47 eshell/esh-groups.el \
48 mh-e/mh-loaddefs.el
36801f7f 49
170a9e70
GM
50# Files to compile before others during a bootstrap. This is done to
51# speed up the bootstrap process. The CC files are compiled first
52# because CC mode tweaks the compilation process, and requiring
53# cc-mode when it is not compiled doesn't work during the
54# bootstrapping.
d849789b 55
dce6b995
GM
56COMPILE_FIRST = \
57 $(lisp)/emacs-lisp/byte-opt.el \
58 $(lisp)/emacs-lisp/bytecomp.el \
170a9e70
GM
59 $(lisp)/subr.el \
60 $(lisp)/progmodes/cc-mode.el \
61 $(lisp)/progmodes/cc-vars.el
d849789b 62
7ec641b8
GM
63# The actual Emacs command run in the targets below.
64
7f25090d 65emacs = EMACSLOADPATH=$(lisp) $(EMACS) $(EMACSOPT)
7ec641b8 66
80c382e5 67# Common command to find subdirectories
7ec641b8 68
39cc05f5 69setwins=subdirs=`(cd $$wd; find . -type d -print)`; \
f83a4f35 70 for file in $$subdirs; do \
8bde1d70 71 case $$file in */Old | */RCS | */CVS | */CVS/* | */.* | */.*/* | */=* ) ;; \
39cc05f5 72 *) wins="$$wins $$wd/$$file" ;; \
f83a4f35 73 esac; \
80c382e5 74 done
8464af45 75
39cc05f5 76setwins_almost=subdirs=`(cd $$wd; find . -type d -print)`; \
865e97c1 77 for file in $$subdirs; do \
8bde1d70 78 case $$file in */Old | */RCS | */CVS | */CVS/* | */.* | */.*/* | */=* | */obsolete | */term ) ;; \
39cc05f5 79 *) wins="$$wins $$wd/$$file" ;; \
865e97c1
GM
80 esac; \
81 done
80c382e5
SM
82
83doit:
84
cd1b15b8 85$(lisp)/cus-load.el:
cc953d27 86 touch $@
cd1b15b8 87custom-deps: $(lisp)/cus-load.el doit
30089f1d 88 wd=$(lisp); $(setwins_almost); \
4746aeeb 89 echo Directories: $$wins; \
cd1b15b8 90 $(EMACS) $(EMACSOPT) -l cus-dep --eval '(setq generated-custom-dependencies-file "$(lisp)/cus-load.el")' -f custom-make-dependencies $$wins
009368b9 91
29ad9e56 92finder-data: doit
30089f1d 93 wd=$(lisp); $(setwins_almost); \
4746aeeb 94 echo Directories: $$wins; \
cd1b15b8 95 $(EMACS) $(EMACSOPT) -l finder --eval '(setq generated-finder-keywords-file "$(lisp)/finder-inf.el")' -f finder-compile-keywords-make-dist $$wins
009368b9 96
cd1b15b8 97$(lisp)/loaddefs.el:
cc953d27
SM
98 echo ";;; loaddefs.el --- automatically extracted autoloads" >> $@
99 echo ";;" >> $@; echo ";;; Code:" >> $@
100 echo "\f" >> $@
101 echo ";;; Local Variables:" >> $@
102 echo ";;; version-control: never" >> $@
103 echo ";;; no-byte-compile: t" >> $@
104 echo ";;; no-update-autoloads: t" >> $@
105 echo ";;; End:" >> $@
106 echo ";;; loaddefs.el ends here" >> $@
cd1b15b8 107autoloads: $(lisp)/loaddefs.el doit
dce6b995 108 wd=$(lisp); $(setwins); \
4746aeeb 109 echo Directories: $$wins; \
49ac2ac5 110 $(EMACS) $(EMACSOPT) -l autoload --eval '(setq generated-autoload-file "$(lisp)/loaddefs.el")' -f batch-update-autoloads $$wins
f83a4f35 111
cd1b15b8 112$(lisp)/subdirs.el:
cc953d27 113 $(MAKE) $(MFLAGS) update-subdirs
98b918b6 114update-subdirs: doit
dce6b995 115 wd=$(lisp); $(setwins); \
98b918b6 116 for file in $$wins; do \
dce6b995 117 $(srcdir)/update-subdirs $$file; \
98b918b6
RS
118 done;
119
9af14567 120updates: update-subdirs autoloads mh-autoloads finder-data custom-deps
c48c3772 121
fbb43902
GM
122# Update the AUTHORS file.
123
124update-authors:
938cbd34 125 $(emacs) -l authors -f batch-update-authors $(srcdir)/AUTHORS $(srcdir)
fbb43902 126
7ab2c289 127TAGS: $(lisptagsfiles1) $(lisptagsfiles2)
f800daf6 128 els=`echo $(lisptagsfiles1) $(lisptagsfiles2) | sed -e "s,$(lisp)/loaddefs[^ ]*,," -e "s,$(lisp)/ldefs-boot[^ ]*,,"`; \
77389930 129 ${ETAGS} $$els
7ab2c289 130
4136efcb 131TAGS-LISP: $(lisptagsfiles1) $(lisptagsfiles2)
f800daf6 132 els=`echo $(lisptagsfiles1) $(lisptagsfiles2) | sed -e "s,$(lisp)/loaddefs[^ ]*,," -e "s,$(lisp)/ldefs-boot[^ ]*,,"`; \
77389930 133 ${ETAGS} -o TAGS-LISP $$els
7ec641b8 134
67292de0
GM
135.SUFFIXES: .elc .el
136
cd1b15b8 137.el.elc: $(lisp)/subdirs.el
7f25090d 138 -$(emacs) -f batch-byte-compile $<
cc953d27 139
938cbd34
LK
140# Compile all Lisp files, but don't recompile those that are up to
141# date. Some files don't actually get compiled because they set the
142# local variable no-byte-compile.
61b92c33 143
938cbd34
LK
144# All .elc files are made writable before compilation in case we
145# checked out read-only (CVS option -r). Files MUST be compiled one by
146# one. If we compile several files in a row we can't make sure that
147# the compilation environment is clean. We also set the load-path of
148# the Emacs used for compilation to the current directory and its
149# subdirectories, to make sure require's and load's in the files being
150# compiled find the right files.
29ad9e56 151
1eee3de4 152compile: $(lisp)/subdirs.el mh-autoloads doit
61b92c33
RS
153 find $(lisp) -name "*.elc" -print | xargs chmod +w >/dev/null 2>&1; \
154 wd=$(lisp); $(setwins); \
938cbd34 155 els=`echo $$wins | tr ' \011' '\012\012' | \
61b92c33 156 sed -e 's|\(.\)$$|\1/|' -e 's|^\./||' -e 's|$$|*.el|'`; \
61b92c33 157 for el in $(COMPILE_FIRST) $$els; do \
6ad1de49
EZ
158 if test -f $$el; \
159 then \
160 echo Compiling $$el; \
90b37ca3 161 $(emacs) -f batch-byte-compile-if-not-done $$el || exit 1; \
6ad1de49 162 fi \
61b92c33
RS
163 done
164
938cbd34
LK
165# Compile all Lisp files. This is like `compile' but compiles files
166# unconditionally. Some files don't actually get compiled because they
167# set the local variable no-byte-compile.
168
cd1b15b8 169compile-always: $(lisp)/subdirs.el doit
4244e7dc
RS
170 # `|| true' prevents old Bash versions from getting confused
171 # by an error.
e85a77bd 172 find $(lisp) -name "*.elc" -print | xargs chmod +w >/dev/null 2>&1 || true; \
dce6b995 173 wd=$(lisp); $(setwins); \
938cbd34 174 els=`echo $$wins | tr ' \011' '\012\012' | \
cc953d27 175 sed -e 's|\(.\)$$|\1/|' -e 's|^\./||' -e 's|$$|*.el|'`; \
d849789b 176 for el in $(COMPILE_FIRST) $$els; do \
6ad1de49
EZ
177 if test -f $$el; \
178 then \
179 echo Compiling $$el; \
180 $(emacs) -f batch-byte-compile $$el || exit 1; \
181 fi \
8256e31b 182 done
96ff0f09 183
f1180544 184compile-calc:
cd1b15b8 185 for el in `find $(lisp)/calc -name '*.el'`; do \
dcf91c25
CW
186 echo Compiling $$el; \
187 $(emacs) -f batch-byte-compile $$el || exit 1; \
188 done
189
a9b67cf4
GM
190# Backup compiled Lisp files in elc.tar.gz. If that file already
191# exists, make a backup of it.
192
193backup-compiled-files:
dce6b995
GM
194 -mv $(lisp)/elc.tar.gz $(lisp)/elc.tar.gz~
195 -tar czf $(lisp)/elc.tar.gz $(lisp)/*.elc $(lisp)/*/*.elc
a9b67cf4
GM
196
197# Compile Lisp files, but save old compiled files first.
198
61b92c33 199compile-after-backup: backup-compiled-files compile-always
a9b67cf4 200
7ec641b8
GM
201# Recompile all Lisp files which are newer than their .elc files.
202# Note that this doesn't create .elc files. It only recompiles if an
203# .elc is present.
204
1eee3de4 205recompile: doit mh-autoloads $(lisp)/progmodes/cc-mode.elc
90b37ca3 206 $(EMACS) $(EMACSOPT) --eval "(batch-byte-recompile-directory 0)" $(lisp)
7ec641b8 207
7fefaee7
MS
208# CC Mode uses a compile time macro system which causes a compile time
209# dependency in cc-mode.elc on the macros in cc-langs.el and the
210# version string in cc-defs.el.
84456793
MS
211$(lisp)/progmodes/cc-mode.elc: \
212 $(lisp)/progmodes/cc-mode.el \
213 $(lisp)/progmodes/cc-langs.el \
214 $(lisp)/progmodes/cc-defs.el
215 $(EMACS) $(EMACSOPT) -f batch-byte-compile $(lisp)/progmodes/cc-mode.el
7fefaee7 216
1eee3de4
BW
217# Update MH-E internal autoloads. These are not to be confused with
218# the autoloads for the MH-E entry points, which are already in
219# loaddefs.el.
220MH-E-SRC = $(lisp)/mh-e/mh-acros.el $(lisp)/mh-e/mh-alias.el \
221 $(lisp)/mh-e/mh-comp.el $(lisp)/mh-e/mh-customize.el \
222 $(lisp)/mh-e/mh-e.el $(lisp)/mh-e/mh-funcs.el \
223 $(lisp)/mh-e/mh-mime.el $(lisp)/mh-e/mh-pick.el \
224 $(lisp)/mh-e/mh-print.el $(lisp)/mh-e/mh-inc.el \
225 $(lisp)/mh-e/mh-init.el $(lisp)/mh-e/mh-index.el \
226 $(lisp)/mh-e/mh-identity.el $(lisp)/mh-e/mh-junk.el \
227 $(lisp)/mh-e/mh-seq.el $(lisp)/mh-e/mh-speed.el \
228 $(lisp)/mh-e/mh-utils.el
229
230mh-autoloads: $(lisp)/mh-e/mh-loaddefs.el
231$(lisp)/mh-e/mh-loaddefs.el: $(MH-E-SRC)
232 echo ";;; mh-loaddefs.el --- automatically extracted autoloads" > $@
233 echo ";;" >> $@
234 echo ";;; Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc." >> $@
235 echo ";;; Author: Bill Wohler <wohler@newt.com>" >> $@
236 echo ";;; Keywords: mail" >> $@
237 echo ";;; Commentary:" >> $@
238 echo ";;; Change Log:" >> $@
239 echo ";;; Code:" >> $@
240 $(EMACS) $(EMACSOPT) \
241 -l autoload \
242 --eval "(setq generate-autoload-cookie \";;;###mh-autoload\")" \
fde7576e 243 --eval "(setq generated-autoload-file \"$(lisp)/mh-e/mh-loaddefs.el\")" \
1eee3de4 244 --eval "(setq make-backup-files nil)" \
fde7576e 245 -f batch-update-autoloads $(lisp)/mh-e
1eee3de4
BW
246 echo "\f" >> $@
247 echo "(provide 'mh-loaddefs)" >> $@
248 echo ";;; Local Variables:" >> $@
249 echo ";;; version-control: never" >> $@
250 echo ";;; no-byte-compile: t" >> $@
251 echo ";;; no-update-autoloads: t" >> $@
252 echo ";;; End:" >> $@
253 echo ";;; mh-loaddefs.el ends here" >> $@
254
eb7b668e
MB
255# Prepare a bootstrap in the lisp subdirectory.
256#
f586d18e
LK
257# Build loaddefs.el to make sure it's up-to-date. If it's not, that
258# might lead to errors during the bootstrap because something fails to
259# autoload as expected. If there is no emacs binary, then we can't
71d77b40
LT
260# build autoloads yet. In that case we have to use ldefs-boot.el.
261# Bootstrap should always work with ldefs-boot.el. Therefore,
262# whenever a new autoload cookie gets added that is necessary during
263# bootstrapping, ldefs-boot.el should be updated by overwriting it with
264# an up-to-date copy of loaddefs.el that is uncorrupted by
265# local changes. (Because loaddefs.el is an automatically generated
266# file, we don't want to store it in the source repository).
a9b67cf4 267
36801f7f 268bootstrap-prepare:
eb7b668e
MB
269 if test -x $(EMACS); then \
270 $(MAKE) $(MFLAGS) autoloads; \
271 else \
f586d18e 272 cp $(lisp)/ldefs-boot.el $(lisp)/loaddefs.el; \
eb7b668e 273 fi
36801f7f 274
366fc3f9 275maintainer-clean: distclean
36801f7f 276 cd $(lisp); rm -f *.elc */*.elc $(AUTOGENEL)
a9b67cf4 277
0571ccec
KS
278bootstrap-clean:
279 cd $(lisp); rm -f *.elc */*.elc
280
a9b67cf4
GM
281# Generate/update files for the bootstrap process.
282
1eee3de4 283bootstrap: update-subdirs autoloads mh-autoloads compile
21d07b1d
MR
284
285# Generate/update files after the bootstrap process.
286# custom-deps needs `preloaded-file-list'.
287
288bootstrap-after: finder-data custom-deps
a9b67cf4 289
43280888 290distclean:
64865454 291 -rm -f ./Makefile
43280888 292
7ec641b8 293# Makefile ends here.