no .bat scripts any more
[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 include $(TOP)/mk/wordsize.mk
21
22 $(TOP)/mk/wordsize.mk : $(TOP)/mk/wordsize.mk.in
23 $(CPP) $(RAWCPP_FLAGS) -x c $(TOP)/mk/wordsize.mk.in > $(TOP)/mk/wordsize.mk
24
25 ifeq "$(PYTHON)" ""
26 $(error Python must be installed in order to use the testsuite)
27 endif
28
29 # export the value of $MAKE for invocation in ghc-regress/driver/
30 export MAKE
31
32 # ghastly hack, because the driver requires that $tool be an absolute path name.
33 GHC_STAGE1_ABS = $(GHC_COMPILER_DIR_ABS)/stage1/ghc-inplace
34 GHC_STAGE2_ABS = $(GHC_COMPILER_DIR_ABS)/stage2/ghc-inplace
35 GHC_STAGE3_ABS = $(GHC_COMPILER_DIR_ABS)/stage3/ghc-inplace
36 GHC_PKG_ABS = $(GHC_PKG_DIR_ABS)/ghc-pkg-inplace
37 HP2PS_ABS = $(GHC_HP2PS_DIR_ABS)/hp2ps
38 GS = gs
39
40 RUNTESTS = $(TOP)/driver/runtests.py
41 COMPILER = ghc
42 CONFIGDIR = $(TOP)/config
43 CONFIG = $(CONFIGDIR)/$(COMPILER)
44
45 # can be overriden from the command line
46 ifneq "$(stage)" ""
47 TEST_HC = $(GHC_STAGE$(stage)_ABS)
48 else
49 TEST_HC = $(GHC_STAGE1_ABS)
50 endif
51
52 GHC_PKG = $(GHC_PKG_ABS)
53
54 RUNTEST_OPTS =
55
56 ifeq "$(GhcWithNativeCodeGen)" "YES"
57 RUNTEST_OPTS += -e ghc_with_native_codegen=1
58 else
59 RUNTEST_OPTS += -e ghc_with_native_codegen=0
60 endif
61
62 ifeq "$(filter p, $(GhcLibWays))" "p"
63 RUNTEST_OPTS += -e ghc_with_profiling=1
64 else
65 RUNTEST_OPTS += -e ghc_with_profiling=0
66 endif
67
68 ifeq "$(GhcWithInterpreter)" "YES"
69 RUNTEST_OPTS += -e ghc_with_interpreter=1
70 else
71 RUNTEST_OPTS += -e ghc_with_interpreter=0
72 endif
73
74 ifeq "$(filter thr, $(GhcRTSWays))" "thr"
75 RUNTEST_OPTS += -e ghc_with_threaded_rts=1
76 else
77 RUNTEST_OPTS += -e ghc_with_threaded_rts=0
78 endif
79
80 ifeq "$(GhcWithSMP)" "YES"
81 RUNTEST_OPTS += -e ghc_with_smp=1
82 else
83 RUNTEST_OPTS += -e ghc_with_smp=0
84 endif
85
86 ifneq "$(THREADS)" ""
87 RUNTEST_OPTS += --thread=$(THREADS)
88 else
89 USETHREADS=0
90 endif
91
92 RUNTEST_OPTS += \
93 --rootdir=. \
94 --config=$(CONFIG) \
95 -e config.confdir=\"$(CONFIGDIR)\" \
96 -e config.compiler=\"$(TEST_HC)\" \
97 -e config.compiler_always_flags.append"(\"-D$(HostPlatform_CPP)\")" \
98 -e config.compiler_always_flags.append"(\"$(EXTRA_HC_OPTS)\")" \
99 -e config.ghc_pkg=\"$(GHC_PKG)\" \
100 -e config.hp2ps=\"$(HP2PS_ABS)\" \
101 -e config.gs=\"$(GS)\" \
102 -e config.platform=\"$(TARGETPLATFORM)\" \
103 -e config.wordsize=\"$(WORDSIZE)\" \
104 -e default_testopts.cleanup=\"$(CLEANUP)\" \
105 -e "if '$(USETHREADS)': config.use_threads=int($(USETHREADS))" \
106 -e config.timeout="int($(TIMEOUT)) or config.timeout" \
107 -e config.timeout_prog=\"$(TOP)/timeout/timeout\" \
108 -e config.top=\"$(TOP)\" \
109 $(EXTRA_RUNTEST_OPTS)
110
111 # HostPlatform_CPP should ideally be TargetPlatform_CPP, but that
112 # doesn't exist; they're always the same anyway
113
114 ifeq "$(fast)" "YES"
115 setfast = -e config.fast=1
116 else
117 setfast =
118 endif
119
120 ifeq "$(accept)" "YES"
121 setaccept = -e config.accept=1
122 else
123 setaccept =
124 endif
125
126 TESTS =
127 TEST =
128 WAY =
129
130 all :: test
131
132 timeout : $(TOP)/timeout/timeout$(exeext)
133
134 $(TOP)/timeout/timeout$(exeext) :
135 @echo "Looks like you don't have timeout, building it first..."
136 cd $(TOP)/timeout && $(MAKE) $(MFLAGS) all
137
138 test: timeout
139 $(PYTHON) $(RUNTESTS) $(RUNTEST_OPTS) \
140 $(patsubst %, --only=%, $(TEST)) \
141 $(patsubst %, --only=%, $(TESTS)) \
142 $(patsubst %, --way=%, $(WAY)) \
143 $(patsubst %, --skipway=%, $(SKIPWAY)) \
144 $(setfast) \
145 $(setaccept)
146
147 verbose: test
148
149 accept:
150 $(MAKE) accept=YES
151
152 fast:
153 $(MAKE) fast=YES MAKEFLAGS=
154