Newsgroups: comp.lang.c Path: utzoo!utdoe!contact!ross From: ross@contact.uucp (Ross Ridge) Subject: Re: A question on C programming style Reply-To: ross@contact.UUCP (Ross Ridge) Organization: Contact Public Unix BBS. Toronto, Canada. Date: Wed, 17 Apr 91 00:54:35 GMT Message-ID: <1991Apr17.005435.26299@contact.uucp> References: <1991Apr12.103621.8907@umiami.ir.miami.edu> <1991Apr13.013911.18151@athena.mit.edu> In article kers@hplb.hpl.hp.com (Chris Dollin) writes: >I handle this particular problem by having entries >for each .h file, treating the includes as ``dependencies'', with a ``touch'' >command as the action: thus, if foo.h includes bar.h and baz.h, I have > > foo.h: bar.h baz.h > touch foo.h Well I tend to think something on the order of: fred.o: fred.c foo.h bar.h baz.h bob.o: bob.c foo.h bar.h baz.h jane.o: jane.c foo.h bar.h baz.h is the way to go. It's a better representation of the true depedencies. But to make this more managable I use a simple make macro: FOO_H = foo.h bar.h baz.h fred.o: fred.c $(FOO_H) bob.o: bob.c $(FOO_H) jane.o: jane.c $(FOO_H) This lets you quickly update your makefile when add or remove #include's from your foo.h file. (It also has the great advantage of letting you do "FOO_H =" when you get fustrated because every little change to foo.h causes everything to be recompiled.) Ross Ridge Disclaimer: This isn't my idea, I stole it from the GNU CC makefile. I wonder if this makes this covered by the GNU copyleft? Hmm... -- Ross Ridge // "The Great HTMU" [oo] ross@contact.uucp -()- ross@watcsc.uwaterloo.ca //