Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cabal "os" flag with operating system version

Tags:

haskell

cabal

I'd like a flag that is conditioned on the version of the OS, and not just the OS:

if os(darwin) && os-version() >= 10.7

or

if os-version(>=10.7)

or something with that behavior.

I could do it with make and sw_vers -productVersion, but I want to keep the Cabal file with build-type: Simple (I mean it even has a frameworks field).

Context: I have some bindings to some Cocoa functions that were introduced in OSX 10.7 or so. I'd like Cabal to not try to build on older Macs, rather than spamming the person installing the package with unhelpful "symbol not found" errors or whatnot.

https://www.haskell.org/cabal/users-guide/developing-packages.html#configurations (Under "conditions") seems to say no.

like image 245
sam boosalis Avatar asked Mar 30 '15 20:03

sam boosalis


1 Answers

You're correct. Cabal does not offer this feature. Here's the relevant ticket. However, for OS X you don't need to necessarily move from build-type: Simple. Rather you can use CPP and the macros provided by apple, as discussed at another SO question.

like image 102
sclv Avatar answered Oct 03 '22 03:10

sclv