building a helper binary with cabal

Evan Martin martine at danga.com
Sat Mar 1 03:02:49 EST 2008


[resent after subscribing to the list]

I'm working on a package that requires building a helper binary as
part of its install process.  This binary is written in C (with good
reason), and on a Debian system would be installed into a path like
/usr/lib/myproject/mybinary, because it's only used internally by the
main program binary.

My setup is up to this point:

> gccProgram :: Program
> gccProgram = simpleProgram "gcc"

> type BuildHook = PackageDescription -> LocalBuildInfo
>                -> UserHooks -> BuildFlags -> IO ()
> creplChildBuild :: BuildHook -> BuildHook
> creplChildBuild oldhook desc buildinfo hooks flags = do
>   oldhook desc buildinfo hooks flags
>   rawSystemProgramConf (buildVerbose flags) gccProgram (buildPrograms flags)
>       ["child.c", "-o", buildDir buildinfo </> "child", "-ldl"]

> buildHooks = simpleUserHooks {
>   hookedPrograms = [gccProgram],
>   buildHook = creplChildBuild (buildHook simpleUserHooks)
> }

> main = defaultMainWithHooks buildHooks

However, it's unclear to me how to set up the install rule that would
copy that binary into the appropriate place.
Any tips?  It seems I want to grab the "install" hook, but from there
how do I specify where to install the file?  There seem to be no
helper functions to facilitate installing.

(I appreciate that all of this is pretty new.  So if it's not possible
for me to do what I want, take it as an example of the sort of thing
I'd like for Cabal to support...)


More information about the Libraries mailing list