ocramz
ocramz

Reputation: 833

Haskell inline-c multi-step build/link with Cabal

I am writing an FFI-heavy library that uses inline-c, and the build process is:

QUESTION: Currently I'm doing the above in a makefile (see https://github.com/ocramz/petsc-hs/blob/master/makefile ), but I'd like to package it up in a Cabal file (working version : https://github.com/ocramz/petsc-hs/blob/master/petsc-hs.cabal).

SUB-QUESTIONS:

Thank you in advance for all pointers

Upvotes: 1

Views: 185

Answers (1)

ErikR
ErikR

Reputation: 52049

How does one control the build/link sequence in Cabal?

You can use Build-Type: Custom in your cabal file and control everything with a custom Setup.hs.

Have a look at the UserHooks data type for all of the phases of cabal which you can control.

Some examples:

Are relative paths supported in Cabal? couldn't find this mentioned in the guide and bash-like ~ doesn't work

If your library is external to your cabal package, I would consider using pkg-config on Unix/Linux systems to have cabal locate the library. See the answers to this SO question: How to specify dependency on external C library in .cabal?

If your library is part of your cabal package, check out this blog post and related github repo which shows how to write a custom Setup.hs file to build and install the library in the right place for cabal:

Upvotes: 2

Related Questions