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