
On 09 August 2005 09:56, Bernard Pope wrote:
On Tue, 2005-08-09 at 09:36 +0100, Simon Marlow wrote:
The problem, of course, is how to get the value of $datadir to the program if it is configurable. I suggested a CPP symbol, but that is far from ideal (we don't do it this way in fptools projects any more for various reasons). Another option is to have the Setup script generate a file containing the declarations:
-- paths.h prefix="/usr/local" bindir="bin" -- or absolute libdir="lib/foo-1.0/ghc-6.4" datadir="share/foo-1.0"
which you can then #include into Haskell source. Another alternative, if you want to avoid CPP, is to have Setup generate a complete Haskell module with these declarations, but then you have to somehow choose an appropriate module name that doesn't clash.
paths.h gets my vote. Anyone have any better ideas?
What if, say, you have some C code in your package that also wants to know the values of these paths?
There's no single solution that works for all languages. The good news is that prefix/bindir/libdir/datadir would be available in the LocalBuildInfo, so you would be able to implement any scheme you like using the postConf hook. And maybe we could refer to these values in the .cabal file, so you could write extra-cc-options: -Dprefix=$prefix (probably some quoting required somewhere, but you get the idea). Cheers, Simon