3 # Copyright (C) 2010-2013 Free Software Foundation, Inc.
5 # This file is part of GNU Emacs.
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 3 of the License, or
10 # (at your option) any later version.
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.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 abs_srcdir
= @abs_srcdir@
24 abs_top_srcdir
= @abs_top_srcdir@
25 abs_top_builddir
= @abs_top_builddir@
28 # You can specify a different executable on the make command line,
29 # e.g. "make EMACS=../src/emacs ...".
31 # We sometimes change directory before running Emacs (typically when
32 # building out-of-tree, we chdir to the source directory), so we need
33 # to use an absolute file name.
34 EMACS
= ${abs_top_builddir}/src
/emacs
36 # Command line flags for Emacs.
38 EMACSOPT
= -batch
--no-site-file
--no-site-lisp
40 # Extra flags to pass to the byte compiler
41 BYTE_COMPILE_EXTRA_FLAGS
=
42 # For example to not display the undefined function warnings you can use this:
43 # BYTE_COMPILE_EXTRA_FLAGS = --eval '(setq byte-compile-warnings (quote (not unresolved)))'
44 # The example above is just for developers, it should not be used by default.
46 # The actual Emacs command run in the targets below.
47 emacs
= EMACSLOADPATH
="$(abs_top_srcdir)/lisp:$(abs_srcdir)" LC_ALL
=C
"$(EMACS)" $(EMACSOPT
)
49 # Common command to find subdirectories
50 setwins
=subdirs
=`find . -type d -print`; \
51 for file in
$$subdirs; do \
52 case
$$file in
*/.
* |
*/.
*/* |
*/=* | .
/data
* ) ;; \
53 *) wins
="$$wins$${wins:+ }$$file" ;; \
62 # Files MUST be compiled one by one. If we compile several files in a
63 # row (i.e., in the same instance of Emacs) we can't make sure that
64 # the compilation environment is clean. We also set the load-path of
65 # the Emacs used for compilation to the current directory and its
66 # subdirectories, to make sure require's and load's in the files being
67 # compiled find the right files.
71 # An old-fashioned suffix rule, which, according to the GNU Make manual,
72 # cannot have prerequisites.
75 @
$(emacs
) $(BYTE_COMPILE_EXTRA_FLAGS
) -f batch-byte-compile
$<
77 .PHONY
: lisp-compile compile-main compile compile-always
80 cd ..
/..
/lisp
&& $(MAKE
) $(MFLAGS
) compile EMACS
="$(EMACS)"
82 # In `compile-main' we could directly do
83 # ... | xargs $(MAKE) $(MFLAGS) EMACS="$(EMACS)"
84 # and it works, but it generates a lot of messages like
85 # make[2]: « gnus/gnus-mlspl.elc » is up to date.
86 # so instead, we use "xargs echo" to split the list of file into manageable
87 # chunks and then use an intermediate `compile-targets' target so the
88 # actual targets (the .elc files) are not mentioned as targets on the
92 .PHONY
: compile-targets
93 # TARGETS is set dynamically in the recursive call from `compile-main'.
94 compile-targets
: $(TARGETS
)
96 # Compile all the Elisp files that need it. Beware: it approximates
97 # `no-byte-compile', so watch out for false-positives!
98 compile-main
: compile-clean lisp-compile
99 @
(cd
$(srcdir) && $(setwins
); \
100 els
=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
101 for el in
$$els; do \
102 test -f
$$el || continue
; \
103 test ! -f
$${el}c
&& GREP_OPTIONS
= grep
'^;.*no-byte-compile: t' $$el > /dev
/null
&& continue
; \
105 done | xargs echo
) | \
106 while read chunk
; do \
107 $(MAKE
) $(MFLAGS
) compile-targets EMACS
="$(EMACS)" TARGETS
="$$chunk"; \
110 .PHONY
: compile-clean
111 # Erase left-over .elc files that do not have a corresponding .el file.
113 @cd
$(srcdir) && $(setwins
); \
114 elcs
=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.elc |g'`; \
115 for el in
$$(echo
$$elcs | sed
-e
's/\.elc/\.el/g'); do \
116 if
test -f
"$$el" -o \
! -f
"$${el}c"; then
:; else \
122 # Compile all Lisp files, but don't recompile those that are up to
123 # date. Some .el files don't get compiled because they set the
124 # local variable no-byte-compile.
125 # Calling make recursively because suffix rule cannot have prerequisites.
126 # Explicitly pass EMACS (sometimes ../src/bootstrap-emacs) to those
127 # sub-makes that run rules that use it, for the sake of some non-GNU makes.
128 compile
: $(LOADDEFS
) autoloads compile-first
129 $(MAKE
) $(MFLAGS
) compile-main EMACS
="$(EMACS)"
131 # Compile all Lisp files. This is like `compile' but compiles files
132 # unconditionally. Some files don't actually get compiled because they
133 # set the local variable no-byte-compile.
134 compile-always
: bootstrap-clean
135 $(MAKE
) $(MFLAGS
) compile EMACS
="$(EMACS)"
138 -cd
$(srcdir) && rm -f
*.elc
*/*.elc
*/*/*.elc
*/*/*/*.elc
143 maintainer-clean
: distclean bootstrap-clean
146 @
(cd
$(srcdir) && $(setwins
); \
147 pattern
=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
148 for el in
$$pattern; do \
149 test -f
$$el || continue
; \
150 args
="$$args -l $$el"; \
153 echo Testing
$$els; \
154 $(emacs
) $$args -f ert-run-tests-batch-and-exit
)
156 # Makefile ends here.