Cabal-1.24.2.0: A framework for packaging Haskell software

CopyrightIsaac Jones 2003-2004
LicenseBSD3
Maintainercabal-devel@haskell.org
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Distribution.Simple.InstallDirs

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

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 directories. This is particularly the case on Unix style systems.

Constructors

InstallDirs 

Fields

Instances

Functor InstallDirs Source # 

Methods

fmap :: (a -> b) -> InstallDirs a -> InstallDirs b #

(<$) :: a -> InstallDirs b -> InstallDirs a #

Eq dir => Eq (InstallDirs dir) Source # 

Methods

(==) :: InstallDirs dir -> InstallDirs dir -> Bool #

(/=) :: InstallDirs dir -> InstallDirs dir -> Bool #

Read dir => Read (InstallDirs dir) Source # 
Show dir => Show (InstallDirs dir) Source # 

Methods

showsPrec :: Int -> InstallDirs dir -> ShowS #

show :: InstallDirs dir -> String #

showList :: [InstallDirs dir] -> ShowS #

Generic (InstallDirs dir) Source # 

Associated Types

type Rep (InstallDirs dir) :: * -> * #

Methods

from :: InstallDirs dir -> Rep (InstallDirs dir) x #

to :: Rep (InstallDirs dir) x -> InstallDirs dir #

Semigroup dir => Semigroup (InstallDirs dir) Source # 

Methods

(<>) :: InstallDirs dir -> InstallDirs dir -> InstallDirs dir #

sconcat :: NonEmpty (InstallDirs dir) -> InstallDirs dir #

stimes :: Integral b => b -> InstallDirs dir -> InstallDirs dir #

(Semigroup dir, Monoid dir) => Monoid (InstallDirs dir) Source # 

Methods

mempty :: InstallDirs dir #

mappend :: InstallDirs dir -> InstallDirs dir -> InstallDirs dir #

mconcat :: [InstallDirs dir] -> InstallDirs dir #

Binary dir => Binary (InstallDirs dir) Source # 

Methods

put :: InstallDirs dir -> Put #

get :: Get (InstallDirs dir) #

putList :: [InstallDirs dir] -> Put #

type Rep (InstallDirs dir) Source # 
type Rep (InstallDirs dir) = D1 (MetaData "InstallDirs" "Distribution.Simple.InstallDirs" "Cabal-1.24.2.0-DZNolZ9MBQLKV7GSAwAGX6" False) (C1 (MetaCons "InstallDirs" PrefixI True) ((:*:) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "prefix") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir)) ((:*:) (S1 (MetaSel (Just Symbol "bindir") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir)) (S1 (MetaSel (Just Symbol "libdir") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir)))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "libsubdir") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir)) (S1 (MetaSel (Just Symbol "dynlibdir") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir))) ((:*:) (S1 (MetaSel (Just Symbol "libexecdir") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir)) (S1 (MetaSel (Just Symbol "includedir") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir))))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "datadir") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir)) ((:*:) (S1 (MetaSel (Just Symbol "datasubdir") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir)) (S1 (MetaSel (Just Symbol "docdir") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir)))) ((:*:) ((:*:) (S1 (MetaSel (Just Symbol "mandir") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir)) (S1 (MetaSel (Just Symbol "htmldir") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir))) ((:*:) (S1 (MetaSel (Just Symbol "haddockdir") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir)) (S1 (MetaSel (Just Symbol "sysconfdir") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 dir)))))))

type InstallDirTemplates = InstallDirs PathTemplate Source #

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 substitution (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/$libname/$compiler.

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

absoluteInstallDirs :: PackageIdentifier -> UnitId -> CompilerInfo -> CopyDest -> Platform -> InstallDirs PathTemplate -> InstallDirs FilePath Source #

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 

prefixRelativeInstallDirs :: PackageIdentifier -> UnitId -> CompilerInfo -> Platform -> 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).

substituteInstallDirTemplates :: PathTemplateEnv -> InstallDirTemplates -> InstallDirTemplates Source #

Substitute the install dir templates into each other.

To prevent cyclic substitutions, only some variables are allowed in particular dir templates. If out of scope vars are present, they are not substituted for. Checking for any remaining unsubstituted vars can be done as a subsequent operation.

The reason it is done this way is so that in prefixRelativeInstallDirs we can replace prefix with the PrefixVar and get resulting PathTemplates that still have the PrefixVar in them. Doing this makes it each to check which paths are relative to the $prefix.

data PathTemplateVariable Source #

Constructors

PrefixVar

The $prefix path variable

BindirVar

The $bindir path variable

LibdirVar

The $libdir path variable

LibsubdirVar

The $libsubdir path variable

DynlibdirVar

The $dynlibdir path variable

DatadirVar

The $datadir path variable

DatasubdirVar

The $datasubdir path variable

DocdirVar

The $docdir path variable

HtmldirVar

The $htmldir path variable

PkgNameVar

The $pkg package name path variable

PkgVerVar

The $version package version path variable

PkgIdVar

The $pkgid package Id path variable, eg foo-1.0

LibNameVar

The $libname path variable

CompilerVar

The compiler name and version, eg ghc-6.6.1

OSVar

The operating system name, eg windows or linux

ArchVar

The CPU architecture name, eg i386 or x86_64

AbiVar

The Compiler's ABI identifier, $arch-$os-$compiler-$abitag

AbiTagVar

The optional ABI tag for the compiler

ExecutableNameVar

The executable name; used in shell wrappers

TestSuiteNameVar

The name of the test suite being run

TestSuiteResultVar

The result of the test suite being run, eg pass, fail, or error.

BenchmarkNameVar

The name of the benchmark being run

Instances

Eq PathTemplateVariable Source # 
Ord PathTemplateVariable Source # 
Read PathTemplateVariable Source # 
Show PathTemplateVariable Source # 
Generic PathTemplateVariable Source # 
Binary PathTemplateVariable Source # 
type Rep PathTemplateVariable Source # 
type Rep PathTemplateVariable = D1 (MetaData "PathTemplateVariable" "Distribution.Simple.InstallDirs" "Cabal-1.24.2.0-DZNolZ9MBQLKV7GSAwAGX6" False) ((:+:) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "PrefixVar" PrefixI False) U1) (C1 (MetaCons "BindirVar" PrefixI False) U1)) ((:+:) (C1 (MetaCons "LibdirVar" PrefixI False) U1) ((:+:) (C1 (MetaCons "LibsubdirVar" PrefixI False) U1) (C1 (MetaCons "DynlibdirVar" PrefixI False) U1)))) ((:+:) ((:+:) (C1 (MetaCons "DatadirVar" PrefixI False) U1) ((:+:) (C1 (MetaCons "DatasubdirVar" PrefixI False) U1) (C1 (MetaCons "DocdirVar" PrefixI False) U1))) ((:+:) (C1 (MetaCons "HtmldirVar" PrefixI False) U1) ((:+:) (C1 (MetaCons "PkgNameVar" PrefixI False) U1) (C1 (MetaCons "PkgVerVar" PrefixI False) U1))))) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "PkgIdVar" PrefixI False) U1) (C1 (MetaCons "LibNameVar" PrefixI False) U1)) ((:+:) (C1 (MetaCons "CompilerVar" PrefixI False) U1) ((:+:) (C1 (MetaCons "OSVar" PrefixI False) U1) (C1 (MetaCons "ArchVar" PrefixI False) U1)))) ((:+:) ((:+:) (C1 (MetaCons "AbiVar" PrefixI False) U1) ((:+:) (C1 (MetaCons "AbiTagVar" PrefixI False) U1) (C1 (MetaCons "ExecutableNameVar" PrefixI False) U1))) ((:+:) (C1 (MetaCons "TestSuiteNameVar" PrefixI False) U1) ((:+:) (C1 (MetaCons "TestSuiteResultVar" PrefixI False) U1) (C1 (MetaCons "BenchmarkNameVar" PrefixI False) U1))))))

toPathTemplate :: FilePath -> PathTemplate Source #

Convert a FilePath to a PathTemplate including any template vars.

fromPathTemplate :: PathTemplate -> FilePath Source #

Convert back to a path, any remaining vars are included

initialPathTemplateEnv :: PackageIdentifier -> UnitId -> CompilerInfo -> Platform -> PathTemplateEnv Source #

The initial environment has all the static stuff but no paths