Hierarchical modules and compilation output redirection

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

Martin Norbäck
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.
You could use a recent version of hmake, with the -d OUTPUT_DIR option. This will place .o files in directories corresponding to their hierarchical names. e.g. hmake -ghc Main -i. -d OUTPUT_DIR generates OUTPUT_DIR/Main.o OUTPUT_DIR/Bar/Module.o OUTPUT_DIR/Foo/Module.o and links them to a final executable ./Main. Regards, Malcolm
participants (2)
-
Malcolm Wallace
-
Martin Norbäck