Merge from emacs-24; up to 2012-04-20T05:47:55Z!eliz@gnu.org
[emacs.git] / test / automated / Makefile.in
blobc07d5a1897d51d1f98d361dbc8330982f78b189f
1 # Maintenance productions for the automated test directory
2 # Copyright (C) 2010-2012 Free Software Foundation, Inc.
4 # This file is part of GNU Emacs.
6 # GNU Emacs is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # GNU Emacs is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19 SHELL = /bin/sh
21 srcdir = @srcdir@
22 top_srcdir = @top_srcdir@
23 abs_top_builddir = @abs_top_builddir@
24 test = $(srcdir)
25 VPATH = $(srcdir)
26 lispsrc = $(top_srcdir)/lisp
27 lisp = ${abs_top_builddir}/lisp
29 # You can specify a different executable on the make command line,
30 # e.g. "make EMACS=../src/emacs ...".
32 # We sometimes change directory before running Emacs (typically when
33 # building out-of-tree, we chdir to the source directory), so we need
34 # to use an absolute file name.
35 EMACS = ${abs_top_builddir}/src/emacs
37 # Command line flags for Emacs.
39 EMACSOPT = -batch --no-site-file --no-site-lisp
41 # Extra flags to pass to the byte compiler
42 BYTE_COMPILE_EXTRA_FLAGS =
43 # For example to not display the undefined function warnings you can use this:
44 # BYTE_COMPILE_EXTRA_FLAGS = --eval '(setq byte-compile-warnings (quote (not unresolved)))'
45 # The example above is just for developers, it should not be used by default.
47 # The actual Emacs command run in the targets below.
48 emacs = EMACSLOADPATH=$(lispsrc):$(test) LC_ALL=C $(EMACS) $(EMACSOPT)
50 # Common command to find subdirectories
51 setwins=subdirs=`(find . -type d -print)`; \
52 for file in $$subdirs; do \
53 case $$file in */.* | */.*/* | */=* ) ;; \
54 *) wins="$$wins $$file" ;; \
55 esac; \
56 done
58 all: test
60 doit:
63 # Files MUST be compiled one by one. If we compile several files in a
64 # row (i.e., in the same instance of Emacs) we can't make sure that
65 # the compilation environment is clean. We also set the load-path of
66 # the Emacs used for compilation to the current directory and its
67 # subdirectories, to make sure require's and load's in the files being
68 # compiled find the right files.
70 .SUFFIXES: .elc .el
72 # An old-fashioned suffix rule, which, according to the GNU Make manual,
73 # cannot have prerequisites.
74 .el.elc:
75 @echo Compiling $<
76 @$(emacs) $(BYTE_COMPILE_EXTRA_FLAGS) -f batch-byte-compile $<
78 .PHONY: lisp-compile compile-main compile compile-always
80 lisp-compile:
81 cd $(lisp); $(MAKE) $(MFLAGS) compile EMACS=$(EMACS)
83 # In `compile-main' we could directly do
84 # ... | xargs $(MAKE) $(MFLAGS) EMACS="$(EMACS)"
85 # and it works, but it generates a lot of messages like
86 # make[2]: « gnus/gnus-mlspl.elc » is up to date.
87 # so instead, we use "xargs echo" to split the list of file into manageable
88 # chunks and then use an intermediate `compile-targets' target so the
89 # actual targets (the .elc files) are not mentioned as targets on the
90 # make command line.
93 .PHONY: compile-targets
94 # TARGETS is set dynamically in the recursive call from `compile-main'.
95 compile-targets: $(TARGETS)
97 # Compile all the Elisp files that need it. Beware: it approximates
98 # `no-byte-compile', so watch out for false-positives!
99 compile-main: compile-clean lisp-compile
100 @(cd $(test); $(setwins); \
101 els=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
102 for el in $$els; do \
103 test -f $$el || continue; \
104 test ! -f $${el}c && GREP_OPTIONS= grep '^;.*no-byte-compile: t' $$el > /dev/null && continue; \
105 echo "$${el}c"; \
106 done | xargs echo) | \
107 while read chunk; do \
108 $(MAKE) $(MFLAGS) compile-targets EMACS="$(EMACS)" TARGETS="$$chunk"; \
109 done
111 .PHONY: compile-clean
112 # Erase left-over .elc files that do not have a corresponding .el file.
113 compile-clean:
114 @cd $(test); $(setwins); \
115 elcs=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.elc |g'`; \
116 for el in $$(echo $$elcs | sed -e 's/\.elc/\.el/g'); do \
117 if test -f "$$el" -o \! -f "$${el}c"; then :; else \
118 echo rm "$${el}c"; \
119 rm "$${el}c"; \
120 fi \
121 done
123 # Compile all Lisp files, but don't recompile those that are up to
124 # date. Some .el files don't get compiled because they set the
125 # local variable no-byte-compile.
126 # Calling make recursively because suffix rule cannot have prerequisites.
127 # Explicitly pass EMACS (sometimes ../src/bootstrap-emacs) to those
128 # sub-makes that run rules that use it, for the sake of some non-GNU makes.
129 compile: $(LOADDEFS) autoloads compile-first
130 $(MAKE) $(MFLAGS) compile-main EMACS=$(EMACS)
132 # Compile all Lisp files. This is like `compile' but compiles files
133 # unconditionally. Some files don't actually get compiled because they
134 # set the local variable no-byte-compile.
135 compile-always: doit
136 cd $(test); rm -f *.elc */*.elc */*/*.elc */*/*/*.elc
137 $(MAKE) $(MFLAGS) compile EMACS=$(EMACS)
139 bootstrap-clean:
140 cd $(test); rm -f *.elc */*.elc */*/*.elc */*/*/*.elc
142 distclean:
143 -rm -f ./Makefile
145 maintainer-clean: distclean bootstrap-clean
147 check: compile-main
148 @(cd $(test); $(setwins); \
149 pattern=`echo "$$wins " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 's| |/*.el |g'`; \
150 for el in $$pattern; do \
151 test -f $$el || continue; \
152 args="$$args -l $$el"; \
153 els="$$els $$el"; \
154 done; \
155 echo Testing $$els; \
156 $(emacs) $$args -f ert-run-tests-batch-and-exit)
158 # Makefile ends here.