help-make
[Top][All Lists]
Advanced

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

Re: make always builds everything


From: Edgar
Subject: Re: make always builds everything
Date: Sun, 13 Nov 2011 21:30:22 -0600
User-agent: Thunderbird 2.0.0.24 (Windows/20100228)

Paul Smith wrote:
On Sat, 2011-11-12 at 18:42 -0600, Edgar wrote:
I'm relatively new to make, but for the life of me I can't get make to work the way it is supposed to by only rebuilding what is necessary. It always rebuilds everything all over again and I don't know what I am doing wrong. Hopefully someone here can take a look at my makefiles and tell me what is wrong.

Generally we prefer that you create a small, completely self-contained
example that shows the problem and post that here, instead of referring
us to a large and complex build environment and asking us to debug it.

One excellent reason for this is that by trying to generate a minimal
example of the problem, probably 80% of the time you'll figure it out
for yourself and end up not needing to ask for help at all.


However, I took a quick jump over to your thread at gamedev.net and
immediately saw your problem.

All your rules have extra prerequisites on them:

        $(OBJDIR)/%.d : src/%.c makebuilddirs $(FIXDFILES)
            ...
        $(OBJDIR)/%.o : src/%.c $(OBJDIR)/%.d
            ...
        makebuilddirs :
                -$(MKDIR) $(LIBDIR)
                -$(MKDIR) $(subst /,$(SLASH),$(OBJDIR))

Here we see that all .o's depend on the .d files and all .d files depend
on a target "makebuilddirs".  That target creates directories, but the
target itself (a file named "makebuilddirs") is never created.  That
means that the target "makebuilddirs" is never up to date, and that
means that the .d target is always out of date, and that means that
the .o target is always out of date, and that means make will always
rebuild it.

Every time you run make it "rebuilds" the makebuilddirs target and that
causes every other target in your makefile which depends on it (or
depends on something that depends on it) to be rebuilt.

If you run make with the -d flag (debugging) you'll see what is going
on.  It does generate a lot of output, I know, but it's not too hard to
understand if you study it for a few minutes.  Creating a small example
is also an excellent way to reduce the amount of output that -d gives to
a more manageable level.


Cheers!

I started to figure that out yesterday after I added in $? to check the prerequisites that were newer than the target.

FYI, I finally figured out how to get make to check for directories, as targets and in a $(wildcard ...) search - just add a trailing slash onto the folder name! Otherwise, it thinks it is a real file.

Anyway, thanks a lot for looking at my makefile.



reply via email to

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