testsuite: Add test for #11076
[ghc.git] / ghc / ghc.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009-2012 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
7 # To understand how the build system works and how to modify it, see
8 # http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13 ghc_USES_CABAL = YES
14 ghc_PACKAGE = ghc-bin
15 ghc_EXECUTABLE = ghc
16
17 ghc_stage1_CONFIGURE_OPTS += --flags=stage1
18 ghc_stage2_CONFIGURE_OPTS += --flags=stage2
19 ghc_stage3_CONFIGURE_OPTS += --flags=stage3
20
21 ifeq "$(GhcWithInterpreter)" "YES"
22 ghc_stage2_CONFIGURE_OPTS += --flags=ghci
23 ghc_stage3_CONFIGURE_OPTS += --flags=ghci
24 endif
25
26 # This package doesn't pass the Cabal checks because data-dir
27 # points outside the source directory. This isn't a real problem, so
28 # we just skip the check.
29 ghc_NO_CHECK = YES
30
31 ghc_stage1_MORE_HC_OPTS = $(GhcStage1HcOpts)
32 ghc_stage2_MORE_HC_OPTS = $(GhcStage2HcOpts)
33 ghc_stage3_MORE_HC_OPTS = $(GhcStage3HcOpts)
34
35 # We need __GLASGOW_HASKELL__ in hschooks.c, so we have to build C
36 # sources with GHC:
37 ghc_stage1_UseGhcForCC = YES
38 ghc_stage2_UseGhcForCC = YES
39 ghc_stage3_UseGhcForCC = YES
40
41 ghc_stage1_C_FILES_NODEPS = ghc/hschooks.c
42
43 ghc_stage2_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
44 ghc_stage3_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
45
46 ghc_stage1_MORE_HC_OPTS += -no-hs-main
47 ghc_stage2_MORE_HC_OPTS += -no-hs-main
48 ghc_stage3_MORE_HC_OPTS += -no-hs-main
49
50 ifeq "$(GhcDebugged)" "YES"
51 ghc_stage1_MORE_HC_OPTS += -debug
52 ghc_stage2_MORE_HC_OPTS += -debug
53 ghc_stage3_MORE_HC_OPTS += -debug
54 endif
55
56 ifeq "$(GhcDynamic)" "YES"
57 ghc_stage2_MORE_HC_OPTS += -dynamic
58 ghc_stage3_MORE_HC_OPTS += -dynamic
59 endif
60
61 ifeq "$(GhcThreaded)" "YES"
62 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
63 ghc_stage2_MORE_HC_OPTS += -threaded
64 ghc_stage3_MORE_HC_OPTS += -threaded
65 endif
66
67 ifeq "$(GhcProfiled)" "YES"
68 ghc_stage2_PROGRAM_WAY = p
69 endif
70
71 ghc_stage1_PROGNAME = ghc-stage1
72 ghc_stage2_PROGNAME = ghc-stage2
73 ghc_stage3_PROGNAME = ghc-stage3
74
75 ghc_stage1_SHELL_WRAPPER = YES
76 ghc_stage2_SHELL_WRAPPER = YES
77 ghc_stage3_SHELL_WRAPPER = YES
78 ghc_stage1_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
79 ghc_stage2_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
80 ghc_stage3_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
81 ghc_stage1_INSTALL_INPLACE = YES
82 ghc_stage2_INSTALL_INPLACE = YES
83 ghc_stage3_INSTALL_INPLACE = YES
84
85 ghc_stage$(INSTALL_GHC_STAGE)_INSTALL = YES
86 ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_NAME = ghc-$(ProjectVersion)
87
88 # We override the program name to be ghc, rather than ghc-stage2.
89 # This means the right program name is used in error messages etc.
90 define ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_EXTRA
91 echo 'executablename="$$exedir/ghc"' >> "$(WRAPPER)"
92 endef
93
94 # if stage is set to something other than "1" or "", disable stage 1
95 # See Note [Stage1Only vs stage=1] in mk/config.mk.in.
96 ifneq "$(filter-out 1,$(stage))" ""
97 ghc_stage1_NOT_NEEDED = YES
98 endif
99 # if stage is set to something other than "2" or "", disable stage 2
100 ifneq "$(filter-out 2,$(stage))" ""
101 ghc_stage2_NOT_NEEDED = YES
102 endif
103 # When cross-compiling, the stage 1 compiler is our release compiler, so omit stage 2
104 # See Note [Stage1Only vs stage=1] in mk/config.mk.in.
105 ifeq "$(Stage1Only)" "YES"
106 ghc_stage2_NOT_NEEDED = YES
107 endif
108 # stage 3 has to be requested explicitly with stage=3
109 ifneq "$(stage)" "3"
110 ghc_stage3_NOT_NEEDED = YES
111 endif
112 $(eval $(call build-prog,ghc,stage1,0))
113 $(eval $(call build-prog,ghc,stage2,1))
114 $(eval $(call build-prog,ghc,stage3,2))
115
116 ifneq "$(BINDIST)" "YES"
117
118 ghc/stage1/build/tmp/$(ghc_stage1_PROG) : $(BOOT_LIBS)
119 ifeq "$(GhcProfiled)" "YES"
120 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(compiler_stage2_p_LIB)
121 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_p_LIB))
122 endif
123
124 # Modules here import HsVersions.h, so we need ghc_boot_platform.h
125 $(ghc_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
126 $(ghc_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
127 $(ghc_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
128
129 all_ghc_stage1 : $(GHC_STAGE1)
130 all_ghc_stage2 : $(GHC_STAGE2)
131 all_ghc_stage3 : $(GHC_STAGE3)
132
133 $(INPLACE_LIB)/settings : settings
134 "$(CP)" $< $@
135
136 $(INPLACE_LIB)/platformConstants: $(includes_GHCCONSTANTS_HASKELL_VALUE)
137 "$(CP)" $< $@
138
139 # The GHC programs need to depend on all the helper programs they might call,
140 # and the settings files they use
141
142 GHC_DEPENDENCIES += $$(unlit_INPLACE)
143 GHC_DEPENDENCIES += $(INPLACE_LIB)/settings
144 GHC_DEPENDENCIES += $(INPLACE_LIB)/platformConstants
145
146 $(GHC_STAGE1) : | $(GHC_DEPENDENCIES)
147 $(GHC_STAGE2) : | $(GHC_DEPENDENCIES)
148 $(GHC_STAGE3) : | $(GHC_DEPENDENCIES)
149
150 ifeq "$(GhcUnregisterised)" "NO"
151 $(GHC_STAGE1) : | $$(ghc-split_INPLACE)
152 $(GHC_STAGE2) : | $$(ghc-split_INPLACE)
153 $(GHC_STAGE3) : | $$(ghc-split_INPLACE)
154 endif
155
156 ifeq "$(Windows_Host)" "YES"
157 $(GHC_STAGE1) : | $$(touchy_INPLACE)
158 $(GHC_STAGE2) : | $$(touchy_INPLACE)
159 $(GHC_STAGE3) : | $$(touchy_INPLACE)
160 endif
161
162 # Modules like vector:Data.Vector.Fusion.Stream.Monadic use annotations,
163 # which means they depend on GHC.Desugar. To ensure that This module is
164 # available by the time it is needed, we make the stage 2 compiler
165 # depend on it.
166 $(GHC_STAGE2) : $(foreach w,$(GhcLibWays),libraries/base/dist-install/build/GHC/Desugar.$($w_osuf))
167
168 endif
169
170 INSTALL_LIBS += settings
171
172 ifeq "$(Windows_Host)" "NO"
173 install: install_ghc_link
174 .PHONY: install_ghc_link
175 install_ghc_link:
176 $(call removeFiles,"$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc")
177 $(LN_S) $(CrossCompilePrefix)ghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc"
178 else
179 # On Windows we install the main binary as $(bindir)/ghc.exe
180 # To get ghc-<version>.exe we have a little C program in driver/ghc
181 install: install_ghc_post
182 .PHONY: install_ghc_post
183 install_ghc_post: install_bins
184 $(call removeFiles,"$(DESTDIR)$(bindir)/ghc.exe")
185 "$(MV)" -f $(DESTDIR)$(bindir)/ghc-stage$(INSTALL_GHC_STAGE).exe $(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc.exe
186 endif
187