CABAL_GHC_FLAGS += -cpp
endif
-# Euch, hideous hack:
-CABAL_VERSION = $(shell grep "^Version:" Cabal/Cabal.cabal | sed -e "s/^Version: //" -e 's/\./,/g')
-
BOOTSTRAPPING_FLAGS = $(CABAL_GHC_FLAGS) -DCABAL_VERSION=$(CABAL_VERSION) -odir $(HERE_ABS)/bootstrapping -hidir $(HERE_ABS)/bootstrapping -i$(HERE_ABS)/Cabal -i$(HERE_ABS)/filepath -i$(HERE_ABS)/hpc
.PHONY: boot
nothing=
space=$(nothing) $(nothing)
+comma=,
GHC_PKG_INSTALL_PROG = $(FPTOOLS_TOP_ABS)/utils/ghc-pkg/dist-install/build/ghc-pkg/ghc-pkg
$(UTILS_ABS)/installPackage/install-inplace/bin/installPackage
STAGE3_PACKAGE_CONF = $(FPTOOLS_TOP_ABS)/stage3.package.conf
+# Euch, hideous hack:
+CABAL_DOTTED_VERSION = $(shell grep "^Version:" $(LIBRARIES_ABS)/Cabal/Cabal.cabal | sed "s/^Version: //")
+CABAL_VERSION = $(subst .,$(comma),$(CABAL_DOTTED_VERSION))
+CABAL_CONSTRAINT = --constraint="Cabal == $(CABAL_DOTTED_VERSION)"
+
# We rely on all the CONFIGURE_ARGS being quoted with '...', and there
# being no 's inside the values.
FLAGGED_CONFIGURE_ARGS = $(subst $(space)',\
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/cabal.mk
-# We should stop installPackage being installed itself, but we do need
-# to build it with the stage2 compiler as we need to use it when
-# installing.
+# If the bootstrapping compiler already has a newer version of Cabal
+# than the in-tree Cabal, then we need to forcibly use the in-tree one.
+# Otherwise we use one Cabal for some things and the other Cabal for
+# other things, and Cabal (rightly) complains about the version
+# mismatch.
+EXTRA_INPLACE_CONFIGURE_FLAGS += $(CABAL_CONSTRAINT)
+EXTRA_STAGE2_CONFIGURE_FLAGS += $(CABAL_CONSTRAINT)