Hierarchical modules and compilation output redirection

Martin Norbäck d95mback@dtek.chalmers.se
15 Oct 2002 16:34:46 +0200


I am using hierarchical modules with ghc, and I have a bunch of common
modules used by several projects, which should build on serveral
platforms.

Now, assume I have the following:

.
|-- Bar
|   `-- Module.hs
|-- Foo
|   `-- Module.hs
`-- Main.hs


Main imports both Bar.Module and Foo.module.

Currently I am using -osuf ARCHITECTURE.o with ghc --make, which works,
but clutters the common modules directory with .o files. (I may want to
keep it clean.)

So I want to redirect the output with -odir OUTPUT_DIR

However it won't work since ghc wll put the compilation output of both
modules in OUTPUT_DIR/Module.o and subsequently fail to link.

Is there a way to get the files named Bar.Module.o and Foo.Module.o or
such? Is there a better way?

Another thing that would be good would be a way to redirect output to a
directory relative to where the source file is, say for instance that
the output of Bar/Module.hs should be put in Bar/ARCHITECTURE/Module.o
and the output of Foo/Module.hs should be put in
Foo/ARCHITECTURE/Module.o.

This is just a cosmetic matter, since I can use -osuf and get a similar
effect, but using a separate dir would reduce clutter in the directory.

Regards,

	Martin