Commit 5b57a50a authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Refactor the code for managing installation directories

New types for the collection of installation directory templates and a
separate type for the collection of actual real install FilePaths.
The templates are represented with a PathTemplate adt.
Dir templates can now be relative to each other, eg $htmldir to $docdir
Default install dir templates are now specified compactly in one place.
Adding new dirs should be considerably simpler than previously.
This patch should not actualy change where anything is installed.
parent ad4f2030
......@@ -63,6 +63,7 @@ Library {
Distribution.Simple.Haddock,
Distribution.Simple.Hugs,
Distribution.Simple.Install,
Distribution.Simple.InstallDirs,
Distribution.Simple.JHC,
Distribution.Simple.LocalBuildInfo,
Distribution.Simple.NHC,
......
......@@ -59,9 +59,9 @@ import Distribution.Setup ( CopyDest(..), BuildFlags(..),
MakefileFlags(..) )
import Distribution.PreProcess ( preprocessSources, PPSuffixHandler )
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(..), mkBinDir, mkBinDirRel,
mkLibDir, mkLibDirRel, mkDataDir,mkDataDirRel,
mkLibexecDir, mkLibexecDirRel, mkProgDirRel )
( LocalBuildInfo(..),
InstallDirs(..), absoluteInstallDirs,
prefixRelativeInstallDirs )
import Distribution.Simple.Configure
( localBuildInfoFile )
import Distribution.Simple.Utils( createDirectoryIfMissingVerbose, die )
......@@ -69,7 +69,7 @@ import Distribution.System
import System.FilePath ( (</>), pathSeparator )
import Data.Maybe ( maybeToList, fromJust )
import Data.Maybe ( maybeToList, fromJust, isNothing )
import Control.Monad ( unless, when )
import System.Directory ( getModificationTime, doesFileExist )
......@@ -202,7 +202,7 @@ buildPathsModule pkg_descr lbi =
"getDataFileName :: FilePath -> IO FilePath\n"++
"getDataFileName name = return (datadir ++ "++path_sep++" ++ name)\n"
| otherwise =
"\nprefix = " ++ show (prefix lbi) ++
"\nprefix = " ++ flat_prefix ++
"\nbindirrel = " ++ show (fromJust flat_bindirrel) ++
"\n\n"++
"getBinDir :: IO FilePath\n"++
......@@ -230,27 +230,35 @@ buildPathsModule pkg_descr lbi =
then writeFile paths_filepath (header++body)
else return ()
where
flat_bindir = mkBinDir pkg_descr lbi NoCopyDest
flat_bindirrel = mkBinDirRel pkg_descr lbi NoCopyDest
flat_libdir = mkLibDir pkg_descr lbi NoCopyDest
flat_libdirrel = mkLibDirRel pkg_descr lbi NoCopyDest
flat_datadir = mkDataDir pkg_descr lbi NoCopyDest
flat_datadirrel = mkDataDirRel pkg_descr lbi NoCopyDest
flat_libexecdir = mkLibexecDir pkg_descr lbi NoCopyDest
flat_libexecdirrel = mkLibexecDirRel pkg_descr lbi NoCopyDest
flat_progdirrel = mkProgDirRel pkg_descr lbi NoCopyDest
InstallDirs {
prefix = flat_prefix,
bindir = flat_bindir,
libdir = flat_libdir,
datadir = flat_datadir,
libexecdir = flat_libexecdir
} = absoluteInstallDirs pkg_descr lbi NoCopyDest
InstallDirs {
bindir = flat_bindirrel,
libdir = flat_libdirrel,
datadir = flat_datadirrel,
libexecdir = flat_libexecdirrel,
progdir = flat_progdirrel
} = prefixRelativeInstallDirs pkg_descr lbi
mkGetDir _ (Just dirrel) = "getPrefixDirRel " ++ show dirrel
mkGetDir dir Nothing = "return " ++ show dir
absolute = case os of
Windows MingW ->
hasLibs pkg_descr ||
flat_bindirrel == Nothing
_ ->
hasLibs pkg_descr ||
flat_progdirrel == Nothing ||
not isHugs
-- In several cases we cannot make relocatable installations
absolute =
hasLibs pkg_descr -- we can only make progs relocatable
|| isNothing flat_bindirrel -- if the bin dir is an absolute path
|| not (supportsRelocatableProgs (compilerFlavor (compiler lbi)))
supportsRelocatableProgs Hugs = True
supportsRelocatableProgs GHC = case os of
Windows _ -> True
_ -> False
supportsRelocatableProgs _ = False
paths_modulename = autogenModuleName pkg_descr
paths_filename = paths_modulename ++ ".hs"
......
......@@ -86,11 +86,12 @@ import Distribution.Program
, findProgramAndVersion )
import Distribution.Setup
( ConfigFlags(..), CopyDest(..) )
import Distribution.Simple.InstallDirs
( InstallDirs(..), InstallDirTemplates(..), defaultInstallDirs
, toPathTemplate )
import Distribution.Simple.LocalBuildInfo
( LocalBuildInfo(..), distPref, default_prefix, default_datadir
, default_bindir, default_libsubdir, default_libexecdir, default_libdir
, default_datasubdir, mkLibDirRel, mkLibexecDir, mkDataDirRel, mkBinDir
, mkLibDir, mkDataDir, mkBinDirRel, mkLibexecDirRel)
( LocalBuildInfo(..), distPref, absoluteInstallDirs
, prefixRelativeInstallDirs )
import Distribution.Simple.Utils
( die, warn, rawSystemStdout )
import Distribution.Simple.Register
......@@ -115,7 +116,7 @@ import Data.Char
import Data.List
( intersperse, nub, isPrefixOf )
import Data.Maybe
( fromMaybe )
( fromMaybe, isNothing )
import System.Directory
( doesFileExist )
import System.Environment
......@@ -245,22 +246,20 @@ configure (pkg_descr0, pbi) cfg
removeInstalledConfig
-- installation directories
defPrefix <- default_prefix
defDataDir <- default_datadir pkg_descr
let
pref = fromMaybe defPrefix (configPrefix cfg)
my_bindir = fromMaybe default_bindir
(configBinDir cfg)
my_libdir = fromMaybe (default_libdir comp)
(configLibDir cfg)
my_libsubdir = fromMaybe (default_libsubdir comp)
(configLibSubDir cfg)
my_libexecdir = fromMaybe default_libexecdir
(configLibExecDir cfg)
my_datadir = fromMaybe defDataDir
(configDataDir cfg)
my_datasubdir = fromMaybe default_datasubdir
(configDataSubDir cfg)
defaultDirs <- defaultInstallDirs flavor (hasLibs pkg_descr)
let maybeDefault confField dirField =
maybe (dirField defaultDirs) toPathTemplate (confField cfg)
installDirs = defaultDirs {
prefixDirTemplate = maybeDefault configPrefix prefixDirTemplate,
binDirTemplate = maybeDefault configBinDir binDirTemplate,
libDirTemplate = maybeDefault configLibDir libDirTemplate,
libSubdirTemplate = maybeDefault configLibSubDir libSubdirTemplate,
libexecDirTemplate = maybeDefault configLibExecDir libexecDirTemplate,
dataDirTemplate = maybeDefault configDataDir dataDirTemplate,
dataSubdirTemplate = maybeDefault configDataSubDir dataSubdirTemplate
-- docDirTemplate =
-- htmlDirTemplate =
}
-- check extensions
let lib = library pkg_descr
......@@ -290,15 +289,11 @@ configure (pkg_descr0, pbi) cfg
"--enable-split-objs; ignoring")
return False
let lbi = LocalBuildInfo{prefix=pref, compiler=comp,
let lbi = LocalBuildInfo{
installDirTemplates = installDirs,
compiler=comp,
buildDir=distPref </> "build",
scratchDir=distPref </> "scratch",
bindir=my_bindir,
libdir=my_libdir,
libsubdir=my_libsubdir,
libexecdir=my_libexecdir,
datadir=my_datadir,
datasubdir=my_datasubdir,
packageDeps=dep_pkgs,
localPkgDescr=pkg_descr,
withPrograms=newConfig'',
......@@ -311,13 +306,17 @@ configure (pkg_descr0, pbi) cfg
userConf=configUser cfg
}
let dirs = absoluteInstallDirs pkg_descr lbi NoCopyDest
relative = prefixRelativeInstallDirs pkg_descr lbi
-- FIXME: maybe this should only be printed when verbose?
message $ "Using install prefix: " ++ pref
message $ "Using install prefix: " ++ prefix dirs
messageDir pkg_descr lbi "Binaries" mkBinDir mkBinDirRel
messageDir pkg_descr lbi "Libraries" mkLibDir mkLibDirRel
messageDir pkg_descr lbi "Private binaries" mkLibexecDir mkLibexecDirRel
messageDir pkg_descr lbi "Data files" mkDataDir mkDataDirRel
messageDir "Binaries" pkg_descr (bindir dirs) (bindir relative)
messageDir "Libraries" pkg_descr (libdir dirs) (libdir relative)
messageDir "Private binaries" pkg_descr (libexecdir dirs)(libexecdir relative)
messageDir "Data files" pkg_descr (datadir dirs) (datadir relative)
messageDir "documentation" pkg_descr (docdir dirs) (docdir relative)
message $ "Using compiler: " ++ compilerPath comp
message $ "Compiler flavor: " ++ show flavor
......@@ -328,19 +327,14 @@ configure (pkg_descr0, pbi) cfg
return lbi
messageDir :: PackageDescription -> LocalBuildInfo -> String
-> (PackageDescription -> LocalBuildInfo -> CopyDest -> FilePath)
-> (PackageDescription -> LocalBuildInfo -> CopyDest -> Maybe FilePath)
-> IO ()
messageDir pkg_descr lbi name mkDir mkDirRel
= message (name ++ " installed in: " ++ mkDir pkg_descr lbi NoCopyDest ++ rel_note)
messageDir :: String -> PackageDescription -> FilePath -> Maybe FilePath -> IO ()
messageDir name pkg_descr dir isPrefixRelative
= message (name ++ " installed in: " ++ dir ++ rel_note)
where
rel_note = case os of
Windows MingW
| not (hasLibs pkg_descr) &&
mkDirRel pkg_descr lbi NoCopyDest == Nothing
-> " (fixed location)"
_ -> ""
Windows MingW | not (hasLibs pkg_descr)
&& isNothing isPrefixRelative -> " (fixed location)"
_ -> ""
-- |Converts build dependencies to a versioned dependency. only sets
-- version information for exact versioned dependencies.
......
......@@ -24,7 +24,8 @@ module Distribution.Simple.GHCPackageConfig (
import Distribution.PackageDescription (PackageDescription(..), BuildInfo(..), Library(..))
import Distribution.Package (PackageIdentifier(..), showPackageId)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..),mkLibDir)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..), absoluteInstallDirs)
import Distribution.Simple.InstallDirs (InstallDirs(..))
import Distribution.Setup (CopyDest(..))
#ifndef __NHC__
......@@ -82,19 +83,21 @@ canWriteLocalPackageConfig = checkPermission writable
mkGHCPackageConfig :: PackageDescription -> LocalBuildInfo -> GHCPackageConfig
mkGHCPackageConfig pkg_descr lbi
= defaultGHCPackageConfig {
name = pkg_name,
name = pkgName pkg,
auto = True,
import_dirs = [mkLibDir pkg_descr lbi NoCopyDest],
library_dirs = (mkLibDir pkg_descr lbi NoCopyDest:
maybe [] (extraLibDirs . libBuildInfo) (library pkg_descr)),
import_dirs = [libdir installDirs],
library_dirs = libdir installDirs
: maybe [] (extraLibDirs . libBuildInfo) lib,
hs_libraries = ["HS"++(showPackageId (package pkg_descr))],
extra_libraries = maybe [] (extraLibs . libBuildInfo) (library pkg_descr),
include_dirs = maybe [] (includeDirs . libBuildInfo) (library pkg_descr),
c_includes = maybe [] (includes . libBuildInfo) (library pkg_descr),
extra_libraries = maybe [] (extraLibs . libBuildInfo) lib,
include_dirs = maybe [] (includeDirs . libBuildInfo) lib,
c_includes = maybe [] (includes . libBuildInfo) lib,
package_deps = map pkgName (packageDeps lbi)
}
where
pkg_name = pkgName (package pkg_descr)
pkg = package pkg_descr
lib = library pkg_descr
installDirs = absoluteInstallDirs pkg_descr lbi NoCopyDest
data GHCPackageConfig
= GHCPackage {
......
......@@ -56,9 +56,13 @@ import Distribution.Program(lookupProgram, Program(..), programPath,
import Distribution.PreProcess (ppCpp', ppUnlit, preprocessSources,
PPSuffixHandler, runSimplePreProcessor)
import Distribution.Setup
import Distribution.Simple.InstallDirs (InstallDirTemplates(..),
PathTemplateVariable(..),
toPathTemplate, fromPathTemplate,
substPathTemplate,
initialPathTemplateEnv)
import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..), hscolourPref,
haddockPref, distPref, substDir )
haddockPref, distPref )
import Distribution.Simple.Utils (die, warn, createDirectoryIfMissingVerbose,
moduleToFilePath, findFile)
......@@ -117,8 +121,10 @@ haddock pkg_descr lbi suffixes haddockFlags@HaddockFlags {
(programVersion confHaddock)
let have_src_hyperlink_flags = version >= Version [0,8] []
have_new_flags = version > Version [0,8] []
let comp = compiler lbi
pkgTool = compilerPkgTool comp
let ghcpkgFlags = if have_new_flags
then ["--ghc-pkg=" ++ programPath (compilerPkgTool (compiler lbi))]
then ["--ghc-pkg=" ++ programPath pkgTool]
else []
let cssFileFlag = case haddockCss haddockFlags of
Nothing -> []
......@@ -134,7 +140,6 @@ haddock pkg_descr lbi suffixes haddockFlags@HaddockFlags {
,"--source-entity=src/%{MODULE/./-}.html#%{NAME}"]
else []
let pkgTool = compilerPkgTool (compiler lbi)
let getField pkgId f = do
let name = showPackageId pkgId
s <- rawSystemStdout verbosity (programPath pkgTool) ["field", name, f]
......@@ -150,7 +155,14 @@ haddock pkg_descr lbi suffixes haddockFlags@HaddockFlags {
interface <- getField pkgId "haddock-interfaces"
html <- case haddockHtmlLocation haddockFlags of
Nothing -> getField pkgId "haddock-html"
Just htmlTemplate -> return (substDir pkgId lbi htmlTemplate)
Just htmlStrTemplate ->
let env0 = initialPathTemplateEnv pkgId (compilerId comp)
prefixSubst = prefixDirTemplate (installDirTemplates lbi)
env = (PrefixVar, prefixSubst) : env0
expandTemplateVars = fromPathTemplate
. substPathTemplate env
. toPathTemplate
in return (expandTemplateVars htmlStrTemplate)
return $ if null interface
then Nothing
else Just $ "--read-interface=" ++
......
......@@ -57,13 +57,15 @@ module Distribution.Simple.Install (
#endif
#endif
import Distribution.Package (PackageIdentifier(..))
import Distribution.PackageDescription (
PackageDescription(..), BuildInfo(..), Library(..),
setupMessage, hasLibs, withLib, withExe )
import Distribution.Simple.LocalBuildInfo (
LocalBuildInfo(..), mkLibDir, mkBinDir, mkDataDir, mkProgDir,
mkHaddockDir, mkIncludeDir, haddockPref)
import Distribution.Simple.Utils(createDirectoryIfMissingVerbose, copyFileVerbose, die, copyDirectoryRecursiveVerbose)
LocalBuildInfo(..), InstallDirs(..), absoluteInstallDirs, haddockPref)
import Distribution.Simple.Utils (createDirectoryIfMissingVerbose,
copyFileVerbose, die,
copyDirectoryRecursiveVerbose)
import Distribution.Compiler (CompilerFlavor(..), Compiler(..))
import Distribution.Setup (CopyFlags(..), CopyDest(..))
......@@ -90,31 +92,36 @@ install :: PackageDescription -- ^information from the .cabal file
-> CopyFlags -- ^flags sent to copy or install
-> IO ()
install pkg_descr lbi (CopyFlags copydest verbosity) = do
let InstallDirs {
libdir = libPref,
bindir = binPref,
datadir = dataPref,
progdir = progPref,
htmldir = htmlPref,
includedir = incPref
} = absoluteInstallDirs pkg_descr lbi copydest
let dataFilesExist = not (null (dataFiles pkg_descr))
docExists <- doesDirectoryExist $ haddockPref pkg_descr
when (verbosity >= verbose)
(putStrLn ("directory " ++ haddockPref pkg_descr ++
" does exist: " ++ show docExists))
when (dataFilesExist || docExists) $ do
let dataPref = mkDataDir pkg_descr lbi copydest
createDirectoryIfMissingVerbose verbosity True dataPref
flip mapM_ (dataFiles pkg_descr) $ \ file -> do
let dir = takeDirectory file
createDirectoryIfMissingVerbose verbosity True (dataPref </> dir)
copyFileVerbose verbosity file (dataPref </> file)
when docExists $ do
let targetDir = mkHaddockDir pkg_descr lbi copydest
let targetDir = htmlPref </> pkgName (package pkg_descr)
createDirectoryIfMissingVerbose verbosity True targetDir
copyDirectoryRecursiveVerbose verbosity (haddockPref pkg_descr) targetDir
-- setPermissionsRecursive [Read] targetDir
let buildPref = buildDir lbi
let libPref = mkLibDir pkg_descr lbi copydest
let binPref = mkBinDir pkg_descr lbi copydest
setupMessage verbosity ("Installing: " ++ libPref ++ " & " ++ binPref) pkg_descr
-- install include files for all compilers - they may be needed to compile
-- haskell files (using the CPP extension)
when (hasLibs pkg_descr) $ installIncludeFiles verbosity pkg_descr libPref
when (hasLibs pkg_descr) $ installIncludeFiles verbosity pkg_descr incPref
case compilerFlavor (compiler lbi) of
GHC -> do when (hasLibs pkg_descr)
......@@ -125,8 +132,7 @@ install pkg_descr lbi (CopyFlags copydest verbosity) = do
JHC -> do withLib pkg_descr () $ JHC.installLib verbosity libPref buildPref pkg_descr
withExe pkg_descr $ JHC.installExe verbosity binPref buildPref pkg_descr
Hugs -> do
let progPref = mkProgDir pkg_descr lbi copydest
let targetProgPref = mkProgDir pkg_descr lbi NoCopyDest
let targetProgPref = progdir (absoluteInstallDirs pkg_descr lbi NoCopyDest)
let scratchPref = scratchDir lbi
Hugs.install verbosity libPref progPref binPref targetProgPref scratchPref pkg_descr
NHC -> die ("installing with nhc98 is not yet implemented")
......@@ -136,7 +142,7 @@ install pkg_descr lbi (CopyFlags copydest verbosity) = do
-- | Install the files listed in install-includes
installIncludeFiles :: Verbosity -> PackageDescription -> FilePath -> IO ()
installIncludeFiles verbosity PackageDescription{library=Just l} theLibdir
installIncludeFiles verbosity PackageDescription{library=Just l} incdir
= do
createDirectoryIfMissingVerbose verbosity True incdir
incs <- mapM (findInc relincdirs) (installIncludes lbi)
......@@ -145,7 +151,6 @@ installIncludeFiles verbosity PackageDescription{library=Just l} theLibdir
where
relincdirs = filter (not.isAbsolute) (includeDirs lbi)
lbi = libBuildInfo l
incdir = mkIncludeDir theLibdir
findInc [] f = die ("can't find include file " ++ f)
findInc (d:ds) f = do
......
This diff is collapsed.
......@@ -46,61 +46,34 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -}
module Distribution.Simple.LocalBuildInfo (
LocalBuildInfo(..),
default_prefix,
default_bindir,
default_libdir,
default_libsubdir,
default_libexecdir,
default_datadir,
default_datasubdir,
mkLibDir, mkLibDirRel,
mkBinDir, mkBinDirRel,
mkLibexecDir, mkLibexecDirRel,
mkDataDir, mkDataDirRel,
mkHaddockDir,
mkProgDirRel, mkProgDir,
absolutePath, prefixRelPath,
substDir,
-- * Installation directories
module Distribution.Simple.InstallDirs,
absoluteInstallDirs, prefixRelativeInstallDirs,
-- ** Deprecated install dir functions
mkLibDir, mkBinDir, mkLibexecDir, mkDataDir,
-- * Build directories
distPref, srcPref,
hscolourPref, haddockPref,
autogenModulesDir,
mkIncludeDir
autogenModulesDir
) where
import Distribution.Simple.InstallDirs hiding (absoluteInstallDirs,
prefixRelativeInstallDirs)
import qualified Distribution.Simple.InstallDirs as InstallDirs
import Distribution.Setup (CopyDest(..))
import Distribution.Program (ProgramConfiguration)
import Distribution.PackageDescription (PackageDescription(..))
import Distribution.Package (PackageIdentifier(..), showPackageId)
import Distribution.Compiler (Compiler(..), CompilerFlavor(..), showCompilerId)
import Distribution.Setup (CopyDest(..))
import Distribution.System
import Distribution.Version (showVersion)
import System.FilePath
#if mingw32_HOST_OS || mingw32_TARGET_OS
import Data.Maybe (fromMaybe)
import Distribution.PackageDescription (hasLibs)
import Foreign
import Foreign.C
#endif
import Distribution.Package (PackageIdentifier(..))
import Distribution.Compiler (Compiler(..))
import System.FilePath (FilePath, (</>))
-- |Data cached after configuration step. See also
-- 'Distribution.Setup.ConfigFlags'.
data LocalBuildInfo = LocalBuildInfo {
prefix :: FilePath,
-- ^ The installation directory (eg. @\/usr\/local@, or
-- @C:\/Program Files\/foo-1.2@ on Windows.
bindir :: FilePath,
-- ^ The bin directory
libdir :: FilePath,
-- ^ The lib directory
libsubdir :: FilePath,
-- ^ Subdirectory of libdir into which libraries are installed
libexecdir :: FilePath,
-- ^ The lib directory
datadir :: FilePath,
-- ^ The data directory
datasubdir :: FilePath,
-- ^ Subdirectory of datadir into which data files are installed
installDirTemplates :: InstallDirTemplates,
-- ^ The installation directories for the various differnt
-- kinds of files
compiler :: Compiler,
-- ^ The compiler we're building with
buildDir :: FilePath,
......@@ -149,216 +122,47 @@ haddockPref pkg_descr
autogenModulesDir :: LocalBuildInfo -> String
autogenModulesDir lbi = buildDir lbi </> "autogen"
-- |The place where install-includes are installed, relative to libdir
mkIncludeDir :: FilePath -> FilePath
mkIncludeDir = (</> "include")
-- -----------------------------------------------------------------------------
-- Default directories
{-
The defaults are as follows:
Windows:
prefix = C:\Program Files
bindir = $prefix\$pkgid
libdir = $prefix\Haskell
libsubdir = $pkgid\$compiler
datadir = $prefix (for an executable)
= $prefix\Common Files (for a library)
datasubdir = $pkgid
libexecdir = $prefix\$pkgid
Unix:
prefix = /usr/local
bindir = $prefix/bin
libdir = $prefix/lib/$pkgid/$compiler
libsubdir = $pkgid/$compiler
datadir = $prefix/share/$pkgid
datasubdir = $pkgid
libexecdir = $prefix/libexec
-}
default_prefix :: IO String
#if mingw32_HOST_OS || mingw32_TARGET_OS
# if __HUGS__
default_prefix = return "C:\\Program Files"
# else
default_prefix = getProgramFilesDir
# endif
#else
default_prefix = return "/usr/local"
#endif
#if mingw32_HOST_OS || mingw32_TARGET_OS
getProgramFilesDir = do
m <- shGetFolderPath csidl_PROGRAM_FILES
return (fromMaybe "C:\\Program Files" m)
getCommonFilesDir = do
m <- shGetFolderPath csidl_PROGRAM_FILES_COMMON
case m of
Nothing -> getProgramFilesDir
Just s -> return s
shGetFolderPath id =
allocaBytes long_path_size $ \pPath -> do
r <- c_SHGetFolderPath nullPtr id nullPtr 0 pPath
if (r /= 0)
then return Nothing
else do s <- peekCString pPath; return (Just s)
where
long_path_size = 1024
csidl_PROGRAM_FILES = 0x0026 :: CInt
csidl_PROGRAM_FILES_COMMON = 0x002b :: CInt
foreign import stdcall unsafe "shlobj.h SHGetFolderPathA"
c_SHGetFolderPath :: Ptr ()
-> CInt
-> Ptr ()
-> CInt
-> CString
-> IO CInt
#endif
default_bindir :: FilePath
default_bindir = "$prefix" </> path
where path = case os of
Windows _ -> "Haskell" </> "bin"
_ -> "bin"
default_libdir :: Compiler -> FilePath
default_libdir _ = "$prefix" </> path
where path = case os of
Windows _ -> "Haskell"
_ -> "lib"
default_libsubdir :: Compiler -> FilePath
default_libsubdir hc =
case compilerFlavor hc of
Hugs -> "hugs" </> "packages" </> "$pkg"
JHC -> "$compiler"
_ -> "$pkgid" </> "$compiler"
default_libexecdir :: FilePath
default_libexecdir = "$prefix" </> path
where path = case os of
Windows _ -> "$pkgid"
_ -> "libexec"
-- Wrappers for a couple functions from InstallDirs
-- |See 'InstallDirs.absoluteInstallDirs'
absoluteInstallDirs :: PackageDescription -> LocalBuildInfo -> CopyDest
-> InstallDirs FilePath
absoluteInstallDirs pkg_descr lbi copydest =
InstallDirs.absoluteInstallDirs
(package pkg_descr)
(compilerId (compiler lbi))
copydest
(installDirTemplates lbi)
-- |See 'InstallDirs.prefixRelativeInstallDirs'
prefixRelativeInstallDirs :: PackageDescription -> LocalBuildInfo
-> InstallDirs (Maybe FilePath)
prefixRelativeInstallDirs pkg_descr lbi =
InstallDirs.prefixRelativeInstallDirs
(package pkg_descr)
(compilerId (compiler lbi))
(installDirTemplates lbi)
default_datadir :: PackageDescription -> IO FilePath
#if mingw32_HOST_OS || mingw32_TARGET_OS
default_datadir pkg_descr
| hasLibs pkg_descr = getCommonFilesDir
| otherwise = return ("$prefix" </> "Haskell")
#else