Compiling using gmake

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiling using gmake

Christian Brolin
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?



_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: Compiling using gmake

David Fox-7
On Sat, Nov 5, 2011 at 4:41 PM, Christian Brolin <[hidden email]> 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"

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: Compiling using gmake

Simon Marlow-7
In reply to this post by Christian Brolin
On 05/11/2011 23:41, Christian Brolin wrote:

> 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?

In GHC's build system we use explicit -o options, as well as -odir and
-hidir.

Cheers,
        Simon


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users