From de1dc327aec65641d113a2bf2e19d731d815b702 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Wed, 15 Nov 2017 13:59:17 +0800 Subject: [PATCH] Allow ${pkgroot} prefix. This change adds the ability to pass `--prefix=\${pkgroot}`. It is on purpose undocumented, as it should be only used with absolute care. --- Cabal/Distribution/Simple/Configure.hs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Cabal/Distribution/Simple/Configure.hs b/Cabal/Distribution/Simple/Configure.hs index 29ebe54b384..5aaf7f7f055 100644 --- a/Cabal/Distribution/Simple/Configure.hs +++ b/Cabal/Distribution/Simple/Configure.hs @@ -726,9 +726,25 @@ configure (pkg_descr0, pbi) cfg = do let dirs = absoluteInstallDirs pkg_descr lbi NoCopyDest relative = prefixRelativeInstallDirs (packageId pkg_descr) lbi - unless (isAbsolute (prefix dirs)) $ die' verbosity $ + -- PKGROOT: allowing ${pkgroot} to be passed as --prefix to + -- cabal configure, is only a hidden option. It allows packages + -- to be relocatable with their package database. This however + -- breaks when the Paths_* or other includes are used that + -- contain hard coded paths. This is still an open TODO. + -- + -- Allowing ${pkgroot} here, however requires less custom hooks + -- in scripts that *really* want ${pkgroot}. See haskell/cabal/#4872 + unless (isAbsolute (prefix dirs) + || "${pkgroot}" `isPrefixOf` prefix dirs) $ die' verbosity $ "expected an absolute directory name for --prefix: " ++ prefix dirs + when ("${pkgroot}" `isPrefixOf` prefix dirs) $ + warn verbosity $ "Using ${pkgroot} in prefix " ++ prefix dirs + ++ " will not work if you rely on the Path_* module " + ++ " or other hard coded paths. Cabal does not yet " + ++ " support fully relocatable builds! " + ++ " See #462 #2302 #2994 #3305 #3473 #3586 #3909 #4097 #4291 #4872" + info verbosity $ "Using " ++ display currentCabalId ++ " compiled by " ++ display currentCompilerId info verbosity $ "Using compiler: " ++ showCompilerId comp