[Haskell-cafe] Custom cabal languages (hooks?)

Duncan Coutts duncan.coutts at googlemail.com
Sat Nov 28 11:46:56 EST 2009

On Sat, 2009-11-28 at 14:47 +0100, Svein Ove Aas wrote:
> I'm currently working on a binding to Brian Gladman's C/assembler AES
> implementation.
> This code is sufficiently small that it makes little sense to create a
> separate C library for it; furthermore, it isn't typically packaged by
> the various linux distributions, never mind other OSs. As a result,
> I'd like to make it part of the cabalized AES package.
> This works well enough with the pure-C variant of the implementation,
> but it also has assembly-based implementations of the core encryption
> routines for x86 and x86_64, specifically using yasm, which I would
> like to use when possible.

The simplest thing from the cabal pov would be to just include the asm
inline into a .c file.

> So, two problems..
> - First, I need to make cabal detect yasm's presence, and call out to
> it when appropriate. The former I can do with a configure script;

That's the bit that's actually easy within a Setup.hs, no need for
non-portable ./configure scripts.

> the latter, I'm not quite sure how to do. Currently, cabal can only do C;
> basically, I'm looking for a way to let it use any language that can
> be compiled to .o files.

Right, there's no support for that in the "Simple" build system. You'd
have to use the hooks.

> - Second, having manually compiled the C/asm bits to .a and .so form,
> I did eventually get cabal to link (seemingly) correctly against it,
> but it then did not proceed to copy libaes.so into
> ~/.cabal/lib/AES/.... I'm not sure how to make it do that, either. I
> suppose I'll have to use hooks, but I'd appreciate a little advice on
> how, exactly

Right, it's only expecting one library. You could either link the stuff
into the same lib or add copying code in the copy hook.


More information about the Haskell-Cafe mailing list