+
+mkObjPath :: FilePath -> String -> IO FilePath
+-- Construct the filename of a .o file.
+-- Does *not* check whether the .o file exists
+mkObjPath path basename
+ = do odir <- readIORef v_Output_dir
+ osuf <- readIORef v_Object_suf
+
+ let obj_path | Just d <- odir = d
+ | otherwise = path
+
+ return (obj_path ++ '/':basename ++ '.':osuf)
+
+-- -----------------------------------------------------------------------------
+-- findLinkable isn't related to the other stuff in here,
+-- but there's no other obvious place for it
+
+findLinkable :: ModuleName -> ModLocation -> IO (Maybe Linkable)
+findLinkable mod locn
+ = do let obj_fn = ml_obj_file locn
+ obj_exist <- doesFileExist obj_fn
+ if not obj_exist
+ then return Nothing
+ else
+ do let stub_fn = case splitFilename3 obj_fn of
+ (dir, base, ext) -> dir ++ "/" ++ base ++ "_stub.o"
+ stub_exist <- doesFileExist stub_fn
+ obj_time <- getModificationTime obj_fn
+ if stub_exist
+ then return (Just (LM obj_time mod [DotO obj_fn, DotO stub_fn]))
+ else return (Just (LM obj_time mod [DotO obj_fn]))
+
+-- -----------------------------------------------------------------------------
+-- Utils
+
+dots_to_slashes = map (\c -> if c == '.' then '/' else c)
+