[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fun with auto generated dependencies & clean...
From: |
Rick Flower |
Subject: |
Re: Fun with auto generated dependencies & clean... |
Date: |
Thu, 19 Apr 2007 15:46:13 -0700 |
User-agent: |
Thunderbird 2.0.0.0 (Windows/20070326) |
Mike Shal wrote:
The problem is you're building the dependencies before each build,
rather than during the build. This is because you've made a rule for
the dependency files (%.d: %.cc) and you're including them. It is only
necessary to have the dependency files available for the *next* build.
See: http://make.paulandlesley.org/autodep.html
Sounds good.. I'm still reading the above site.. Thanks for the link
%.d: %.cc
@echo "Building depends..."
$(target_gpp) -MM $(GPPFLAGS) $< \
| sed "/.*\.o:/ s%^[ ]*%\$$(OBJDIR)/%" > $@
I would get rid of this rule, or perhaps move the commands into the
%.o: %.cc rule so the .d and .o files are built at the same time.
I'm working on this..
$(OBJDIR)/%.o : %.cc %.d
@echo "Prerequisites are: $^"
$(target_gpp) $(GPPFLAGS) -c $< -o $@
Here I would remove %.d from the rule, since the .o file doesn't need
the .d file to be built (again, you just want the .d to hang around
for the next time you build). If you moved your commands from the .d
Done..
rule here, you would always create the .d file when you create the .o
file. Or, assuming you're using a recent version of gcc, look into the
-MMD flag. This flag will create the .o and .d simultaneously (thus
saving you an extraneous preprocessing step). Also look at the other
-M flags (like -MT, -MF, etc) to get the .d file in the location you
want it, and have it specify the correct rule. IIRC these flags
changed behavior a few times during the 3.X releases, but I think
they're stable now.
I'm using some pretty old compilers (gcc-2.95.3 for ppc and gcc-2.9 for
pentium) and both seem to handle -MMD properly and generate the
requisite .d files, but neither version knows anything about -MF or -MT
so I guess I'll have to do without.. Normally in the past we would
create a .depends_${target} file for each src directory we had for our
sun or ppc builds and generate them before building the objects for that
directory. If we go and switch paradigms here and have the compiler
both build and generate depends at the same time, is it safe to rename
the files to be something like file1.d_${target} and is there some way
to teach Make to look for them instead of file1.d without getting into
the same sort of issues I've got now? Or... Can I still use the
monolithic single file for all depends and just concatenate each ".d"
file contents into the bigger file after building each object? The only
thing gained by doing that is less clutter I suppose.. I'm not sure how
my other group members are going to like the extra files since they're
used to a single file that we've had up to now for each directory..
Not sure if that necessarily helps with the issue of specifying both
clean and all at the same time (it seems like you would still have
issues with -j), but it would be more efficient :)
It's been very interesting. I'll see where this all takes me.. Thanks
for the suggestions/info so far!