[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: how to include dependencies only if includes changed
From: |
Mark Galeck (CW) |
Subject: |
RE: how to include dependencies only if includes changed |
Date: |
Mon, 9 Nov 2009 10:25:28 -0800 |
> See http://make.paulandlesley.org/autodep.html for a good way to handle auto
> dependencies in make. Using the methods described in the article, you will
> only build dependencies when they are needed.
Oh yes, Pete, I am very much aware of this article. In fact, I combined ideas
from that article, with the auto-dep section from GNU make manual, to implement
the auto-dependencies. The problem is, and I believe neither that article nor
make manual address it, is that I don't want to "-include" all the dependencies
unless necessary. This is because I am dealing with a code base of over 8
million lines, more than 1000 .c files, each depending on around 500 .h files.
The dependencies, all of them, take about 1 minute to "-include", even if you
are just rebuilding one .o file. It is OK with me, but other developers would
not be happy about it.
I did finally come up with some solution, let me write it here, maybe someone
can comment if there is a better way. The target chooseIncl, is OS dependent:
it decides whether any included files have changed since last time, and based
on that invokes
$(MAKE) incl
or
$(MAKE) noIncl
--------------------
Main makefile (relevant fragments)
------------------------
-include included
.PHONY: all incl noIncl
all: mainProgram
incl noIncl: all
#goals that do not need any .d makefiles
GOALS_REQ_NO_INCLUDE = noIncl lastIncl clean
#goals that require some .d makefiles
GOALS_REQ_INCLUDE = $(filter-out $(GOALS_REQ_NO_INCLUDE), $(MAKECMDGOALS))
#goals that require all .d makefiles
GOALS_REQ_ALL_INCLUDE = $(filter-out %.o, $( GOALS_REQ_INCLUDE))
ifneq (, $( GOALS_REQ_ALL_INCLUDE))
-include $(OBJECTS:.o=.d)
else
-include $(GOALS_REQ_INCLUDE:.o=.d)
Endif
--------------------------------
"included" makefile,generated automatically by a Perl script when mainProgram
is rebuilt (relevant fragments)
-------------------------------
chooseIncl:
($(MAKE) -q lastIncl && ( $(MAKE) noIncl & touch lastIncl)) || ($(MAKE)
incl & touch lastIncl)
lastIncl:\
foobar.h\
foobar1.h\
(... all the header files)