Help! no environment variable expansion in package files ?!?

Simon Marlow simonmar at microsoft.com
Thu Apr 28 09:49:05 EDT 2005


On 28 April 2005 14:37, Daan Leijen wrote:

> I am trying to prepare a new release of wxHaskell based
> on ghc 6.4 but I am in despair. It seems that the new
> package descriptions do no longer allow environment
> variables in there. For example:
> 
>  import-dirs:${wxhlibdir}/imports
> 
> I would like the ${wxhlibdir} to be replaced by the
> value in the environment. This feature is absolutely
> *essential* to get the windows installer working.
> I use a batch file that gets the current directory
> and puts that in the environment before call ghc-pkg.
> 
> On unix, I can use sed to make it work, but this does
> not hold for windows. What can I do to allow the user
> to install wxhaskell at arbitrary places using just a
> batch file? (ie. we can not assume that cygwin is available)
> I can hardly believe if no one has thought of this before,
> so I hope it is just a syntax issue.

I didn't port the feature to the new version of ghc-pkg.  Sorry about
that, the reasons were that (a) there are other ways to do it, and (b)
the other ways are in general better, because you can substitute
multiple values for a variable.

I suggest you use CPP ('gcc -E -undef -traditional -P' or 'cpphs').
This is what we use in GHC to get values into the package.conf files.
e.g. in a Makefile you would write something like:

package.conf : package.conf.in
	gcc -E -undef -traditional -P -x c $< >$@ \
		-DWXHLIBDIR='"$(wxhlibdir)"'

(untested; I copied this mostly from GHC's build system).

Another option, if you use autoconf, is to process the file using the
configure script.

Cheers,
	Simon


More information about the Libraries mailing list