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