Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 514 lines (448 sloc) 24.785 kb
34cc75e @igfoo GHC new build system megapatch
igfoo authored
1 # -----------------------------------------------------------------------------
c59c053 @simonmar Add a header to all build system files:
simonmar authored
2 #
3 # (c) 2009 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 # -----------------------------------------------------------------------------
34cc75e @igfoo GHC new build system megapatch
igfoo authored
14 # For expressing extra dependencies on source files
15
16 define compiler-hs-dependency # args: $1 = module, $2 = dependency
17
18 $$(foreach stage,1 2 3,\
19 $$(foreach way,$$(compiler_stage$$(stage)_WAYS),\
2675f2b @igfoo Fix the compiler-hs-dependency's
igfoo authored
20 compiler/stage$$(stage)/build/$1.$$($$(way)_osuf))) : $2
34cc75e @igfoo GHC new build system megapatch
igfoo authored
21
22 endef
23
24 # -----------------------------------------------------------------------------
25 # Create compiler configuration
26 #
27 # The 'echo' commands simply spit the values of various make variables
28 # into Config.hs, whence they can be compiled and used by GHC itself
29
30 compiler_CONFIG_HS = compiler/main/Config.hs
31
aea784a @igfoo Eliminate mkdependC
igfoo authored
32 # This is just to avoid generating a warning when generating deps
33 # involving RtsFlags.h
34 compiler_stage1_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
35 compiler_stage2_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
36 compiler_stage3_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
37
3a60f71 @igfoo Don't make C deps for compiler/parser/cutils.c in stage1
igfoo authored
38 compiler_stage1_C_FILES_NODEPS = compiler/parser/cutils.c
39
34cc75e @igfoo GHC new build system megapatch
igfoo authored
40 ifneq "$(BINDIST)" "YES"
aa5e377 @igfoo Give each stage its own Config.hs
igfoo authored
41 compiler/stage1/package-data.mk : compiler/stage1/build/Config.hs
42 compiler/stage2/package-data.mk : compiler/stage2/build/Config.hs
43 compiler/stage3/package-data.mk : compiler/stage3/build/Config.hs
34cc75e @igfoo GHC new build system megapatch
igfoo authored
44 endif
45
aa5e377 @igfoo Give each stage its own Config.hs
igfoo authored
46 compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
47 "$(RM)" $(RM_OPTS) $@
704041f @igfoo Tidy up Config.hs generation
igfoo authored
48 @echo 'Creating $@ ... '
06c0128 @igfoo Add platform info to "ghc --info" output
igfoo authored
49 @echo '{-# LANGUAGE CPP #-}' >> $@
704041f @igfoo Tidy up Config.hs generation
igfoo authored
50 @echo 'module Config where' >> $@
06c0128 @igfoo Add platform info to "ghc --info" output
igfoo authored
51 @echo >> $@
52 @echo '#include "ghc_boot_platform.h"' >> $@
53 @echo >> $@
fdac48f @igfoo change how Integer's are handled in Core
igfoo authored
54 @echo 'data IntegerLibrary = IntegerGMP | IntegerSimple' >> $@
1e87c0a @igfoo Improve the handling of Integer literals
igfoo authored
55 @echo ' deriving Eq' >> $@
fdac48f @igfoo change how Integer's are handled in Core
igfoo authored
56 @echo >> $@
157964f @igfoo Rename the c*Platform variables to c*PlatformString
igfoo authored
57 @echo 'cBuildPlatformString :: String' >> $@
58 @echo 'cBuildPlatformString = BuildPlatform_NAME' >> $@
59 @echo 'cHostPlatformString :: String' >> $@
60 @echo 'cHostPlatformString = HostPlatform_NAME' >> $@
61 @echo 'cTargetPlatformString :: String' >> $@
62 @echo 'cTargetPlatformString = TargetPlatform_NAME' >> $@
06c0128 @igfoo Add platform info to "ghc --info" output
igfoo authored
63 @echo >> $@
704041f @igfoo Tidy up Config.hs generation
igfoo authored
64 @echo 'cProjectName :: String' >> $@
65 @echo 'cProjectName = "$(ProjectName)"' >> $@
66 @echo 'cProjectVersion :: String' >> $@
67 @echo 'cProjectVersion = "$(ProjectVersion)"' >> $@
68 @echo 'cProjectVersionInt :: String' >> $@
69 @echo 'cProjectVersionInt = "$(ProjectVersionInt)"' >> $@
70 @echo 'cProjectPatchLevel :: String' >> $@
71 @echo 'cProjectPatchLevel = "$(ProjectPatchLevel)"' >> $@
72 @echo 'cBooterVersion :: String' >> $@
73 @echo 'cBooterVersion = "$(GhcVersion)"' >> $@
74 @echo 'cStage :: String' >> $@
75 @echo 'cStage = show (STAGE :: Int)' >> $@
001b9a4 @igfoo Keep separate linker flags, for when we want to link with gcc or ld
igfoo authored
76 @echo 'cGccLinkerOpts :: [String]' >> $@
77 @echo 'cGccLinkerOpts = words "$(CONF_GCC_LINKER_OPTS_STAGE$*)"' >> $@
78 @echo 'cLdLinkerOpts :: [String]' >> $@
79 @echo 'cLdLinkerOpts = words "$(CONF_LD_LINKER_OPTS_STAGE$*)"' >> $@
704041f @igfoo Tidy up Config.hs generation
igfoo authored
80 @echo 'cIntegerLibrary :: String' >> $@
81 @echo 'cIntegerLibrary = "$(INTEGER_LIBRARY)"' >> $@
fdac48f @igfoo change how Integer's are handled in Core
igfoo authored
82 @echo 'cIntegerLibraryType :: IntegerLibrary' >> $@
83 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
84 @echo 'cIntegerLibraryType = IntegerGMP' >> $@
85 else ifeq "$(INTEGER_LIBRARY)" "integer-simple"
86 @echo 'cIntegerLibraryType = IntegerSimple' >> $@
87 else ifneq "$(CLEANING)" "YES"
88 $(error Unknown integer library)
89 endif
9b8f6b8 @igfoo Clarify the "object splitting" variable names
igfoo authored
90 @echo 'cSupportsSplitObjs :: String' >> $@
91 @echo 'cSupportsSplitObjs = "$(SupportsSplitObjs)"' >> $@
704041f @igfoo Tidy up Config.hs generation
igfoo authored
92 @echo 'cGhcWithInterpreter :: String' >> $@
93 @echo 'cGhcWithInterpreter = "$(GhcWithInterpreter)"' >> $@
94 @echo 'cGhcWithNativeCodeGen :: String' >> $@
95 @echo 'cGhcWithNativeCodeGen = "$(GhcWithNativeCodeGen)"' >> $@
96 @echo 'cGhcWithSMP :: String' >> $@
97 @echo 'cGhcWithSMP = "$(GhcWithSMP)"' >> $@
98 @echo 'cGhcRTSWays :: String' >> $@
99 @echo 'cGhcRTSWays = "$(GhcRTSWays)"' >> $@
100 @echo 'cGhcUnregisterised :: String' >> $@
101 @echo 'cGhcUnregisterised = "$(GhcUnregisterised)"' >> $@
102 @echo 'cGhcEnableTablesNextToCode :: String' >> $@
103 @echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@
104 @echo 'cLeadingUnderscore :: String' >> $@
105 @echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@
106 @echo 'cRAWCPP_FLAGS :: String' >> $@
107 @echo 'cRAWCPP_FLAGS = "$(RAWCPP_FLAGS)"' >> $@
108 @echo 'cLdIsGNULd :: String' >> $@
109 @echo 'cLdIsGNULd = "$(LdIsGNULd)"' >> $@
a52ff76 @simonmar Change the way module initialisation is done (#3252, #4417)
simonmar authored
110 @echo 'cLdHasBuildId :: String' >> $@
111 @echo 'cLdHasBuildId = "$(LdHasBuildId)"' >> $@
704041f @igfoo Tidy up Config.hs generation
igfoo authored
112 @echo 'cLD_X :: String' >> $@
113 @echo 'cLD_X = "$(LD_X)"' >> $@
114 @echo 'cGHC_DRIVER_DIR :: String' >> $@
115 @echo 'cGHC_DRIVER_DIR = "$(GHC_DRIVER_DIR)"' >> $@
116 @echo 'cGHC_UNLIT_PGM :: String' >> $@
117 @echo 'cGHC_UNLIT_PGM = "$(GHC_UNLIT_PGM)"' >> $@
118 @echo 'cGHC_UNLIT_DIR :: String' >> $@
119 @echo 'cGHC_UNLIT_DIR = "$(GHC_UNLIT_DIR)"' >> $@
120 @echo 'cGHC_SPLIT_PGM :: String' >> $@
121 @echo 'cGHC_SPLIT_PGM = "$(GHC_SPLIT_PGM)"' >> $@
122 @echo 'cGHC_SPLIT_DIR :: String' >> $@
123 @echo 'cGHC_SPLIT_DIR = "$(GHC_SPLIT_DIR)"' >> $@
124 @echo 'cGHC_SYSMAN_PGM :: String' >> $@
125 @echo 'cGHC_SYSMAN_PGM = "$(GHC_SYSMAN)"' >> $@
126 @echo 'cGHC_SYSMAN_DIR :: String' >> $@
127 @echo 'cGHC_SYSMAN_DIR = "$(GHC_SYSMAN_DIR)"' >> $@
128 @echo 'cDEFAULT_TMPDIR :: String' >> $@
129 @echo 'cDEFAULT_TMPDIR = "$(DEFAULT_TMPDIR)"' >> $@
130 @echo 'cRelocatableBuild :: Bool' >> $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
131 ifeq "$(RelocatableBuild)" "YES"
704041f @igfoo Tidy up Config.hs generation
igfoo authored
132 @echo 'cRelocatableBuild = True' >> $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
133 else
704041f @igfoo Tidy up Config.hs generation
igfoo authored
134 @echo 'cRelocatableBuild = False' >> $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
135 endif
704041f @igfoo Tidy up Config.hs generation
igfoo authored
136 @echo 'cLibFFI :: Bool' >> $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
137 ifeq "$(UseLibFFIForAdjustors)" "YES"
704041f @igfoo Tidy up Config.hs generation
igfoo authored
138 @echo 'cLibFFI = True' >> $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
139 else
704041f @igfoo Tidy up Config.hs generation
igfoo authored
140 @echo 'cLibFFI = False' >> $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
141 endif
142 @echo done.
143
aa5e377 @igfoo Give each stage its own Config.hs
igfoo authored
144 # XXX 2010-08-19: This is a legacy clean. Remove later.
145 $(eval $(call clean-target,compiler,config_hs,compiler/main/Config.hs))
34cc75e @igfoo GHC new build system megapatch
igfoo authored
146
147 # -----------------------------------------------------------------------------
148 # Create platform includes
149
150 # Here we generate a little header file containing CPP symbols that GHC
151 # uses to determine which platform it is building on/for. The platforms
152 # can differ between stage1 and stage2 if we're cross-compiling, so we
153 # need one of these header files per stage.
154
155 PLATFORM_H = ghc_boot_platform.h
156
883d980 @igfoo Use "order only constraints" for directories
igfoo authored
157 compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
158 "$(RM)" $(RM_OPTS) $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
159 @echo "Creating $@..."
40ecf8e @igfoo Correct the values in ghc_boot_platform.h
igfoo authored
160 @echo "#ifndef __PLATFORM_H__" >> $@
161 @echo "#define __PLATFORM_H__" >> $@
162 @echo >> $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
163 @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
40ecf8e @igfoo Correct the values in ghc_boot_platform.h
igfoo authored
164 @echo "#define HostPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
165 @echo "#define TargetPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
166 @echo >> $@
167 @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
168 @echo "#define $(BuildPlatform_CPP)_HOST 1" >> $@
169 @echo "#define $(HostPlatform_CPP)_TARGET 1" >> $@
170 @echo >> $@
171 @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
172 @echo "#define $(BuildArch_CPP)_HOST_ARCH 1" >> $@
173 @echo "#define $(HostArch_CPP)_TARGET_ARCH 1" >> $@
174 @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
175 @echo "#define HOST_ARCH \"$(BuildArch_CPP)\"" >> $@
176 @echo "#define TARGET_ARCH \"$(HostArch_CPP)\"" >> $@
177 @echo >> $@
178 @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
179 @echo "#define $(BuildOS_CPP)_HOST_OS 1" >> $@
180 @echo "#define $(HostOS_CPP)_TARGET_OS 1" >> $@
181 @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
182 @echo "#define HOST_OS \"$(BuildOS_CPP)\"" >> $@
183 @echo "#define TARGET_OS \"$(HostOS_CPP)\"" >> $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
184 ifeq "$(HostOS_CPP)" "irix"
40ecf8e @igfoo Correct the values in ghc_boot_platform.h
igfoo authored
185 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@
186 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
187 @echo "#endif" >> $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
188 endif
40ecf8e @igfoo Correct the values in ghc_boot_platform.h
igfoo authored
189 @echo >> $@
190 @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
191 @echo "#define $(BuildVendor_CPP)_HOST_VENDOR 1" >> $@
192 @echo "#define $(HostVendor_CPP)_TARGET_VENDOR 1" >> $@
193 @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
194 @echo "#define HOST_VENDOR \"$(BuildVendor_CPP)\"" >> $@
195 @echo "#define TARGET_VENDOR \"$(HostVendor_CPP)\"" >> $@
196 @echo >> $@
197 @echo "#endif /* __PLATFORM_H__ */" >> $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
198 @echo "Done."
199
200 # For stage2 and above, the BUILD platform is the HOST of stage1, and
201 # the HOST platform is the TARGET of stage1. The TARGET remains the same
202 # (stage1 is the cross-compiler, not stage2).
883d980 @igfoo Use "order only constraints" for directories
igfoo authored
203 compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
204 "$(RM)" $(RM_OPTS) $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
205 @echo "Creating $@..."
40ecf8e @igfoo Correct the values in ghc_boot_platform.h
igfoo authored
206 @echo "#ifndef __PLATFORM_H__" >> $@
207 @echo "#define __PLATFORM_H__" >> $@
208 @echo >> $@
209 @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
210 @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
211 @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
40ecf8e @igfoo Correct the values in ghc_boot_platform.h
igfoo authored
212 @echo >> $@
213 @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
214 @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
215 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
216 @echo >> $@
217 @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
218 @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
219 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
220 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
221 @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
222 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
223 @echo >> $@
224 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
225 @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
226 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
227 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
228 @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
229 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
230 ifeq "$(TargetOS_CPP)" "irix"
231 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@
232 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
233 @echo "#endif" >> $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
234 endif
40ecf8e @igfoo Correct the values in ghc_boot_platform.h
igfoo authored
235 @echo >> $@
236 @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
237 @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
238 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
239 @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
240 @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
241 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
242 @echo >> $@
243 @echo "#endif /* __PLATFORM_H__ */" >> $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
244 @echo "Done."
245
246 compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
247 "$(CP)" $< $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
248
249 # ----------------------------------------------------------------------------
250 # Generate supporting stuff for prelude/PrimOp.lhs
251 # from prelude/primops.txt
252
253 # XXX: these should go in stage1/stage2/stage3
254 PRIMOP_BITS = compiler/primop-data-decl.hs-incl \
255 compiler/primop-tag.hs-incl \
256 compiler/primop-list.hs-incl \
257 compiler/primop-has-side-effects.hs-incl \
258 compiler/primop-out-of-line.hs-incl \
259 compiler/primop-commutable.hs-incl \
46176df @simonmar Assign more accurate code sizes to primops, so that the inlining
simonmar authored
260 compiler/primop-code-size.hs-incl \
34cc75e @igfoo GHC new build system megapatch
igfoo authored
261 compiler/primop-can-fail.hs-incl \
262 compiler/primop-strictness.hs-incl \
263 compiler/primop-primop-info.hs-incl
264
265 compiler_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
266 compiler_CPP_OPTS += ${GhcCppOpts}
267
8838983 @igfoo Build fixes for OS X amd64 following libffi update
igfoo authored
268 compiler/stage2/build/LibFFI.hs : libffi/dist-install/build/ffi.h
269
34cc75e @igfoo GHC new build system megapatch
igfoo authored
270 $(PRIMOPS_TXT) compiler/parser/Parser.y: %: %.pp compiler/stage1/$(PLATFORM_H)
271 $(CPP) $(RAWCPP_FLAGS) -P $(compiler_CPP_OPTS) -x c $< | grep -v '^#pragma GCC' > $@
272
273 $(eval $(call clean-target,compiler,primop, $(PRIMOPS_TXT) compiler/parser/Parser.y $(PRIMOP_BITS)))
274
0eeb7f0 @simonmar Don't try to rebuild compiler/primop-*.hs-incl when BootingFromHc
simonmar authored
275 ifneq "$(BootingFromHc)" "YES"
34cc75e @igfoo GHC new build system megapatch
igfoo authored
276 compiler/primop-data-decl.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
277 "$(GENPRIMOP_INPLACE)" --data-decl < $< > $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
278 compiler/primop-tag.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
279 "$(GENPRIMOP_INPLACE)" --primop-tag < $< > $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
280 compiler/primop-list.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
281 "$(GENPRIMOP_INPLACE)" --primop-list < $< > $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
282 compiler/primop-has-side-effects.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
283 "$(GENPRIMOP_INPLACE)" --has-side-effects < $< > $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
284 compiler/primop-out-of-line.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
285 "$(GENPRIMOP_INPLACE)" --out-of-line < $< > $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
286 compiler/primop-commutable.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
287 "$(GENPRIMOP_INPLACE)" --commutable < $< > $@
46176df @simonmar Assign more accurate code sizes to primops, so that the inlining
simonmar authored
288 compiler/primop-code-size.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
289 "$(GENPRIMOP_INPLACE)" --code-size < $< > $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
290 compiler/primop-can-fail.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
291 "$(GENPRIMOP_INPLACE)" --can-fail < $< > $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
292 compiler/primop-strictness.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
293 "$(GENPRIMOP_INPLACE)" --strictness < $< > $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
294 compiler/primop-primop-info.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE)
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
295 "$(GENPRIMOP_INPLACE)" --primop-primop-info < $< > $@
34cc75e @igfoo GHC new build system megapatch
igfoo authored
296
297 # Usages aren't used any more; but the generator
298 # can still generate them if we want them back
299 compiler/primop-usage.hs-incl: $(PRIMOPS_TXT)
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
300 "$(GENPRIMOP_INPLACE)" --usage < $< > $@
0eeb7f0 @simonmar Don't try to rebuild compiler/primop-*.hs-incl when BootingFromHc
simonmar authored
301 endif
34cc75e @igfoo GHC new build system megapatch
igfoo authored
302
303 # -----------------------------------------------------------------------------
304 # Configuration
305
306 compiler_stage1_CONFIGURE_OPTS += --flags=stage1
307 compiler_stage2_CONFIGURE_OPTS += --flags=stage2
308 compiler_stage3_CONFIGURE_OPTS += --flags=stage3
309
310 ifeq "$(GhcWithNativeCodeGen)" "YES"
311 compiler_stage1_CONFIGURE_OPTS += --flags=ncg
312 compiler_stage2_CONFIGURE_OPTS += --flags=ncg
313 endif
314
315 ifeq "$(GhcWithInterpreter)" "YES"
316 compiler_stage2_CONFIGURE_OPTS += --flags=ghci
317
318 ifeq "$(BuildSharedLibs)" "YES"
319 compiler_stage2_CONFIGURE_OPTS += --enable-shared
320 # If we are going to use dynamic libraries instead of .o files for ghci,
321 # we will need to always retain CAFs in the compiler.
322 # ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
323 # function which sets the keepCAFs flag for the RTS before any Haskell
324 # code is run.
325 compiler_stage2_CONFIGURE_OPTS += --flags=dynlibs
326 endif
327
328 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
329 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
330 # or not?
331 # XXX This should logically be a CPP option, but there doesn't seem to
332 # be a flag for that
24a3fee Add support of TNTC to llvm backend
David Terei authored
333 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
34cc75e @igfoo GHC new build system megapatch
igfoo authored
334 endif
335
336 # Should the debugger commands be enabled?
337 ifeq "$(GhciWithDebugger)" "YES"
338 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DDEBUGGER
339 endif
340
341 endif
342
343 ifeq "$(TargetOS_CPP)" "openbsd"
344 compiler_CONFIGURE_OPTS += --ld-options=-E
345 endif
346
347 ifeq "$(GhcUnregisterised)" "NO"
49a8e5c Add new LLVM code generator to GHC. (Version 2)
David Terei authored
348 else
349 compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS
34cc75e @igfoo GHC new build system megapatch
igfoo authored
350 endif
351
1caf694 Delete GhcLibProfiled
simonpj@microsoft.com authored
352 # If we're profiling GHC then we want lots of SCCs, so -auto-all
9142c23 @igfoo Always enable the archive-loading code
igfoo authored
353 # We also don't want to waste time building the non-profiling library.
354 # Unfortunately this means that we have to tell ghc-pkg --force as it
355 # gets upset when libHSghc-6.9.a doesn't exist.
34cc75e @igfoo GHC new build system megapatch
igfoo authored
356 ifeq "$(GhcProfiled)" "YES"
357 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-auto-all
4e077ce @igfoo Fixes for when HADDOCK_DOCS=NO
igfoo authored
358 # We seem to still build the vanilla libraries even if we say
359 # --disable-library-vanilla, but installation then fails, as Cabal
360 # doesn't copy the vanilla .hi files, but ghc-pkg complains about
361 # their absence when we register the package. So for now, we just
362 # leave the vanilla libraries enabled.
363 # compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla
34cc75e @igfoo GHC new build system megapatch
igfoo authored
364 compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force
365 endif
366
367 compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
368
369 compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1
370 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2
371 compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3
a4bef98 @simonmar Invoke Haddock directly from the build system, instead of via Cabal
simonmar authored
372 compiler_stage2_HADDOCK_OPTS += --optghc=-DSTAGE=2
34cc75e @igfoo GHC new build system megapatch
igfoo authored
373
374 compiler/stage1/package-data.mk : compiler/ghc.mk
375 compiler/stage2/package-data.mk : compiler/ghc.mk
376 compiler/stage3/package-data.mk : compiler/ghc.mk
377
378 # -----------------------------------------------------------------------------
379 # And build the package
380
381 compiler_PACKAGE = ghc
382
7b45c46 @simonmar Further fixes to the stage1 version hack; fix validate.
simonmar authored
383 # Note [fiddle-stage1-version]
2a45176 @simonmar don't rebuild the whole of stage 1 just because the date has changed
simonmar authored
384 # The version of the GHC package changes every day, since the
385 # patchlevel is the current date. We don't want to force
386 # recompilation of the entire compiler when this happens, so for stage
387 # 1 we omit the patchlevel from the version number. For stage 2 we
388 # have to include the patchlevel since this is the package we install,
389 # however.
7b45c46 @simonmar Further fixes to the stage1 version hack; fix validate.
simonmar authored
390 #
391 # Note: we also have to tweak the version number of the package itself
392 # when it gets registered; see Note [munge-stage1-package-config]
393 # below.
f041c30 @igfoo Fix the stage1 version number munging
igfoo authored
394 # The ProjectPatchLevel > 20000000 iff it's a date. If it's e.g. 6.12.1
395 # then we don't want to remove it
93853f4 @igfoo Avoid a failing shell command when cleaning
igfoo authored
396 ifneq "$(CLEANING)" "YES"
f041c30 @igfoo Fix the stage1 version number munging
igfoo authored
397 ifeq "$(shell [ $(ProjectPatchLevel) -gt 20000000 ] && echo YES)" "YES"
398 compiler_stage1_VERSION_MUNGED = YES
399 endif
93853f4 @igfoo Avoid a failing shell command when cleaning
igfoo authored
400 endif
354503a @igfoo Don't register the non-munged stage1 ghc package
igfoo authored
401
f041c30 @igfoo Fix the stage1 version number munging
igfoo authored
402 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
2a45176 @simonmar don't rebuild the whole of stage 1 just because the date has changed
simonmar authored
403 define compiler_PACKAGE_MAGIC
404 compiler_stage1_VERSION = $(subst .$(ProjectPatchLevel),,$(ProjectVersion))
405 endef
354503a @igfoo Don't register the non-munged stage1 ghc package
igfoo authored
406
407 # Don't register the non-munged package
408 compiler_stage1_REGISTER_PACKAGE = NO
409
7b45c46 @simonmar Further fixes to the stage1 version hack; fix validate.
simonmar authored
410 endif
2a45176 @simonmar don't rebuild the whole of stage 1 just because the date has changed
simonmar authored
411
34cc75e @igfoo GHC new build system megapatch
igfoo authored
412 # haddocking only happens for stage2
413 compiler_stage1_DO_HADDOCK = NO
414 compiler_stage3_DO_HADDOCK = NO
415
416 # Don't do splitting for the GHC package, it takes too long and
417 # there's not much benefit.
418 compiler_stage1_SplitObjs = NO
419 compiler_stage2_SplitObjs = NO
420 compiler_stage3_SplitObjs = NO
421
6ffa3d7 @simonmar the 'stage=0' trick to disable all compiler builds stopped working; fix ...
simonmar authored
422 # if stage is set to something other than "1" or "", disable stage 1
423 ifneq "$(filter-out 1,$(stage))" ""
a196911 @igfoo Fix "make 2"
igfoo authored
424 compiler_stage1_NOT_NEEDED = YES
425 endif
6ffa3d7 @simonmar the 'stage=0' trick to disable all compiler builds stopped working; fix ...
simonmar authored
426 # if stage is set to something other than "2" or "", disable stage 2
427 ifneq "$(filter-out 2,$(stage))" ""
428 compiler_stage2_NOT_NEEDED = YES
429 endif
430 # stage 3 has to be requested explicitly with stage=3
85f096f @igfoo Make sure all the clean rules are always included
igfoo authored
431 ifneq "$(stage)" "3"
432 compiler_stage3_NOT_NEEDED = YES
34cc75e @igfoo GHC new build system megapatch
igfoo authored
433 endif
85f096f @igfoo Make sure all the clean rules are always included
igfoo authored
434 $(eval $(call build-package,compiler,stage1,0))
34cc75e @igfoo GHC new build system megapatch
igfoo authored
435 $(eval $(call build-package,compiler,stage2,1))
85f096f @igfoo Make sure all the clean rules are always included
igfoo authored
436 $(eval $(call build-package,compiler,stage3,2))
34cc75e @igfoo GHC new build system megapatch
igfoo authored
437
9142c23 @igfoo Always enable the archive-loading code
igfoo authored
438 # after build-package, because that adds --enable-library-for-ghci
439 # to compiler_stage*_CONFIGURE_OPTS:
440 # We don't build the GHCi library for the ghc package. We can load it
441 # the .a file instead, and as object splitting isn't on for the ghc
442 # package this isn't much slower.However, not building the package saves
443 # a significant chunk of disk space.
444 compiler_stage1_CONFIGURE_OPTS += --disable-library-for-ghci
445 compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
446 compiler_stage3_CONFIGURE_OPTS += --disable-library-for-ghci
447
a998343 @simonmar pick up changes to $(GhcStage1HcOpts) without re-configuring the ghc pac...
simonmar authored
448 # after build-package, because that sets compiler_stage1_HC_OPTS:
449 compiler_stage1_HC_OPTS += $(GhcStage1HcOpts)
450 compiler_stage2_HC_OPTS += $(GhcStage2HcOpts)
451 compiler_stage3_HC_OPTS += $(GhcStage3HcOpts)
452
b3199f6 @ezyang Flag for defaulting the codegen GhcStageXDefaultNewCodegen.
ezyang authored
453 ifeq "$(GhcStage1DefaultNewCodegen)" "YES"
454 compiler_stage1_HC_OPTS += -DGHC_DEFAULT_NEW_CODEGEN
455 endif
456
457 ifeq "$(GhcStage2DefaultNewCodegen)" "YES"
458 compiler_stage2_HC_OPTS += -DGHC_DEFAULT_NEW_CODEGEN
459 endif
460
461 ifeq "$(GhcStage3DefaultNewCodegen)" "YES"
462 compiler_stage3_HC_OPTS += -DGHC_DEFAULT_NEW_CODEGEN
463 endif
464
34cc75e @igfoo GHC new build system megapatch
igfoo authored
465 ifneq "$(BINDIST)" "YES"
466
0ca48da @igfoo Make "make tags" work in the new build system
igfoo authored
467 compiler_stage2_TAGS_HC_OPTS = -package ghc
468 $(eval $(call tags-package,compiler,stage2))
469
aea784a @igfoo Eliminate mkdependC
igfoo authored
470 $(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
471 $(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
472 $(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
34cc75e @igfoo GHC new build system megapatch
igfoo authored
473
aea784a @igfoo Eliminate mkdependC
igfoo authored
474 $(compiler_stage1_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
475 $(compiler_stage2_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
476 $(compiler_stage3_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS)
7b45c46 @simonmar Further fixes to the stage1 version hack; fix validate.
simonmar authored
477
2675f2b @igfoo Fix the compiler-hs-dependency's
igfoo authored
478 # Every Constants.o object file depends on includes/GHCConstants.h:
f031f89 @simonmar Add some manual dependencies, and -fforce-recomp for Constants and PrimO...
simonmar authored
479 $(eval $(call compiler-hs-dependency,Constants,$(includes_GHCCONSTANTS) includes/HaskellConstants.hs))
2675f2b @igfoo Fix the compiler-hs-dependency's
igfoo authored
480
481 # Every PrimOp.o object file depends on $(PRIMOP_BITS):
482 $(eval $(call compiler-hs-dependency,PrimOp,$(PRIMOP_BITS)))
483
f031f89 @simonmar Add some manual dependencies, and -fforce-recomp for Constants and PrimO...
simonmar authored
484 # GHC itself doesn't know about the above dependencies, so we have to
485 # switch off the recompilation checker for those modules:
c1ce11e @simonmar fix -fforce-recomp setting: module is PrimOp, not PrimOps
simonmar authored
486 compiler/prelude/PrimOp_HC_OPTS += -fforce-recomp
f031f89 @simonmar Add some manual dependencies, and -fforce-recomp for Constants and PrimO...
simonmar authored
487 compiler/main/Constants_HC_OPTS += -fforce-recomp
488
2febde4 @simonmar Undo part of #4003 patch
simonmar authored
489 # Workaround for #4003 in GHC 6.12.2. It didn't happen in 6.12.1, and
490 # will be fixed in 6.12.3. Unfortunately we don't have a way to do
491 # this for just stage1 in the build system.
492 ifeq "$(GhcVersion)" "6.12.2"
493 compiler/hsSyn/HsLit_HC_OPTS += -fomit-interface-pragmas
494 endif
495
7b45c46 @simonmar Further fixes to the stage1 version hack; fix validate.
simonmar authored
496 # Note [munge-stage1-package-config]
497 # Strip the date/patchlevel from the version of stage1. See Note
498 # [fiddle-stage1-version] above.
f041c30 @igfoo Fix the stage1 version number munging
igfoo authored
499 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
7b45c46 @simonmar Further fixes to the stage1 version hack; fix validate.
simonmar authored
500 compiler/stage1/inplace-pkg-config-munged: compiler/stage1/inplace-pkg-config
e0e0e1e @igfoo Be more precise about munging compiler/stage1/inplace-pkg-config
igfoo authored
501 sed -e 's/^\(version: .*\)\.$(ProjectPatchLevel)$$/\1/' \
7254726 @simonmar Add unique package identifiers (InstalledPackageId) in the package DB
simonmar authored
502 -e 's/^\(id: .*\)\.$(ProjectPatchLevel)$$/\1/' \
e0e0e1e @igfoo Be more precise about munging compiler/stage1/inplace-pkg-config
igfoo authored
503 -e 's/^\(hs-libraries: HSghc-.*\)\.$(ProjectPatchLevel)$$/\1/' \
504 < $< > $@
0ef6ba7 @igfoo Quote commands that we run, so they work if there are space in their pat...
igfoo authored
505 "$(compiler_stage1_GHC_PKG)" update --force $(compiler_stage1_GHC_PKG_OPTS) $@
7b45c46 @simonmar Further fixes to the stage1 version hack; fix validate.
simonmar authored
506
a3be88f @igfoo Build system improvements
igfoo authored
507 # We need to make sure the munged config is in the database before we
508 # try to configure ghc-bin
509 ghc/stage1/package-data.mk : compiler/stage1/inplace-pkg-config-munged
7b45c46 @simonmar Further fixes to the stage1 version hack; fix validate.
simonmar authored
510 endif
511
34cc75e @igfoo GHC new build system megapatch
igfoo authored
512 endif
513
Something went wrong with that request. Please try again.