- remove_suffix dir -- "/...stuff.../ghc/compiler" --> "/...stuff..."
- = ASSERT2( not (null p1) &&
- not (null p2) &&
- dir == top_dir ++ "/ghc/compiler",
- text dir )
- top_dir
+ -- In an installed tree, the ghc binary lives in $libexecdir, which
+ -- is normally $libdir/bin. So we strip off a /bin suffix here.
+ -- In a build tree, the ghc binary lives in $fptools/ghc/compiler,
+ -- so we strip off the /ghc/compiler suffix here too, leaving a
+ -- standard TOPDIR.
+ remove_suffix ghc_bin_dir -- ghc_bin_dir is in standard Unix format
+ | "/ghc/compiler" `isSuffixOf` ghc_bin_dir = back_two
+ | "/bin" `isSuffixOf` ghc_bin_dir = back_one
+ | otherwise = ghc_bin_dir