Cabal-3.10.1.0: A framework for packaging Haskell software

Copyright | Isaac Jones 2003-2004
License | BSD3
Maintainer | cabal-devel@haskell.org
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

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

- data InstallDirs dir = InstallDirs {
  - prefix :: dir
  - bindir :: dir
  - libdir :: dir
  - libsubdir :: dir
  - dynlibdir :: dir
  - flibdir :: dir
  - libexecdir :: dir
  - libexecsubdir :: dir
  - includedir :: dir
  - datadir :: dir
  - datasubdir :: dir
  - docdir :: dir
  - mandir :: dir
  - htmldir :: dir
  - haddockdir :: dir
  - sysconfdir :: dir
  }
- type InstallDirTemplates = InstallDirs PathTemplate
- defaultInstallDirs :: CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates
- defaultInstallDirs' :: Bool -> CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates
- combineInstallDirs :: (a -> b -> c) -> InstallDirs a -> InstallDirs b -> InstallDirs c
- absoluteInstallDirs :: PackageIdentifier -> UnitId -> CompilerInfo -> CopyDest -> Platform -> InstallDirs PathTemplate -> InstallDirs FilePath
- data CopyDest
  - = NoCopyDest
  - | CopyTo FilePath
  - | CopyToDb FilePath
- prefixRelativeInstallDirs :: PackageIdentifier -> UnitId -> CompilerInfo -> Platform -> InstallDirTemplates -> InstallDirs (Maybe FilePath)
- substituteInstallDirTemplates :: PathTemplateEnv -> InstallDirTemplates -> InstallDirTemplates
- data PathTemplate
- data PathTemplateVariable
  - = PrefixVar
  - | BindirVar
  - | LibdirVar
  - | LibsubdirVar
  - | DynlibdirVar
  - | DatadirVar
  - | DatasubdirVar
  - | DocdirVar
  - | HtmldirVar
  - | PkgNameVar
  - | PkgVerVar
  - | PkgIdVar
  - | LibNameVar
  - | CompilerVar
  - | OSVar
  - | ArchVar
  - | AbiVar
  - | AbiTagVar
  - | ExecutableNameVar
  - | TestSuiteNameVar
  - | TestSuiteResultVar
  - | BenchmarkNameVar
- type PathTemplateEnv = [(PathTemplateVariable, PathTemplate)]
- toPathTemplate :: FilePath -> PathTemplate
- fromPathTemplate :: PathTemplate -> FilePath
- combinePathTemplate :: PathTemplate -> PathTemplate -> PathTemplate
- substPathTemplate :: PathTemplateEnv -> PathTemplate -> PathTemplate
- initialPathTemplateEnv :: PackageIdentifier -> UnitId -> CompilerInfo -> Platform -> PathTemplateEnv
- platformTemplateEnv :: Platform -> PathTemplateEnv
- compilerTemplateEnv :: CompilerInfo -> PathTemplateEnv
- packageTemplateEnv :: PackageIdentifier -> UnitId -> PathTemplateEnv
- abiTemplateEnv :: CompilerInfo -> Platform -> PathTemplateEnv
- installDirsTemplateEnv :: InstallDirs PathTemplate -> PathTemplateEnv

# 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

- prefix :: dir
- bindir :: dir
- libdir :: dir
- libsubdir :: dir
- dynlibdir :: dir
- flibdir :: dir

  foreign libraries

- libexecdir :: dir
- libexecsubdir :: dir
- includedir :: dir
- datadir :: dir
- datasubdir :: dir
- docdir :: dir
- mandir :: dir
- htmldir :: dir
- haddockdir :: dir
- sysconfdir :: dir

#### Instances

Instances details

Functor InstallDirs Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods fmap :: (a -> b) -> InstallDirs a -> InstallDirs b Source # (<$) :: a -> InstallDirs b -> InstallDirs a Source #
Structured dir => Structured (InstallDirs dir) Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods structure :: Proxy (InstallDirs dir) -> Structure Source # structureHash' :: Tagged (InstallDirs dir) MD5
(Semigroup dir, Monoid dir) => Monoid (InstallDirs dir) Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods mempty :: InstallDirs dir Source # mappend :: InstallDirs dir -> InstallDirs dir -> InstallDirs dir Source # mconcat :: [InstallDirs dir] -> InstallDirs dir Source #
Semigroup dir => Semigroup (InstallDirs dir) Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods (<>) :: InstallDirs dir -> InstallDirs dir -> InstallDirs dir Source # sconcat :: NonEmpty (InstallDirs dir) -> InstallDirs dir Source # stimes :: Integral b => b -> InstallDirs dir -> InstallDirs dir Source #
Generic (InstallDirs dir) Source # |
Instance details Defined in Distribution.Simple.InstallDirs Associated Types type Rep (InstallDirs dir) :: Type -> Type Source # Methods from :: InstallDirs dir -> Rep (InstallDirs dir) x Source # to :: Rep (InstallDirs dir) x -> InstallDirs dir Source #
Read dir => Read (InstallDirs dir) Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods readsPrec :: Int -> ReadS (InstallDirs dir) Source # readList :: ReadS [InstallDirs dir] Source # readPrec :: ReadPrec (InstallDirs dir) Source # readListPrec :: ReadPrec [InstallDirs dir] Source #
Show dir => Show (InstallDirs dir) Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods showsPrec :: Int -> InstallDirs dir -> ShowS Source # show :: InstallDirs dir -> String Source # showList :: [InstallDirs dir] -> ShowS Source #
Binary dir => Binary (InstallDirs dir) Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods put :: InstallDirs dir -> Put # get :: Get (InstallDirs dir) # putList :: [InstallDirs dir] -> Put #
Eq dir => Eq (InstallDirs dir) Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods (==) :: InstallDirs dir -> InstallDirs dir -> Bool # (/=) :: InstallDirs dir -> InstallDirs dir -> Bool #
type Rep (InstallDirs dir) Source # |

Instance details

Defined in Distribution.Simple.InstallDirs

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

type InstallDirTemplates = InstallDirs PathTemplate Source #

The installation directories in terms of `PathTemplate`s 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.

defaultInstallDirs :: CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates Source #

defaultInstallDirs' :: Bool -> CompilerFlavor -> Bool -> Bool -> IO InstallDirTemplates Source #

combineInstallDirs :: (a -> b -> c) -> InstallDirs a -> InstallDirs b -> InstallDirs c Source #

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 |
CopyToDb FilePath | when using the ${pkgroot} as prefix. The CopyToDb will adjust the paths to be relative to the provided package database when copying / installing.

#### Instances

Instances details

Generic CopyDest Source # |
Instance details Defined in Distribution.Simple.InstallDirs Associated Types type Rep CopyDest :: Type -> Type Source # Methods from :: CopyDest -> Rep CopyDest x Source # to :: Rep CopyDest x -> CopyDest Source #
Show CopyDest Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods showsPrec :: Int -> CopyDest -> ShowS Source # show :: CopyDest -> String Source # showList :: [CopyDest] -> ShowS Source #
Binary CopyDest Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods put :: CopyDest -> Put # get :: Get CopyDest # putList :: [CopyDest] -> Put #
Eq CopyDest Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods (==) :: CopyDest -> CopyDest -> Bool # (/=) :: CopyDest -> CopyDest -> Bool #
type Rep CopyDest Source # |

Instance details

Defined in Distribution.Simple.InstallDirs

type Rep CopyDest = D1 ('MetaData "CopyDest" "Distribution.Simple.InstallDirs" "Cabal-3.10.1.0" 'False) (C1 ('MetaCons "NoCopyDest" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "CopyTo" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FilePath)) :+: C1 ('MetaCons "CopyToDb" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 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 `PathTemplate`s that still have the `PrefixVar` in them. Doing this makes it each to check which paths are relative to the $prefix.

data PathTemplate Source #

An abstract path, possibly containing variables that need to be substituted for to get a real `FilePath`.

#### Instances

Instances details

Structured PathTemplate Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods structure :: Proxy PathTemplate -> Structure Source # structureHash' :: Tagged PathTemplate MD5
Generic PathTemplate Source # |
Instance details Defined in Distribution.Simple.InstallDirs Associated Types type Rep PathTemplate :: Type -> Type Source # Methods from :: PathTemplate -> Rep PathTemplate x Source # to :: Rep PathTemplate x -> PathTemplate Source #
Read PathTemplate Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods readsPrec :: Int -> ReadS PathTemplate Source # readList :: ReadS [PathTemplate] Source # readPrec :: ReadPrec PathTemplate Source # readListPrec :: ReadPrec [PathTemplate] Source #
Show PathTemplate Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods showsPrec :: Int -> PathTemplate -> ShowS Source # show :: PathTemplate -> String Source # showList :: [PathTemplate] -> ShowS Source #
Binary PathTemplate Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods put :: PathTemplate -> Put # get :: Get PathTemplate # putList :: [PathTemplate] -> Put #
Eq PathTemplate Source # |
Instance details Defined in Distribution.Simple.InstallDirs Methods (==) :: PathTemplate -> PathTemplate -> Bool # (/=) :: PathTemplate -> PathTemplate -> Bool #
Ord PathTemplate Source # |

Instance details

Defined in Distribution.Simple.InstallDirs

Methods

compare :: PathTemplate -> PathTemplate -> Ordering #

(<) :: PathTemplate -> PathTemplate -> Bool #

(<=) :: PathTemplate -> PathTemplate -> Bool #

(>) :: PathTemplate -> PathTemplate -> Bool #

(>=) :: PathTemplate -> PathTemplate -> Bool #

max :: PathTemplate -> PathTemplate -> PathTemplate #

min :: PathTemplate -> PathTemplate -> PathTemplate #

type Rep PathTemplate Source # |
Instance details Defined in Distribution.Simple.InstallDirs type Rep PathTemplate = D1 ('MetaData "PathTemplate" "Distribution.Simple.InstallDirs" "Cabal-3.10.1.0" 'True) (C1 ('MetaCons "PathTemplate" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [PathComponent])))

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,
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

Instances details

Structured PathTemplateVariable Source # |
Instance details Defined in Distribution.Simple.InstallDirs.Internal Methods structure :: Proxy PathTemplateVariable -> Structure Source # structureHash' :: Tagged PathTemplateVariable MD5
Generic PathTemplateVariable Source # |
Instance details Defined in Distribution.Simple.InstallDirs.Internal Associated Types type Rep PathTemplateVariable :: Type -> Type Source # Methods from :: PathTemplateVariable -> Rep PathTemplateVariable x Source # to :: Rep PathTemplateVariable x -> PathTemplateVariable Source #
Read PathTemplateVariable Source # |
Instance details Defined in Distribution.Simple.InstallDirs.Internal Methods readsPrec :: Int -> ReadS PathTemplateVariable Source # readList :: ReadS [PathTemplateVariable] Source # readPrec :: ReadPrec PathTemplateVariable Source # readListPrec :: ReadPrec [PathTemplateVariable] Source #
Show PathTemplateVariable Source # |
Instance details Defined in Distribution.Simple.InstallDirs.Internal Methods showsPrec :: Int -> PathTemplateVariable -> ShowS Source # show :: PathTemplateVariable -> String Source # showList :: [PathTemplateVariable] -> ShowS Source #
Binary PathTemplateVariable Source # |
Instance details Defined in Distribution.Simple.InstallDirs.Internal Methods put :: PathTemplateVariable -> Put # get :: Get PathTemplateVariable # putList :: [PathTemplateVariable] -> Put #
Eq PathTemplateVariable Source # |
Instance details Defined in Distribution.Simple.InstallDirs.Internal Methods (==) :: PathTemplateVariable -> PathTemplateVariable -> Bool # (/=) :: PathTemplateVariable -> PathTemplateVariable -> Bool #
Ord PathTemplateVariable Source # |

Instance details

Defined in Distribution.Simple.InstallDirs.Internal

Methods

compare :: PathTemplateVariable -> PathTemplateVariable -> Ordering #

(<) :: PathTemplateVariable -> PathTemplateVariable -> Bool #

(<=) :: PathTemplateVariable -> PathTemplateVariable -> Bool #

(>) :: PathTemplateVariable -> PathTemplateVariable -> Bool #

(>=) :: PathTemplateVariable -> PathTemplateVariable -> Bool #

max :: PathTemplateVariable -> PathTemplateVariable -> PathTemplateVariable #

min :: PathTemplateVariable -> PathTemplateVariable -> PathTemplateVariable #

type Rep PathTemplateVariable Source # |

Instance details

Defined in Distribution.Simple.InstallDirs.Internal

type Rep PathTemplateVariable = D1 ('MetaData "PathTemplateVariable" "Distribution.Simple.InstallDirs.Internal" "Cabal-3.10.1.0" 'False) ((((C1 ('MetaCons "PrefixVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BindirVar" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "LibdirVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LibsubdirVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DynlibdirVar" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "DatadirVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DatasubdirVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "DocdirVar" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "HtmldirVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PkgNameVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PkgVerVar" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "PkgIdVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LibNameVar" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "CompilerVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "OSVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ArchVar" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "AbiVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "AbiTagVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ExecutableNameVar" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "TestSuiteNameVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "TestSuiteResultVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BenchmarkNameVar" 'PrefixI 'False) (U1 :: Type -> Type))))))

type PathTemplateEnv = [(PathTemplateVariable, PathTemplate)] Source #

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

combinePathTemplate :: PathTemplate -> PathTemplate -> PathTemplate Source #

substPathTemplate :: PathTemplateEnv -> PathTemplate -> PathTemplate Source #

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

The initial environment has all the static stuff but no paths

platformTemplateEnv :: Platform -> PathTemplateEnv Source #

compilerTemplateEnv :: CompilerInfo -> PathTemplateEnv Source #

packageTemplateEnv :: PackageIdentifier -> UnitId -> PathTemplateEnv Source #

abiTemplateEnv :: CompilerInfo -> Platform -> PathTemplateEnv Source #

installDirsTemplateEnv :: InstallDirs PathTemplate -> PathTemplateEnv Source #