[Haskell-cafe] Dynamic package information with Setup.hs

Peter Simons simons at cryp.to
Thu Nov 21 20:10:45 UTC 2013

Hi Thiago,

 > I've written a shell script that will download and build this C
 > library to a subdirectory of the user's
 > HOME(~/.cabal-tmp/{lib,include}).

please don't do that. It's notoriously hard to get this use case right
so that it works for everybody. Some people may want that library built
as a shared object; others may want it with profiling and/or debug
information. The next guy may want that library compiled with a
different version of GCC than the one GHC uses by default. Others may
want to link bindings to a copy of that library that's installed in
their system (under a path that you cannot guess).

What you should do is to add

  Extra-Libraries:      my-external-library

to your Cabal file and trust that the user specifies appropriate flags
at configure time to ensure that the compiler can find it if necessary.

You can distribute a shell script that tries to build the C library and
the Haskell library with convenient defaults, i.e. your script should

  cabal configure --extra-include-dirs=PATH --extra-lib-dirs=PATH

with appropriate paths after having built the C code, but please make
sure that your Haskell package works fine for people who want to build
the C library themselves without using your script.

Take care,

More information about the Haskell-Cafe mailing list