EMACSOPT = -batch --no-site-file --multibyte
# Extra flags to pass to the byte compiler
-BYTE_COMPILE_EXTRA_FLAGS =
+BYTE_COMPILE_EXTRA_FLAGS =
# For example to not display the undefined function warnings you can use this:
# BYTE_COMPILE_EXTRA_FLAGS = --eval '(setq byte-compile-warnings (quote (not unresolved)))'
# The example above is just for developers, it should not be used by default.
eshell/esh-groups.el
# Files to compile before others during a bootstrap. This is done to
-# speed up the bootstrap process. The CC files are compiled first
-# because CC mode tweaks the compilation process, and requiring
-# cc-mode when it is not compiled doesn't work during the
-# bootstrapping.
+# speed up the bootstrap process.
COMPILE_FIRST = \
- $(lisp)/emacs-lisp/byte-opt.el \
- $(lisp)/emacs-lisp/bytecomp.el \
- $(lisp)/subr.el \
- $(lisp)/progmodes/cc-mode.el \
- $(lisp)/progmodes/cc-vars.el
+ $(lisp)/emacs-lisp/bytecomp.elc \
+ $(lisp)/emacs-lisp/byte-opt.elc \
+ $(lisp)/emacs-lisp/autoload.elc
# The actual Emacs command run in the targets below.
emacs = EMACSLOADPATH=$(lisp) LC_ALL=C $(EMACS) $(EMACSOPT)
-# Prerequisites for running $(emacs)
-emacs-deps = $(lisp)/subdirs.el
# Common command to find subdirectories
esac; \
done
+# `compile-main' tends to be slower than `recompile' but can be parallelized
+# with "make -j" and results in more deterministic compilation warnings.
+# cus-load and finder-inf are not explicitly requested by anything, so
+# we add them here to make sure they get built.
+all: compile-main $(lisp)/cus-load.el $(lisp)/finder-inf.el
+ @: Let us check that we byte-compiled all the files.
+ $(MAKE) $(MFLAGS) compile-last EMACS=$(EMACS)
+
doit:
+# custom-deps and finder-data both used to scan _all_ the *.el files.
+# This could lead to problems in parallel builds if automatically
+# generated *.el files (eg loaddefs etc) were being changed at the same time.
+# One solution was to add autoloads as a prerequisite:
+# http://lists.gnu.org/archive/html/emacs-pretest-bug/2007-01/msg00469.html
+# http://lists.gnu.org/archive/html/bug-gnu-emacs/2007-12/msg00171.html
+# However, this meant that running these targets modified loaddefs.el,
+# every time (due to time-stamping). Calling these rules from
+# bootstrap-after would modify loaddefs after src/emacs, resulting
+# in make install remaking src/emacs for no real reason:
+# http://lists.gnu.org/archive/html/emacs-devel/2008-02/msg00311.html
+# Nowadays these commands don't scan automatically generated files,
+# since they will never contain any useful information
+# (see finder-no-scan-regexp and custom-dependencies-no-scan-regexp).
$(lisp)/cus-load.el:
- touch $@
-# Note that custom-deps and finder-data depend on autoloads rather
-# than on loaddefs.el, so that autoloads does not run in parallel with
-# them under "make -j", because that could delete loaddefs.el from
-# under their feet.
-custom-deps: $(emacs-deps) autoloads $(lisp)/cus-load.el doit
+ $(MAKE) $(MFLAGS) custom-deps
+custom-deps: doit
wd=$(lisp); $(setwins_almost); \
echo Directories: $$wins; \
$(emacs) -l cus-dep --eval '(setq generated-custom-dependencies-file "$(lisp)/cus-load.el")' -f custom-make-dependencies $$wins
-finder-data: $(emacs-deps) autoloads doit
+$(lisp)/finder-inf.el:
+ $(MAKE) $(MFLAGS) finder-data
+finder-data: doit
wd=$(lisp); $(setwins_almost); \
echo Directories: $$wins; \
$(emacs) -l finder --eval '(setq generated-finder-keywords-file "$(lisp)/finder-inf.el")' -f finder-compile-keywords-make-dist $$wins
# The chmod +w is to handle env var CVSREAD=1. Files named
# are identified by being the value of `generated-autoload-file'.
-autoloads: $(emacs-deps) $(LOADDEFS) doit
+autoloads: $(LOADDEFS) doit
chmod +w $(lisp)/ps-print.el $(lisp)/emulation/tpu-edt.el \
$(lisp)/emacs-lisp/cl-loaddefs.el
wd=$(lisp); $(setwins_almost); \
echo Directories: $$wins; \
$(emacs) -l autoload --eval '(setq generated-autoload-file "$(lisp)/loaddefs.el")' -f batch-update-autoloads $$wins
-# Note: every rule that runs $(emacs) and is called during bootstrap must
-# depend on this.
+# This is required by the bootstrap-emacs target in ../src/Makefile, so
+# we know that if we have an emacs executable, we also have a subdirs.el.
$(lisp)/subdirs.el:
$(MAKE) $(MFLAGS) update-subdirs
update-subdirs: doit
.PHONY: update-elclist
-## Post-bootstrap, find the list of .elc files, exclude the members
-## of COMPILE_FIRST, and use sed to update ELCFILES in Makefile.in.
+## Post-bootstrap, find the list of .elc files and use sed to update
+## ELCFILES in Makefile.in.
## Errors in the final sed are non-fatal, since they have no effect on
## building Emacs. chmod +w is for CVSREAD=1.
## "echo" is non-portable with regards to backslashes, eg between zsh
update-elclist:
echo "/^ELCFILES/,/^$$/c\\" > temp.sed
echo "ELCFILES =" | sed -e 's/$$/ \\\\\\/' >> temp.sed
- exclude=`echo $(COMPILE_FIRST) | sed -e 's, ,\\\\|,g' -e 's,\/,\\\\/,g'`; \
- ls $(lisp)/*.elc $(lisp)/*/*.elc | sed -e "/$$exclude/d" -e "s|^$(lisp)| \$$(lisp)|" -e 's/$$/ \\\\\\/' -e '$$ s/ \\\\//' >> temp.sed
+ LC_COLLATE=C ls $(lisp)/*.elc $(lisp)/*/*.elc | sed -e "s|^$(lisp)| \$$(lisp)|" -e 's/$$/ \\\\\\/' -e '$$ s/ \\\\//' >> temp.sed
echo "" >> temp.sed
-sed -f temp.sed $(lisp)/Makefile.in > temp-elcfiles || rm temp-elcfiles
rm temp.sed
$(lisp)/emacs-lisp/backquote.elc \
$(lisp)/emacs-lisp/benchmark.elc \
$(lisp)/emacs-lisp/bindat.elc \
+ $(lisp)/emacs-lisp/byte-opt.elc \
$(lisp)/emacs-lisp/byte-run.elc \
+ $(lisp)/emacs-lisp/bytecomp.elc \
$(lisp)/emacs-lisp/check-declare.elc \
$(lisp)/emacs-lisp/checkdoc.elc \
$(lisp)/emacs-lisp/cl-compat.elc \
$(lisp)/eshell/eshell.elc \
$(lisp)/expand.elc \
$(lisp)/ezimage.elc \
+ $(lisp)/face-remap.elc \
$(lisp)/facemenu.elc \
$(lisp)/faces.elc \
$(lisp)/ffap.elc \
$(lisp)/gnus/nngateway.elc \
$(lisp)/gnus/nnheader.elc \
$(lisp)/gnus/nnimap.elc \
+ $(lisp)/gnus/nnir.elc \
$(lisp)/gnus/nnkiboze.elc \
$(lisp)/gnus/nnlistserv.elc \
$(lisp)/gnus/nnmail.elc \
$(lisp)/international/robin.elc \
$(lisp)/international/titdic-cnv.elc \
$(lisp)/international/utf-7.elc \
- $(lisp)/isearch-multi.elc \
$(lisp)/isearch.elc \
$(lisp)/isearchb.elc \
$(lisp)/iswitchb.elc \
$(lisp)/language/ethio-util.elc \
$(lisp)/language/ethiopic.elc \
$(lisp)/language/european.elc \
+ $(lisp)/language/hanja-util.elc \
$(lisp)/language/ind-util.elc \
$(lisp)/language/indian.elc \
$(lisp)/language/japan-util.elc \
$(lisp)/minibuf-eldef.elc \
$(lisp)/minibuffer.elc \
$(lisp)/misc.elc \
+ $(lisp)/misearch.elc \
$(lisp)/mouse-copy.elc \
$(lisp)/mouse-drag.elc \
$(lisp)/mouse-sel.elc \
$(lisp)/net/ldap.elc \
$(lisp)/net/net-utils.elc \
$(lisp)/net/netrc.elc \
+ $(lisp)/net/newst-backend.elc \
+ $(lisp)/net/newst-plainview.elc \
+ $(lisp)/net/newst-reader.elc \
+ $(lisp)/net/newst-ticker.elc \
+ $(lisp)/net/newst-treeview.elc \
$(lisp)/net/newsticker.elc \
$(lisp)/net/ntlm.elc \
$(lisp)/net/quickurl.elc \
$(lisp)/net/tramp.elc \
$(lisp)/net/trampver.elc \
$(lisp)/net/webjump.elc \
+ $(lisp)/net/xesam.elc \
$(lisp)/net/zeroconf.elc \
$(lisp)/newcomment.elc \
$(lisp)/novice.elc \
$(lisp)/nxml/rng-xsd.elc \
$(lisp)/nxml/xmltok.elc \
$(lisp)/nxml/xsd-regexp.elc \
- $(lisp)/obsolete/auto-show.elc \
$(lisp)/obsolete/awk-mode.elc \
- $(lisp)/obsolete/bg-mouse.elc \
$(lisp)/obsolete/fast-lock.elc \
- $(lisp)/obsolete/float.elc \
- $(lisp)/obsolete/hilit19.elc \
- $(lisp)/obsolete/hscroll.elc \
$(lisp)/obsolete/iso-acc.elc \
$(lisp)/obsolete/iso-insert.elc \
$(lisp)/obsolete/iso-swed.elc \
$(lisp)/obsolete/lazy-lock.elc \
- $(lisp)/obsolete/lselect.elc \
- $(lisp)/obsolete/mlsupport.elc \
$(lisp)/obsolete/old-whitespace.elc \
- $(lisp)/obsolete/ooutline.elc \
$(lisp)/obsolete/options.elc \
- $(lisp)/obsolete/profile.elc \
$(lisp)/obsolete/rnews.elc \
$(lisp)/obsolete/rnewspost.elc \
- $(lisp)/obsolete/rsz-mini.elc \
$(lisp)/obsolete/sc.elc \
$(lisp)/obsolete/scribe.elc \
$(lisp)/obsolete/swedish.elc \
- $(lisp)/obsolete/uncompress.elc \
$(lisp)/obsolete/x-menu.elc \
$(lisp)/org/org-agenda.elc \
$(lisp)/org/org-archive.elc \
$(lisp)/org/org-export-latex.elc \
$(lisp)/org/org-faces.elc \
$(lisp)/org/org-gnus.elc \
+ $(lisp)/org/org-id.elc \
$(lisp)/org/org-info.elc \
$(lisp)/org/org-irc.elc \
$(lisp)/org/org-jsinfo.elc \
$(lisp)/progmodes/cc-fonts.elc \
$(lisp)/progmodes/cc-langs.elc \
$(lisp)/progmodes/cc-menus.elc \
+ $(lisp)/progmodes/cc-mode.elc \
$(lisp)/progmodes/cc-styles.elc \
$(lisp)/progmodes/cc-subword.elc \
+ $(lisp)/progmodes/cc-vars.elc \
$(lisp)/progmodes/cfengine.elc \
$(lisp)/progmodes/cmacexp.elc \
$(lisp)/progmodes/compile.elc \
$(lisp)/speedbar.elc \
$(lisp)/startup.elc \
$(lisp)/strokes.elc \
+ $(lisp)/subr.elc \
$(lisp)/t-mouse.elc \
$(lisp)/tabify.elc \
$(lisp)/talk.elc \
$(lisp)/tar-mode.elc \
$(lisp)/tempo.elc \
$(lisp)/term.elc \
- $(lisp)/term/mac-win.elc \
+ $(lisp)/term/common-win.elc \
+ $(lisp)/term/ns-win.elc \
$(lisp)/term/pc-win.elc \
$(lisp)/term/rxvt.elc \
$(lisp)/term/sun.elc \
$(lisp)/textmodes/reftex-vars.elc \
$(lisp)/textmodes/reftex.elc \
$(lisp)/textmodes/remember.elc \
+ $(lisp)/textmodes/rst.elc \
$(lisp)/textmodes/sgml-mode.elc \
$(lisp)/textmodes/spell.elc \
$(lisp)/textmodes/table.elc \
$(lisp)/url/url-util.elc \
$(lisp)/url/url-vars.elc \
$(lisp)/url/url.elc \
- $(lisp)/url/vc-dav.elc \
$(lisp)/userlock.elc \
+ $(lisp)/vc-annotate.elc \
$(lisp)/vc-arch.elc \
$(lisp)/vc-bzr.elc \
$(lisp)/vc-cvs.elc \
+ $(lisp)/vc-dav.elc \
+ $(lisp)/vc-dir.elc \
$(lisp)/vc-dispatcher.elc \
$(lisp)/vc-git.elc \
$(lisp)/vc-hg.elc \
$(lisp)/xml.elc \
$(lisp)/xt-mouse.elc
+# The src/Makefile.in has its own set of dependencies and when they decide
+# that one Lisp file needs to be re-compiled, we had better recompile it as
+# well, otherwise every subsequent make will again call us, until we finally
+# end up deciding that yes, the file deserves recompilation.
+# One option is to try and reproduce exactly the same dependencies here as
+# we have in src/Makefile.in, but it turns out to be painful
+# (e.g. src/Makefile.in may have a dependency for ../lisp/foo.elc where we
+# only know of $(lisp)/foo.elc). So instead we provide a direct way for
+# src/Makefile.in to rebuild a particular Lisp file, no questions asked.
+compile-onefile:
+ @echo Compiling $(THEFILE)
+ @$(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $(THEFILE)
+
# Files MUST be compiled one by one. If we compile several files in a
# row (i.e., in the same instance of Emacs) we can't make sure that
# the compilation environment is clean. We also set the load-path of
.PHONY: compile-first compile-main compile-last compile compile-always
-compile-first: $(emacs-deps) $(LOADDEFS) autoloads $(COMPILE_FIRST)
- for el in $(COMPILE_FIRST); do \
- echo Compiling $$el; \
- $(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile-if-not-done $$el || exit 1; \
- done
+compile-first: $(COMPILE_FIRST)
compile-main: $(ELCFILES)
# date. Some .el files don't get compiled because they set the
# local variable no-byte-compile.
# Calling make recursively because suffix rule cannot have prerequisites.
-compile: $(emacs-deps) $(LOADDEFS) autoloads compile-first
- $(MAKE) $(MFLAGS) compile-main
- $(MAKE) $(MFLAGS) compile-last
+# Explicitly pass EMACS (sometimes ../src/bootstrap-emacs) to those
+# sub-makes that run rules that use it, for the sake of some non-GNU makes.
+compile: $(LOADDEFS) autoloads compile-first
+ $(MAKE) $(MFLAGS) compile-main EMACS=$(EMACS)
+ $(MAKE) $(MFLAGS) compile-last EMACS=$(EMACS)
+
+## Doing this causes make install to dump another emacs.
+# $(MAKE) $(MFLAGS) update-elclist
# Compile all Lisp files. This is like `compile' but compiles files
# unconditionally. Some files don't actually get compiled because they
# set the local variable no-byte-compile.
compile-always: doit
cd $(lisp); rm -f *.elc */*.elc
- $(MAKE) $(MFLAGS) compile
+ $(MAKE) $(MFLAGS) compile EMACS=$(EMACS)
## In case any files are missing from ELCFILES.
compile-last:
@wd=$(lisp); $(setwins); \
els=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
- for el in $(COMPILE_FIRST) $$els; do \
+ for el in $$els; do \
test -f $$el || continue; \
test -f $${el}c && continue; \
grep 'no-byte-compile: t' $$el > /dev/null && continue; \
# Recompile all Lisp files which are newer than their .elc files and compile
# new ones.
-# FIXME this could use the 'compile' target now, and let make figure out
-# what needs to be done. That would be parallelizable, but would not
-# pick up new files not in ELCFILES.
+# This has the same effect as compile-main (followed up with compile-last,
+# if ELCFILES is out of date). recompile has some advantages:
+# i) It is faster (on a single processor), since it only has to start
+# Emacs once. It was 33% faster on a test with a random 10% of the .el
+# files needing recompilation.
+# ii) The explicit cc-mode dependency.
+# recompile's disadvantages are:
+# i) Not parallelizable.
+# ii) Compiling multiple files in the same instance of Emacs is wrong,
+# since the environment of later files is affected by definitions in
+# earlier ones.
recompile: doit $(LOADDEFS) $(lisp)/progmodes/cc-mode.elc
$(emacs) --eval "(batch-byte-recompile-directory 0)" $(lisp)
$(lisp)/progmodes/cc-mode.el \
$(lisp)/progmodes/cc-langs.el \
$(lisp)/progmodes/cc-defs.el
- $(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $@
+ $(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $<
# Update MH-E internal autoloads. These are not to be confused with
# the autoloads for the MH-E entry points, which are already in loaddefs.el.
$(MH_E_DIR)/mh-xface.el
mh-autoloads: $(MH_E_DIR)/mh-loaddefs.el
-$(MH_E_DIR)/mh-loaddefs.el: $(emacs-deps) $(MH_E_SRC)
+$(MH_E_DIR)/mh-loaddefs.el: $(MH_E_SRC)
$(emacs) -l autoload \
--eval "(setq generate-autoload-cookie \";;;###mh-autoload\")" \
--eval "(setq generated-autoload-file \"$@\")" \
$(CAL_DIR)/holidays.el $(CAL_DIR)/lunar.el \
$(CAL_DIR)/solar.el
-$(CAL_DIR)/cal-loaddefs.el: $(emacs-deps) $(CAL_SRC)
+$(CAL_DIR)/cal-loaddefs.el: $(CAL_SRC)
$(emacs) -l autoload \
--eval "(setq generate-autoload-cookie \";;;###cal-autoload\")" \
--eval "(setq generated-autoload-file \"$@\")" \
--eval "(setq make-backup-files nil)" \
-f batch-update-autoloads $(CAL_DIR)
-$(CAL_DIR)/diary-loaddefs.el: $(emacs-deps) $(CAL_SRC)
+$(CAL_DIR)/diary-loaddefs.el: $(CAL_SRC)
$(emacs) -l autoload \
--eval "(setq generate-autoload-cookie \";;;###diary-autoload\")" \
--eval "(setq generated-autoload-file \"$@\")" \
--eval "(setq make-backup-files nil)" \
-f batch-update-autoloads $(CAL_DIR)
-$(CAL_DIR)/hol-loaddefs.el: $(emacs-deps) $(CAL_SRC)
+$(CAL_DIR)/hol-loaddefs.el: $(CAL_SRC)
$(emacs) -l autoload \
--eval "(setq generate-autoload-cookie \";;;###holiday-autoload\")" \
--eval "(setq generated-autoload-file \"$@\")" \
# local changes. (Because loaddefs.el is an automatically generated
# file, we don't want to store it in the source repository).
-bootstrap-prepare:
- if test -x $(EMACS); then \
- $(MAKE) $(MFLAGS) autoloads; \
- fi
-
-autogen-clean:
- cd $(lisp); rm -f $(AUTOGENEL)
-
-maintainer-clean: distclean bootstrap-clean autogen-clean
-
-## NB note that this rules assume only one level of subdirs below lisp/.
-## If nested subdirs are added, it's probably time to switch to:
-## find $(lisp) -name "*.elc" -exec rm -f '{}' ';'
bootstrap-clean:
- cd $(lisp); rm -f *.elc */*.elc
-
-# Generate/update files for the bootstrap process.
-
-bootstrap: update-subdirs autoloads compile
-
-# Generate/update files after the bootstrap process.
-# custom-deps needs `preloaded-file-list'.
-
-bootstrap-after: finder-data custom-deps update-elclist
+ cd $(lisp); rm -f *.elc */*.elc $(AUTOGENEL)
distclean:
-rm -f ./Makefile
+maintainer-clean: distclean bootstrap-clean
+
.PHONY: check-declare
check-declare: