Cabal: bindir/libdir/datadir

Ross Paterson ross at
Fri Oct 7 07:07:58 EDT 2005

On Fri, Oct 07, 2005 at 11:10:14AM +0100, Simon Marlow wrote:
> Ok, here's what I use in Alex:
> #include "Paths.hs-inc"
> getDataDir :: IO FilePath
> getDataDir = do 
>   m <- getPrefix binDirRel
>   return (fromMaybe prefix m `joinFileName` dataDirRel)
> getPrefix :: FilePath -> IO (Maybe FilePath)
>   -- always returns Nothing on Unix, on Windows calculates
>   -- prefix from the path of the executable, assuming the current
>   -- executable is in $prefix/$bindirrel.
> This code is always the same, so as Krasimir pointed out we should
> provide it to the executable via Paths.hs-inc somehow.  Good ideas for
> how to do this are welcome.

Yes, getDataDir is the right interface to provide.

For Hugs, the "executable" will be the file containing the Main
module, and the data files might as well go in the same directory,
at least on Windows.

> So we could actually make $libextradir visible and explicit, i.e. change
> the scheme to this:
>   libdirrel   = lib (by default)
>   libextradir = $package/$compiler
>   libInstDir  = $prefix/$libdirrel/$libextradir
> Is that what you want?

Yes, setting libdirrel independently from libextradir gives
interoperability with autoconf, and also means installers don't have
to mess with Cabal's placement policy unless they really want to.
One could specify libdirrel with a new option or with --libdir
(possibly extended with substitutions).

More information about the Libraries mailing list