help-make
[Top][All Lists]
Advanced

[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
(see http://www.gnu.org/s/hello/manual/make/Prerequisite-Types.html,
i.e. note the pipe character below):

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

Hope this helps!

Chris

-----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
OBJFILES = $(SRCFILES:.cpp=.o)
DFILES = $(OBJFILES:.o=.d)

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

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

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

$(OBJDIRECTORY) :
    mkdir $(OBJDIRECTORY)

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

Here is the output :
c:\ctwoplus\progcode\allegro\Eagle\maketest>make
g++    -c -o test.o test.cpp
g++ -o test.exe test.o

c:\ctwoplus\progcode\allegro\Eagle\maketest>make
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 
directory?

Thanks,
Edgar


_______________________________________________
Help-make mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-make



reply via email to

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