{-# OPTIONS -fno-warn-incomplete-patterns #-}
-----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.66 2001/05/28 03:31:19 sof Exp $
+-- $Id: Main.hs,v 1.68 2001/06/13 10:23:23 simonmar Exp $
--
-- GHC Driver program
--
-----------------------------------------------------------------------------
-- ToDo:
--- -nohi doesn't work
-- new mkdependHS doesn't support all the options that the old one did (-X et al.)
-- time commands when run with -v
-- split marker
Left err -> throwDyn (InstallationError (showSDoc err));
Right pkg_details -> do
- writeIORef v_Package_details pkg_details
+ writeIORef v_Package_details (mungePackagePaths top_dir pkg_details)
-- find the phase to stop after (i.e. -E, -C, -c, -S flags)
(flags2, mode, stop_flag) <- getGhcMode argv'
when (mode == DoLink) (doLink o_files)
when (mode == DoMkDLL) (doMkDLL o_files)
}
- -- grab the last -B option on the command line, and
- -- set topDir to its value.
+
+
+-- grab the last -B option on the command line, and
+-- set topDir to its value.
setTopDir :: [String] -> IO [String]
setTopDir args = do
let (minusbs, others) = partition (prefixMatch "-B") args
some -> writeIORef v_TopDir (drop 2 (last some)))
return others
+
+-- replace the string "$libdir" at the beginning of a path with the
+-- current TOPDIR (obtained from the -B option if present, or the
+-- wired-in libdir otherwise).
+mungePackagePaths top_dir ps = map munge_pkg ps
+ where
+ munge_pkg p = p{ import_dirs = munge_paths (import_dirs p),
+ include_dirs = munge_paths (include_dirs p),
+ library_dirs = munge_paths (library_dirs p) }
+
+ munge_paths = map munge_path
+
+ munge_path p
+ | Just p' <- my_prefix_match "$libdir" p = top_dir ++ p'
+ | otherwise = trace ("not: " ++ p) p
+
+
beginMake :: [String] -> IO ()
beginMake fileish_args
= do let (objs, mods) = partition objish_file fileish_args