# have to deal with variations in the package support of different
# versions of GHC.
+ifneq "$(UseStage1)" "YES"
+
+SRC_HC_OPTS += -DUSING_COMPAT
+
# Use libghccompat.a:
SRC_HC_OPTS += -i$(GHC_COMPAT_DIR)
SRC_LD_OPTS += -L$(GHC_COMPAT_DIR) -lghccompat
-optdep--exclude-module=Distribution.Compiler \
-optdep--exclude-module=Distribution.Version \
-optdep--exclude-module=System.Directory.Internals
+
+PACKAGE_CABAL =
+
+else
+
+PACKAGE_CABAL = -package Cabal
+
+endif
+
import Distribution.ParseUtils
import Distribution.Package
import Distribution.Version
-import Compat.Directory ( getAppUserDataDirectory, createDirectoryIfMissing )
-import Compat.RawSystem ( rawSystem )
+
+#ifdef USING_COMPAT
+import Compat.Directory ( getAppUserDataDirectory, createDirectoryIfMissing )
+import Compat.RawSystem ( rawSystem )
+#else
+import System.Directory ( getAppUserDataDirectory, createDirectoryIfMissing )
+import System.Cmd ( rawSystem )
+#endif
import Prelude
# This causes libghccompat.a to be used:
include $(GHC_COMPAT_DIR)/compat.mk
+SRC_HC_OPTS += $(PACKAGE_CABAL)
+
# This is required because libghccompat.a must be built with
# $(GhcHcOpts) because it is linked to the compiler, and hence
# we must also build with $(GhcHcOpts) here:
#endif
#if defined(__GLASGOW_HASKELL__) && !defined(BUILD_NHC)
-import Compat.RawSystem ( rawSystem )
+#ifdef USING_COMPAT
+import Compat.RawSystem ( rawSystem )
+#else
+import System.Cmd ( rawSystem )
+#endif
#define HAVE_rawSystem
#elif __NHC__ >= 117
import System.Cmd ( rawSystem )
import System.Exit
import Data.Char
-import Compat.RawSystem ( rawSystem )
-import Compat.Directory ( findExecutable )
+#ifdef USING_COMPAT
+import Compat.RawSystem ( rawSystem )
+import Compat.Directory ( findExecutable )
+#else
+import System.Cmd ( rawSystem )
+import System.Directory ( findExecutable )
+#endif
main = do
args <- getArgs