Drop support for -this-package-key
[hadrian.git] / src / Environment.hs
1 module Environment (setupEnvironment) where
2
3 import System.Environment
4
5 import Base
6
7 -- | The build system invokes many external builders whose behaviour is
8 -- influenced by the environment variables. We need to modify some of them
9 -- for better robustness of the build system.
10 setupEnvironment :: IO ()
11 setupEnvironment = do
12 -- ghc-cabal refuses to work when GHC_PACKAGE_PATH is set (e.g. by Stack)
13 unsetEnv "GHC_PACKAGE_PATH"
14
15 -- in MinGW if PWD is set to a Windows "C:\\" style path then configure
16 -- `pwd` will return the Windows path, and then modifying $PATH will fail.
17 -- See https://github.com/snowleopard/hadrian/issues/189 for details.
18 unsetEnv "PWD"
19
20 -- On Windows, some path variables start a prefix like "C:\\" which may
21 -- lead to failures of scripts such as autoreconf. One particular variable
22 -- which causes issues is ACLOCAL_PATH. At the moment we simply reset it
23 -- if it contains a problematic Windows path.
24 -- TODO: Handle Windows paths in ACLOCAL_PATH more gracefully.
25 aclocal <- lookupEnv "ACLOCAL_PATH"
26 case aclocal of
27 Nothing -> return ()
28 Just s -> when (":\\" `isPrefixOf` drop 1 s) $ unsetEnv "ACLOCAL_PATH"