The LLVM backend now only works with 2.9+, don't try it if we have 2.7
[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-package-conf -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 ifeq "$(GhcWithNativeCodeGen)" "YES"
43 RUNTEST_OPTS += -e ghc_with_native_codegen=1
44 else
45 RUNTEST_OPTS += -e ghc_with_native_codegen=0
46 endif
47
48 HASKELL98_LIBDIR := $(shell "$(GHC_PKG)" field haskell98 library-dirs | sed 's/^[^:]*: *//')
49 HAVE_PROFILING := $(shell if [ -f $(subst \,/,$(HASKELL98_LIBDIR))/libHShaskell98-*_p.a ]; then echo YES; else echo NO; fi)
50
51 ifeq "$(HAVE_PROFILING)" "YES"
52 RUNTEST_OPTS += -e ghc_with_profiling=1
53 else
54 RUNTEST_OPTS += -e ghc_with_profiling=0
55 endif
56
57 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
58 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
59 else
60 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
61 endif
62
63 ifeq "$(filter dyn, $(GhcRTSWays))" "dyn"
64 RUNTEST_OPTS += -e ghc_with_dynamic_rts=1
65 else
66 RUNTEST_OPTS += -e ghc_with_dynamic_rts=0
67 endif
68
69 ifeq "$(GhcWithInterpreter)" "NO"
70 RUNTEST_OPTS += -e ghc_with_interpreter=0
71 else ifeq "$(GhcStage)" "1"
72 RUNTEST_OPTS += -e ghc_with_interpreter=0
73 else
74 RUNTEST_OPTS += -e ghc_with_interpreter=1
75 endif
76
77 ifeq "$(GhcUnregisterised)" "YES"
78 RUNTEST_OPTS += -e ghc_unregisterised=1
79 else
80 RUNTEST_OPTS += -e ghc_unregisterised=0
81 endif
82
83 ifeq "$(GhcWithSMP)" "YES"
84 RUNTEST_OPTS += -e ghc_with_smp=1
85 else
86 RUNTEST_OPTS += -e ghc_with_smp=0
87 endif
88
89 LLVM_VERSION = $(shell $(SHELL) -c "llvmc --version | grep version | sed 's/^.*version \([0-9]*\)\.\([0-9]*\).*$$/\1\.\2/'" 2> /dev/null)
90
91 ifneq "$(LLVM_VERSION)" ""
92 ifneq "$(LLVM_VERSION)" "2.7"
93 RUNTEST_OPTS += -e ghc_with_llvm=1
94 else
95 RUNTEST_OPTS += -e ghc_with_llvm=0
96 endif
97 else
98 RUNTEST_OPTS += -e ghc_with_llvm=0
99 endif
100
101 ifeq "$(WINDOWS)" "YES"
102 RUNTEST_OPTS += -e windows=True
103 else
104 RUNTEST_OPTS += -e windows=False
105 endif
106
107 ifeq "$(DARWIN)" "YES"
108 RUNTEST_OPTS += -e darwin=True
109 else
110 RUNTEST_OPTS += -e darwin=False
111 endif
112
113 ifeq "$(IN_TREE_COMPILER)" "YES"
114 RUNTEST_OPTS += -e in_tree_compiler=True
115 else
116 RUNTEST_OPTS += -e in_tree_compiler=False
117 endif
118
119 ifneq "$(THREADS)" ""
120 RUNTEST_OPTS += --threads=$(THREADS)
121 endif
122
123 ifneq "$(CLEAN_ONLY)" ""
124 RUNTEST_OPTS += -e clean_only=True
125 else
126 RUNTEST_OPTS += -e clean_only=False
127 endif
128
129 ifneq "$(CHECK_FILES_WRITTEN)" ""
130 RUNTEST_OPTS += --check-files-written
131 endif
132
133 RUNTEST_OPTS += \
134 --rootdir=. \
135 --config=$(CONFIG) \
136 -e 'config.confdir="$(CONFIGDIR)"' \
137 -e 'config.compiler="$(TEST_HC)"' \
138 -e 'config.compiler_always_flags.append("$(EXTRA_HC_OPTS)")' \
139 -e 'config.ghc_pkg="$(GHC_PKG)"' \
140 -e 'config.hp2ps="$(HP2PS_ABS)"' \
141 -e 'config.hpc="$(HPC)"' \
142 -e 'config.gs="$(GS)"' \
143 -e 'config.platform="$(TARGETPLATFORM)"' \
144 -e 'config.os="$(TargetOS_CPP)"' \
145 -e 'config.arch="$(TargetARCH_CPP)"' \
146 -e 'config.wordsize="$(WORDSIZE)"' \
147 -e 'default_testopts.cleanup="$(CLEANUP)"' \
148 -e 'config.timeout=int($(TIMEOUT)) or config.timeout' \
149 -e 'config.timeout_prog="$(TIMEOUT_PROGRAM)"' \
150 -e 'config.exeext="$(exeext)"' \
151 -e 'config.top="$(TOP_ABS)"'
152
153 ifneq "$(OUTPUT_SUMMARY)" ""
154 RUNTEST_OPTS += \
155 --output-summary "$(OUTPUT_SUMMARY)"
156 endif
157
158 RUNTEST_OPTS += \
159 $(EXTRA_RUNTEST_OPTS)
160
161 ifeq "$(fast)" "YES"
162 setfast = -e config.fast=1
163 else
164 setfast =
165 endif
166
167 ifeq "$(accept)" "YES"
168 setaccept = -e config.accept=1
169 else
170 setaccept =
171 endif
172
173 TESTS =
174 TEST =
175 WAY =
176
177 .PHONY: all boot test verbose accept fast
178
179 all: test
180
181 TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
182
183 boot: $(TIMEOUT_PROGRAM)
184
185 $(TIMEOUT_PROGRAM) :
186 @echo "Looks like you don't have timeout, building it first..."
187 $(MAKE) -C $(TOP)/timeout all
188
189 test: $(TIMEOUT_PROGRAM)
190 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
191 $(patsubst %, --only=%, $(TEST)) \
192 $(patsubst %, --only=%, $(TESTS)) \
193 $(patsubst %, --way=%, $(WAY)) \
194 $(patsubst %, --skipway=%, $(SKIPWAY)) \
195 $(setfast) \
196 $(setaccept)
197
198 verbose: test
199
200 accept:
201 $(MAKE) accept=YES
202
203 fast:
204 $(MAKE) fast=YES
205