Fix building runghc on Windows
[ghc-hetmet.git] / utils / runghc / runghc.hs
index 84675bc..911d0f8 100644 (file)
@@ -32,6 +32,12 @@ import System.Exit
 import System.FilePath
 import System.IO
 
+#if defined(mingw32_HOST_OS)
+import Control.Monad
+import Foreign
+import Foreign.C.String
+#endif
+
 main :: IO ()
 main = do
     args <- getArgs
@@ -76,9 +82,14 @@ doIt ghc args = do
                  hClose h
                  doIt ghc (ghc_args ++ [filename])
         filename : prog_args -> do
-            let c1 = ":set prog " ++ show filename
+            let xflag = if takeExtension filename == ".lhs"
+                        then []
+                        else ["-x", "hs"]
+                c1 = ":set prog " ++ show filename
                 c2 = ":main " ++ show prog_args
-            res <- rawSystem ghc (["-ignore-dot-ghci"] ++ ghc_args ++
+            res <- rawSystem ghc (["-ignore-dot-ghci"] ++
+                                  xflag ++
+                                  ghc_args ++
                                   [ "-e", c1, "-e", c2, filename])
             exitWith res