Don't use -package array everywhere
[nofib.git] / mk / boilerplate.mk
1 #################################################################################
2 #
3 # nofib/mk/boilerplate.mk
4 #
5 # Boilerplate Makefile for an fptools project
6 #
7 #################################################################################
8
9 # Begin by slurping in the boilerplate from one level up,
10 # with standard TOP-mangling
11 # Remember, TOP is the top level of the innermost level
12
13 default : all
14
15 show:
16 @echo '$(VALUE)="$($(VALUE))"'
17
18 RM = rm -f
19 SIZE = size
20 STRIP = strip
21 PERL = /usr/bin/perl
22 CONTEXT_DIFF = diff -U 1
23 DEFAULT_TMPDIR = /tmp
24 EXECUTABLE_FILE = chmod +x
25
26 # Benchmarks controls which set of tests should be run
27 # You can run one or more of
28 # imaginary
29 # spectral
30 # real
31 # parallel
32 # gc
33 # smp
34 # fibon
35 NoFibSubDirs = imaginary spectral real shootout
36
37 # Haskell compiler options for nofib
38 NoFibHcOpts = -O2
39
40 # Number of times to run each program
41 NoFibRuns = 5
42
43 # -----------------------------------------------------------------
44 # Everything after this point
45 # augments or overrides previously set variables.
46 # (these files are optional, so `make' won't fret if it
47 # cannot get to them).
48 # -----------------------------------------------------------------
49
50 SRC_HC_OPTS += $(NoFibHcOpts) -Rghc-timing
51
52 ifeq "$(WithNofibHc)" ""
53
54 STAGE1_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage1)
55 STAGE2_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage2)
56 STAGE3_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage3)
57
58 ifneq "$(wildcard $(STAGE1_GHC) $(STAGE1_GHC).exe)" ""
59
60 ifeq "$(BINDIST)" "YES"
61 HC := $(abspath $(TOP)/../)/bindisttest/install dir/bin/ghc
62 else ifeq "$(stage)" "1"
63 HC := $(STAGE1_GHC)
64 else ifeq "$(stage)" "3"
65 HC := $(STAGE3_GHC)
66 else
67 # use stage2 by default
68 HC := $(STAGE2_GHC)
69 endif
70
71 else
72 HC := $(shell which ghc)
73 endif
74
75 else
76
77 # We want to support both "ghc" and "/usr/bin/ghc" as values of WithNofibHc
78 # passed in by the user, but
79 # which ghc == /usr/bin/ghc
80 # which /usr/bin/ghc == /usr/bin/ghc
81 # so on unix-like platforms we can just always 'which' it.
82 # However, on cygwin, we can't just use which:
83 # $ which c:/ghc/ghc-7.4.1/bin/ghc.exe
84 # which: no ghc.exe in (./c:/ghc/ghc-7.4.1/bin)
85 # so we start off by using realpath, and if that succeeds then we use
86 # that value. Otherwise we fall back on 'which'.
87 HC_REALPATH := $(realpath $(WithNofibHc))
88 ifeq "$(HC_REALPATH)" ""
89 HC := $(shell which '$(WithNofibHc)')
90 else
91 HC := $(HC_REALPATH)
92 endif
93
94 endif
95
96 MKDEPENDHS := $(HC) # ToDo: wrong, if $(HC) isn't GHC.
97 BOOT_HC := $(HC)
98
99 define get-ghc-rts-field # $1 = result variable, $2 = field name
100 $1 := $$(shell '$$(HC)' +RTS --info | grep '^ .("$2",' | tr -d '\r' | sed -e 's/.*", *"//' -e 's/")$$$$//')
101 endef
102
103 define get-ghc-field # $1 = result variable, $2 = field name
104 $1 := $$(shell '$$(HC)' --info | grep '^ .("$2",' | tr -d '\r' | sed -e 's/.*", *"//' -e 's/")$$$$//')
105 endef
106
107 $(eval $(call get-ghc-rts-field,HC_VERSION,GHC version))
108 $(eval $(call get-ghc-field,SplitObjs,Object splitting supported))
109 $(eval $(call get-ghc-field,CC,C compiler command))
110
111 define ghc-ge # $1 = major version, $2 = minor version
112 HC_VERSION_GE_$1_$2 := $$(shell if [ `echo $$(HC_VERSION) | sed 's/\..*//'` -gt $1 ]; then echo YES; else if [ `echo $$(HC_VERSION) | sed 's/\..*//'` -ge $1 ] && [ `echo $$(HC_VERSION) | sed -e 's/[^.]*\.//' -e 's/\..*//'` -ge $2 ]; then echo YES; else echo NO; fi; fi)
113 endef
114
115 $(eval $(call ghc-ge,6,13))
116
117 RUNTEST = $(TOP)/runstdtest/runstdtest
118
119 include $(TOP)/mk/ghc-paths.mk
120 include $(TOP)/mk/ghc-opts.mk
121 include $(TOP)/mk/paths.mk
122 include $(TOP)/mk/opts.mk
123
124 -include .depend