Quoting fix
[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 RUNTEST_OPTS =
29
30 $(eval $(call get-ghc-rts-field,WORDSIZE,Word size))
31 $(eval $(call get-ghc-rts-field,TARGETPLATFORM,Target platform))
32 $(eval $(call get-ghc-rts-field,TargetOS_CPP,Target OS))
33 ifeq "$(filter $(TargetOS_CPP), cygwin32 mingw32)" ""
34 exeext =
35 else
36 exeext = .exe
37 endif
38
39 $(eval $(call get-ghc-feature-bool,GhcWithNativeCodeGen,Have native code generator))
40 ifeq "$(GhcWithNativeCodeGen)" "YES"
41 RUNTEST_OPTS += -e ghc_with_native_codegen=1
42 else
43 RUNTEST_OPTS += -e ghc_with_native_codegen=0
44 endif
45
46 HAVE_PROFILING:=$(if $(wildcard $(shell "$(GHC_PKG)" field haskell98 library-dirs | sed 's/^[^:]*: *//')/libHShaskell98-*_p.a),YES,NO)
47
48 ifeq "$(HAVE_PROFILING)" "YES"
49 RUNTEST_OPTS += -e ghc_with_profiling=1
50 else
51 RUNTEST_OPTS += -e ghc_with_profiling=0
52 endif
53
54 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
55 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
56 else
57 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
58 endif
59
60 ifeq "$(filter dyn, $(GhcRTSWays))" "dyn"
61 RUNTEST_OPTS += -e ghc_with_dynamic_rts=1
62 else
63 RUNTEST_OPTS += -e ghc_with_dynamic_rts=0
64 endif
65
66 $(eval $(call get-ghc-feature-bool,GhcWithInterpreter,Have interpreter))
67 ifeq "$(GhcWithInterpreter)" "YES"
68 RUNTEST_OPTS += -e ghc_with_interpreter=1
69 else
70 RUNTEST_OPTS += -e ghc_with_interpreter=0
71 endif
72
73 $(eval $(call get-ghc-feature-bool,GhcUnregisterised,Unregisterised))
74 ifeq "$(GhcUnregisterised)" "YES"
75 RUNTEST_OPTS += -e ghc_unregisterised=1
76 else
77 RUNTEST_OPTS += -e ghc_unregisterised=0
78 endif
79
80 $(eval $(call get-ghc-feature-bool,GhcWithSMP,Support SMP))
81 ifeq "$(GhcWithSMP)" "YES"
82 RUNTEST_OPTS += -e ghc_with_smp=1
83 else
84 RUNTEST_OPTS += -e ghc_with_smp=0
85 endif
86
87 ifneq "$(THREADS)" ""
88 RUNTEST_OPTS += --threads=$(THREADS)
89 endif
90
91 RUNTEST_OPTS += \
92 --rootdir=. \
93 --config=$(CONFIG) \
94 -e 'config.confdir="$(CONFIGDIR)"' \
95 -e 'config.compiler="$(TEST_HC)"' \
96 -e 'config.compiler_always_flags.append("$(EXTRA_HC_OPTS)")' \
97 -e 'config.ghc_pkg="$(GHC_PKG)"' \
98 -e 'config.hp2ps="$(HP2PS_ABS)"' \
99 -e 'config.hpc="$(HPC)"' \
100 -e 'config.gs="$(GS)"' \
101 -e 'config.platform="$(TARGETPLATFORM)"' \
102 -e 'config.os="$(TargetOS_CPP)"' \
103 -e 'config.wordsize="$(WORDSIZE)"' \
104 -e 'default_testopts.cleanup="$(CLEANUP)"' \
105 -e 'config.timeout=int($(TIMEOUT)) or config.timeout' \
106 -e 'config.timeout_prog="$(TIMEOUT_PROGRAM)"' \
107 -e 'config.exeext="$(exeext)"' \
108 -e 'config.top="$(TOP_ABS)"' \
109 $(EXTRA_RUNTEST_OPTS)
110
111 ifeq "$(fast)" "YES"
112 setfast = -e config.fast=1
113 else
114 setfast =
115 endif
116
117 ifeq "$(accept)" "YES"
118 setaccept = -e config.accept=1
119 else
120 setaccept =
121 endif
122
123 TESTS =
124 TEST =
125 WAY =
126
127 .PHONY: all boot test verbose accept fast
128
129 all: test
130
131 TIMEOUT_PROGRAM = $(TOP)/timeout/install-inplace/bin/timeout$(exeext)
132
133 boot: $(TIMEOUT_PROGRAM)
134
135 $(TIMEOUT_PROGRAM) :
136 @echo "Looks like you don't have timeout, building it first..."
137 $(MAKE) -C $(TOP)/timeout all
138
139 test: $(TIMEOUT_PROGRAM)
140 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
141 $(patsubst %, --only=%, $(TEST)) \
142 $(patsubst %, --only=%, $(TESTS)) \
143 $(patsubst %, --way=%, $(WAY)) \
144 $(patsubst %, --skipway=%, $(SKIPWAY)) \
145 $(setfast) \
146 $(setaccept)
147
148 verbose: test
149
150 accept:
151 $(MAKE) accept=YES
152
153 fast:
154 $(MAKE) fast=YES
155