[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: make always builds, part 2

From: Warlich, Christof
Subject: RE: make always builds, part 2
Date: Tue, 15 Nov 2011 13:49:14 +0100

Try making the $(OBJDIRECTORY) dependency an "order-only" dependency
i.e. note the pipe character below):

%.d : %.cpp | $(OBJDIRECTORY)
    g++ -MM -o $@ $<

Hope this helps!


-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Edgar
Sent: Dienstag, 15. November 2011 07:24
To: address@hidden
Subject: make always builds, part 2

I can't get my makefile to work correctly. I have an .a file that 
depends on .o files that depend on .d files that depend on an output 
object directory existing. The problem is that the d files always build 
because make says the directory is newer than the d files, but it was 
created 8 days ago, and the d files were just created.

I tried to make a small example of it, but this just has problems of its 
own (doesn't make $(OBJDIRECTORY) or test.d even though they are 
prerequisites of test.o, or at least I think they should be, but if not, 
why not?)

OBJDIRECTORY = build\obj\Dynamic\Release

SRCFILES = test.cpp

test.exe : $(OBJFILES)
    g++ -o test.exe $(OBJFILES)

%.o : %.cpp %.d
    g++ -c -o $@ $<

%.d : %.cpp $(OBJDIRECTORY)
    g++ -MM -o $@ $<

    mkdir $(OBJDIRECTORY)

restart :
    del test.exe
    del *.o
    del *.d
    -rmdir $(OBJDIRECTORY)

Here is the output :
g++    -c -o test.o test.cpp
g++ -o test.exe test.o

make: `test.exe' is up to date.

So, can anyone tell me why my library's makefile always says the d files 
are out of date because the directory is newer (even though it is not),
or why this small example makefile doesn't build the d file or make the 


Help-make mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]