-----------------------------------------------------------------------------
--- $Id: DriverState.hs,v 1.42 2001/06/12 17:07:23 simonmar Exp $
+-- $Id: DriverState.hs,v 1.43 2001/06/13 10:23:23 simonmar Exp $
--
-- Settings for the driver
--
getPackageImportPath :: IO [String]
getPackageImportPath = do
ps <- getPackageInfo
- munge_paths (concatMap import_dirs ps)
+ return (nub (filter (not.null) (concatMap import_dirs ps)))
getPackageIncludePath :: IO [String]
getPackageIncludePath = do
ps <- getPackageInfo
- munge_paths (concatMap include_dirs ps)
+ return (nub (filter (not.null) (concatMap include_dirs ps)))
-- includes are in reverse dependency order (i.e. rts first)
getPackageCIncludes :: IO [String]
getPackageLibraryPath :: IO [String]
getPackageLibraryPath = do
ps <- getPackageInfo
- munge_paths (concatMap library_dirs ps)
+ return (nub (filter (not.null) (concatMap library_dirs ps)))
getPackageLibraries :: IO [String]
getPackageLibraries = do
[] -> Nothing
(p:_) -> Just p
-munge_paths ps = do
- topdir <- readIORef v_TopDir
- return (nub (filter (not.null) (map (munge_path topdir) ps)))
- where munge_path topdir p
- | Just p' <- my_prefix_match "$libdir" p = topdir ++ p'
- | otherwise = p
-
-----------------------------------------------------------------------------
-- Ways
{-# OPTIONS -fno-warn-incomplete-patterns #-}
-----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.67 2001/05/31 11:32:25 simonmar Exp $
+-- $Id: Main.hs,v 1.68 2001/06/13 10:23:23 simonmar Exp $
--
-- GHC Driver program
--
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