summaryrefslogtreecommitdiff
path: root/compiler/GHC/Platform.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Platform.hs')
-rw-r--r--compiler/GHC/Platform.hs27
1 files changed, 24 insertions, 3 deletions
diff --git a/compiler/GHC/Platform.hs b/compiler/GHC/Platform.hs
index 856903bbd1..09c6ef37aa 100644
--- a/compiler/GHC/Platform.hs
+++ b/compiler/GHC/Platform.hs
@@ -31,19 +31,24 @@ module GHC.Platform
, PlatformMisc(..)
, SseVersion (..)
, BmiVersion (..)
+ -- * Shared libraries
+ , platformSOName
+ , platformHsSOName
+ , platformSOExt
)
where
import Prelude -- See Note [Why do we import Prelude here?]
-import Data.Word
-import Data.Int
-
import GHC.Read
import GHC.ByteOrder (ByteOrder(..))
import GHC.Platform.Constants
import GHC.Platform.ArchOS
+import Data.Word
+import Data.Int
+import System.FilePath
+
-- | Platform description
--
-- This is used to describe platforms so that we can generate code for them.
@@ -212,3 +217,19 @@ data PlatformMisc = PlatformMisc
, platformMisc_ghcRtsWithLibdw :: Bool
, platformMisc_llvmTarget :: String
}
+
+platformSOName :: Platform -> FilePath -> FilePath
+platformSOName platform root = case platformOS platform of
+ OSMinGW32 -> root <.> platformSOExt platform
+ _ -> ("lib" ++ root) <.> platformSOExt platform
+
+platformHsSOName :: Platform -> FilePath -> FilePath
+platformHsSOName platform root = ("lib" ++ root) <.> platformSOExt platform
+
+platformSOExt :: Platform -> FilePath
+platformSOExt platform
+ = case platformOS platform of
+ OSDarwin -> "dylib"
+ OSMinGW32 -> "dll"
+ _ -> "so"
+