Minor simplifications for test/automated/Makefile
[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 abs_top_srcdir = @abs_top_srcdir@
24 abs_top_builddir = @abs_top_builddir@
25 test = $(srcdir)
26 VPATH = $(srcdir)
27
28 # You can specify a different executable on the make command line,
29 # e.g. "make EMACS=../src/emacs ...".
30
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
35
36 # Command line flags for Emacs.
37
38 EMACSOPT = -batch --no-site-file --no-site-lisp
39
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.
45
46 # The actual Emacs command run in the targets below.
47 emacs = EMACSLOADPATH="$(abs_top_srcdir)/lisp:$(abs_srcdir)" LC_ALL=C "$(EMACS)" $(EMACSOPT)
48
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" ;; \
54 esac; \
55 done
56
57 all: check
58
59 doit:
60
61
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.
68
69 .SUFFIXES: .elc .el
70
71 # An old-fashioned suffix rule, which, according to the GNU Make manual,
72 # cannot have prerequisites.
73 .el.elc:
74 @echo Compiling $<
75 @$(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $<
76
77 .PHONY: lisp-compile compile-main compile compile-always
78
79 lisp-compile:
80 cd ../../lisp && $(MAKE) $(MFLAGS) compile EMACS="$(EMACS)"
81
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
89 # make command line.
90
91
92 .PHONY: compile-targets
93 # TARGETS is set dynamically in the recursive call from `compile-main'.
94 compile-targets: $(TARGETS)
95
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 $(test); $(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; \
104 echo "$${el}c"; \
105 done | xargs echo) | \
106 while read chunk; do \
107 $(MAKE) $(MFLAGS) compile-targets EMACS="$(EMACS)" TARGETS="$$chunk"; \
108 done
109
110 .PHONY: compile-clean
111 # Erase left-over .elc files that do not have a corresponding .el file.
112 compile-clean:
113 @cd $(test); $(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 \
117 echo rm "$${el}c"; \
118 rm "$${el}c"; \
119 fi \
120 done
121
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)"
130
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: doit
135 cd $(test); rm -f *.elc */*.elc */*/*.elc */*/*/*.elc
136 $(MAKE) $(MFLAGS) compile EMACS="$(EMACS)"
137
138 bootstrap-clean:
139 cd $(test); rm -f *.elc */*.elc */*/*.elc */*/*/*.elc
140
141 distclean:
142 -rm -f ./Makefile
143
144 maintainer-clean: distclean bootstrap-clean
145
146 check: compile-main
147 @(cd $(test); $(setwins); \
148 pattern=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
149 for el in $$pattern; do \
150 test -f $$el || continue; \
151 args="$$args -l $$el"; \
152 els="$$els $$el"; \
153 done; \
154 echo Testing $$els; \
155 $(emacs) $$args -f ert-run-tests-batch-and-exit)
156
157 # Makefile ends here.