Merge from trunk after a lot of time.
[bpt/emacs.git] / test / automated / Makefile.in
1 ### @configure_input@
2
3 # Copyright (C) 2010-2013 Free Software Foundation, Inc.
4
5 # This file is part of GNU Emacs.
6
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.
11
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.
16
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/>.
19
20 SHELL = @SHELL@
21
22 srcdir = @srcdir@
23 top_srcdir = @top_srcdir@
24 abs_top_builddir = @abs_top_builddir@
25 test = $(srcdir)
26 VPATH = $(srcdir)
27 lispsrc = $(top_srcdir)/lisp
28 lisp = ${abs_top_builddir}/lisp
29
30 # You can specify a different executable on the make command line,
31 # e.g. "make EMACS=../src/emacs ...".
32
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
37
38 # Command line flags for Emacs.
39
40 EMACSOPT = -batch --no-site-file --no-site-lisp
41
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.
47
48 # The actual Emacs command run in the targets below.
49 emacs = EMACSLOADPATH=$(lispsrc):$(test) LC_ALL=C $(EMACS) $(EMACSOPT)
50
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" ;; \
56 esac; \
57 done
58
59 all: check
60
61 doit:
62
63
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.
70
71 .SUFFIXES: .elc .el
72
73 # An old-fashioned suffix rule, which, according to the GNU Make manual,
74 # cannot have prerequisites.
75 .el.elc:
76 @echo Compiling $<
77 @$(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $<
78
79 .PHONY: lisp-compile compile-main compile compile-always
80
81 lisp-compile:
82 cd $(lisp); $(MAKE) $(MFLAGS) compile EMACS=$(EMACS)
83
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
91 # make command line.
92
93
94 .PHONY: compile-targets
95 # TARGETS is set dynamically in the recursive call from `compile-main'.
96 compile-targets: $(TARGETS)
97
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; \
106 echo "$${el}c"; \
107 done | xargs echo) | \
108 while read chunk; do \
109 $(MAKE) $(MFLAGS) compile-targets EMACS="$(EMACS)" TARGETS="$$chunk"; \
110 done
111
112 .PHONY: compile-clean
113 # Erase left-over .elc files that do not have a corresponding .el file.
114 compile-clean:
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 \
119 echo rm "$${el}c"; \
120 rm "$${el}c"; \
121 fi \
122 done
123
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)
132
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.
136 compile-always: doit
137 cd $(test); rm -f *.elc */*.elc */*/*.elc */*/*/*.elc
138 $(MAKE) $(MFLAGS) compile EMACS=$(EMACS)
139
140 bootstrap-clean:
141 cd $(test); rm -f *.elc */*.elc */*/*.elc */*/*/*.elc
142
143 distclean:
144 -rm -f ./Makefile
145
146 maintainer-clean: distclean bootstrap-clean
147
148 check: compile-main
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"; \
154 els="$$els $$el"; \
155 done; \
156 echo Testing $$els; \
157 $(emacs) $$args -f ert-run-tests-batch-and-exit)
158
159 # Makefile ends here.