summaryrefslogtreecommitdiff
path: root/testsuite/timeout/Makefile
blob: 9626eaea19c197271d9dc429d71578fea83084d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
TOP = ..

# If we're cleaning then we don't want to do all the GHC detection hardwork,
# and we certainly don't want to fail if GHC etc can't be found!
# However, we can't just put this conditional in boilerplate.mk, as
# some of the tests have a "clean" makefile target that relies on GHC_PKG
# being defined.
ifneq "$(MAKECMDGOALS)" "clean"
ifneq "$(MAKECMDGOALS)" "distclean"
ifneq "$(MAKECMDGOALS)" "maintainer-clean"

include $(TOP)/mk/boilerplate.mk

TIMEOUT_PROGRAM = install-inplace/bin/timeout$(exeext)

PREFIX := $(abspath install-inplace)
$(eval $(call canonicalise,PREFIX))

ifneq "$(GCC)" ""
WITH_GCC = --with-gcc='$(GCC)'
endif

ifeq "$(WINDOWS)" "NO"
# Use a python timeout program, so that we don't have to worry about
# whether or not the compiler we're testing has built the timeout
# program correctly
$(TIMEOUT_PROGRAM): timeout.py
	rm -rf install-inplace
	mkdir install-inplace
	mkdir install-inplace/bin
	cp $< $@.py
	echo '#!/bin/sh' > $@
	echo 'exec "${PYTHON}" $$0.py "$$@"' >> $@
	chmod +x $@
else
# The python timeout program doesn't work on mingw, so we still use the
# Haskell program on Windows
$(TIMEOUT_PROGRAM): timeout.hs
	rm -rf install-inplace
	'$(TEST_HC)' --make Setup
	./Setup configure --with-compiler='$(TEST_HC)' \
	                  --with-hc-pkg='$(GHC_PKG)' \
	                  --with-hsc2hs='$(HSC2HS)' \
	                  $(WITH_GCC) \
	                  --ghc-option=-threaded --prefix='$(PREFIX)'
	./Setup build
	./Setup install
endif

boot all :: calibrate.out $(TIMEOUT_PROGRAM)

calibrate.out:
	$(RM) -f TimeMe.o TimeMe.hi TimeMe TimeMe.exe
	$(PYTHON) calibrate '$(STAGE1_GHC)' > $@
# We use stage 1 to do the calibration, as stage 2 may not exist.
# This isn't necessarily the compiler we'll be running the testsuite
# with, but it's really the performance of the machine that we're
# interested in

endif
endif
endif

clean distclean maintainer-clean:
	test ! -f Setup || ./Setup clean
	$(RM) -rf install-inplace
	$(RM) -f calibrate.out
	$(RM) -f Setup Setup.exe Setup.hi Setup.o