Refactor kcHsTyVarBndrs
[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 ifneq "$(GhcDynamic)" ""
57 $(error GhcDynamic is no longer supported, use DYNAMIC_GHC_PROGRAMS instead)
58 endif
59
60 ifeq "$(GhcThreaded)" "YES"
61 # Use threaded RTS with GHCi, so threads don't get blocked at the prompt.
62 ghc_stage2_MORE_HC_OPTS += -threaded
63 ghc_stage3_MORE_HC_OPTS += -threaded
64 endif
65
66 ifeq "$(GhcProfiled)" "YES"
67 ghc_stage2_PROGRAM_WAY = p
68 endif
69
70 ghc_stage1_PROGNAME = ghc-stage1
71 ghc_stage2_PROGNAME = ghc-stage2
72 ghc_stage3_PROGNAME = ghc-stage3
73
74 ghc_stage1_SHELL_WRAPPER = YES
75 ghc_stage2_SHELL_WRAPPER = YES
76 ghc_stage3_SHELL_WRAPPER = YES
77 ghc_stage1_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
78 ghc_stage2_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
79 ghc_stage3_SHELL_WRAPPER_NAME = ghc/ghc.wrapper
80 ghc_stage1_INSTALL_INPLACE = YES
81 ghc_stage2_INSTALL_INPLACE = YES
82 ghc_stage3_INSTALL_INPLACE = YES
83
84 ghc_stage$(INSTALL_GHC_STAGE)_INSTALL = YES
85 ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_NAME = ghc-$(ProjectVersion)
86
87 # We override the program name to be ghc, rather than ghc-stage2.
88 # This means the right program name is used in error messages etc.
89 define ghc_stage$(INSTALL_GHC_STAGE)_INSTALL_SHELL_WRAPPER_EXTRA
90 echo 'executablename="$$exedir/ghc"' >> "$(WRAPPER)"
91 endef
92
93 # if stage is set to something other than "1" or "", disable stage 1
94 # See Note [Stage1Only vs stage=1] in mk/config.mk.in.
95 ifneq "$(filter-out 1,$(stage))" ""
96 ghc_stage1_NOT_NEEDED = YES
97 endif
98 # if stage is set to something other than "2" or "", disable stage 2
99 ifneq "$(filter-out 2,$(stage))" ""
100 ghc_stage2_NOT_NEEDED = YES
101 endif
102 # When cross-compiling, the stage 1 compiler is our release compiler, so omit stage 2
103 # See Note [Stage1Only vs stage=1] in mk/config.mk.in.
104 ifeq "$(Stage1Only)" "YES"
105 ghc_stage2_NOT_NEEDED = YES
106 endif
107 # stage 3 has to be requested explicitly with stage=3
108 ifneq "$(stage)" "3"
109 ghc_stage3_NOT_NEEDED = YES
110 endif
111 $(eval $(call build-prog,ghc,stage1,0))
112 $(eval $(call build-prog,ghc,stage2,1))
113 $(eval $(call build-prog,ghc,stage3,2))
114
115 ifneq "$(BINDIST)" "YES"
116
117 ghc/stage1/build/tmp/$(ghc_stage1_PROG) : $(BOOT_LIBS)
118 ifeq "$(GhcProfiled)" "YES"
119 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(compiler_stage2_p_LIB)
120 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_p_LIB))
121 endif
122
123 # Modules here import HsVersions.h, so we need ghc_boot_platform.h
124 $(ghc_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
125 $(ghc_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
126 $(ghc_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
127
128 all_ghc_stage1 : $(GHC_STAGE1)
129 all_ghc_stage2 : $(GHC_STAGE2)
130 all_ghc_stage3 : $(GHC_STAGE3)
131
132 $(INPLACE_LIB)/settings : settings
133 "$(CP)" $< $@
134
135 $(INPLACE_LIB)/llvm-targets : llvm-targets
136 "$(CP)" $< $@
137
138 $(INPLACE_LIB)/platformConstants: $(includes_GHCCONSTANTS_HASKELL_VALUE)
139 "$(CP)" $< $@
140
141 # The GHC programs need to depend on all the helper programs they might call,
142 # and the settings files they use
143
144 GHC_DEPENDENCIES += $$(unlit_INPLACE)
145 GHC_DEPENDENCIES += $(INPLACE_LIB)/settings
146 GHC_DEPENDENCIES += $(INPLACE_LIB)/llvm-targets
147 GHC_DEPENDENCIES += $(INPLACE_LIB)/platformConstants
148
149 $(GHC_STAGE1) : | $(GHC_DEPENDENCIES)
150 $(GHC_STAGE2) : | $(GHC_DEPENDENCIES)
151 $(GHC_STAGE3) : | $(GHC_DEPENDENCIES)
152
153 ifeq "$(GhcUnregisterised)" "NO"
154 $(GHC_STAGE1) : | $$(ghc-split_INPLACE)
155 $(GHC_STAGE2) : | $$(ghc-split_INPLACE)
156 $(GHC_STAGE3) : | $$(ghc-split_INPLACE)
157 endif
158
159 ifeq "$(Windows_Host)" "YES"
160 $(GHC_STAGE1) : | $$(touchy_INPLACE)
161 $(GHC_STAGE2) : | $$(touchy_INPLACE)
162 $(GHC_STAGE3) : | $$(touchy_INPLACE)
163 endif
164
165 # Modules like vector:Data.Vector.Fusion.Stream.Monadic use annotations,
166 # which means they depend on GHC.Desugar. To ensure that This module is
167 # available by the time it is needed, we make the stage 2 compiler
168 # depend on it.
169 $(GHC_STAGE2) : $(foreach w,$(GhcLibWays),libraries/base/dist-install/build/GHC/Desugar.$($w_osuf))
170
171 endif
172
173 INSTALL_LIBS += settings
174 INSTALL_LIBS += llvm-targets
175
176 ifeq "$(Windows_Host)" "NO"
177 install: install_ghc_link
178 .PHONY: install_ghc_link
179 install_ghc_link:
180 $(call removeFiles,"$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc")
181 $(LN_S) $(CrossCompilePrefix)ghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc"
182 else
183 # On Windows we install the main binary as $(bindir)/ghc.exe
184 # To get ghc-<version>.exe we have a little C program in driver/ghc
185 install: install_ghc_post
186 .PHONY: install_ghc_post
187 install_ghc_post: install_bins
188 $(call removeFiles,"$(DESTDIR)$(bindir)/ghc.exe")
189 "$(MV)" -f $(DESTDIR)$(bindir)/ghc-stage$(INSTALL_GHC_STAGE).exe $(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc.exe
190 endif
191