<div dir="ltr">you should look at libs that have c libs embedded in them approach it. a good simple example would be lz4hs.  Its really quite simple and doesn't require crazy hacks</div><div class="gmail_extra"><br><br>

<div class="gmail_quote">On Thu, Nov 21, 2013 at 4:25 PM, Thiago Padilha <span dir="ltr"><<a href="mailto:tpadilha84@gmail.com" target="_blank">tpadilha84@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">On Thu, Nov 21, 2013 at 5:10 PM, Peter Simons <<a href="mailto:simons@cryp.to">simons@cryp.to</a>> wrote:<br>
> You can distribute a shell script that tries to build the C library and<br>
> the Haskell library with convenient defaults, i.e. your script should<br>
> call<br>
><br>
>   cabal configure --extra-include-dirs=PATH --extra-lib-dirs=PATH<br>
><br>
> with appropriate paths after having built the C code, but please make<br>
> sure that your Haskell package works fine for people who want to build<br>
> the C library themselves without using your script.<br>
<br>
</div>  Peter,<br>
<br>
  My reason for taking this route is to simplify the installation by making the<br>
C library a transparent part of the package. This is similar to the haskell<br>
bindings to zlib( the difference is that it bundles zlib source code in the<br>
'cbits' directory since zlib build is simple everything just works).<br>
<br>
  This is common in package managers for other platforms(node.js,<br>
python) as it simplifies installation by users that have little experience with<br>
building C packages.<br>
<br>
  The goal is to have a generic Setup.hs file that I can use for packaging<br>
haskell bindings to libraries that have non-trivial build procedures, and still<br>
have everything working after a simple 'cabal install LIB'<br>
<br>
  With that said, I agree that allowing customization by advanced users is<br>
essential. Like you suggested, I already use the 'extra-libraries' field without<br>
specifying extra-lib-dirs/include-dirs.<br>
<br>
  I still would like to follow the automatic build route with the following<br>
changes:<br>
<br>
  - The Setup.hs file will only invoke the download/build script if the<br>
    --extra-lib-dirs/--include-dirs weren't passed to cabal(I believe the Args<br>
    argument for the preConf hook is suitable for that)<br>
  - An additional flag could be provided for users wanting to build against the<br>
    system's version of the library.<br>
<br>
  This should hide the installation details by providing reasonable defaults<br>
(like a library version that is guaranteed to work with the binding) while still<br>
giving full control to advanced users.<br>
<br>
  What do you think?<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br></div>