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