Commit 53277279 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Pattern match on an OS datatype rather than using ifdef everywhere

parent 8742ba8e
...@@ -70,6 +70,7 @@ Library { ...@@ -70,6 +70,7 @@ Library {
Distribution.Simple.SetupWrapper, Distribution.Simple.SetupWrapper,
Distribution.Simple.SrcDist, Distribution.Simple.SrcDist,
Distribution.Simple.Utils, Distribution.Simple.Utils,
Distribution.System,
Distribution.Verbosity, Distribution.Verbosity,
Distribution.Version, Distribution.Version,
Distribution.Compat.ReadP, Distribution.Compat.ReadP,
......
...@@ -71,6 +71,7 @@ module Distribution.Program( ...@@ -71,6 +71,7 @@ module Distribution.Program(
import qualified Distribution.Compat.Map as Map import qualified Distribution.Compat.Map as Map
import Distribution.Compat.Directory (findExecutable) import Distribution.Compat.Directory (findExecutable)
import Distribution.Simple.Utils (die, rawSystemExit, rawSystemStdout) import Distribution.Simple.Utils (die, rawSystemExit, rawSystemStdout)
import Distribution.System
import Distribution.Version (Version, readVersion) import Distribution.Version (Version, readVersion)
import Distribution.Verbosity import Distribution.Verbosity
import System.Directory (doesFileExist) import System.Directory (doesFileExist)
...@@ -261,11 +262,11 @@ greencardProgram :: Program ...@@ -261,11 +262,11 @@ greencardProgram :: Program
greencardProgram = simpleProgram "greencard" greencardProgram = simpleProgram "greencard"
ldProgram :: Program ldProgram :: Program
#if defined(mingw32_TARGET_OS) || defined(mingw32_HOST_OS) ldProgram = case os of
ldProgram = Program "ld" "ld" [] (FoundOnSystem "<what-your-hs-compiler-shipped-with>") Windows MingW ->
#else Program "ld" "ld" Nothing []
ldProgram = simpleProgram "ld" (FoundOnSystem "<what-your-hs-compiler-shipped-with>")
#endif _ -> simpleProgram "ld"
tarProgram :: Program tarProgram :: Program
tarProgram = simpleProgram "tar" tarProgram = simpleProgram "tar"
......
...@@ -65,6 +65,7 @@ import Distribution.Simple.LocalBuildInfo ...@@ -65,6 +65,7 @@ import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Configure import Distribution.Simple.Configure
( localBuildInfoFile ) ( localBuildInfoFile )
import Distribution.Simple.Utils( createDirectoryIfMissingVerbose, die ) import Distribution.Simple.Utils( createDirectoryIfMissingVerbose, die )
import Distribution.System
import System.FilePath ( (</>), pathSeparator ) import System.FilePath ( (</>), pathSeparator )
...@@ -242,11 +243,14 @@ buildPathsModule pkg_descr lbi = ...@@ -242,11 +243,14 @@ buildPathsModule pkg_descr lbi =
mkGetDir _ (Just dirrel) = "getPrefixDirRel " ++ show dirrel mkGetDir _ (Just dirrel) = "getPrefixDirRel " ++ show dirrel
mkGetDir dir Nothing = "return " ++ show dir mkGetDir dir Nothing = "return " ++ show dir
#if mingw32_HOST_OS absolute = case os of
absolute = hasLibs pkg_descr || flat_bindirrel == Nothing Windows MingW ->
#else hasLibs pkg_descr ||
absolute = hasLibs pkg_descr || flat_progdirrel == Nothing || not isHugs flat_bindirrel == Nothing
#endif _ ->
hasLibs pkg_descr ||
flat_progdirrel == Nothing ||
not isHugs
paths_modulename = autogenModuleName pkg_descr paths_modulename = autogenModuleName pkg_descr
paths_filename = paths_modulename ++ ".hs" paths_filename = paths_modulename ++ ".hs"
...@@ -319,18 +323,14 @@ filename_stuff = ...@@ -319,18 +323,14 @@ filename_stuff =
" _ -> path1\n"++ " _ -> path1\n"++
"\n"++ "\n"++
"pathSeparator :: Char\n"++ "pathSeparator :: Char\n"++
#if mingw32_HOST_OS (case os of
"pathSeparator = '\\\\'\n"++ Windows _ -> "pathSeparator = '\\\\'\n"
#else _ -> "pathSeparator = '/'\n") ++
"pathSeparator = '/'\n"++
#endif
"\n"++ "\n"++
"isPathSeparator :: Char -> Bool\n"++ "isPathSeparator :: Char -> Bool\n"++
#if mingw32_HOST_OS (case os of
"isPathSeparator c = c == '/' || c == '\\\\'\n" Windows _ -> "isPathSeparator c = c == '/' || c == '\\\\'\n"
#else _ -> "isPathSeparator c = c == '/'\n")
"isPathSeparator c = c == '/'\n"
#endif
-- ------------------------------------------------------------ -- ------------------------------------------------------------
-- * Testing -- * Testing
......
...@@ -67,6 +67,7 @@ module Distribution.Simple.Configure (configure, ...@@ -67,6 +67,7 @@ module Distribution.Simple.Configure (configure,
import Distribution.Simple.LocalBuildInfo import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Register (removeInstalledConfig) import Distribution.Simple.Register (removeInstalledConfig)
import Distribution.Setup(ConfigFlags(..), CopyDest(..)) import Distribution.Setup(ConfigFlags(..), CopyDest(..))
import Distribution.System
import Distribution.Compiler(CompilerFlavor(..), Compiler(..), import Distribution.Compiler(CompilerFlavor(..), Compiler(..),
compilerVersion, compilerPath, compilerPkgToolPath, compilerVersion, compilerPath, compilerPkgToolPath,
extensionsToFlags) extensionsToFlags)
...@@ -78,7 +79,7 @@ import Distribution.PackageDescription( ...@@ -78,7 +79,7 @@ import Distribution.PackageDescription(
finalizePackageDescription, finalizePackageDescription,
HookedBuildInfo, sanityCheckPackage, updatePackageDescription, HookedBuildInfo, sanityCheckPackage, updatePackageDescription,
BuildInfo(..), Executable(..), setupMessage, BuildInfo(..), Executable(..), setupMessage,
satisfyDependency) satisfyDependency, hasLibs)
import Distribution.Simple.Utils (die, warn, rawSystemStdout) import Distribution.Simple.Utils (die, warn, rawSystemStdout)
import Distribution.Version (Version(..), Dependency(..), VersionRange(ThisVersion), import Distribution.Version (Version(..), Dependency(..), VersionRange(ThisVersion),
showVersion, showVersionRange) showVersion, showVersionRange)
...@@ -113,10 +114,6 @@ import Distribution.Compat.ReadP ...@@ -113,10 +114,6 @@ import Distribution.Compat.ReadP
import Distribution.Compat.Directory (createDirectoryIfMissing) import Distribution.Compat.Directory (createDirectoryIfMissing)
import Prelude hiding (catch) import Prelude hiding (catch)
#ifdef mingw32_HOST_OS
import Distribution.PackageDescription (hasLibs)
#endif
#ifdef DEBUG #ifdef DEBUG
import Test.HUnit import Test.HUnit
#endif #endif
...@@ -316,23 +313,15 @@ messageDir :: PackageDescription -> LocalBuildInfo -> String ...@@ -316,23 +313,15 @@ messageDir :: PackageDescription -> LocalBuildInfo -> String
-> (PackageDescription -> LocalBuildInfo -> CopyDest -> FilePath) -> (PackageDescription -> LocalBuildInfo -> CopyDest -> FilePath)
-> (PackageDescription -> LocalBuildInfo -> CopyDest -> Maybe FilePath) -> (PackageDescription -> LocalBuildInfo -> CopyDest -> Maybe FilePath)
-> IO () -> IO ()
messageDir pkg_descr lbi name mkDir messageDir pkg_descr lbi name mkDir mkDirRel
#if mingw32_HOST_OS
mkDirRel
#else
_
#endif
= message (name ++ " installed in: " ++ mkDir pkg_descr lbi NoCopyDest ++ rel_note) = message (name ++ " installed in: " ++ mkDir pkg_descr lbi NoCopyDest ++ rel_note)
where where
#if mingw32_HOST_OS rel_note = case os of
rel_note Windows MingW
| not (hasLibs pkg_descr) && | not (hasLibs pkg_descr) &&
mkDirRel pkg_descr lbi NoCopyDest == Nothing mkDirRel pkg_descr lbi NoCopyDest == Nothing
= " (fixed location)" -> " (fixed location)"
| otherwise = "" _ -> ""
#else
rel_note = ""
#endif
-- |Converts build dependencies to a versioned dependency. only sets -- |Converts build dependencies to a versioned dependency. only sets
-- version information for exact versioned dependencies. -- version information for exact versioned dependencies.
......
...@@ -76,6 +76,7 @@ import Distribution.Version ( Version(..) ) ...@@ -76,6 +76,7 @@ import Distribution.Version ( Version(..) )
import qualified Distribution.Simple.GHCPackageConfig as GHC import qualified Distribution.Simple.GHCPackageConfig as GHC
( localPackageConfig, ( localPackageConfig,
canReadLocalPackageConfig ) canReadLocalPackageConfig )
import Distribution.System
import Distribution.Verbosity import Distribution.Verbosity
import Language.Haskell.Extension (Extension(..)) import Language.Haskell.Extension (Extension(..))
...@@ -271,14 +272,11 @@ build pkg_descr lbi verbosity = do ...@@ -271,14 +272,11 @@ build pkg_descr lbi verbosity = do
runAr = rawSystemProgramConf verbosity "ar" (withPrograms lbi) runAr = rawSystemProgramConf verbosity "ar" (withPrograms lbi)
#if defined(mingw32_TARGET_OS) || defined(mingw32_HOST_OS) rawSystemLd = case os of
rawSystemLd = rawSystemExit Windows MingW -> rawSystemExit
maxCommandLineSize = 30 * 1024 _ -> rawSystemPathExit
#else
rawSystemLd = rawSystemPathExit
--TODO: discover this at configure time on unix --TODO: discover this at configure time on unix
maxCommandLineSize = 30 * 1024 maxCommandLineSize = 30 * 1024
#endif
ifVanillaLib False $ xargs maxCommandLineSize ifVanillaLib False $ xargs maxCommandLineSize
runAr arArgs arObjArgs runAr arArgs arObjArgs
...@@ -430,22 +428,18 @@ mkGHCiLibName pref lib = pref </> ("HS" ++ lib) <.> ".o" ...@@ -430,22 +428,18 @@ mkGHCiLibName pref lib = pref </> ("HS" ++ lib) <.> ".o"
findLdProgram :: LocalBuildInfo -> IO FilePath findLdProgram :: LocalBuildInfo -> IO FilePath
#if defined(mingw32_TARGET_OS) || defined(mingw32_HOST_OS) findLdProgram lbi
findLdProgram lbi = = case os of
let Windows MingW ->
compilerDir = takeDirectory $ compilerPath (compiler lbi) do let compilerDir = takeDirectory $ compilerPath (compiler lbi)
baseDir = takeDirectory compilerDir baseDir = takeDirectory compilerDir
binInstallLd = baseDir </> "gcc-lib" </> "ld.exe" binInstallLd = baseDir </> "gcc-lib" </> "ld.exe"
in do mb <- lookupProgram "ld" (withPrograms lbi)
mb <- lookupProgram "ld" (withPrograms lbi) case fmap programLocation mb of
case fmap programLocation mb of Just (UserSpecified s) -> return s
Just (UserSpecified s) -> return s -- assume we're using an installed copy of GHC..
-- assume we're using an installed copy of GHC.. _ -> return binInstallLd
_ -> return binInstallLd _ -> return "ld"
#else
findLdProgram _ =
return "ld"
#endif
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
-- Building a Makefile -- Building a Makefile
......
...@@ -66,6 +66,7 @@ import Distribution.Compat.Directory ...@@ -66,6 +66,7 @@ import Distribution.Compat.Directory
( copyFile, removeDirectoryRecursive ) ( copyFile, removeDirectoryRecursive )
import System.FilePath ( (</>), takeExtension, (<.>), import System.FilePath ( (</>), takeExtension, (<.>),
searchPathSeparator, normalise, takeDirectory ) searchPathSeparator, normalise, takeDirectory )
import Distribution.System
import Distribution.Verbosity import Distribution.Verbosity
import Distribution.Package ( PackageIdentifier(..) ) import Distribution.Package ( PackageIdentifier(..) )
...@@ -343,17 +344,18 @@ install verbosity libDir installProgDir binDir targetProgDir buildPref pkg_descr ...@@ -343,17 +344,18 @@ install verbosity libDir installProgDir binDir targetProgDir buildPref pkg_descr
-- FIX (HUGS): use extensions, and options from file too? -- FIX (HUGS): use extensions, and options from file too?
-- see http://hackage.haskell.org/trac/hackage/ticket/43 -- see http://hackage.haskell.org/trac/hackage/ticket/43
let hugsOptions = hcOptions Hugs (options (buildInfo exe)) let hugsOptions = hcOptions Hugs (options (buildInfo exe))
#if mingw32_HOST_OS || mingw32_TARGET_OS let exeFile = case os of
let exeFile = binDir </> exeName exe <.> ".bat" Windows _ -> binDir </> exeName exe <.> ".bat"
let script = unlines [ _ -> binDir </> exeName exe
"@echo off", let script = case os of
unwords ("runhugs" : hugsOptions ++ [targetName, "%*"])] Windows _ ->
#else let args = hugsOptions ++ [targetName, "%*"]
let exeFile = binDir </> exeName exe in unlines ["@echo off",
let script = unlines [ unwords ("runhugs" : args)]
"#! /bin/sh", _ ->
unwords ("runhugs" : hugsOptions ++ [targetName, "\"$@\""])] let args = hugsOptions ++ [targetName, "\"$@\""]
#endif in unlines ["#! /bin/sh",
unwords ("runhugs" : args)]
writeFile exeFile script writeFile exeFile script
perms <- getPermissions exeFile perms <- getPermissions exeFile
setPermissions exeFile perms { executable = True, readable = True } setPermissions exeFile perms { executable = True, readable = True }
......
...@@ -73,6 +73,7 @@ import Distribution.PackageDescription (PackageDescription(..)) ...@@ -73,6 +73,7 @@ import Distribution.PackageDescription (PackageDescription(..))
import Distribution.Package (PackageIdentifier(..), showPackageId) import Distribution.Package (PackageIdentifier(..), showPackageId)
import Distribution.Compiler (Compiler(..), CompilerFlavor(..), showCompilerId) import Distribution.Compiler (Compiler(..), CompilerFlavor(..), showCompilerId)
import Distribution.Setup (CopyDest(..)) import Distribution.Setup (CopyDest(..))
import Distribution.System
import Distribution.Version (showVersion) import Distribution.Version (showVersion)
import System.FilePath import System.FilePath
#if mingw32_HOST_OS || mingw32_TARGET_OS #if mingw32_HOST_OS || mingw32_TARGET_OS
...@@ -222,35 +223,29 @@ foreign import stdcall unsafe "shlobj.h SHGetFolderPathA" ...@@ -222,35 +223,29 @@ foreign import stdcall unsafe "shlobj.h SHGetFolderPathA"
#endif #endif
default_bindir :: FilePath default_bindir :: FilePath
default_bindir = "$prefix" </> default_bindir = "$prefix" </> path
#if mingw32_HOST_OS || mingw32_TARGET_OS where path = case os of
"Haskell" </> "bin" Windows _ -> "Haskell" </> "bin"
#else _ -> "bin"
"bin"
#endif
default_libdir :: Compiler -> FilePath default_libdir :: Compiler -> FilePath
default_libdir _ = "$prefix" </> default_libdir _ = "$prefix" </> path
#if mingw32_HOST_OS || mingw32_TARGET_OS where path = case os of
"Haskell" Windows _ -> "Haskell"
#else _ -> "lib"
"lib"
#endif
default_libsubdir :: Compiler -> FilePath default_libsubdir :: Compiler -> FilePath
default_libsubdir hc = default_libsubdir hc =
case compilerFlavor hc of case compilerFlavor hc of
Hugs -> "hugs" </> "packages" </> "$pkg" Hugs -> "hugs" </> "packages" </> "$pkg"
JHC -> "$compiler" JHC -> "$compiler"
_ -> "$pkgid" </> "$compiler" _ -> "$pkgid" </> "$compiler"
default_libexecdir :: FilePath default_libexecdir :: FilePath
default_libexecdir = "$prefix" </> default_libexecdir = "$prefix" </> path
#if mingw32_HOST_OS || mingw32_TARGET_OS where path = case os of
"$pkgid" Windows _ -> "$pkgid"
#else _ -> "libexec"
"libexec"
#endif
default_datadir :: PackageDescription -> IO FilePath default_datadir :: PackageDescription -> IO FilePath
#if mingw32_HOST_OS || mingw32_TARGET_OS #if mingw32_HOST_OS || mingw32_TARGET_OS
...@@ -333,18 +328,7 @@ absolutePath pkg_descr lbi copydest s = ...@@ -333,18 +328,7 @@ absolutePath pkg_descr lbi copydest s =
case copydest of case copydest of
NoCopyDest -> substDir (package pkg_descr) lbi s NoCopyDest -> substDir (package pkg_descr) lbi s
CopyPrefix d -> substDir (package pkg_descr) lbi{prefix=d} s CopyPrefix d -> substDir (package pkg_descr) lbi{prefix=d} s
CopyTo p -> p </> (dropAbsolutePrefix (substDir (package pkg_descr) lbi s)) CopyTo p -> p </> (dropDrive (substDir (package pkg_descr) lbi s))
where
-- | If the function is applied to an absolute path then it returns a local path droping
-- the absolute prefix in the path. Under Windows the prefix is \"\\\", \"c:\" or \"c:\\\". Under
-- Unix the prefix is always \"\/\".
dropAbsolutePrefix :: FilePath -> FilePath
dropAbsolutePrefix (c:cs) | isPathSeparator c = cs
#if mingw32_HOST_OS || mingw32_TARGET_OS
dropAbsolutePrefix (_:':':c:cs) | isPathSeparator c = cs -- path with drive letter
dropAbsolutePrefix (_:':':cs) = cs
#endif
dropAbsolutePrefix cs = cs
substDir :: PackageIdentifier -> LocalBuildInfo -> String -> String substDir :: PackageIdentifier -> LocalBuildInfo -> String -> String
substDir pkgId lbi xs = loop xs substDir pkgId lbi xs = loop xs
......
...@@ -81,6 +81,7 @@ import Distribution.Simple.Utils (createDirectoryIfMissingVerbose, ...@@ -81,6 +81,7 @@ import Distribution.Simple.Utils (createDirectoryIfMissingVerbose,
import Distribution.Simple.GHCPackageConfig (mkGHCPackageConfig, showGHCPackageConfig) import Distribution.Simple.GHCPackageConfig (mkGHCPackageConfig, showGHCPackageConfig)
import qualified Distribution.Simple.GHCPackageConfig import qualified Distribution.Simple.GHCPackageConfig
as GHC (localPackageConfig, canWriteLocalPackageConfig, maybeCreateLocalPackageConfig) as GHC (localPackageConfig, canWriteLocalPackageConfig, maybeCreateLocalPackageConfig)
import Distribution.System
import Distribution.Compat.Directory import Distribution.Compat.Directory
(removeDirectoryRecursive, (removeDirectoryRecursive,
setPermissions, getPermissions, Permissions(executable) setPermissions, getPermissions, Permissions(executable)
...@@ -100,18 +101,14 @@ import Test.HUnit (Test) ...@@ -100,18 +101,14 @@ import Test.HUnit (Test)
#endif #endif
regScriptLocation :: FilePath regScriptLocation :: FilePath
#if mingw32_HOST_OS || mingw32_TARGET_OS regScriptLocation = case os of
regScriptLocation = "register.bat" Windows _ -> "register.bat"
#else _ -> "register.sh"
regScriptLocation = "register.sh"
#endif
unregScriptLocation :: FilePath unregScriptLocation :: FilePath
#if mingw32_HOST_OS || mingw32_TARGET_OS unregScriptLocation = case os of
unregScriptLocation = "unregister.bat" Windows _ -> "unregister.bat"
#else _ -> "unregister.sh"
unregScriptLocation = "unregister.sh"
#endif
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
-- Registration -- Registration
...@@ -165,23 +162,19 @@ register pkg_descr lbi regFlags ...@@ -165,23 +162,19 @@ register pkg_descr lbi regFlags
putStrLn ("create " ++ instConf) putStrLn ("create " ++ instConf)
writeInstalledConfig pkg_descr lbi inplace (Just instConf) writeInstalledConfig pkg_descr lbi inplace (Just instConf)
let register_flags let register_flags
| ghc_63_plus = "update": | ghc_63_plus = let conf = case os of
#if !(mingw32_HOST_OS || mingw32_TARGET_OS) Windows MingW
if genScript | genScript -> []
then [] _ -> [instConf]
else in "update" : conf
#endif | otherwise = let conf = case os of
[instConf] Windows MingW
| otherwise = "--update-package": | genScript -> []
#if !(mingw32_HOST_OS || mingw32_TARGET_OS) _ -> ["--input-file="++instConf]
if genScript in "--update-package" : conf
then []
else let allFlags = register_flags
#endif
["--input-file="++instConf]
let allFlags = register_flags
++ config_flags ++ config_flags
++ if ghc_63_plus && genScript then ["-"] else [] ++ if ghc_63_plus && genScript then ["-"] else []
let pkgTool = compilerPkgToolPath hc let pkgTool = compilerPkgToolPath hc
...@@ -374,16 +367,15 @@ rawSystemEmit :: FilePath -- ^Script name ...@@ -374,16 +367,15 @@ rawSystemEmit :: FilePath -- ^Script name
-> IO () -> IO ()
rawSystemEmit _ False verbosity path args rawSystemEmit _ False verbosity path args
= rawSystemExit verbosity path args = rawSystemExit verbosity path args
rawSystemEmit scriptName True _ path args = do rawSystemEmit scriptName True _ path args
#if mingw32_HOST_OS || mingw32_TARGET_OS = case os of
writeFile scriptName ("@" ++ path ++ concatMap (' ':) args) Windows _ ->
#else writeFile scriptName ("@" ++ path ++ concatMap (' ':) args)
writeFile scriptName ("#!/bin/sh\n\n" _ -> do writeFile scriptName ("#!/bin/sh\n\n"
++ (path ++ concatMap (' ':) args) ++ (path ++ concatMap (' ':) args)
++ "\n") ++ "\n")
p <- getPermissions scriptName p <- getPermissions scriptName
setPermissions scriptName p{executable=True} setPermissions scriptName p{executable=True}
#endif
-- |Like rawSystemEmit, except it has string for pipeFrom. FIX: chmod +x -- |Like rawSystemEmit, except it has string for pipeFrom. FIX: chmod +x
rawSystemPipe :: FilePath -- ^Script location rawSystemPipe :: FilePath -- ^Script location
...@@ -392,18 +384,17 @@ rawSystemPipe :: FilePath -- ^Script location ...@@ -392,18 +384,17 @@ rawSystemPipe :: FilePath -- ^Script location
-> FilePath -- ^Program to run -> FilePath -- ^Program to run
-> [String] -- ^Args -> [String] -- ^Args
-> IO () -> IO ()
rawSystemPipe scriptName _ pipeFrom path args = do rawSystemPipe scriptName _ pipeFrom path args
#if mingw32_HOST_OS || mingw32_TARGET_OS = case os of
writeFile scriptName ("@" ++ path ++ concatMap (' ':) args) Windows _ ->
#else writeFile scriptName ("@" ++ path ++ concatMap (' ':) args)
writeFile scriptName ("#!/bin/sh\n\n" _ -> do writeFile scriptName ("#!/bin/sh\n\n"
++ "echo '" ++ escapeForShell pipeFrom ++ "echo '" ++ escapeForShell pipeFrom
++ "' | " ++ "' | "
++ (path ++ concatMap (' ':) args) ++ (path ++ concatMap (' ':) args)
++ "\n") ++ "\n")
p <- getPermissions scriptName p <- getPermissions scriptName
setPermissions scriptName p{executable=True} setPermissions scriptName p{executable=True}
#endif
where escapeForShell [] = [] where escapeForShell [] = []
escapeForShell ('\'':cs) = "'\\''" ++ escapeForShell cs escapeForShell ('\'':cs) = "'\\''" ++ escapeForShell cs
escapeForShell (c :cs) = c : escapeForShell cs escapeForShell (c :cs) = c : escapeForShell cs
......
...@@ -84,6 +84,7 @@ module Distribution.Simple.Utils ( ...@@ -84,6 +84,7 @@ module Distribution.Simple.Utils (
import Distribution.Compat.RawSystem (rawSystem) import Distribution.Compat.RawSystem (rawSystem)
import Distribution.Compat.Exception (bracket) import Distribution.Compat.Exception (bracket)
import Distribution.System
#if __GLASGOW_HASKELL__ >= 604 #if __GLASGOW_HASKELL__ >= 604
import Control.Exception (evaluate) import Control.Exception (evaluate)
...@@ -470,11 +471,9 @@ findHookedPackageDesc dir = do ...@@ -470,11 +471,9 @@ findHookedPackageDesc dir = do
-- | Extension for executable files -- | Extension for executable files
-- (typically @\"\"@ on Unix and @\"exe\"@ on Windows or OS\/2) -- (typically @\"\"@ on Unix and @\"exe\"@ on Windows or OS\/2)
exeExtension :: String exeExtension :: String
#if mingw32_HOST_OS || mingw32_TARGET_OS exeExtension = case os of
exeExtension = "exe" Windows _ -> "exe"
#else _ -> ""
exeExtension = ""
#endif
-- ToDo: This should be determined via autoconf (AC_OBJEXT) -- ToDo: This should be determined via autoconf (AC_OBJEXT)
-- | Extension for object files. For GHC and NHC the extension is @\"o\"@. -- | Extension for object files. For GHC and NHC the extension is @\"o\"@.
...@@ -485,12 +484,9 @@ objExtension = "o" ...@@ -485,12 +484,9 @@ objExtension = "o"
-- | Extension for dynamically linked (or shared) libraries -- | Extension for dynamically linked (or shared) libraries
-- (typically @\"so\"@ on Unix and @\"dll\"@ on Windows) -- (typically @\"so\"@ on Unix and @\"dll\"@ on Windows)
dllExtension :: String dllExtension :: String
#if mingw32_HOST_OS || mingw32_TARGET_OS dllExtension = case os of
dllExtension = "dll" Windows _ -> "dll"
#else _ -> "so"
dllExtension = "so"
#endif
-- ------------------------------------------------------------ -- ------------------------------------------------------------
-- * Testing -- * Testing
......