ghc-dup: 56b028458393662b6ac45e489fb1051c0a7c739b
1:
2: default: all
3:
4: HAVE_EVAL := NO
5: $(eval HAVE_EVAL := YES)
6:
7: ifeq "$(HAVE_EVAL)" "NO"
8: $(error Your make does not support eval. You need GNU make >= 3.81)
9: endif
10:
11: ifeq "$(abspath /)" ""
12: $(error Your make does not support abspath. You need GNU make >= 3.81)
13: endif
14:
15: show:
16: @echo '$(VALUE)="$($(VALUE))"'
17:
18: define canonicalise
19: # $1 = path variable
20: $1_CYGPATH := $$(shell $(SHELL) -c "cygpath -m '$$($1)'" 2> /dev/null)
21: ifneq "$$($1_CYGPATH)" ""
22: # We use 'override' in case we are trying to update a value given on
23: # the commandline (e.g. TEST_HC)
24: override $1 := $$($1_CYGPATH)
25: endif
26: endef
27:
28: define canonicaliseExecutable
29: # $1 = program path variable
30: ifneq "$$(shell test -x '$$($1).exe' && echo exists)" ""
31: # We use 'override' in case we are trying to update a value given on
32: # the commandline (e.g. TEST_HC)
33: override $1 := $$($1).exe
34: endif
35: $(call canonicalise,$1)
36: endef
37:
38: ifeq "$(TEST_HC)" ""
39:
40: STAGE1_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage1)
41: STAGE2_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage2)
42: STAGE3_GHC := $(abspath $(TOP)/../inplace/bin/ghc-stage3)
43:
44: ifneq "$(wildcard $(STAGE1_GHC) $(STAGE1_GHC).exe)" ""
45:
46: IN_TREE_COMPILER = YES
47: ifeq "$(BINDIST)" "YES"
48: TEST_HC := $(abspath $(TOP)/../)/bindisttest/install dir/bin/ghc
49: else ifeq "$(stage)" "1"
50: TEST_HC := $(STAGE1_GHC)
51: else ifeq "$(stage)" "3"
52: TEST_HC := $(STAGE3_GHC)
53: else
54: # use stage2 by default
55: TEST_HC := $(STAGE2_GHC)
56: endif
57:
58: else
59: IN_TREE_COMPILER = NO
60: TEST_HC := $(shell which ghc)
61: endif
62:
63: else
64: IN_TREE_COMPILER = NO
65: # We want to support both "ghc" and "/usr/bin/ghc" as values of TEST_HC
66: # passed in by the user, but
67: # which ghc == /usr/bin/ghc
68: # which /usr/bin/ghc == /usr/bin/ghc
69: # so we can just always 'which' it. We need to use 'override' in order
70: # to override a value given on the commandline.
71: override TEST_HC := $(shell which '$(TEST_HC)')
72: endif
73:
74: # We can't use $(dir ...) here as TEST_HC might be in a path
75: # containing spaces
76: BIN_ROOT = $(shell dirname '$(TEST_HC)')
77:
78: ifeq "$(GHC_PKG)" ""
79: GHC_PKG := $(BIN_ROOT)/ghc-pkg
80: endif
81:
82: ifeq "$(HSC2HS)" ""
83: HSC2HS := $(BIN_ROOT)/hsc2hs
84: endif
85:
86: ifeq "$(HP2PS_ABS)" ""
87: HP2PS_ABS := $(BIN_ROOT)/hp2ps
88: endif
89:
90: ifeq "$(HPC)" ""
91: HPC := $(BIN_ROOT)/hpc
92: endif
93:
94: $(eval $(call canonicaliseExecutable,TEST_HC))
95: ifeq "$(shell test -x '$(TEST_HC)' && echo exists)" ""
96: $(error Cannot find ghc: $(TEST_HC))
97: endif
98:
99: $(eval $(call canonicaliseExecutable,GHC_PKG))
100: ifeq "$(shell test -x '$(GHC_PKG)' && echo exists)" ""
101: $(error Cannot find ghc-pkg: $(GHC_PKG))
102: endif
103:
104: $(eval $(call canonicaliseExecutable,HSC2HS))
105: ifeq "$(shell test -x '$(HSC2HS)' && echo exists)" ""
106: $(error Cannot find hsc2hs: $(HSC2HS))
107: endif
108:
109: $(eval $(call canonicaliseExecutable,HP2PS_ABS))
110: ifeq "$(shell test -x '$(HP2PS_ABS)' && echo exists)" ""
111: $(error Cannot find hp2ps: $(HP2PS_ABS))
112: endif
113:
114: $(eval $(call canonicaliseExecutable,HPC))
115: ifeq "$(shell test -x '$(HPC)' && echo exists)" ""
116: $(error Cannot find hpc: $(HPC))
117: endif
118:
119: # Be careful when using this. On Windows it ends up looking like
120: # c:/foo/bar which confuses make, as make thinks that the : is Makefile
121: # syntax
122: TOP_ABS := $(abspath $(TOP))
123: $(eval $(call canonicalise,TOP_ABS))
124:
125: GS = gs
126: CP = cp
127: RM = rm -f
128: PYTHON = python
129:
130: # -----------------------------------------------------------------------------
131: # configuration of TEST_HC
132:
133: # ghc-config.hs is a short Haskell program that runs ghc --info, parses
134: # the results, and emits a little .mk file with make bindings for the values.
135: # This way we cache the results for different values of $(TEST_HC)
136:
137: $(TOP)/mk/ghc-config : $(TOP)/mk/ghc-config.hs
138: "$(TEST_HC)" --make -o $@ $<
139:
140: empty=
141: space=$(empty) $(empty)
142: ghc-config-mk = $(TOP)/mk/ghcconfig$(subst $(space),_,$(subst :,_,$(subst /,_,$(subst \,_,$(TEST_HC))))).mk
143:
144: $(ghc-config-mk) : $(TOP)/mk/ghc-config
145: $(TOP)/mk/ghc-config "$(TEST_HC)" >"$@"; if [ $$? != 0 ]; then $(RM) "$@"; exit 1; fi
146: # If the ghc-config fails, remove $@, and fail
147:
148: ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
149: include $(ghc-config-mk)
150: endif
151:
152: # -----------------------------------------------------------------------------
153:
154: ifeq "$(HostOS)" "mingw32"
155: WINDOWS = YES
156: else
157: WINDOWS = NO
158: endif
159: ifeq "$(HostOS)" "darwin"
160: DARWIN = YES
161: else
162: DARWIN = NO
163: endif
164:
Generated by git2html.