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