1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-12 09:28:24 +00:00
emacs/lisp/Makefile.in
Lars Ingebrigtsen 4252cea163 Clarify lisp/Makefile.in comment
* lisp/Makefile.in: Clarify comment.
2022-08-07 14:41:01 +02:00

535 lines
21 KiB
Makefile

### @configure_input@
# Copyright (C) 2000-2022 Free Software Foundation, Inc.
# This file is part of GNU Emacs.
# GNU Emacs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# GNU Emacs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
lisp = $(srcdir)
VPATH = $(srcdir)
EXEEXT = @EXEEXT@
# Empty for all systems except MinGW, where xargs needs an explicit
# limitation.
XARGS_LIMIT = @XARGS_LIMIT@
HAVE_NATIVE_COMP = @HAVE_NATIVE_COMP@
ifeq ($(HAVE_NATIVE_COMP),yes)
ifndef NATIVE_FULL_AOT
NATIVE_SKIP_NONDUMP = 1
endif
endif
-include ${top_builddir}/src/verbose.mk
FIND_DELETE = @FIND_DELETE@
# You can specify a different executable on the make command line,
# e.g. "make EMACS=../src/emacs ...".
# We never change directory before running Emacs, so a relative file
# name is fine, and makes life easier. If we need to change
# directory, we can use emacs --chdir.
EMACS = ../src/emacs${EXEEXT}
# Command line flags for Emacs.
EMACSOPT = -batch --no-site-file --no-site-lisp
# Extra flags to pass to the byte compiler
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.
# All generated autoload files.
loaddefs = $(shell find ${srcdir} -name '*loaddefs.el' ! -name '.*')
# Elisp files auto-generated.
AUTOGENEL = ${loaddefs} ${srcdir}/cus-load.el ${srcdir}/finder-inf.el \
${srcdir}/subdirs.el ${srcdir}/eshell/esh-groups.el
# Set load-prefer-newer for the benefit of the non-bootstrappers.
BYTE_COMPILE_FLAGS = \
--eval "(setq load-prefer-newer t byte-compile-warnings 'all)" \
$(BYTE_COMPILE_EXTRA_FLAGS)
# ... but we must prefer .elc files for those in the early bootstrap.
# A larger `max-specpdl-size' is needed for emacs-lisp/comp.el.
compile-first: BYTE_COMPILE_FLAGS = \
--eval '(setq max-specpdl-size 5000)' $(BYTE_COMPILE_EXTRA_FLAGS)
# Files to compile before others during a bootstrap. This is done to
# speed up the bootstrap process. They're ordered by size, so we use
# the slowest-compiler on the smallest file and move to larger files
# as the compiler gets faster. 'loaddefs-gen.elc'/'radix-tree.el'
# comes last because they're not used by the compiler (so its
# compilation does not speed up subsequent compilations), it's only
# placed here so as to speed up generation of the loaddefs.el files.
COMPILE_FIRST = \
$(lisp)/emacs-lisp/macroexp.elc \
$(lisp)/emacs-lisp/cconv.elc \
$(lisp)/emacs-lisp/byte-opt.elc \
$(lisp)/emacs-lisp/bytecomp.elc
ifeq ($(HAVE_NATIVE_COMP),yes)
COMPILE_FIRST += $(lisp)/emacs-lisp/comp.elc
COMPILE_FIRST += $(lisp)/emacs-lisp/comp-cstr.elc
endif
COMPILE_FIRST += $(lisp)/emacs-lisp/loaddefs-gen.elc
COMPILE_FIRST += $(lisp)/emacs-lisp/radix-tree.elc
# Files to compile early in compile-main. Works around bug#25556.
# Also compile the ja-dic file used to convert the Japanese dictionary
# to speed things up. The org files are used to convert org files to
# texi files.
MAIN_FIRST = ./emacs-lisp/eieio.el ./emacs-lisp/eieio-base.el \
./cedet/semantic/db.el ./emacs-lisp/cconv.el \
./international/ja-dic-cnv.el \
./org/ox.el ./org/ox-texinfo.el ./org/org-macro.el ./org/org-element.el \
./org/oc.el ./org/ol.el ./emacs-lisp/cl-lib.el
# Prevent any settings in the user environment causing problems.
unexport EMACSDATA EMACSDOC EMACSLOADPATH EMACSPATH
# The actual Emacs command run in the targets below.
emacs = '$(EMACS)' $(EMACSOPT)
## Subdirectories, relative to builddir.
SUBDIRS = $(sort $(shell find ${srcdir} -type d -print))
## Subdirectories, relative to srcdir.
SUBDIRS_REL = $(patsubst ${srcdir}%,.%,${SUBDIRS})
## All subdirectories except 'obsolete' and 'term'.
SUBDIRS_ALMOST = $(filter-out ${srcdir}/obsolete ${srcdir}/term,${SUBDIRS})
## All subdirectories except 'obsolete', 'term', and 'leim' (and subdirs).
## We don't want the leim files listed as packages, especially
## since many share basenames with files in language/.
SUBDIRS_FINDER = $(filter-out ${srcdir}/leim%,${SUBDIRS_ALMOST})
## All subdirectories in which we might want to create subdirs.el.
SUBDIRS_SUBDIRS = $(filter-out ${srcdir}/cedet% ${srcdir}/leim%,${SUBDIRS})
# cus-load, finder-inf and autoloads 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 generate-ja-dic \
org-manuals autoloads
PHONY_EXTRAS =
.PHONY: all custom-deps finder-data autoloads update-subdirs $(PHONY_EXTRAS) \
generate-ja-dic org-manuals
# 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:
# https://lists.gnu.org/r/emacs-pretest-bug/2007-01/msg00469.html
# https://lists.gnu.org/r/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:
# https://lists.gnu.org/r/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).
custom-deps:
$(AM_V_at)$(MAKE) PHONY_EXTRAS=$(lisp)/cus-load.el $(lisp)/cus-load.el
$(lisp)/cus-load.el:
$(AM_V_GEN)$(emacs) -l cus-dep \
--eval '(setq generated-custom-dependencies-file (unmsys--file-name "$(srcdir)/cus-load.el"))' \
-f custom-make-dependencies ${SUBDIRS_ALMOST}
finder-data:
$(AM_V_at)$(MAKE) PHONY_EXTRAS=$(lisp)/finder-inf.el \
$(lisp)/finder-inf.el
$(lisp)/finder-inf.el:
$(AM_V_GEN)$(emacs) -l finder \
--eval '(setq generated-finder-keywords-file (unmsys--file-name "$(srcdir)/finder-inf.el"))' \
-f finder-compile-keywords-make-dist ${SUBDIRS_FINDER}
# This is the OKURO-NASI compilation trigger.
generate-ja-dic: main-first
$(AM_V_at)$(MAKE) -C ../leim generate-ja-dic EMACS="$(EMACS)"
$(AM_V_at)$(MAKE) compile-targets TARGETS="./leim/ja-dic/ja-dic.elc"
org-manuals: main-first
$(AM_V_at)$(MAKE) -C ../doc/misc org.texi modus-themes.texi
## Comments on loaddefs generation:
# loaddefs depends on gen-lisp because in ../src, the emacs target
# depends on loaddefs, but not on, for instance, leim-list. So having
# leim as a dependency of loaddefs (via gen-lisp) ensures leim-list
# gets created before the final emacs is dumped. Having leim
# dependencies in ../src as well would create a parallel race
# condition.
#
# FIXME: Is the following true any more?
#
# We'd really like to add "make -C ../admin/unidata all" to gen-lisp,
# but it causes a race condition in parallel builds because ../src
# also runs that rule. Given the limitations of recursive make, the
# only way to fix that would be to remove unidata from ../src rules,
# but that doesn't seem possible due to the various non-trivial
# dependencies.
# The real dependencies of loaddefs.el aren't known to Make, they are
# implemented in loaddefs-generate--emacs-batch, so autoloads is an
# "all" dependency. "leim" isn't really a dependency here, but we
# need leim-list.el at about the same time, so ensure that it's
# generated, too.
autoloads: $(lisp)/emacs-lisp/loaddefs-gen.elc gen-lisp
$(AM_V_GEN)$(emacs) \
-l $(lisp)/emacs-lisp/loaddefs-gen.elc \
-f loaddefs-generate--emacs-batch ${SUBDIRS_ALMOST}
# autoloads always runs, but only updates when there's something new.
# Provide a force option to enable regeneration of all loaddefs files.
.PHONY: autoloads-force
autoloads-force:
rm -f $(lisp)/loaddefs.el
$(MAKE) autoloads
ldefs-boot.el: autoloads-force
sed '/^;; Local Variables:/a ;; no-byte-compile: t'\
< $(lisp)/loaddefs.el > $(lisp)/ldefs-boot.el
# 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:
$(AM_V_GEN)$(MAKE) update-subdirs
update-subdirs:
$(AM_V_at)for file in ${SUBDIRS_SUBDIRS}; do \
$(srcdir)/../build-aux/update-subdirs $$file; \
done;
.PHONY: updates repo-update update-authors
# Some modes of make-dist use this.
updates: update-subdirs autoloads finder-data custom-deps
# This is useful after updating from the repository; but it doesn't do
# anything that a plain "make" at top-level doesn't. The only
# difference between this and this directory's "all" rule is that this
# runs "autoloads" as well (because it uses "compile" rather than
# "compile-main"). In a bootstrap, $(lisp) in src/Makefile triggers
# this directory's autoloads rule.
repo-update: compile finder-data custom-deps
# Update etc/AUTHORS
update-authors:
$(emacs) -L "$(top_srcdir)/admin" -l authors \
-f batch-update-authors "$(top_srcdir)/etc/AUTHORS" "$(top_srcdir)"
FORCE:
.PHONY: FORCE
tagsfiles = $(shell find ${srcdir} -name '*.el' \
! -name '.*' ! -name '*loaddefs.el')
tagsfiles := $(filter-out ${srcdir}/ldefs-boot.el,${tagsfiles})
tagsfiles := $(filter-out ${srcdir}/eshell/esh-groups.el,${tagsfiles})
ETAGS = ../lib-src/etags${EXEEXT}
${ETAGS}: FORCE
${MAKE} -C ../lib-src $(notdir $@)
## The use of xargs is to stop the command line getting too long
## on MS Windows, when the MSYS Bash passes it to a MinGW compiled
## etags. It might be better to use find in a similar way to
## compile-main. But maybe this is not even necessary any more now
## that this uses relative filenames.
TAGS: ${ETAGS} ${tagsfiles}
$(AM_V_GEN)rm -f $@
$(AM_V_at)touch $@
$(AM_V_at)ls ${tagsfiles} | xargs $(XARGS_LIMIT) "${ETAGS}" -a -o $@
# 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.
# Use byte-compile-refresh-preloaded to try and work around some of
# the most common problems of not bootstrapping from a clean state.
THEFILE = no-such-file
.PHONY: $(THEFILE)c
$(THEFILE)c:
ifeq ($(HAVE_NATIVE_COMP),yes)
$(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \
-l comp -f byte-compile-refresh-preloaded \
-f batch-byte+native-compile $(THEFILE)
else
$(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \
-l bytecomp -f byte-compile-refresh-preloaded \
-f batch-byte-compile $(THEFILE)
endif
ifeq ($(HAVE_NATIVE_COMP),yes)
.PHONY: $(THEFILE)n
$(THEFILE)n:
$(AM_V_ELN)$(emacs) $(BYTE_COMPILE_FLAGS) \
-l comp -f byte-compile-refresh-preloaded \
--eval '(batch-native-compile t)' $(THEFILE)
endif
# 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
# the Emacs used for compilation to the current directory and its
# subdirectories, to make sure require's and load's in the files being
# compiled find the right files.
.SUFFIXES: .elc .el
# An old-fashioned suffix rule, which, according to the GNU Make manual,
# cannot have prerequisites.
ifeq ($(HAVE_NATIVE_COMP),yes)
ifeq ($(ANCIENT),yes)
# The first compilation of compile-first, using an interpreted compiler:
# The resulting .elc files get given a date of 1971-01-01 so that their
# date stamp is earlier than the source files, causing these to be compiled
# into native code at the second recursive invocation of this $(MAKE),
# using these .elc's. This is faster than just compiling the native code
# directly using the interpreted compile-first files. (Note: 1970-01-01
# fails on some systems.)
.el.elc:
$(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \
-l comp -f batch-byte-compile $<
touch -t 197101010000 $@
else
.el.elc:
$(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) \
-l comp -f batch-byte+native-compile $<
endif
else
.el.elc:
$(AM_V_ELC)$(emacs) $(BYTE_COMPILE_FLAGS) -f batch-byte-compile $<
endif
.PHONY: compile-first compile-main compile compile-always
compile-first: $(COMPILE_FIRST)
# In 'compile-main' we could directly do
# ... | xargs $(MAKE)
# and it works, but it generates a lot of messages like
# make[2]: gnus/gnus-mlspl.elc is up to date.
# so instead, we use "xargs echo" to split the list of file into manageable
# chunks and then use an intermediate 'compile-targets' target so the
# actual targets (the .elc files) are not mentioned as targets on the
# make command line.
.PHONY: compile-targets
# TARGETS is set dynamically in the recursive call from 'compile-main'.
# Do not build comp.el unless necessary not to exceed max-specpdl-size and
# max-lisp-eval-depth in normal builds.
ifneq ($(HAVE_NATIVE_COMP),yes)
compile-targets: $(filter-out ./emacs-lisp/comp-cstr.elc,$(filter-out ./emacs-lisp/comp.elc,$(TARGETS)))
else
compile-targets: $(TARGETS)
endif
# Compile all the Elisp files that need it. Beware: it approximates
# 'no-byte-compile', so watch out for false-positives!
# The "autoloads" target has to run first, because it may generate new
# loaddefs files. But don't depend on it, because that might trigger
# unnecessary rebuilds.
compile-main: gen-lisp compile-clean main-first | autoloads
@(cd $(lisp) && \
els=`echo "${SUBDIRS_REL} " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
for el in $$els; do \
test -f $$el || continue; \
test ! -f $${el}c && \
GREP_OPTIONS= grep '^;.*[^a-zA-Z]no-byte-compile: *t' $$el > /dev/null && \
continue; \
echo "$${el}c"; \
done | xargs $(XARGS_LIMIT) echo) | \
while read chunk; do \
$(MAKE) compile-targets \
NATIVE_DISABLED=$(NATIVE_SKIP_NONDUMP) \
TARGETS="$$chunk"; \
done
# Compile some important files first.
main-first:
@(cd $(lisp) && \
for el in ${MAIN_FIRST}; do \
echo "$${el}c"; \
done | xargs $(XARGS_LIMIT) echo) | \
while read chunk; do \
$(MAKE) compile-targets \
NATIVE_DISABLED=$(NATIVE_SKIP_NONDUMP) \
TARGETS="$$chunk"; \
done
.PHONY: compile-clean
# Erase left-over .elc files that do not have a corresponding .el file.
compile-clean:
@cd $(lisp) && \
elcs=`echo "${SUBDIRS_REL} " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.elc |g'`; \
for el in `echo $$elcs | sed -e 's/\.elc/\.el/g'`; do \
if test -f "$$el" || test ! -f "$${el}c"; then :; else \
echo rm "$${el}c"; \
rm "$${el}c"; \
fi; \
done
.PHONY: gen-lisp leim semantic
## make -C ../admin/unidata all should be here, but that would race
## with ../src. See comments above for loaddefs.
gen-lisp: leim semantic
# (re)compile titdic-cnv before recursing into `leim` since its used to
# generate some of the Quail source files from tables.
leim: $(lisp)/international/titdic-cnv.elc
$(MAKE) -C ../leim all EMACS="$(EMACS)"
semantic:
$(MAKE) -C ../admin/grammars all EMACS="$(EMACS:.%=../.%)"
# Compile all Lisp files, but don't recompile those that are up to
# 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: $(LOADDEFS) autoloads compile-first
$(MAKE) compile-main
# 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:
find $(lisp) -name '*.elc' $(FIND_DELETE)
$(MAKE) compile
.PHONY: backup-compiled-files compile-after-backup
# Backup compiled Lisp files in elc.tar.gz. If that file already
# exists, make a backup of it.
backup-compiled-files:
-mv $(lisp)/elc.tar.gz $(lisp)/elc.tar.gz~
-tar czf $(lisp)/elc.tar.gz $(lisp)/*.elc $(lisp)/*/*.elc $(lisp)/*/*/*.elc $(lisp)/*/*/*/*.elc
# Compile Lisp files, but save old compiled files first.
compile-after-backup: backup-compiled-files compile-always
# This does the same job as the "compile" rule, but in a different way.
# Rather than spawning a separate Emacs instance to compile each file,
# it uses the same Emacs instance to compile everything.
# This is faster on a single core, since it avoids the overhead of
# starting Emacs many times (it was 33% faster on a test with a
# random 10% of the .el files needing recompilation).
# Unlike compile, this is not parallelizable; so if you have more than
# one core and use make -j#, compile will be (much) faster.
# This rule also produces less accurate compilation warnings.
# The environment of later files is affected by definitions in
# earlier ones, so it does not produce some warnings that it should.
# It can also produces spurious warnings about "invalid byte code" if
# files that use byte-compile-dynamic are updated.
# There is no reason to use this rule unless you only have a single
# core and CPU time is an issue.
.PHONY: compile-one-process
compile-one-process: $(LOADDEFS) compile-first
$(emacs) $(BYTE_COMPILE_FLAGS) \
--eval "(batch-byte-recompile-directory 0)" $(lisp)
.PHONY: bootstrap-clean distclean maintainer-clean
bootstrap-clean:
find $(lisp) -name '*.elc' $(FIND_DELETE)
rm -f $(AUTOGENEL)
distclean:
-rm -f ./Makefile $(lisp)/loaddefs.el $(lisp)/loaddefs.elc
maintainer-clean: distclean bootstrap-clean
rm -f TAGS
.PHONY: check-declare
check-declare:
$(emacs) -l check-declare --eval '(check-declare-directory "$(lisp)")'
## This finds a lot of duplicates between foo.el and obsolete/foo.el.
check-defun-dups:
sed -n -e '/^(defun /s/\(.\)(.*/\1/p' \
$$(find . -name '*.el' ! -name '.*' -print | \
grep -Ev '(loaddefs|ldefs-boot)\.el|obsolete') | sort | uniq -d
# Dependencies
## None of the following matters for bootstrap, which is the only way
## to ensure a correct compilation of all lisp files.
## Manually specifying dependencies of a handful of lisp files, (and
## ones that don't change very often at that) seems pretty pointless
## to me.
# https://debbugs.gnu.org/1004
# CC Mode uses a compile time macro system which causes a compile time
# dependency in cc-*.elc files on the macros in other cc-*.el and the
# version string in cc-defs.el.
$(lisp)/progmodes/cc-align.elc\
$(lisp)/progmodes/cc-cmds.elc $(lisp)/progmodes/cc-compat.elc\
$(lisp)/progmodes/cc-engine.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-vars.elc: \
$(lisp)/progmodes/cc-bytecomp.elc $(lisp)/progmodes/cc-defs.elc
$(lisp)/progmodes/cc-align.elc $(lisp)/progmodes/cc-cmds.elc: \
$(lisp)/progmodes/cc-vars.elc $(lisp)/progmodes/cc-engine.elc
$(lisp)/progmodes/cc-compat.elc: \
$(lisp)/progmodes/cc-vars.elc $(lisp)/progmodes/cc-styles.elc \
$(lisp)/progmodes/cc-engine.elc
$(lisp)/progmodes/cc-defs.elc: $(lisp)/progmodes/cc-bytecomp.elc
$(lisp)/progmodes/cc-engine.elc: $(lisp)/progmodes/cc-langs.elc \
$(lisp)/progmodes/cc-vars.elc
$(lisp)/progmodes/cc-fonts.elc: $(lisp)/progmodes/cc-langs.elc \
$(lisp)/progmodes/cc-vars.elc $(lisp)/progmodes/cc-engine.elc
$(lisp)/progmodes/cc-langs.elc: $(lisp)/progmodes/cc-vars.elc
$(lisp)/progmodes/cc-mode.elc: $(lisp)/progmodes/cc-langs.elc \
$(lisp)/progmodes/cc-vars.elc $(lisp)/progmodes/cc-engine.elc \
$(lisp)/progmodes/cc-styles.elc $(lisp)/progmodes/cc-cmds.elc \
$(lisp)/progmodes/cc-align.elc $(lisp)/progmodes/cc-menus.elc
$(lisp)/progmodes/cc-styles.elc: $(lisp)/progmodes/cc-vars.elc \
$(lisp)/progmodes/cc-align.elc
# https://debbugs.gnu.org/43037
# js.elc (like all modes using CC Mode's compile time macros) needs to
# be compiled under the same version of CC Mode it will run with.
$(lisp)/progmodes/js.elc: $(lisp)/progmodes/cc-defs.elc \
$(lisp)/progmodes/cc-engine.elc $(lisp)/progmodes/cc-mode.elc
# Makefile ends here.