# -----------------------------------------------------------------------------
-# $Id: Makefile,v 1.22 2003/06/04 15:18:29 panne Exp $
TOP=../..
include $(TOP)/mk/boilerplate.mk
# -----------------------------------------------------------------------------
# ghc-pkg.bin
+ghc_ge_504 = $(shell if (test $(GhcCanonVersion) -ge 504); then echo YES; else echo NO; fi)
+ghc_eq_600 = $(shell if (test $(GhcCanonVersion) -eq 600); then echo YES; else echo NO; fi)
+ghc_lt_600 = $(shell if (test $(GhcCanonVersion) -lt 600); then echo YES; else echo NO; fi)
+
SRC_HC_OPTS += -cpp -DPKG_TOOL -DWANT_PRETTY
-ghc_ge_504 = $(shell if (test $(GhcCanonVersion) -ge 504); then echo YES; else echo NO; fi)
+# <= 6.0.x quotes arguments when invoking utils (using double quotes), hence
+# the need to escape the double quotes. >= 6.2.x does not.
+# ..but apparently 5.04.x on non-win32 platforms doesn't, so catch this (and
+# assume pre-5.04 behave similarly.)
+ifeq "$(ghc_lt_600)" "YES"
+ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32YES"
+SRC_HC_OPTS += -D'GHC_PKG_VERSION=\"$(ProjectVersion)\"'
+else
+SRC_HC_OPTS += -D'GHC_PKG_VERSION="$(ProjectVersion)"'
+endif
+else
+ifeq "$(ghc_eq_600)" "YES"
+SRC_HC_OPTS += -D'GHC_PKG_VERSION=\"$(ProjectVersion)\"'
+else
+SRC_HC_OPTS += -D'GHC_PKG_VERSION="$(ProjectVersion)"'
+endif
+endif
ifeq "$(ghc_ge_504)" "NO"
SRC_HC_OPTS += -package lang -package util -package text