Fix library flavor detection for the validate script as well
[ghc.git] / testsuite / mk / test.mk
1 # -----------------------------------------------------------------------------
2 # Examples of use:
3 #
4 # make -- run all the tests in the current directory
5 # make verbose -- as make test, but up the verbosity
6 # make accept -- run the tests, accepting the current output
7 #
8 # The following variables may be set on the make command line:
9 #
10 # TEST -- specific test to run
11 # TESTS -- specific tests to run (same as $TEST really)
12 # EXTRA_HC_OPTS -- extra flags to send to the Haskell compiler
13 # EXTRA_RUNTEST_OPTS -- extra flags to give the test driver
14 # CONFIG -- use a different configuration file
15 # COMPILER -- select a configuration file from config/
16 # THREADS -- run n tests at once
17 #
18 # -----------------------------------------------------------------------------
19
20 # export the value of $MAKE for invocation in tests/driver/
21 export MAKE
22
23 RUNTESTS = $(TOP)/driver/runtests.py
24 COMPILER = ghc
25 CONFIGDIR = $(TOP)/config
26 CONFIG = $(CONFIGDIR)/$(COMPILER)
27
28 # TEST_HC_OPTS is passed to every invocation of TEST_HC
29 # in nested Makefiles
30 TEST_HC_OPTS = -fforce-recomp -dcore-lint -dcmm-lint -dno-debug-output -no-user-$(GhcPackageDbFlag) -rtsopts $(EXTRA_HC_OPTS)
31
32 RUNTEST_OPTS =
33
34 ifeq "$(filter $(TargetOS_CPP), cygwin32 mingw32)" ""
35 exeext =
36 else
37 exeext = .exe
38 endif
39
40 RUNTEST_OPTS += -e ghc_compiler_always_flags="'$(TEST_HC_OPTS)'"
41
42 RUNTEST_OPTS += -e ghc_debugged=$(GhcDebugged)
43
44 ifeq "$(GhcWithNativeCodeGen)" "YES"
45 RUNTEST_OPTS += -e ghc_with_native_codegen=1
46 else
47 RUNTEST_OPTS += -e ghc_with_native_codegen=0
48 endif
49
50 BASE_LIBDIR := $(shell "$(GHC_PKG)" field base library-dirs | sed 's/^[^:]*: *//')
51 HAVE_VANILLA := $(shell if [ -f '$(subst \,/,$(BASE_LIBDIR))/Prelude.hi' ]; then echo YES; else echo NO; fi)
52 HAVE_DYNAMIC := $(shell if [ -f '$(subst \,/,$(BASE_LIBDIR))/Prelude.dyn_hi' ]; then echo YES; else echo NO; fi)
53 HAVE_PROFILING := $(shell if [ -f '$(subst \,/,$(BASE_LIBDIR))/Prelude.p_hi' ]; then echo YES; else echo NO; fi)
54
55 ifeq "$(HAVE_VANILLA)" "YES"
56 RUNTEST_OPTS += -e ghc_with_vanilla=1
57 else
58 RUNTEST_OPTS += -e ghc_with_vanilla=0
59 endif
60
61 ifeq "$(HAVE_DYNAMIC)" "YES"
62 RUNTEST_OPTS += -e ghc_with_dynamic=1
63 else
64 RUNTEST_OPTS += -e ghc_with_dynamic=0
65 endif
66
67 ifeq "$(HAVE_PROFILING)" "YES"
68 RUNTEST_OPTS += -e ghc_with_profiling=1
69 else
70 RUNTEST_OPTS += -e ghc_with_profiling=0
71 endif
72
73 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
74 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
75 else
76 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
77 endif
78
79 ifeq "$(filter dyn, $(GhcRTSWays))" "dyn"
80 RUNTEST_OPTS += -e ghc_with_dynamic_rts=1
81 else
82 RUNTEST_OPTS += -e ghc_with_dynamic_rts=0
83 endif
84
85 ifeq "$(GhcWithInterpreter)" "NO"
86 RUNTEST_OPTS += -e ghc_with_interpreter=0
87 else ifeq "$(GhcStage)" "1"
88 RUNTEST_OPTS += -e ghc_with_interpreter=0
89 else
90 RUNTEST_OPTS += -e ghc_with_interpreter=1
91 endif
92
93 ifeq "$(GhcUnregisterised)" "YES"
94 RUNTEST_OPTS += -e ghc_unregisterised=1
95 else
96 RUNTEST_OPTS += -e ghc_unregisterised=0
97 endif
98
99 ifeq "$(GhcDynamicByDefault)" "YES"
100 RUNTEST_OPTS += -e ghc_dynamic_by_default=True
101 CABAL_MINIMAL_BUILD = --enable-shared --disable-library-vanilla
102 else
103 RUNTEST_OPTS += -e ghc_dynamic_by_default=False
104 CABAL_MINIMAL_BUILD = --enable-library-vanilla --disable-shared
105 endif
106
107 ifeq "$(GhcDynamic)" "YES"
108 RUNTEST_OPTS += -e ghc_dynamic=True
109 CABAL_PLUGIN_BUILD = --enable-shared --disable-library-vanilla
110 else
111 RUNTEST_OPTS += -e ghc_dynamic=False
112 CABAL_PLUGIN_BUILD = --enable-library-vanilla --disable-shared
113 endif
114
115 ifeq "$(GhcWithSMP)" "YES"
116 RUNTEST_OPTS += -e ghc_with_smp=1
117 else
118 RUNTEST_OPTS += -e ghc_with_smp=0
119 endif
120
121 ifneq "$(shell $(SHELL) -c 'llc --version | grep version' 2> /dev/null)" ""
122 RUNTEST_OPTS += -e ghc_with_llvm=1
123 else
124 RUNTEST_OPTS += -e ghc_with_llvm=0
125 endif
126
127 ifeq "$(WINDOWS)" "YES"
128 RUNTEST_OPTS += -e windows=True
129 else
130 RUNTEST_OPTS += -e windows=False
131 endif
132
133 ifeq "$(DARWIN)" "YES"
134 RUNTEST_OPTS += -e darwin=True
135 else
136 RUNTEST_OPTS += -e darwin=False
137 endif
138
139 ifeq "$(IN_TREE_COMPILER)" "YES"
140 RUNTEST_OPTS += -e in_tree_compiler=True
141 else
142 RUNTEST_OPTS += -e in_tree_compiler=False
143 endif
144
145 ifneq "$(THREADS)" ""
146 RUNTEST_OPTS += --threads=$(THREADS)
147 endif
148
149 ifneq "$(CLEAN_ONLY)" ""
150 RUNTEST_OPTS += -e clean_only=True
151 else
152 RUNTEST_OPTS += -e clean_only=False
153 endif
154
155 ifneq "$(CHECK_FILES_WRITTEN)" ""
156 RUNTEST_OPTS += --check-files-written
157 endif
158
159 RUNTEST_OPTS += \
160 --rootdir=. \
161 --config=$(CONFIG) \
162 -e 'config.confdir="$(CONFIGDIR)"' \
163 -e 'config.compiler="$(TEST_HC)"' \
164 -e 'config.ghc_pkg="$(GHC_PKG)"' \
165 -e 'config.hp2ps="$(HP2PS_ABS)"' \
166 -e 'config.hpc="$(HPC)"' \
167 -e 'config.gs="$(GS)"' \
168 -e 'config.platform="$(TARGETPLATFORM)"' \
169 -e 'config.os="$(TargetOS_CPP)"' \
170 -e 'config.arch="$(TargetARCH_CPP)"' \
171 -e 'config.wordsize="$(WORDSIZE)"' \
172 -e 'default_testopts.cleanup="$(CLEANUP)"' \
173 -e 'config.timeout=int($(TIMEOUT)) or config.timeout' \
174 -e 'config.timeout_prog="$(TIMEOUT_PROGRAM)"' \
175 -e 'config.exeext="$(exeext)"' \
176 -e 'config.top="$(TOP_ABS)"'
177
178 ifneq "$(OUTPUT_SUMMARY)" ""
179 RUNTEST_OPTS += \
180 --output-summary "$(OUTPUT_SUMMARY)"
181 endif
182
183 RUNTEST_OPTS += \
184 $(EXTRA_RUNTEST_OPTS)
185
186 ifeq "$(list_broken)" "YES"
187 set_list_broken = -e config.list_broken=True
188 else
189 set_list_broken =
190 endif
191
192 ifeq "$(fast)" "YES"
193 setfast = -e config.fast=1
194 else
195 setfast =
196 endif
197
198 ifeq "$(accept)" "YES"
199 setaccept = -e config.accept=1
200 else
201 setaccept =
202 endif
203
204 TESTS =
205 TEST =
206 WAY =
207
208 .PHONY: all boot test verbose accept fast
209
210 all: test
211
212 TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
213
214 boot: $(TIMEOUT_PROGRAM)
215
216 $(TIMEOUT_PROGRAM) :
217 @echo "Looks like you don't have timeout, building it first..."
218 $(MAKE) -C $(TOP)/timeout all
219
220 test: $(TIMEOUT_PROGRAM)
221 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
222 $(patsubst %, --only=%, $(TEST)) \
223 $(patsubst %, --only=%, $(TESTS)) \
224 $(patsubst %, --way=%, $(WAY)) \
225 $(patsubst %, --skipway=%, $(SKIPWAY)) \
226 $(set_list_broken) \
227 $(setfast) \
228 $(setaccept)
229
230 verbose: test
231
232 accept:
233 $(MAKE) accept=YES
234
235 fast:
236 $(MAKE) fast=YES
237
238 list_broken:
239 $(MAKE) list_broken=YES
240