Cabal: bindir/libdir/datadir
Ross Paterson
ross at soi.city.ac.uk
Fri Oct 7 05:07:00 EDT 2005
On Thu, Oct 06, 2005 at 11:29:30AM +0100, Simon Marlow wrote:
> [...]
> How can the package itself find out what these paths are? As discussed
> previously, Cabal generates a file Paths.hs-inc containing
>
> prefix = "<dir>"
> binDirRel = "<dir>"
> libDirRel = "<dir>"
> ... etc ...
>
> which can be #included into Haskell source. Additionally I have the
> function:
>
> getPrefix :: FilePath{-binDirRel-} -> IO (Maybe FilePath)
>
> which figures out prefix when called from a binary installed in
> $prefix/$bindirrel. If it returns Nothing, then you can fall back to
> the hard-coded value of prefix from Paths.hs-inc.
Can you show the client code to find data files under any system and
compiler?
> There's one thing I'm not sure about yet: the default $libdirrel on Unix
> systems is lib/<pkgid>/<compiler>, eg. lib/pkg-0.2/ghc-6.4, and you
> might want to change just the "lib" bit, eg. to get
> lib64/pkg-0.2/ghc-6.4. It's annoying to have to specify the <pkgid> and
> <compiler> when Cabal knows them, so we might want a simple substitution
> syntax, such as --libdirrel=lib64/%p/%c. Sound reasonable?
There's a difference between the package libdir's you're talking about
(e.g. $prefix/lib/$PackageId/$CompilerId) and --libdir in autoconf
(default $prefix/lib). You couldn't easily generate the options to
configure from *dirrel. But do we really need an option to specify the
package libdir, or just --libdir (in the autoconf sense)? "lib64/%p/%c"
is easier than the full thing, but it still exposes Cabal's placement
policy to lots of installers. Similarly bindir, datadir, libexecdir
and maybe includedir. There would be no problem with generalizing the
autoconf options, though, say to allow substitutions (e.g. of prefix).
Of course I'm being Unix-centric. I've seen a couple of proposals
for layouts on Windows, and am unsure which is preferred.
> We might also want a simple way in the .cabal file to specify some files
> to be installed in $datadir (I think someone suggested this before).
> It's quite annoying to do it with hooks.
Yes indeed.
More information about the Libraries
mailing list