{-# LANGUAGE CPP #-} {-# LANGUAGE ScopedTypeVariables #-} {- ----------------------------------------------------------------------------- -- -- (c) The University of Glasgow 2001-2017 -- -- Finding the compiler's base directory. -- ----------------------------------------------------------------------------- -} module SysTools.BaseDir ( expandTopDir, expandToolDir , findTopDir, findToolDir ) where #include "HsVersions.h" import GhcPrelude import Panic import System.Environment (lookupEnv) import System.FilePath import Data.List -- POSIX #if defined(darwin_HOST_OS) || defined(linux_HOST_OS) || defined(freebsd_HOST_OS) import System.Environment (getExecutablePath) #endif -- Windows #if defined(mingw32_HOST_OS) import System.Environment (getExecutablePath) import System.Directory (doesDirectoryExist) #endif #if defined(mingw32_HOST_OS) # if defined(i386_HOST_ARCH) # define WINDOWS_CCONV stdcall # elif defined(x86_64_HOST_ARCH) # define WINDOWS_CCONV ccall # else # error Unknown mingw32 arch # endif #endif {- Note [topdir: How GHC finds its files] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GHC needs various support files (library packages, RTS etc), plus various auxiliary programs (cp, gcc, etc). It starts by finding topdir, the root of GHC's support files On Unix: - ghc always has a shell wrapper that passes a -B