[Haskell-cafe] CABAL: conditional executable?

Henning Thielemann lemming at henning-thielemann.de
Tue Mar 4 04:18:12 EST 2008


On Tue, 4 Mar 2008, Magnus Therning wrote:

> I'm putting together a package consisting of 2 executables. Only one of
> them is pure Haskell and thus buildable on all platforms, the other
> relies on Windows API calls and can only be built on that platform.  I
> found the “if os(...)” conditional in the CABAL docs but I'm having
> problems getting it to do what I want.
>
> if os(mingw32)
>  executable foo
>    ...
>
> Results in the error “Section expected”.  Swapping the two lines like this
>
> executable foo
>  if os(mingw32)
>    ...
>
> results in “Setup.hs: Error: No 'Main-Is' field found for executable foo”.

It sounds like another instance of the case that parts of a package cannot 
be build under some circumstances. Keep in mind that other packages might 
rely on the installed second executable if they find that the package is 
installed. Thus, I guess it's better to extract the second executable to a 
different package for Window's only stuff.


More information about the Haskell-Cafe mailing list