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