| 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 | # ----------------------------------------------------------------------------- |
|---|
| 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),\ |
|---|
| 20 | compiler/stage$$(stage)/build/$1.$$($$(way)_osuf))) : $2 |
|---|
| 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 | # This is just to avoid generating a warning when generating deps |
|---|
| 31 | # involving RtsFlags.h |
|---|
| 32 | compiler_stage1_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES |
|---|
| 33 | compiler_stage2_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES |
|---|
| 34 | compiler_stage3_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES |
|---|
| 35 | |
|---|
| 36 | compiler_stage1_C_FILES_NODEPS = compiler/parser/cutils.c |
|---|
| 37 | |
|---|
| 38 | ifneq "$(BINDIST)" "YES" |
|---|
| 39 | compiler/stage1/package-data.mk : compiler/stage1/build/Config.hs |
|---|
| 40 | compiler/stage2/package-data.mk : compiler/stage2/build/Config.hs |
|---|
| 41 | compiler/stage3/package-data.mk : compiler/stage3/build/Config.hs |
|---|
| 42 | endif |
|---|
| 43 | |
|---|
| 44 | compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/. |
|---|
| 45 | $(call removeFiles,$@) |
|---|
| 46 | @echo 'Creating $@ ... ' |
|---|
| 47 | @echo '{-# LANGUAGE CPP #-}' >> $@ |
|---|
| 48 | @echo 'module Config where' >> $@ |
|---|
| 49 | @echo >> $@ |
|---|
| 50 | @echo '#include "ghc_boot_platform.h"' >> $@ |
|---|
| 51 | @echo >> $@ |
|---|
| 52 | @echo 'data IntegerLibrary = IntegerGMP | IntegerSimple' >> $@ |
|---|
| 53 | @echo ' deriving Eq' >> $@ |
|---|
| 54 | @echo >> $@ |
|---|
| 55 | @echo 'cBuildPlatformString :: String' >> $@ |
|---|
| 56 | @echo 'cBuildPlatformString = BuildPlatform_NAME' >> $@ |
|---|
| 57 | @echo 'cHostPlatformString :: String' >> $@ |
|---|
| 58 | @echo 'cHostPlatformString = HostPlatform_NAME' >> $@ |
|---|
| 59 | @echo 'cTargetPlatformString :: String' >> $@ |
|---|
| 60 | @echo 'cTargetPlatformString = TargetPlatform_NAME' >> $@ |
|---|
| 61 | @echo >> $@ |
|---|
| 62 | @echo 'cProjectName :: String' >> $@ |
|---|
| 63 | @echo 'cProjectName = "$(ProjectName)"' >> $@ |
|---|
| 64 | @echo 'cProjectVersion :: String' >> $@ |
|---|
| 65 | @echo 'cProjectVersion = "$(ProjectVersion)"' >> $@ |
|---|
| 66 | @echo 'cProjectVersionInt :: String' >> $@ |
|---|
| 67 | @echo 'cProjectVersionInt = "$(ProjectVersionInt)"' >> $@ |
|---|
| 68 | @echo 'cProjectPatchLevel :: String' >> $@ |
|---|
| 69 | @echo 'cProjectPatchLevel = "$(ProjectPatchLevel)"' >> $@ |
|---|
| 70 | @echo 'cBooterVersion :: String' >> $@ |
|---|
| 71 | @echo 'cBooterVersion = "$(GhcVersion)"' >> $@ |
|---|
| 72 | @echo 'cStage :: String' >> $@ |
|---|
| 73 | @echo 'cStage = show (STAGE :: Int)' >> $@ |
|---|
| 74 | @echo 'cGccLinkerOpts :: [String]' >> $@ |
|---|
| 75 | @echo 'cGccLinkerOpts = words "$(CONF_GCC_LINKER_OPTS_STAGE$*)"' >> $@ |
|---|
| 76 | @echo 'cLdLinkerOpts :: [String]' >> $@ |
|---|
| 77 | @echo 'cLdLinkerOpts = words "$(CONF_LD_LINKER_OPTS_STAGE$*)"' >> $@ |
|---|
| 78 | @echo 'cIntegerLibrary :: String' >> $@ |
|---|
| 79 | @echo 'cIntegerLibrary = "$(INTEGER_LIBRARY)"' >> $@ |
|---|
| 80 | @echo 'cIntegerLibraryType :: IntegerLibrary' >> $@ |
|---|
| 81 | ifeq "$(INTEGER_LIBRARY)" "integer-gmp" |
|---|
| 82 | @echo 'cIntegerLibraryType = IntegerGMP' >> $@ |
|---|
| 83 | else ifeq "$(INTEGER_LIBRARY)" "integer-simple" |
|---|
| 84 | @echo 'cIntegerLibraryType = IntegerSimple' >> $@ |
|---|
| 85 | else ifneq "$(CLEANING)" "YES" |
|---|
| 86 | $(error Unknown integer library) |
|---|
| 87 | endif |
|---|
| 88 | @echo 'cSupportsSplitObjs :: String' >> $@ |
|---|
| 89 | @echo 'cSupportsSplitObjs = "$(SupportsSplitObjs)"' >> $@ |
|---|
| 90 | @echo 'cGhcWithInterpreter :: String' >> $@ |
|---|
| 91 | @echo 'cGhcWithInterpreter = "$(GhcWithInterpreter)"' >> $@ |
|---|
| 92 | @echo 'cGhcWithNativeCodeGen :: String' >> $@ |
|---|
| 93 | @echo 'cGhcWithNativeCodeGen = "$(GhcWithNativeCodeGen)"' >> $@ |
|---|
| 94 | @echo 'cGhcWithSMP :: String' >> $@ |
|---|
| 95 | @echo 'cGhcWithSMP = "$(GhcWithSMP)"' >> $@ |
|---|
| 96 | @echo 'cGhcRTSWays :: String' >> $@ |
|---|
| 97 | @echo 'cGhcRTSWays = "$(GhcRTSWays)"' >> $@ |
|---|
| 98 | @echo 'cGhcUnregisterised :: String' >> $@ |
|---|
| 99 | @echo 'cGhcUnregisterised = "$(GhcUnregisterised)"' >> $@ |
|---|
| 100 | @echo 'cGhcEnableTablesNextToCode :: String' >> $@ |
|---|
| 101 | @echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@ |
|---|
| 102 | @echo 'cLeadingUnderscore :: String' >> $@ |
|---|
| 103 | @echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@ |
|---|
| 104 | @echo 'cRAWCPP_FLAGS :: String' >> $@ |
|---|
| 105 | @echo 'cRAWCPP_FLAGS = "$(RAWCPP_FLAGS)"' >> $@ |
|---|
| 106 | @echo 'cLdHasNoCompactUnwind :: String' >> $@ |
|---|
| 107 | @echo 'cLdHasNoCompactUnwind = "$(LdHasNoCompactUnwind)"' >> $@ |
|---|
| 108 | @echo 'cLdIsGNULd :: String' >> $@ |
|---|
| 109 | @echo 'cLdIsGNULd = "$(LdIsGNULd)"' >> $@ |
|---|
| 110 | @echo 'cLdHasBuildId :: String' >> $@ |
|---|
| 111 | @echo 'cLdHasBuildId = "$(LdHasBuildId)"' >> $@ |
|---|
| 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 'cLibFFI :: Bool' >> $@ |
|---|
| 131 | ifeq "$(UseLibFFIForAdjustors)" "YES" |
|---|
| 132 | @echo 'cLibFFI = True' >> $@ |
|---|
| 133 | else |
|---|
| 134 | @echo 'cLibFFI = False' >> $@ |
|---|
| 135 | endif |
|---|
| 136 | @echo done. |
|---|
| 137 | |
|---|
| 138 | # ----------------------------------------------------------------------------- |
|---|
| 139 | # Create platform includes |
|---|
| 140 | |
|---|
| 141 | # Here we generate a little header file containing CPP symbols that GHC |
|---|
| 142 | # uses to determine which platform it is building on/for. The platforms |
|---|
| 143 | # can differ between stage1 and stage2 if we're cross-compiling, so we |
|---|
| 144 | # need one of these header files per stage. |
|---|
| 145 | |
|---|
| 146 | PLATFORM_H = ghc_boot_platform.h |
|---|
| 147 | |
|---|
| 148 | ifeq "$(BuildingCrossCompiler)" "YES" |
|---|
| 149 | compiler/stage1/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H) |
|---|
| 150 | cp $< $@ |
|---|
| 151 | else |
|---|
| 152 | compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/. |
|---|
| 153 | $(call removeFiles,$@) |
|---|
| 154 | @echo "Creating $@..." |
|---|
| 155 | @echo "#ifndef __PLATFORM_H__" >> $@ |
|---|
| 156 | @echo "#define __PLATFORM_H__" >> $@ |
|---|
| 157 | @echo >> $@ |
|---|
| 158 | @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@ |
|---|
| 159 | @echo "#define HostPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@ |
|---|
| 160 | @echo "#define TargetPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@ |
|---|
| 161 | @echo >> $@ |
|---|
| 162 | @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@ |
|---|
| 163 | @echo "#define $(BuildPlatform_CPP)_HOST 1" >> $@ |
|---|
| 164 | @echo "#define $(HostPlatform_CPP)_TARGET 1" >> $@ |
|---|
| 165 | @echo >> $@ |
|---|
| 166 | @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@ |
|---|
| 167 | @echo "#define $(BuildArch_CPP)_HOST_ARCH 1" >> $@ |
|---|
| 168 | @echo "#define $(HostArch_CPP)_TARGET_ARCH 1" >> $@ |
|---|
| 169 | @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@ |
|---|
| 170 | @echo "#define HOST_ARCH \"$(BuildArch_CPP)\"" >> $@ |
|---|
| 171 | @echo "#define TARGET_ARCH \"$(HostArch_CPP)\"" >> $@ |
|---|
| 172 | @echo >> $@ |
|---|
| 173 | @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@ |
|---|
| 174 | @echo "#define $(BuildOS_CPP)_HOST_OS 1" >> $@ |
|---|
| 175 | @echo "#define $(HostOS_CPP)_TARGET_OS 1" >> $@ |
|---|
| 176 | @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@ |
|---|
| 177 | @echo "#define HOST_OS \"$(BuildOS_CPP)\"" >> $@ |
|---|
| 178 | @echo "#define TARGET_OS \"$(HostOS_CPP)\"" >> $@ |
|---|
| 179 | ifeq "$(HostOS_CPP)" "irix" |
|---|
| 180 | @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@ |
|---|
| 181 | @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@ |
|---|
| 182 | @echo "#endif" >> $@ |
|---|
| 183 | endif |
|---|
| 184 | @echo >> $@ |
|---|
| 185 | @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@ |
|---|
| 186 | @echo "#define $(BuildVendor_CPP)_HOST_VENDOR 1" >> $@ |
|---|
| 187 | @echo "#define $(HostVendor_CPP)_TARGET_VENDOR 1" >> $@ |
|---|
| 188 | @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@ |
|---|
| 189 | @echo "#define HOST_VENDOR \"$(BuildVendor_CPP)\"" >> $@ |
|---|
| 190 | @echo "#define TARGET_VENDOR \"$(HostVendor_CPP)\"" >> $@ |
|---|
| 191 | @echo >> $@ |
|---|
| 192 | @echo "#endif /* __PLATFORM_H__ */" >> $@ |
|---|
| 193 | @echo "Done." |
|---|
| 194 | endif |
|---|
| 195 | |
|---|
| 196 | # For stage2 and above, the BUILD platform is the HOST of stage1, and |
|---|
| 197 | # the HOST platform is the TARGET of stage1. The TARGET remains the same |
|---|
| 198 | # (stage1 is the cross-compiler, not stage2). |
|---|
| 199 | compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/. |
|---|
| 200 | $(call removeFiles,$@) |
|---|
| 201 | @echo "Creating $@..." |
|---|
| 202 | @echo "#ifndef __PLATFORM_H__" >> $@ |
|---|
| 203 | @echo "#define __PLATFORM_H__" >> $@ |
|---|
| 204 | @echo >> $@ |
|---|
| 205 | @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@ |
|---|
| 206 | @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@ |
|---|
| 207 | @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@ |
|---|
| 208 | @echo >> $@ |
|---|
| 209 | @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@ |
|---|
| 210 | @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@ |
|---|
| 211 | @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@ |
|---|
| 212 | @echo >> $@ |
|---|
| 213 | @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@ |
|---|
| 214 | @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@ |
|---|
| 215 | @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@ |
|---|
| 216 | @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@ |
|---|
| 217 | @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@ |
|---|
| 218 | @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@ |
|---|
| 219 | @echo >> $@ |
|---|
| 220 | @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@ |
|---|
| 221 | @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@ |
|---|
| 222 | @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@ |
|---|
| 223 | @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@ |
|---|
| 224 | @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@ |
|---|
| 225 | @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@ |
|---|
| 226 | ifeq "$(TargetOS_CPP)" "irix" |
|---|
| 227 | @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@ |
|---|
| 228 | @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@ |
|---|
| 229 | @echo "#endif" >> $@ |
|---|
| 230 | endif |
|---|
| 231 | @echo >> $@ |
|---|
| 232 | @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@ |
|---|
| 233 | @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@ |
|---|
| 234 | @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@ |
|---|
| 235 | @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@ |
|---|
| 236 | @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@ |
|---|
| 237 | @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@ |
|---|
| 238 | @echo >> $@ |
|---|
| 239 | @echo "#endif /* __PLATFORM_H__ */" >> $@ |
|---|
| 240 | @echo "Done." |
|---|
| 241 | |
|---|
| 242 | compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H) |
|---|
| 243 | "$(CP)" $< $@ |
|---|
| 244 | |
|---|
| 245 | # ---------------------------------------------------------------------------- |
|---|
| 246 | # Generate supporting stuff for prelude/PrimOp.lhs |
|---|
| 247 | # from prelude/primops.txt |
|---|
| 248 | |
|---|
| 249 | # XXX: these should go in stage1/stage2/stage3 |
|---|
| 250 | PRIMOP_BITS = compiler/primop-data-decl.hs-incl \ |
|---|
| 251 | compiler/primop-tag.hs-incl \ |
|---|
| 252 | compiler/primop-list.hs-incl \ |
|---|
| 253 | compiler/primop-has-side-effects.hs-incl \ |
|---|
| 254 | compiler/primop-out-of-line.hs-incl \ |
|---|
| 255 | compiler/primop-commutable.hs-incl \ |
|---|
| 256 | compiler/primop-code-size.hs-incl \ |
|---|
| 257 | compiler/primop-can-fail.hs-incl \ |
|---|
| 258 | compiler/primop-strictness.hs-incl \ |
|---|
| 259 | compiler/primop-primop-info.hs-incl |
|---|
| 260 | |
|---|
| 261 | compiler_CPP_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS)) |
|---|
| 262 | compiler_CPP_OPTS += ${GhcCppOpts} |
|---|
| 263 | |
|---|
| 264 | $(PRIMOPS_TXT) compiler/parser/Parser.y: %: %.pp compiler/stage1/$(PLATFORM_H) |
|---|
| 265 | $(CPP) $(RAWCPP_FLAGS) -P $(compiler_CPP_OPTS) -x c $< | grep -v '^#pragma GCC' > $@ |
|---|
| 266 | |
|---|
| 267 | $(eval $(call clean-target,compiler,primop, $(PRIMOPS_TXT) compiler/parser/Parser.y $(PRIMOP_BITS))) |
|---|
| 268 | |
|---|
| 269 | ifneq "$(BootingFromHc)" "YES" |
|---|
| 270 | compiler/primop-data-decl.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) |
|---|
| 271 | "$(GENPRIMOP_INPLACE)" --data-decl < $< > $@ |
|---|
| 272 | compiler/primop-tag.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) |
|---|
| 273 | "$(GENPRIMOP_INPLACE)" --primop-tag < $< > $@ |
|---|
| 274 | compiler/primop-list.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) |
|---|
| 275 | "$(GENPRIMOP_INPLACE)" --primop-list < $< > $@ |
|---|
| 276 | compiler/primop-has-side-effects.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) |
|---|
| 277 | "$(GENPRIMOP_INPLACE)" --has-side-effects < $< > $@ |
|---|
| 278 | compiler/primop-out-of-line.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) |
|---|
| 279 | "$(GENPRIMOP_INPLACE)" --out-of-line < $< > $@ |
|---|
| 280 | compiler/primop-commutable.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) |
|---|
| 281 | "$(GENPRIMOP_INPLACE)" --commutable < $< > $@ |
|---|
| 282 | compiler/primop-code-size.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) |
|---|
| 283 | "$(GENPRIMOP_INPLACE)" --code-size < $< > $@ |
|---|
| 284 | compiler/primop-can-fail.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) |
|---|
| 285 | "$(GENPRIMOP_INPLACE)" --can-fail < $< > $@ |
|---|
| 286 | compiler/primop-strictness.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) |
|---|
| 287 | "$(GENPRIMOP_INPLACE)" --strictness < $< > $@ |
|---|
| 288 | compiler/primop-primop-info.hs-incl: $(PRIMOPS_TXT) $(GENPRIMOP_INPLACE) |
|---|
| 289 | "$(GENPRIMOP_INPLACE)" --primop-primop-info < $< > $@ |
|---|
| 290 | |
|---|
| 291 | # Usages aren't used any more; but the generator |
|---|
| 292 | # can still generate them if we want them back |
|---|
| 293 | compiler/primop-usage.hs-incl: $(PRIMOPS_TXT) |
|---|
| 294 | "$(GENPRIMOP_INPLACE)" --usage < $< > $@ |
|---|
| 295 | endif |
|---|
| 296 | |
|---|
| 297 | # ----------------------------------------------------------------------------- |
|---|
| 298 | # Configuration |
|---|
| 299 | |
|---|
| 300 | compiler_stage1_CONFIGURE_OPTS += --flags=stage1 |
|---|
| 301 | compiler_stage2_CONFIGURE_OPTS += --flags=stage2 |
|---|
| 302 | compiler_stage3_CONFIGURE_OPTS += --flags=stage3 |
|---|
| 303 | |
|---|
| 304 | ifeq "$(GhcWithNativeCodeGen)" "YES" |
|---|
| 305 | compiler_stage1_CONFIGURE_OPTS += --flags=ncg |
|---|
| 306 | compiler_stage2_CONFIGURE_OPTS += --flags=ncg |
|---|
| 307 | endif |
|---|
| 308 | |
|---|
| 309 | ifeq "$(GhcWithInterpreter)" "YES" |
|---|
| 310 | compiler_stage2_CONFIGURE_OPTS += --flags=ghci |
|---|
| 311 | |
|---|
| 312 | ifeq "$(BuildSharedLibs)" "YES" |
|---|
| 313 | compiler_stage2_CONFIGURE_OPTS += --enable-shared |
|---|
| 314 | # If we are going to use dynamic libraries instead of .o files for ghci, |
|---|
| 315 | # we will need to always retain CAFs in the compiler. |
|---|
| 316 | # ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor)) |
|---|
| 317 | # function which sets the keepCAFs flag for the RTS before any Haskell |
|---|
| 318 | # code is run. |
|---|
| 319 | compiler_stage2_CONFIGURE_OPTS += --flags=dynlibs |
|---|
| 320 | endif |
|---|
| 321 | |
|---|
| 322 | ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO" |
|---|
| 323 | # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style |
|---|
| 324 | # or not? |
|---|
| 325 | # XXX This should logically be a CPP option, but there doesn't seem to |
|---|
| 326 | # be a flag for that |
|---|
| 327 | compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE |
|---|
| 328 | endif |
|---|
| 329 | |
|---|
| 330 | # Should the debugger commands be enabled? |
|---|
| 331 | ifeq "$(GhciWithDebugger)" "YES" |
|---|
| 332 | compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DDEBUGGER |
|---|
| 333 | endif |
|---|
| 334 | |
|---|
| 335 | endif |
|---|
| 336 | |
|---|
| 337 | ifeq "$(TargetOS_CPP)" "openbsd" |
|---|
| 338 | compiler_CONFIGURE_OPTS += --ld-options=-E |
|---|
| 339 | endif |
|---|
| 340 | |
|---|
| 341 | ifeq "$(GhcUnregisterised)" "NO" |
|---|
| 342 | else |
|---|
| 343 | compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS |
|---|
| 344 | endif |
|---|
| 345 | |
|---|
| 346 | ifeq "$(GhcProfiled)" "YES" |
|---|
| 347 | |
|---|
| 348 | # If we're profiling GHC then we want SCCs. However, adding -auto-all |
|---|
| 349 | # everywhere tends to give a hard-to-read profile, and adds lots of |
|---|
| 350 | # overhead. A better approach is to proceed top-down; identify the |
|---|
| 351 | # parts of the compiler of interest, and then add further cost centres |
|---|
| 352 | # as necessary. Turn on -auto-all for individual modules like this: |
|---|
| 353 | |
|---|
| 354 | compiler/main/DriverPipeline_HC_OPTS += -auto-all |
|---|
| 355 | compiler/main/GhcMake_HC_OPTS += -auto-all |
|---|
| 356 | compiler/main/GHC_HC_OPTS += -auto-all |
|---|
| 357 | |
|---|
| 358 | # or alternatively add {-# OPTIONS_GHC -auto-all #-} to the top of |
|---|
| 359 | # modules you're interested in. |
|---|
| 360 | |
|---|
| 361 | # We seem to still build the vanilla libraries even if we say |
|---|
| 362 | # --disable-library-vanilla, but installation then fails, as Cabal |
|---|
| 363 | # doesn't copy the vanilla .hi files, but ghc-pkg complains about |
|---|
| 364 | # their absence when we register the package. So for now, we just |
|---|
| 365 | # leave the vanilla libraries enabled. |
|---|
| 366 | # compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla |
|---|
| 367 | compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force |
|---|
| 368 | endif |
|---|
| 369 | |
|---|
| 370 | compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS) |
|---|
| 371 | |
|---|
| 372 | compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1 |
|---|
| 373 | compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2 |
|---|
| 374 | compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3 |
|---|
| 375 | compiler_stage2_HADDOCK_OPTS += --optghc=-DSTAGE=2 |
|---|
| 376 | |
|---|
| 377 | compiler/stage1/package-data.mk : compiler/ghc.mk |
|---|
| 378 | compiler/stage2/package-data.mk : compiler/ghc.mk |
|---|
| 379 | compiler/stage3/package-data.mk : compiler/ghc.mk |
|---|
| 380 | |
|---|
| 381 | # ----------------------------------------------------------------------------- |
|---|
| 382 | # And build the package |
|---|
| 383 | |
|---|
| 384 | compiler_PACKAGE = ghc |
|---|
| 385 | |
|---|
| 386 | # Note [fiddle-stage1-version] |
|---|
| 387 | # The version of the GHC package changes every day, since the |
|---|
| 388 | # patchlevel is the current date. We don't want to force |
|---|
| 389 | # recompilation of the entire compiler when this happens, so for stage |
|---|
| 390 | # 1 we omit the patchlevel from the version number. For stage 2 we |
|---|
| 391 | # have to include the patchlevel since this is the package we install, |
|---|
| 392 | # however. |
|---|
| 393 | # |
|---|
| 394 | # Note: we also have to tweak the version number of the package itself |
|---|
| 395 | # when it gets registered; see Note [munge-stage1-package-config] |
|---|
| 396 | # below. |
|---|
| 397 | # The ProjectPatchLevel > 20000000 iff it's a date. If it's e.g. 6.12.1 |
|---|
| 398 | # then we don't want to remove it |
|---|
| 399 | ifneq "$(CLEANING)" "YES" |
|---|
| 400 | ifeq "$(shell [ $(ProjectPatchLevel) -gt 20000000 ] && echo YES)" "YES" |
|---|
| 401 | compiler_stage1_VERSION_MUNGED = YES |
|---|
| 402 | endif |
|---|
| 403 | endif |
|---|
| 404 | |
|---|
| 405 | ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES" |
|---|
| 406 | compiler_stage1_MUNGED_VERSION = $(subst .$(ProjectPatchLevel),,$(ProjectVersion)) |
|---|
| 407 | define compiler_PACKAGE_MAGIC |
|---|
| 408 | compiler_stage1_VERSION = $(compiler_stage1_MUNGED_VERSION) |
|---|
| 409 | endef |
|---|
| 410 | |
|---|
| 411 | # Don't register the non-munged package |
|---|
| 412 | compiler_stage1_REGISTER_PACKAGE = NO |
|---|
| 413 | |
|---|
| 414 | endif |
|---|
| 415 | |
|---|
| 416 | # haddocking only happens for stage2 |
|---|
| 417 | compiler_stage1_DO_HADDOCK = NO |
|---|
| 418 | compiler_stage3_DO_HADDOCK = NO |
|---|
| 419 | |
|---|
| 420 | # Don't do splitting for the GHC package, it takes too long and |
|---|
| 421 | # there's not much benefit. |
|---|
| 422 | compiler_stage1_SplitObjs = NO |
|---|
| 423 | compiler_stage2_SplitObjs = NO |
|---|
| 424 | compiler_stage3_SplitObjs = NO |
|---|
| 425 | |
|---|
| 426 | # if stage is set to something other than "1" or "", disable stage 1 |
|---|
| 427 | ifneq "$(filter-out 1,$(stage))" "" |
|---|
| 428 | compiler_stage1_NOT_NEEDED = YES |
|---|
| 429 | endif |
|---|
| 430 | # if stage is set to something other than "2" or "", disable stage 2 |
|---|
| 431 | ifneq "$(filter-out 2,$(stage))" "" |
|---|
| 432 | compiler_stage2_NOT_NEEDED = YES |
|---|
| 433 | endif |
|---|
| 434 | # stage 3 has to be requested explicitly with stage=3 |
|---|
| 435 | ifneq "$(stage)" "3" |
|---|
| 436 | compiler_stage3_NOT_NEEDED = YES |
|---|
| 437 | endif |
|---|
| 438 | $(eval $(call build-package,compiler,stage1,0)) |
|---|
| 439 | $(eval $(call build-package,compiler,stage2,1)) |
|---|
| 440 | $(eval $(call build-package,compiler,stage3,2)) |
|---|
| 441 | |
|---|
| 442 | # after build-package, because that adds --enable-library-for-ghci |
|---|
| 443 | # to compiler_stage*_CONFIGURE_OPTS: |
|---|
| 444 | # We don't build the GHCi library for the ghc package. We can load it |
|---|
| 445 | # the .a file instead, and as object splitting isn't on for the ghc |
|---|
| 446 | # package this isn't much slower.However, not building the package saves |
|---|
| 447 | # a significant chunk of disk space. |
|---|
| 448 | compiler_stage1_CONFIGURE_OPTS += --disable-library-for-ghci |
|---|
| 449 | compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci |
|---|
| 450 | compiler_stage3_CONFIGURE_OPTS += --disable-library-for-ghci |
|---|
| 451 | |
|---|
| 452 | # after build-package, because that sets compiler_stage1_HC_OPTS: |
|---|
| 453 | compiler_stage1_HC_OPTS += $(GhcStage1HcOpts) |
|---|
| 454 | compiler_stage2_HC_OPTS += $(GhcStage2HcOpts) |
|---|
| 455 | compiler_stage3_HC_OPTS += $(GhcStage3HcOpts) |
|---|
| 456 | |
|---|
| 457 | ifeq "$(GhcStage1DefaultNewCodegen)" "YES" |
|---|
| 458 | compiler_stage1_HC_OPTS += -DGHC_DEFAULT_NEW_CODEGEN |
|---|
| 459 | endif |
|---|
| 460 | |
|---|
| 461 | ifeq "$(GhcStage2DefaultNewCodegen)" "YES" |
|---|
| 462 | compiler_stage2_HC_OPTS += -DGHC_DEFAULT_NEW_CODEGEN |
|---|
| 463 | endif |
|---|
| 464 | |
|---|
| 465 | ifeq "$(GhcStage3DefaultNewCodegen)" "YES" |
|---|
| 466 | compiler_stage3_HC_OPTS += -DGHC_DEFAULT_NEW_CODEGEN |
|---|
| 467 | endif |
|---|
| 468 | |
|---|
| 469 | ifneq "$(BINDIST)" "YES" |
|---|
| 470 | |
|---|
| 471 | compiler_stage2_TAGS_HC_OPTS = -package ghc |
|---|
| 472 | $(eval $(call tags-package,compiler,stage2)) |
|---|
| 473 | |
|---|
| 474 | $(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H) |
|---|
| 475 | $(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H) |
|---|
| 476 | $(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H) |
|---|
| 477 | |
|---|
| 478 | $(compiler_stage1_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS) |
|---|
| 479 | $(compiler_stage2_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS) |
|---|
| 480 | $(compiler_stage3_depfile_haskell) : $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_GHCCONSTANTS) $(includes_DERIVEDCONSTANTS) $(PRIMOP_BITS) |
|---|
| 481 | |
|---|
| 482 | # Every Constants.o object file depends on includes/GHCConstants.h: |
|---|
| 483 | $(eval $(call compiler-hs-dependency,Constants,$(includes_GHCCONSTANTS) includes/HaskellConstants.hs)) |
|---|
| 484 | |
|---|
| 485 | # Every PrimOp.o object file depends on $(PRIMOP_BITS): |
|---|
| 486 | $(eval $(call compiler-hs-dependency,PrimOp,$(PRIMOP_BITS))) |
|---|
| 487 | |
|---|
| 488 | # GHC itself doesn't know about the above dependencies, so we have to |
|---|
| 489 | # switch off the recompilation checker for those modules: |
|---|
| 490 | compiler/prelude/PrimOp_HC_OPTS += -fforce-recomp |
|---|
| 491 | compiler/main/Constants_HC_OPTS += -fforce-recomp |
|---|
| 492 | |
|---|
| 493 | # LibFFI.hs #includes ffi.h |
|---|
| 494 | compiler/stage2/build/LibFFI.hs : $(libffi_HEADERS) |
|---|
| 495 | # On Windows it seems we also need to link directly to libffi |
|---|
| 496 | ifeq "$(HostOS_CPP)" "mingw32" |
|---|
| 497 | define windowsDynLinkToFfi |
|---|
| 498 | # $1 = way |
|---|
| 499 | ifneq "$$(findstring dyn, $1)" "" |
|---|
| 500 | compiler_stage2_$1_ALL_HC_OPTS += -l$$(LIBFFI_WINDOWS_LIB) |
|---|
| 501 | endif |
|---|
| 502 | endef |
|---|
| 503 | $(foreach way,$(GhcLibWays),$(eval $(call windowsDynLinkToFfi,$(way)))) |
|---|
| 504 | endif |
|---|
| 505 | |
|---|
| 506 | # Note [munge-stage1-package-config] |
|---|
| 507 | # Strip the date/patchlevel from the version of stage1. See Note |
|---|
| 508 | # [fiddle-stage1-version] above. |
|---|
| 509 | ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES" |
|---|
| 510 | compiler/stage1/inplace-pkg-config-munged: compiler/stage1/inplace-pkg-config |
|---|
| 511 | sed -e 's/^\(version: .*\)\.$(ProjectPatchLevel)$$/\1/' \ |
|---|
| 512 | -e 's/^\(id: .*\)\.$(ProjectPatchLevel)$$/\1/' \ |
|---|
| 513 | -e 's/^\(hs-libraries: HSghc-.*\)\.$(ProjectPatchLevel)$$/\1/' \ |
|---|
| 514 | < $< > $@ |
|---|
| 515 | "$(compiler_stage1_GHC_PKG)" update --force $(compiler_stage1_GHC_PKG_OPTS) $@ |
|---|
| 516 | |
|---|
| 517 | # We need to make sure the munged config is in the database before we |
|---|
| 518 | # try to configure ghc-bin |
|---|
| 519 | ghc/stage1/package-data.mk : compiler/stage1/inplace-pkg-config-munged |
|---|
| 520 | endif |
|---|
| 521 | |
|---|
| 522 | endif |
|---|