passing cpp options to c2hs from cabal

Hi all, I have a question about cpp, c2hs and cabal. The short version: What can I put in my cabal file to get "-cppopts=-U__BLOCKS__" passed as an argument in calls to c2hs? Longer story: I need to set up my cabal file so that c2hs gets this extra option to make things build smoothly on some macs. If I run cabal from the command line, I can pass it: cabal install --c2hs-options='--cppopts=-U__BLOCKS__' And this works great. I need to make my .cabal file do this, but c2hs-options doesn't seem to be accepted there. I tried: cpp-options: "-U__BLOCKS__" But if I run cabal install -v I can see this isn't being passed on to c2hs: ... /home/ccasin/.cabal/bin/c2hs --include=dist/build --cppopts=-D__GLASGOW_HASKELL__=610 --cppopts=-Icontrib/libpuz/include --output-dir=dist/build --output=Codec/Game/Puz/Internal.hs ./Codec/Game/Puz/Internal.chs ... Thanks! --Chris Casinghino

Am Samstag 27 Februar 2010 21:27:27 schrieb Chris Casinghino:
Hi all,
I have a question about cpp, c2hs and cabal. The short version:
What can I put in my cabal file to get "-cppopts=-U__BLOCKS__" passed as an argument in calls to c2hs?
Maybe cc-options: -U__BLOCKS__ is worth a try.
Longer story:
I need to set up my cabal file so that c2hs gets this extra option to make things build smoothly on some macs. If I run cabal from the command line, I can pass it:
cabal install --c2hs-options='--cppopts=-U__BLOCKS__'
And this works great. I need to make my .cabal file do this, but c2hs-options doesn't seem to be accepted there. I tried:
cpp-options: "-U__BLOCKS__"
But if I run cabal install -v I can see this isn't being passed on to c2hs:
... /home/ccasin/.cabal/bin/c2hs --include=dist/build --cppopts=-D__GLASGOW_HASKELL__=610 --cppopts=-Icontrib/libpuz/include --output-dir=dist/build --output=Codec/Game/Puz/Internal.hs ./Codec/Game/Puz/Internal.chs ...
Thanks!
--Chris Casinghino

This works great, thanks!
As a footnote: I doubt I will be the only one is confused because
"cc-options" get passed to c2hs but "cpp-options" don't. Perhaps the
cabal designers should revisit this choice.
--Chris
On Sat, Feb 27, 2010 at 3:44 PM, Daniel Fischer
Am Samstag 27 Februar 2010 21:27:27 schrieb Chris Casinghino:
Hi all,
I have a question about cpp, c2hs and cabal. The short version:
What can I put in my cabal file to get "-cppopts=-U__BLOCKS__" passed as an argument in calls to c2hs?
Maybe
cc-options: -U__BLOCKS__
is worth a try.
Longer story:
I need to set up my cabal file so that c2hs gets this extra option to make things build smoothly on some macs. If I run cabal from the command line, I can pass it:
cabal install --c2hs-options='--cppopts=-U__BLOCKS__'
And this works great. I need to make my .cabal file do this, but c2hs-options doesn't seem to be accepted there. I tried:
cpp-options: "-U__BLOCKS__"
But if I run cabal install -v I can see this isn't being passed on to c2hs:
... /home/ccasin/.cabal/bin/c2hs --include=dist/build --cppopts=-D__GLASGOW_HASKELL__=610 --cppopts=-Icontrib/libpuz/include --output-dir=dist/build --output=Codec/Game/Puz/Internal.hs ./Codec/Game/Puz/Internal.chs ...
Thanks!
--Chris Casinghino
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Mon, 2010-03-01 at 10:07 -0500, Chris Casinghino wrote:
This works great, thanks!
As a footnote: I doubt I will be the only one is confused because "cc-options" get passed to c2hs but "cpp-options" don't. Perhaps the cabal designers should revisit this choice.
I mostly agree. What is a bit odd about c2hs is that it mixes cpp flags for the C headers with cpp flags for the .chs file itself. So cc-options are really for the C code, and those get passed to c2hs. The cpp-options are for pre-processing Haskell code, and indeed arguably these should be passed to c2hs too because recent c2hs versions also apply something approximating cpp to the .chs file itself. So depending on whether your -U__BLOCKS__ flag is to influence the C headers or the contents of the .chs file, then use cc-options or cpp-options. I'll update this for some future release. Duncan
participants (3)
-
Chris Casinghino
-
Daniel Fischer
-
Duncan Coutts