Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Cabal/Distribution/Simple/Build/PathsModule.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ generate pkg_descr lbi =
pragmas++
"module " ++ display paths_modulename ++ " (\n"++
" version,\n"++
" getBinDir, getLibDir, getDataDir, getLibexecDir,\n"++
" getBinDir, getLibDir, getHiDir, getDataDir, getLibexecDir,\n"++
" getDataFileName, getSysconfDir\n"++
" ) where\n"++
"\n"++
Expand Down Expand Up @@ -108,9 +108,10 @@ generate pkg_descr lbi =
"\n\nbindirrel :: FilePath\n" ++
"bindirrel = " ++ show flat_bindirreloc ++
"\n"++
"\ngetBinDir, getLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"++
"\ngetBinDir, getLibDir, getHiDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"++
"getBinDir = "++mkGetEnvOrReloc "bindir" flat_bindirreloc++"\n"++
"getLibDir = "++mkGetEnvOrReloc "libdir" flat_libdirreloc++"\n"++
"getHiDir = "++mkGetEnvOrReloc "hidir" flat_hidirreloc++"\n"++
"getDataDir = "++mkGetEnvOrReloc "datadir" flat_datadirreloc++"\n"++
"getLibexecDir = "++mkGetEnvOrReloc "libexecdir" flat_libexecdirreloc++"\n"++
"getSysconfDir = "++mkGetEnvOrReloc "sysconfdir" flat_sysconfdirreloc++"\n"++
Expand All @@ -124,16 +125,18 @@ generate pkg_descr lbi =
"\n"++
filename_stuff
| absolute =
"\nbindir, libdir, datadir, libexecdir, sysconfdir :: FilePath\n"++
"\nbindir, libdir, hidir, datadir, libexecdir, sysconfdir :: FilePath\n"++
"\nbindir = " ++ show flat_bindir ++
"\nlibdir = " ++ show flat_libdir ++
"\nhidir = " ++ show flat_hidir ++
"\ndatadir = " ++ show flat_datadir ++
"\nlibexecdir = " ++ show flat_libexecdir ++
"\nsysconfdir = " ++ show flat_sysconfdir ++
"\n"++
"\ngetBinDir, getLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"++
"\ngetBinDir, getLibDir, getHiDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"++
"getBinDir = "++mkGetEnvOr "bindir" "return bindir"++"\n"++
"getLibDir = "++mkGetEnvOr "libdir" "return libdir"++"\n"++
"getHiDir = "++mkGetEnvOr "hidir" "return hidir"++"\n"++
"getDataDir = "++mkGetEnvOr "datadir" "return datadir"++"\n"++
"getLibexecDir = "++mkGetEnvOr "libexecdir" "return libexecdir"++"\n"++
"getSysconfDir = "++mkGetEnvOr "sysconfdir" "return sysconfdir"++"\n"++
Expand All @@ -151,6 +154,8 @@ generate pkg_descr lbi =
"getBinDir = getPrefixDirRel bindirrel\n\n"++
"getLibDir :: IO FilePath\n"++
"getLibDir = "++mkGetDir flat_libdir flat_libdirrel++"\n\n"++
"getHiDir :: IO FilePath\n"++
"getHiDir = "++mkGetDir flat_hidir flat_hidirrel++"\n\n"++
"getDataDir :: IO FilePath\n"++
"getDataDir = "++ mkGetEnvOr "datadir"
(mkGetDir flat_datadir flat_datadirrel)++"\n\n"++
Expand All @@ -173,20 +178,23 @@ generate pkg_descr lbi =
prefix = flat_prefix,
bindir = flat_bindir,
libdir = flat_libdir,
hidir = flat_hidir,
datadir = flat_datadir,
libexecdir = flat_libexecdir,
sysconfdir = flat_sysconfdir
} = absoluteInstallDirs pkg_descr lbi NoCopyDest
InstallDirs {
bindir = flat_bindirrel,
libdir = flat_libdirrel,
hidir = flat_hidirrel,
datadir = flat_datadirrel,
libexecdir = flat_libexecdirrel,
sysconfdir = flat_sysconfdirrel
} = prefixRelativeInstallDirs (packageId pkg_descr) lbi

flat_bindirreloc = shortRelativePath flat_prefix flat_bindir
flat_libdirreloc = shortRelativePath flat_prefix flat_libdir
flat_hidirreloc = shortRelativePath flat_prefix flat_hidir
flat_datadirreloc = shortRelativePath flat_prefix flat_datadir
flat_libexecdirreloc = shortRelativePath flat_prefix flat_libexecdir
flat_sysconfdirreloc = shortRelativePath flat_prefix flat_sysconfdir
Expand Down
3 changes: 2 additions & 1 deletion Cabal/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ configure (pkg_descr0', pbi) cfg = do

dirinfo "Binaries" (bindir dirs) (bindir relative)
dirinfo "Libraries" (libdir dirs) (libdir relative)
dirinfo "Interfaces" (hidir dirs) (hidir relative)
dirinfo "Private binaries" (libexecdir dirs) (libexecdir relative)
dirinfo "Data files" (datadir dirs) (datadir relative)
dirinfo "Documentation" (docdir dirs) (docdir relative)
Expand Down Expand Up @@ -2013,7 +2014,7 @@ checkRelocatable verbosity pkg lbi
all isJust
(fmap (stripPrefix p)
[ bindir, libdir, dynlibdir, libexecdir, includedir, datadir
, docdir, mandir, htmldir, haddockdir, sysconfdir] )
, hidir, docdir, mandir, htmldir, haddockdir, sysconfdir] )

-- Check if the library dirs of the dependencies that are in the package
-- database to which the package is installed are relative to the
Expand Down
5 changes: 3 additions & 2 deletions Cabal/Distribution/Simple/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,12 +1116,13 @@ installLib :: Verbosity
-> LocalBuildInfo
-> FilePath -- ^install location
-> FilePath -- ^install location for dynamic libraries
-> FilePath -- ^install location for interfaces
-> FilePath -- ^Build location
-> PackageDescription
-> Library
-> ComponentLocalBuildInfo
-> IO ()
installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do
installLib verbosity lbi targetDir dynlibTargetDir hiTargetDir builtDir _pkg lib clbi = do
-- copy .hi files over:
whenVanilla $ copyModuleFiles "hi"
whenProf $ copyModuleFiles "p_hi"
Expand Down Expand Up @@ -1151,7 +1152,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do

copyModuleFiles ext =
findModuleFiles [builtDir] [ext] (libModules lib)
>>= installOrdinaryFiles verbosity targetDir
>>= installOrdinaryFiles verbosity hiTargetDir

cid = compilerId (compiler lbi)
libName = componentUnitId clbi
Expand Down
3 changes: 2 additions & 1 deletion Cabal/Distribution/Simple/Install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ install pkg_descr lbi flags = do
installDirs@(InstallDirs {
bindir = binPref,
libdir = libPref,
hidir = hiPref,
-- dynlibdir = dynlibPref, --see TODO below
datadir = dataPref,
docdir = docPref,
Expand Down Expand Up @@ -130,7 +131,7 @@ install pkg_descr lbi flags = do

withLibLBI pkg_descr lbi $
case compilerFlavor (compiler lbi) of
GHC -> GHC.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr
GHC -> GHC.installLib verbosity lbi libPref dynlibPref hiPref buildPref pkg_descr
GHCJS -> GHCJS.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr
LHC -> LHC.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr
JHC -> JHC.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr
Expand Down
52 changes: 43 additions & 9 deletions Cabal/Distribution/Simple/InstallDirs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,17 @@ data InstallDirs dir = InstallDirs {
prefix :: dir,
bindir :: dir,
libdir :: dir,
libsubdir :: dir,
binlibsubdir :: dir,
hidir :: dir,
libsubdir :: dir, -- This field is deprecated by the introduction of
-- binlibsubdir and hidir. However,
-- we must keep it so that we can still work with
-- Setup executables build against an older version
-- of Cabal. For the same reason, we cannot
-- simply use libsubdir as the binlibsubdir,
-- because then Setup's build against an older
-- Cabal would put .hi files in the same directory
-- as the library object files
dynlibdir :: dir,
libexecdir :: dir,
includedir :: dir,
Expand Down Expand Up @@ -110,6 +120,8 @@ combineInstallDirs combine a b = InstallDirs {
prefix = prefix a `combine` prefix b,
bindir = bindir a `combine` bindir b,
libdir = libdir a `combine` libdir b,
binlibsubdir = binlibsubdir a `combine` binlibsubdir b,
hidir = hidir a `combine` hidir b,
libsubdir = libsubdir a `combine` libsubdir b,
dynlibdir = dynlibdir a `combine` dynlibdir b,
libexecdir = libexecdir a `combine` libexecdir b,
Expand All @@ -125,9 +137,9 @@ combineInstallDirs combine a b = InstallDirs {

appendSubdirs :: (a -> a -> a) -> InstallDirs a -> InstallDirs a
appendSubdirs append dirs = dirs {
libdir = libdir dirs `append` libsubdir dirs,
libdir = libdir dirs `append` binlibsubdir dirs,
datadir = datadir dirs `append` datasubdir dirs,
libsubdir = error "internal error InstallDirs.libsubdir",
binlibsubdir = error "internal error InstallDirs.binlibsubdir",
datasubdir = error "internal error InstallDirs.datasubdir"
}

Expand All @@ -148,7 +160,7 @@ appendSubdirs append dirs = dirs {
-- users to be able to configure @--libdir=\/usr\/lib64@ for example but
-- because by default we want to support installing multiple versions of
-- packages and building the same package for multiple compilers we append the
-- libsubdir to get: @\/usr\/lib64\/$libname\/$compiler@.
-- binlibsubdir to get: @\/usr\/lib64\/$libname\/$compiler@.
--
-- An additional complication is the need to support relocatable packages on
-- systems which support such things, like Windows.
Expand Down Expand Up @@ -177,6 +189,16 @@ defaultInstallDirs comp userInstall _hasLibs = do
prefix = installPrefix,
bindir = "$prefix" </> "bin",
libdir = installLibDir,
binlibsubdir = case comp of
JHC -> "$compiler"
LHC -> "$compiler"
UHC -> "$pkgid"
_other -> "$abi",
hidir = "$libdir" </> case comp of
JHC -> "$compiler"
LHC -> "$compiler"
UHC -> "$pkgid"
_other -> "$abi" </> "$libname",
libsubdir = case comp of
JHC -> "$compiler"
LHC -> "$compiler"
Expand All @@ -186,7 +208,7 @@ defaultInstallDirs comp userInstall _hasLibs = do
libexecdir = case buildOS of
Windows -> "$prefix" </> "$libname"
_other -> "$prefix" </> "libexec",
includedir = "$libdir" </> "$libsubdir" </> "include",
includedir = "$hidir" </> "include",
datadir = case buildOS of
Windows -> "$prefix"
_other -> "$prefix" </> "share",
Expand Down Expand Up @@ -222,10 +244,12 @@ substituteInstallDirTemplates env dirs = dirs'
prefix = subst prefix [],
bindir = subst bindir [prefixVar],
libdir = subst libdir [prefixVar, bindirVar],
binlibsubdir = subst binlibsubdir [],
hidir = subst hidir prefixBinLibVars,
libsubdir = subst libsubdir [],
dynlibdir = subst dynlibdir [prefixVar, bindirVar, libdirVar],
libexecdir = subst libexecdir prefixBinLibVars,
includedir = subst includedir prefixBinLibVars,
includedir = subst includedir (prefixBinLibVars ++ [hidirVar]),
datadir = subst datadir prefixBinLibVars,
datasubdir = subst datasubdir [],
docdir = subst docdir prefixBinLibDataVars,
Expand All @@ -240,12 +264,13 @@ substituteInstallDirTemplates env dirs = dirs'
prefixVar = (PrefixVar, prefix dirs')
bindirVar = (BindirVar, bindir dirs')
libdirVar = (LibdirVar, libdir dirs')
libsubdirVar = (LibsubdirVar, libsubdir dirs')
binlibsubdirVar = (BinlibsubdirVar, binlibsubdir dirs')
hidirVar = (HidirVar, hidir dirs')
datadirVar = (DatadirVar, datadir dirs')
datasubdirVar = (DatasubdirVar, datasubdir dirs')
docdirVar = (DocdirVar, docdir dirs')
htmldirVar = (HtmldirVar, htmldir dirs')
prefixBinLibVars = [prefixVar, bindirVar, libdirVar, libsubdirVar]
prefixBinLibVars = [prefixVar, bindirVar, libdirVar, binlibsubdirVar]
prefixBinLibDataVars = prefixBinLibVars ++ [datadirVar, datasubdirVar]

-- | Convert from abstract install directories to actual absolute ones by
Expand Down Expand Up @@ -330,6 +355,8 @@ data PathTemplateVariable =
PrefixVar -- ^ The @$prefix@ path variable
| BindirVar -- ^ The @$bindir@ path variable
| LibdirVar -- ^ The @$libdir@ path variable
| BinlibsubdirVar -- ^ The @$binlibsubdir@ path variable
| HidirVar -- ^ The @$hidir@ path variable
| LibsubdirVar -- ^ The @$libsubdir@ path variable
| DatadirVar -- ^ The @$datadir@ path variable
| DatasubdirVar -- ^ The @$datasubdir@ path variable
Expand Down Expand Up @@ -425,7 +452,10 @@ installDirsTemplateEnv dirs =
[(PrefixVar, prefix dirs)
,(BindirVar, bindir dirs)
,(LibdirVar, libdir dirs)
,(LibsubdirVar, libsubdir dirs)
,(BinlibsubdirVar, binlibsubdir dirs)
,(HidirVar, hidir dirs)
,(LibsubdirVar, libsubdir dirs) -- We need to keep this around for Setup's
-- build against older versions of Cabal
,(DatadirVar, datadir dirs)
,(DatasubdirVar, datasubdir dirs)
,(DocdirVar, docdir dirs)
Expand All @@ -447,6 +477,8 @@ instance Show PathTemplateVariable where
show LibNameVar = "libname"
show BindirVar = "bindir"
show LibdirVar = "libdir"
show BinlibsubdirVar = "binlibsubdir"
show HidirVar = "hidir"
show LibsubdirVar = "libsubdir"
show DatadirVar = "datadir"
show DatasubdirVar = "datasubdir"
Expand Down Expand Up @@ -475,6 +507,8 @@ instance Read PathTemplateVariable where
where vars = [("prefix", PrefixVar)
,("bindir", BindirVar)
,("libdir", LibdirVar)
,("binlibsubdir", BinlibsubdirVar)
,("hidir", HidirVar)
,("libsubdir", LibsubdirVar)
,("datadir", DatadirVar)
,("datasubdir", DatasubdirVar)
Expand Down
5 changes: 3 additions & 2 deletions Cabal/Distribution/Simple/Register.hs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
IPI.exposedModules = componentExposedModules clbi,
IPI.hiddenModules = otherModules bi,
IPI.trusted = IPI.trusted IPI.emptyInstalledPackageInfo,
IPI.importDirs = [ libdir installDirs | hasModules ],
-- Note. the libsubdir and datasubdir templates have already been expanded
IPI.importDirs = [ hidir installDirs | hasModules ],
-- Note. the binlibsubdir and datasubdir templates have already been expanded
-- into libdir and datadir.
IPI.libraryDirs = if hasLibrary
then libdir installDirs : extraLibDirs bi
Expand Down Expand Up @@ -378,6 +378,7 @@ inplaceInstalledPackageInfo inplaceDir distPref pkg abi_hash lib lbi clbi =
(absoluteInstallDirs pkg lbi NoCopyDest) {
libdir = inplaceDir </> libTargetDir,
datadir = inplaceDir </> dataDir pkg,
hidir = inplaceDir </> libTargetDir,
docdir = inplaceDocdir,
htmldir = inplaceHtmldir,
haddockdir = inplaceHtmldir
Expand Down
18 changes: 15 additions & 3 deletions Cabal/Distribution/Simple/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,14 @@ installDirsOptions =
libdir (\v flags -> flags { libdir = v })
installDirArg

, option "" ["libsubdir"]
"subdirectory of libdir in which libs are installed"
libsubdir (\v flags -> flags { libsubdir = v })
, option "" ["binlibsubdir"]
"subdirectory of libdir in which binary libraries are installed"
binlibsubdir (\v flags -> flags { binlibsubdir = v })
installDirArg

, option "" ["hidir"]
"installation directory for library interface files"
hidir (\v flags -> flags { hidir = v })
installDirArg

, option "" ["libexecdir"]
Expand Down Expand Up @@ -801,6 +806,13 @@ installDirsOptions =
"installation directory for configuration files"
sysconfdir (\v flags -> flags { sysconfdir = v })
installDirArg

, option "" ["libsubdir"]
("subdirectory of libdir in which libs are installed." ++
"Only has an effect on Setup files built against Cabal < 1.24.1"
)
libsubdir (\v flags -> flags { libsubdir = v })
installDirArg
]
where
installDirArg _sf _lf d get set =
Expand Down
1 change: 1 addition & 0 deletions Cabal/doc/developing-packages.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,7 @@ version :: Version

getBinDir :: IO FilePath
getLibDir :: IO FilePath
getHiDir :: IO FilePath
getDataDir :: IO FilePath
getLibexecDir :: IO FilePath
getSysconfDir :: IO FilePath
Expand Down
Loading