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

Remove more ifdeffery

parent 9181d6e9
...@@ -447,13 +447,14 @@ preloadLib dflags lib_paths framework_paths lib_spec ...@@ -447,13 +447,14 @@ preloadLib dflags lib_paths framework_paths lib_spec
Nothing -> maybePutStrLn dflags "done" Nothing -> maybePutStrLn dflags "done"
Just mm -> preloadFailed mm lib_paths lib_spec Just mm -> preloadFailed mm lib_paths lib_spec
#ifdef darwin_TARGET_OS
Framework framework Framework framework
| isDarwinTarget
-> do maybe_errstr <- loadFramework framework_paths framework -> do maybe_errstr <- loadFramework framework_paths framework
case maybe_errstr of case maybe_errstr of
Nothing -> maybePutStrLn dflags "done" Nothing -> maybePutStrLn dflags "done"
Just mm -> preloadFailed mm framework_paths lib_spec Just mm -> preloadFailed mm framework_paths lib_spec
#endif | otherwise -> panic "preloadLib Framework"
where where
preloadFailed :: String -> [String] -> LibrarySpec -> IO () preloadFailed :: String -> [String] -> LibrarySpec -> IO ()
preloadFailed sys_errmsg paths spec preloadFailed sys_errmsg paths spec
...@@ -1052,10 +1053,10 @@ load_dyn dirs dll = do r <- loadDynamic dirs dll ...@@ -1052,10 +1053,10 @@ load_dyn dirs dll = do r <- loadDynamic dirs dll
Nothing -> return () Nothing -> return ()
Just err -> throwDyn (CmdLineError ("can't load .so/.DLL for: " Just err -> throwDyn (CmdLineError ("can't load .so/.DLL for: "
++ dll ++ " (" ++ err ++ ")" )) ++ dll ++ " (" ++ err ++ ")" ))
#ifndef darwin_TARGET_OS
loadFrameworks pkg = return () loadFrameworks pkg
#else | isDarwinTarget = mapM_ load frameworks
loadFrameworks pkg = mapM_ load frameworks | otherwise = return ()
where where
fw_dirs = Packages.frameworkDirs pkg fw_dirs = Packages.frameworkDirs pkg
frameworks = Packages.frameworks pkg frameworks = Packages.frameworks pkg
...@@ -1065,7 +1066,6 @@ loadFrameworks pkg = mapM_ load frameworks ...@@ -1065,7 +1066,6 @@ loadFrameworks pkg = mapM_ load frameworks
Nothing -> return () Nothing -> return ()
Just err -> throwDyn (CmdLineError ("can't load framework: " Just err -> throwDyn (CmdLineError ("can't load framework: "
++ fw ++ " (" ++ err ++ ")" )) ++ fw ++ " (" ++ err ++ ")" ))
#endif
-- Try to find an object file for a given library in the given paths. -- Try to find an object file for a given library in the given paths.
-- If it isn't present, we assume it's a dynamic library. -- If it isn't present, we assume it's a dynamic library.
...@@ -1117,20 +1117,16 @@ loadDynamic paths rootname ...@@ -1117,20 +1117,16 @@ loadDynamic paths rootname
where where
mk_dll_path dir = dir </> mkSOName rootname mk_dll_path dir = dir </> mkSOName rootname
#if defined(darwin_TARGET_OS) mkSOName root
mkSOName root = ("lib" ++ root) <.> "dylib" | isDarwinTarget = ("lib" ++ root) <.> "dylib"
#elif defined(mingw32_TARGET_OS) | isWindowsTarget = -- Win32 DLLs have no .dll extension here, because
-- Win32 DLLs have no .dll extension here, because addDLL tries -- addDLL tries both foo.dll and foo.drv
-- both foo.dll and foo.drv root
mkSOName root = root | otherwise = ("lib" ++ root) <.> "so"
#else
mkSOName root = ("lib" ++ root) <.> "so"
#endif
-- Darwin / MacOS X only: load a framework -- Darwin / MacOS X only: load a framework
-- a framework is a dynamic library packaged inside a directory of the same -- a framework is a dynamic library packaged inside a directory of the same
-- name. They are searched for in different paths than normal libraries. -- name. They are searched for in different paths than normal libraries.
#ifdef darwin_TARGET_OS
loadFramework extraPaths rootname loadFramework extraPaths rootname
= do { either_dir <- Control.Exception.try getHomeDirectory = do { either_dir <- Control.Exception.try getHomeDirectory
; let homeFrameworkPath = case either_dir of ; let homeFrameworkPath = case either_dir of
...@@ -1147,7 +1143,6 @@ loadFramework extraPaths rootname ...@@ -1147,7 +1143,6 @@ loadFramework extraPaths rootname
mk_fwk dir = dir </> (rootname ++ ".framework/" ++ rootname) mk_fwk dir = dir </> (rootname ++ ".framework/" ++ rootname)
-- sorry for the hardcoded paths, I hope they won't change anytime soon: -- sorry for the hardcoded paths, I hope they won't change anytime soon:
defaultFrameworkPaths = ["/Library/Frameworks", "/System/Library/Frameworks"] defaultFrameworkPaths = ["/Library/Frameworks", "/System/Library/Frameworks"]
#endif
\end{code} \end{code}
%************************************************************************ %************************************************************************
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment