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