Compiling using gmake

David Fox ddssff at
Mon Nov 7 14:35:08 CET 2011

On Sat, Nov 5, 2011 at 4:41 PM, Christian Brolin <cbrolin at> wrote:
> Hello
> I try to set-up a gnu makefile for compiling Haskell programs with GHC. I
> want to generate dependencies automatically and I want to put my object (.o)
> files in a binary specifc directories to be able to compile for different
> architechtures. The problem is when GHC derives the dependencies it names
> the object file for the Main module to Main.o and not filename.o as it does
> if I don't specifiy an odir. This gives me two problems, first I cannot have
> more than one Main module in the same directory as I often need, e.g. for
> different test programs. The second problem is that it doesn't match my
> compile command which always names the object files after the the source
> files by just changing extensions from .hs to .o. So gmake does not
> recognize dependencies from my Main modules to other modules.
> I am stuck here. Any ideas?

I found early on that trying to use gmake with haskell is a losing
battle.  Maybe you could change your approach to use cabal?   That way
you can specify the build directory using something like "runhaskell
Setup --builddir dist-whatever build"

More information about the Glasgow-haskell-users mailing list