diff src/Makefile.in @ 96137:eae2eee28ad3

Make "make" do a bootstrap if needed. * src/Makefile.in (emacs${EXEEXT}): Link the new emacs to bootstrap-emacs. (bootstrapclean): Remove. (.el.elc): New rule. (PRECOMP): New var. (../lisp/subdirs.el): Remove. (bootstrap-emacs${EXEEXT}): Remove subdirs.el and charpro.el dependency. (witness-emacs): New target. (mostlyclean): Remove witness-emacs as well. (../lisp/loaddefs.el, ${lisp} ${SOME_MACHINE_LISP}): Add witness-emacs dependency. * lisp/loadup.el: Don't add emacs-<VERS> name when bootstrapping. * lisp/Makefile.in (emacs-deps): Remove. ($(lisp)/cus-load.el, $(lisp)/finder-inf.el): Re-add. (all): Use them. (autogen-clean): Remove. * Makefile.in (maybe_bootstrap, src/bootstrap-emacs${EXEEXT}) (bootstrap-build): Remove. (top_bootclean): New var. (top_distclean, bootstrap-clean): Use it. (bootstrap): Don't recheck config. Make normally.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 21 Jun 2008 01:38:39 +0000
parents d143e6de14ec
children 41be5bc2426e
line wrap: on
line diff
--- a/src/Makefile.in	Fri Jun 20 23:27:07 2008 +0000
+++ b/src/Makefile.in	Sat Jun 21 01:38:39 2008 +0000
@@ -912,6 +912,9 @@
 	ln temacs${EXEEXT} emacs${EXEEXT}
 #else
 	LC_ALL=C $(RUN_TEMACS) -batch -l loadup dump
+	@: This new Emacs is as functional and more efficient then
+	@: bootstrap-emacs, so let us replace it.
+	-ln -f emacs${EXEEXT} bootstrap-emacs${EXEEXT}
 #endif /* ! defined (CANNOT_DUMP) */
 	-./emacs -q -batch -f list-load-path-shadows
 
@@ -1268,12 +1271,10 @@
 	cd ${emacsapp}Contents/MacOS/; cp ../../../../src/emacs${EXEEXT} Emacs${EXEEXT}
 #endif
 
-bootstrapclean:
-	rm -f bootstrap-emacs${EXEEXT} emacs-${version}${EXEEXT}
 mostlyclean:
 	rm -f temacs${EXEEXT} prefix-args${EXEEXT} core *.core \#* *.o libXMenu11.a liblw.a
 	rm -f ../etc/DOC
-	rm -f bootstrap-emacs${EXEEXT} emacs-${version}${EXEEXT}
+	rm -f bootstrap-emacs${EXEEXT} emacs-${version}${EXEEXT} witness-emacs
 	rm -f buildobj.lst
 clean: mostlyclean
 	rm -f emacs-*.*.*${EXEEXT} emacs${EXEEXT}
@@ -1319,22 +1320,49 @@
 
 
 /* Bootstrapping.  */
-
-bootstrap: bootstrap-emacs${EXEEXT}
+/* Bootstrapping right is difficult because of the circular dependencies.
+   Furthermore, we have to deal with the fact that many compilation targets
+   such as loaddefs.el or *.elc can typically be produced by any old
+   Emacs executable, so we would like to avoid rebuilding them whenever
+   we build a new Emacs executable.
+   To solve the circularity, we use 2 different Emacs executables,
+   "emacs" is the main target and "bootstrap-emacs" is the one used
+   to build the *.elc and loaddefs.el files.
+   To solve the freshness issue, we use a third file "witness-emacs"
+   which is used to witness the fact that there is a bootstrap-emacs
+   executable.  */
 
-../lisp/subdirs.el:
-	cd $(lispsource); $(MAKE) update-subdirs
+/* These suffix rules do not allow additional dependencies, sadly, so
+   adding a bootstrap-emacs%{EXEEXT} dependency does not work --Stef */
+.el.elc:
+	cd ${lispsource}; $(MAKE) $(MFLAGS) $@ EMACS=../src/bootstrap-emacs${EXEEXT}
+
+/* Files that need to be compiled early to speed up further compilation.  */
+PRECOMP=../lisp/emacs-lisp/bytecomp.elc ../lisp/emacs-lisp/byte-opt.elc
+${PRECOMP}: witness-emacs
 
-../lisp/loaddefs.el: bootstrap-emacs${EXEEXT}
-	cd $(lispsource); $(MAKE) autoloads EMACS=../src/bootstrap-emacs${EXEEXT}
+/* Since the .el.elc rule cannot specify an extra dependency, we do it here.
+   The byte-compiler dependency is not necessary, but it substantially
+   speeds up byte-compilation of the other files.
+   Of course, it also has the downside of forcing a recompilation of all
+   those files whenever a file in $PRECOMP changes.  */
+${lisp} ${SOME_MACHINE_LISP}: witness-emacs ${PRECOMP}
+
+../lisp/loaddefs.el: witness-emacs
+	cd $(lispsource); $(MAKE) $(MFLAGS) autoloads EMACS=../src/bootstrap-emacs${EXEEXT}
 
 /* Dump an Emacs executable named bootstrap-emacs containing the
    files from loadup.el in source form.  */
 
-bootstrap-emacs${EXEEXT}: temacs${EXEEXT} ${lispsource}international/charprop.el ../lisp/subdirs.el
+bootstrap-emacs${EXEEXT}: temacs${EXEEXT}
 #ifdef CANNOT_DUMP
 	ln temacs${EXEEXT} bootstrap-emacs${EXEEXT}
 #else
 	$(RUN_TEMACS) --batch --load loadup bootstrap
 	mv -f emacs${EXEEXT} bootstrap-emacs${EXEEXT}
 #endif /* ! defined (CANNOT_DUMP) */
+
+witness-emacs:
+	cd $(lispsource); $(MAKE) $(MFLAGS) update-subdirs
+	$(MAKE) $(MFLAGS) bootstrap-emacs${EXEEXT}
+	touch witness-emacs