[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Make rebuilds when it is not necessary
From: |
Rupal Desai |
Subject: |
RE: Make rebuilds when it is not necessary |
Date: |
Tue, 7 Mar 2006 22:59:55 -0800 |
The dummy variable worked. Thank You. Now I just need to figure out
how to make the *.d files for every *.o files.
Rupal
-----Original Message-----
From: Paul Smith [mailto:address@hidden On Behalf Of Paul D. Smith
Sent: Tuesday, March 07, 2006 2:31 AM
To: Rupal Desai
Cc: address@hidden
Subject: Re: Make rebuilds when it is not necessary
%% "Rupal Desai" <address@hidden> writes:
rd> $(OBJS):$(OBJDIR)/%.o: %.cpp $(OBJDIR)
This is (at least one of) your problem(s).
You've added OBJDIR as a prerequisite. That means that any time OBJDIR
is newer than the target (xxxx.o), the .o file will be considered out of
date and rebuilt.
Well, on UNIX anyway, a directory's last modified timestamp is changed
whenever the directory is changed, which means whenever a file is added,
removed, or renamed in that directory.
So, every time a .o is created in that directory it becomes newer than
all the .o's that were already there, and they all rebuild.
For this reason it's virtually always a very bad idea to list a
directory as a normal prerequisite of a target.
You have two choices. I personally prefer to simply always create the
directory immediately when make starts, like this:
__dummy := $(shell [ -d "$(OBJDIR)" ] || mkdir -p "$(OBJDIR)")
or similar.
The alternative, if you have a sufficiently new version of GNU make, is
to use order-only prerequisites:
$(OBJS):$(OBJDIR)/%.o: %.cpp | $(OBJDIR)
--
------------------------------------------------------------------------
-------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad
Scientist