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