Cabal proposal: user-configurable prefixes (thinking of HSFFIG integration as a preprocessor)

Dimitry Golubovsky golubovsky at gmail.com
Wed Aug 3 14:24:05 EDT 2005


I have been thinking how HSFFIG (Isaac once suggested this) could be
integrated with Cabal as a preprocessor. The problem is, external
library header file might be located arbitrarily, up to the decision
of local system maintainer.

I am proposing to extend the "setup configure" command. Currently, one
may invoke:

setup configure --with-alex=/path/to/alex/installed/bin/alex

If however a .cabal file contained stanzas like this:

user-prefix-key: mylib
user-prefix-default: /usr/local/lib
user-prefix-help: The library absolutely necessary to build this package

and the cabal program was appropriately modified (I realize this may
be hard) then it would become possible to run:

setup configure --with-mylib=/path/to/the/location/of/mylib/installed

and setup-configure --help would mention --with-mylib as one of the
possible configuration options.

Then if someone is installing a package requiring this library, and
its installation is not done in standard way, it is up to that person
to locate the library.

Going further, this "mylib" token might become a part of the
`extra-lib-dirs' field:

extra-lib-dirs: $mylib

to be substituted with whatever the user specifies as --with-mylib.

And then a new field needs to be added to the .cabal file format:

extra-include-dirs: $mylib/../include

because a library may be installed anywhere, but relative position of
its include files and the library itself is unlikely to vary.

This extra-include-dirs will be used by the wrapper for HSFFIG, so
that these tokens will be passed to the C preprocessor telling where
to look for headers.

And then HSFFIG may be fit in the preprocessors framework of Cabal.

Suppose we have a file MYLIB.h in the directory where other source
files are placed. Then, having defined HSFFIG as a preprocessor for .h
suffix (I will have to write a replacement of the HSFFIG main program
so that the module name will match the header name without postfixing
with "_H"), MYLIB.h will be converted to MYLIB.hs (or more files if
the splitter is applied)

MYLIB.h will contain then just this

#include <mylib.h>

assuming that the library's include file is mylib.h.

As the extra-include-dirs will be passed properly to the C
preprocessor, the library include file will be found correctly.

PS I understand, this may be hard to implement and I am ready to help
with coding if there is interest in such an integration.

-- 
Dimitry Golubovsky

Anywhere on the Web


More information about the Libraries mailing list