[Haskell-cafe] Arbitrary files in a Cabal package: how to install

Dimitry Golubovsky golubovsky at gmail.com
Mon Jul 25 08:42:53 EDT 2005

Ross Paterson wrote:

I think there should be a new field (data-files?) listing files to be
installed where the program can find them:
- for GHC under Unix, in {prefix}/share/{exeName}/
- for GHC under Windows, in the same directory as the executable
  ({Program Files}/{packageID})
- For Hugs, in the same directory as the Main module


Is there a way for a program/library included in the package to know
its installation prefix (and other details) from the .cabal file at
compile time (so the necessary path would be hardcoded during
compilation) - maybe a CPP macro to be set when preprocessing the

I thought about a bit different approach.

For each data file to be installed, define a separate stanza (just
like for each executable), like this:

extra-files:  list -- (i. e. one or more files covered by this stanza)
preprocess: command line -- (e. g. cp -p)
destination: path -- (relative to the package installation root)

"preprocess" command will be called on each file separately. It is assumed to

- be aware of the OS environment it runs on, if applicable
- read the file pointed to by its first parameter and write the file
where the second parameter points to, after preprocessing.

The minimal preprocessor is cp.

If command line options are needed, they are part of the preprocess' value e. g.

preprocess: gcc -E

In some cases preprocessor may be a shell script placed somewhere
within the package source tree. Relative path to the script is
necessary then to specify.

Dimitry Golubovsky

Anywhere on the Web

More information about the Libraries mailing list