Cabal-1.6.0.3: A framework for packaging Haskell softwareSource codeContentsIndex
Distribution.Simple.InstallDirs
Portabilityportable
Maintainercabal-devel@haskell.org
Description
This manages everything to do with where files get installed (though does not get involved with actually doing any installation). It provides an InstallDirs type which is a set of directories for where to install things. It also handles the fact that we use templates in these install dirs. For example most install dirs are relative to some $prefix and by changing the prefix all other dirs still end up changed appropriately. So it provides a PathTemplate type and functions for substituting for these templates.
Synopsis
data InstallDirs dir = InstallDirs {
prefix :: dir
bindir :: dir
libdir :: dir
libsubdir :: dir
dynlibdir :: dir
libexecdir :: dir
progdir :: dir
includedir :: dir
datadir :: dir
datasubdir :: dir
docdir :: dir
mandir :: dir
htmldir :: dir
haddockdir :: dir
}
type InstallDirTemplates = InstallDirs PathTemplate
defaultInstallDirs :: CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates
combineInstallDirs :: (a -> b -> c) -> InstallDirs a -> InstallDirs b -> InstallDirs c
absoluteInstallDirs :: PackageIdentifier -> CompilerId -> CopyDest -> InstallDirTemplates -> InstallDirs FilePath
data CopyDest
= NoCopyDest
| CopyTo FilePath
| CopyPrefix FilePath
prefixRelativeInstallDirs :: PackageIdentifier -> CompilerId -> InstallDirTemplates -> InstallDirs (Maybe FilePath)
data PathTemplate
data PathTemplateVariable
= PrefixVar
| BindirVar
| LibdirVar
| LibsubdirVar
| DatadirVar
| DatasubdirVar
| DocdirVar
| HtmldirVar
| PkgNameVar
| PkgVerVar
| PkgIdVar
| CompilerVar
| OSVar
| ArchVar
| ExecutableNameVar
toPathTemplate :: FilePath -> PathTemplate
fromPathTemplate :: PathTemplate -> FilePath
substPathTemplate :: [(PathTemplateVariable, PathTemplate)] -> PathTemplate -> PathTemplate
initialPathTemplateEnv :: PackageIdentifier -> CompilerId -> [(PathTemplateVariable, PathTemplate)]
fullPathTemplateEnv :: PackageIdentifier -> CompilerId -> InstallDirs FilePath -> [(PathTemplateVariable, PathTemplate)]
Documentation
data InstallDirs dir Source

The directories where we will install files for packages.

We have several different directories for different types of files since many systems have conventions whereby different types of files in a package are installed in different direcotries. This is particularly the case on unix style systems.

Constructors
InstallDirs
prefix :: dir
bindir :: dir
libdir :: dir
libsubdir :: dir
dynlibdir :: dir
libexecdir :: dir
progdir :: dir
includedir :: dir
datadir :: dir
datasubdir :: dir
docdir :: dir
mandir :: dir
htmldir :: dir
haddockdir :: dir
show/hide Instances
type InstallDirTemplates = InstallDirs PathTemplateSource

The installation directories in terms of PathTemplates that contain variables.

The defaults for most of the directories are relative to each other, in particular they are all relative to a single prefix. This makes it convenient for the user to override the default installation directory by only having to specify --prefix=... rather than overriding each individually. This is done by allowing $-style variables in the dirs. These are expanded by textual substituion (see substPathTemplate).

A few of these installation directories are split into two components, the dir and subdir. The full installation path is formed by combining the two together with /. The reason for this is compatibility with other unix build systems which also support --libdir and --datadir. We would like 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/$pkgid/$compiler.

An additional complication is the need to support relocatable packages on systems which support such things, like Windows.

defaultInstallDirs :: CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplatesSource
combineInstallDirs :: (a -> b -> c) -> InstallDirs a -> InstallDirs b -> InstallDirs cSource
absoluteInstallDirs :: PackageIdentifier -> CompilerId -> CopyDest -> InstallDirTemplates -> InstallDirs FilePathSource
Convert from abstract install directories to actual absolute ones by substituting for all the variables in the abstract paths, to get real absolute path.
data CopyDest Source
The location prefix for the copy command.
Constructors
NoCopyDest
CopyTo FilePath
CopyPrefix FilePath
show/hide Instances
prefixRelativeInstallDirs :: PackageIdentifier -> CompilerId -> InstallDirTemplates -> InstallDirs (Maybe FilePath)Source

Check which of the paths are relative to the installation $prefix.

If any of the paths are not relative, ie they are absolute paths, then it prevents us from making a relocatable package (also known as a "prefix independent" package).

data PathTemplate Source
An abstract path, posibly containing variables that need to be substituted for to get a real FilePath.
show/hide Instances
data PathTemplateVariable Source
Constructors
PrefixVarThe $prefix path variable
BindirVarThe $bindir path variable
LibdirVarThe $libdir path variable
LibsubdirVarThe $libsubdir path variable
DatadirVarThe $datadir path variable
DatasubdirVarThe $datasubdir path variable
DocdirVarThe $docdir path variable
HtmldirVarThe $htmldir path variable
PkgNameVarThe $pkg package name path variable
PkgVerVarThe $version package version path variable
PkgIdVarThe $pkgid package Id path variable, eg foo-1.0
CompilerVarThe compiler name and version, eg ghc-6.6.1
OSVarThe operating system name, eg windows or linux
ArchVarThe cpu architecture name, eg i386 or x86_64
ExecutableNameVarThe executable name; used in shell wrappers
show/hide Instances
toPathTemplate :: FilePath -> PathTemplateSource
Convert a FilePath to a PathTemplate including any template vars.
fromPathTemplate :: PathTemplate -> FilePathSource
Convert back to a path, any remaining vars are included
substPathTemplate :: [(PathTemplateVariable, PathTemplate)] -> PathTemplate -> PathTemplateSource
initialPathTemplateEnv :: PackageIdentifier -> CompilerId -> [(PathTemplateVariable, PathTemplate)]Source
The initial environment has all the static stuff but no paths
fullPathTemplateEnv :: PackageIdentifier -> CompilerId -> InstallDirs FilePath -> [(PathTemplateVariable, PathTemplate)]Source
Produced by Haddock version 2.4.2