November 09, 2004
The 'make' tool documentation is pretty... Lacking. Could someone paste me a simple example makefile?


November 09, 2004
Joey Peters wrote:
> The 'make' tool documentation is pretty... Lacking. Could someone paste me a
> simple example makefile?

'make' is a standard tool that's used a lot more on Unix than it is on Windows (if you know all this, forgive me).  If you're so inclined, O'Reilly has a good little book called "Managing Projects with Make." Here's a sample makefile:

program : main.o mod1.o mod2.o
    sc program main.o mod1.o mod2.o

main.o : main.d
    dmd -c main.d

mod1.o : mod1.d
    dmd mod1.d

mod2.o : mod2.d
    dmd mod2.d

'program' is a target, and its dependencies are listed after the colon.  The following tab-indented line contains the command that builds 'program.'  But first make goes and builds all its dependencies, so mod1.o depends only on 'mod1.d' and is built using the command 'dmd -c main.d,' etc.  Things can get a bit tricky, as makefiles can contain macros like:

name = string

So when you place '$(name)' in the makefile it will be replaced with 'string.'  This should be enough to go on.  There are some rather long makefiles in the dmd source tree that I assume you've found :)


Sean