summaryrefslogtreecommitdiff
path: root/compiler/ghc.mk
diff options
context:
space:
mode:
authorJohn Ericson <git@JohnEricson.me>2019-09-12 23:35:48 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-10-04 21:44:29 -0400
commit75a5dd8e614e6056edf846218c08ddfff9384e04 (patch)
treeb825c16755c11aa363a3cfab7d28bb0544577939 /compiler/ghc.mk
parent05419e55cab272ed39790695f448b311f22669f7 (diff)
downloadhaskell-75a5dd8e614e6056edf846218c08ddfff9384e04.tar.gz
Remove {Build,Host}Platform_NAME from header
They are only used in a file we construct directly, so just skip CPP.
Diffstat (limited to 'compiler/ghc.mk')
-rw-r--r--compiler/ghc.mk84
1 files changed, 51 insertions, 33 deletions
diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index 3f94e87926..7c301552cf 100644
--- a/compiler/ghc.mk
+++ b/compiler/ghc.mk
@@ -29,9 +29,14 @@ compiler_stage1_C_FILES_NODEPS = compiler/parser/cutils.c
# we just skip the check.
compiler_NO_CHECK = YES
+# We need to decrement the 1-indexed compiler stage to be the 0-indexed stage
+# we use everwhere else.
dec1 = 0
dec2 = 1
dec3 = 2
+# TODO(@Ericson2314) Get rid of compiler-specific stage indices. I think the
+# argument was stage n ghc is used to build stage n everything else, but I
+# don't buy that argument.
ifneq "$(BINDIST)" "YES"
@@ -48,40 +53,53 @@ $(foreach n,1 2 3, \
)
endif
-compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
- $(call removeFiles,$@)
- @echo 'Creating $@ ... '
- @echo '{-# LANGUAGE CPP #-}' >> $@
- @echo 'module Config' >> $@
- @echo ' ( module GHC.Version' >> $@
- @echo ' , cBuildPlatformString' >> $@
- @echo ' , cHostPlatformString' >> $@
- @echo ' , cProjectName' >> $@
- @echo ' , cBooterVersion' >> $@
- @echo ' , cStage' >> $@
- @echo ' ) where' >> $@
- @echo >> $@
- @echo 'import GhcPrelude' >> $@
- @echo >> $@
- @echo 'import GHC.Version' >> $@
- @echo >> $@
- @echo '#include "ghcplatform.h"' >> $@
- @echo >> $@
- @echo 'cBuildPlatformString :: String' >> $@
- @echo 'cBuildPlatformString = BuildPlatform_NAME' >> $@
- @echo >> $@
- @echo 'cHostPlatformString :: String' >> $@
- @echo 'cHostPlatformString = HostPlatform_NAME' >> $@
- @echo >> $@
- @echo 'cProjectName :: String' >> $@
- @echo 'cProjectName = "$(ProjectName)"' >> $@
- @echo >> $@
- @echo 'cBooterVersion :: String' >> $@
- @echo 'cBooterVersion = "$(GhcVersion)"' >> $@
- @echo >> $@
- @echo 'cStage :: String' >> $@
- @echo 'cStage = show (STAGE :: Int)' >> $@
+BUILDPLATFORM_1 = $(BUILDPLATFORM)
+BUILDPLATFORM_2 = $(HOSTPLATFORM)
+BUILDPLATFORM_3 = $(TARGETPLATFORM)
+
+HOSTPLATFORM_1 = $(HOSTPLATFORM)
+HOSTPLATFORM_2 = $(TARGETPLATFORM)
+HOSTPLATFORM_3 = $(TARGETPLATFORM)
+
+define compilerConfig
+# $1 = compile stage (1-indexed)
+compiler/stage$1/build/Config.hs : mk/config.mk mk/project.mk | $$$$(dir $$$$@)/.
+ $$(call removeFiles,$$@)
+ @echo 'Creating $$@ ... '
+ @echo '{-# LANGUAGE CPP #-}' >> $$@
+ @echo 'module Config' >> $$@
+ @echo ' ( module GHC.Version' >> $$@
+ @echo ' , cBuildPlatformString' >> $$@
+ @echo ' , cHostPlatformString' >> $$@
+ @echo ' , cProjectName' >> $$@
+ @echo ' , cBooterVersion' >> $$@
+ @echo ' , cStage' >> $$@
+ @echo ' ) where' >> $$@
+ @echo >> $$@
+ @echo 'import GhcPrelude' >> $$@
+ @echo >> $$@
+ @echo 'import GHC.Version' >> $$@
+ @echo >> $$@
+ @echo 'cBuildPlatformString :: String' >> $$@
+ @echo 'cBuildPlatformString = "$(BUILDPLATFORM_$1)"' >> $$@
+ @echo >> $$@
+ @echo 'cHostPlatformString :: String' >> $$@
+ @echo 'cHostPlatformString = "$(HOSTPLATFORM_$1)"' >> $$@
+ @echo >> $$@
+ @echo 'cProjectName :: String' >> $$@
+ @echo 'cProjectName = "$(ProjectName)"' >> $$@
+ @echo >> $$@
+ @echo 'cBooterVersion :: String' >> $$@
+ @echo 'cBooterVersion = "$(GhcVersion)"' >> $$@
+ @echo >> $$@
+ @echo 'cStage :: String' >> $$@
+ @echo 'cStage = show (STAGE :: Int)' >> $$@
@echo done.
+endef
+
+$(eval $(call compilerConfig,0))
+$(eval $(call compilerConfig,1))
+$(eval $(call compilerConfig,2))
# ----------------------------------------------------------------------------
# Generate supporting stuff for prelude/PrimOp.hs