Revert "Revert "Support for multiple signature files in scope.""
[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 ifneq "$(filter-out 1,$(stage))" ""
104 ghc_stage1_NOT_NEEDED = YES
105 endif
106 # if stage is set to something other than "2" or "", disable stage 2
107 ifneq "$(filter-out 2,$(stage))" ""
108 ghc_stage2_NOT_NEEDED = YES
109 endif
110 # When cross-compiling, the stage 1 compiler is our release compiler, so omit stage 2
111 ifeq "$(Stage1Only)" "YES"
112 ghc_stage2_NOT_NEEDED = YES
113 endif
114 # stage 3 has to be requested explicitly with stage=3
115 ifneq "$(stage)" "3"
116 ghc_stage3_NOT_NEEDED = YES
117 endif
118 $(eval $(call build-prog,ghc,stage1,0))
119 $(eval $(call build-prog,ghc,stage2,1))
120 $(eval $(call build-prog,ghc,stage3,2))
121
122 ifneq "$(BINDIST)" "YES"
123
124 ghc/stage1/build/tmp/$(ghc_stage1_PROG) : $(BOOT_LIBS)
125 ifeq "$(GhcProfiled)" "YES"
126 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(compiler_stage2_p_LIB)
127 ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(foreach lib,$(PACKAGES_STAGE1),$(libraries/$(lib)_dist-install_p_LIB))
128 endif
129
130 # Modules here import HsVersions.h, so we need ghc_boot_platform.h
131 $(ghc_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
132 $(ghc_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
133 $(ghc_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
134
135 all_ghc_stage1 : $(GHC_STAGE1)
136 all_ghc_stage2 : $(GHC_STAGE2)
137 all_ghc_stage3 : $(GHC_STAGE3)
138
139 $(INPLACE_LIB)/settings : settings
140 "$(CP)" $< $@
141
142 $(INPLACE_LIB)/platformConstants: $(includes_GHCCONSTANTS_HASKELL_VALUE)
143 "$(CP)" $< $@
144
145 # The GHC programs need to depend on all the helper programs they might call,
146 # and the settings files they use
147
148 GHC_DEPENDENCIES += $$(unlit_INPLACE)
149 GHC_DEPENDENCIES += $(INPLACE_LIB)/settings
150 GHC_DEPENDENCIES += $(INPLACE_LIB)/platformConstants
151
152 $(GHC_STAGE1) : | $(GHC_DEPENDENCIES)
153 $(GHC_STAGE2) : | $(GHC_DEPENDENCIES)
154 $(GHC_STAGE3) : | $(GHC_DEPENDENCIES)
155
156 ifeq "$(GhcUnregisterised)" "NO"
157 $(GHC_STAGE1) : | $$(ghc-split_INPLACE)
158 $(GHC_STAGE2) : | $$(ghc-split_INPLACE)
159 $(GHC_STAGE3) : | $$(ghc-split_INPLACE)
160 endif
161
162 ifeq "$(Windows_Host)" "YES"
163 $(GHC_STAGE1) : | $$(touchy_INPLACE)
164 $(GHC_STAGE2) : | $$(touchy_INPLACE)
165 $(GHC_STAGE3) : | $$(touchy_INPLACE)
166 endif
167
168 # Modules like vector:Data.Vector.Fusion.Stream.Monadic use annotations,
169 # which means they depend on GHC.Desugar. To ensure that This module is
170 # available by the time it is needed, we make the stage 2 compiler
171 # depend on it.
172 $(GHC_STAGE2) : $(foreach w,$(GhcLibWays),libraries/base/dist-install/build/GHC/Desugar.$($w_osuf))
173
174 endif
175
176 INSTALL_LIBS += settings
177
178 ifeq "$(Windows_Host)" "NO"
179 install: install_ghc_link
180 .PHONY: install_ghc_link
181 install_ghc_link:
182 $(call removeFiles,"$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc")
183 $(LN_S) $(CrossCompilePrefix)ghc-$(ProjectVersion) "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc"
184 else
185 # On Windows we install the main binary as $(bindir)/ghc.exe
186 # To get ghc-<version>.exe we have a little C program in driver/ghc
187 install: install_ghc_post
188 .PHONY: install_ghc_post
189 install_ghc_post: install_bins
190 $(call removeFiles,"$(DESTDIR)$(bindir)/ghc.exe")
191 "$(MV)" -f $(DESTDIR)$(bindir)/ghc-stage$(INSTALL_GHC_STAGE).exe $(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc.exe
192 endif
193