Re: Should build dependents when headers change

Henrik Carlqvist <[email protected]>
Newsgroups gmane.comp.gnu.utils
Organization SunSITE.dk - Supporting Open source
Message-ID <[email protected]>
"Eric Lilja" <[email protected]> wrote:
> My problem is that when I do a change in either header and then perform
> a make, make doesn't think anything needs to be recompiled. So I end up
> doing $ make clean ; make which, of course, rebuilds everything. How
> should I teach make to recompile files dependent on the headers I
> mentioned above whenever they have been changed?

I don't know if this group has a FAQ, but I did answer this only two days
ago and it seems that only 5 more messages has been written in this group
since then.

Method 1)

Manually add lines like:

crc32.o: crc32.h globals.h

Method 2)

Let gcc do the job for you, modify the following lines in your Makefile:

%.o: %.cpp %.d
	$(CXX) $(CXXFLAGS) $<

%.d: %.cpp
	$(CXX) -MM $(CXXFLAGS) -MT $@ $< > $@

ifneq ($(wildcard *.d),)
include $(wildcard *.d)
endif

clean:
	rm -f $(OBJECTS) $(EXEC) *~ *.stackdump *.d

regards Henrik
-- 
The address in the header is only to prevent spam. My real address is:
hc8(at)uthyres.com Examples of addresses which go to spammers:
[email protected] root@localhost
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.