+
+-- 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
+
+