[vox-tech] Make question: headers depending on other headers
I have some source files that depend on some other sources' headers. In turn, some of THOSE headers depend on other headers (e.g., a header defining a structure might depend on another header that defines some other structures). Is it useful to list these 'dependencies' within the Makefile? For example, consider foo.c: /* foo.c I do foo things */ #include foo.h /* My header */ #include bar.h /* bar.c's header, so I can get to its function(s) and/or typedefs... */ ... In Makefile, I'd do: foo.o: foo.c foo.h bar.h ...compile foo.c into foo.o... However, say in bar.h, I have: /* bar.h I do things with alcohol (get it? bar? hahaha...) */ #include bar.h /* My header */ #include zzz.h /* Contains some #define's for compile-time options */ ... Should I make bar.h depend on zzz.h? Or foo.o depend on it? Or...? I just want to make sure that in case I touch something somewhere, that everybody who needs to get update GETS updated. Thx! -bill! [EMAIL PROTECTED] Have you visited the Linux Users' Group http://newbreedsoftware.com/bill/of Davis yet!? http://www.lugod.org/ ___ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech
Re: [vox-tech] Make question: headers depending on other headers
I would expect that a choice to do such a thing in a makefile makes little sense to most users who would use it. Few people would ever modify the header files at all. Testing of the header files would likely be done by the developers. Making a makefile option for debug: which includes deps for the heads you are actually altering as well as -ggdb (etc) for debugging for developers. I generally have separate projects which test my own custom header files separate from the project which is using them. Then, there is no need to check the headers files for modification since they should not be modified if they were properly tested. (Test the custom classes/headers extensively so that projects relying upon them don't have weird surprises... the idea of ensuring your foundations are solid before trying to build upon them.) I'd like to see what others say about this though. -ME Bill Kendrick said: I have some source files that depend on some other sources' headers. In turn, some of THOSE headers depend on other headers (e.g., a header defining a structure might depend on another header that defines some other structures). Is it useful to list these 'dependencies' within the Makefile? For example, consider foo.c: /* foo.c I do foo things */ #include foo.h /* My header */ #include bar.h /* bar.c's header, so I can get to its function(s) and/or typedefs... */ ... In Makefile, I'd do: foo.o: foo.c foo.h bar.h ...compile foo.c into foo.o... However, say in bar.h, I have: /* bar.h I do things with alcohol (get it? bar? hahaha...) */ #include bar.h /* My header */ #include zzz.h /* Contains some #define's for compile-time options */ ... Should I make bar.h depend on zzz.h? Or foo.o depend on it? Or...? I just want to make sure that in case I touch something somewhere, that everybody who needs to get update GETS updated. Thx! -bill! [EMAIL PROTECTED] Have you visited the Linux Users' Group http://newbreedsoftware.com/bill/of Davis yet!? http://www.lugod.org/ ___ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech ___ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech
Re: [vox-tech] Make question: headers depending on other headers
On Wed, Mar 31, 2004 at 03:14:36PM -0800, ME wrote: I would expect that a choice to do such a thing in a makefile makes little sense to most users who would use it. Few people would ever modify the header files at all. Testing of the header files would likely be done by the developers. Well, yeah, precisely. :^) I, and others, as developers, don't want to accidentally build a botched version of the app (say, during testing) simply because a change in a .h file didn't get noticed by 'make' :^) Making a makefile option for debug: which includes deps for the heads you are actually altering as well as -ggdb (etc) for debugging for developers. I generally have separate projects which test my own custom header files separate from the project which is using them. Then, there is no need to check the headers files for modification since they should not be modified if they were properly tested. (Test the custom classes/headers extensively so that projects relying upon them don't have weird surprises... the idea of ensuring your foundations are solid before trying to build upon them.) Heh, funny. ;^) I mean uh... Yes, yes indeed. Err... uh... the situation, though... umm... yeah, I know, I suck ;) -bill! ___ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech
Re: [vox-tech] Make question: headers depending on other headers
I think in general you want to use a tool like 'makedepend' or 'gcc -M' instead of trying to write your Makefile dependencies yourself. These track down the headers used by a .c file and output the appropriate Makefile dependency line. I haven't really done this much, but there's a good page of information about it at http://make.paulandlesley.org/autodep.html Matt On Wed, Mar 31, 2004 at 02:56:38PM -0800, Bill Kendrick wrote: I have some source files that depend on some other sources' headers. In turn, some of THOSE headers depend on other headers (e.g., a header defining a structure might depend on another header that defines some other structures). Is it useful to list these 'dependencies' within the Makefile? For example, consider foo.c: /* foo.c I do foo things */ #include foo.h /* My header */ #include bar.h /* bar.c's header, so I can get to its function(s) and/or typedefs... */ ... In Makefile, I'd do: foo.o: foo.c foo.h bar.h ...compile foo.c into foo.o... However, say in bar.h, I have: /* bar.h I do things with alcohol (get it? bar? hahaha...) */ #include bar.h /* My header */ #include zzz.h /* Contains some #define's for compile-time options */ ... Should I make bar.h depend on zzz.h? Or foo.o depend on it? Or...? I just want to make sure that in case I touch something somewhere, that everybody who needs to get update GETS updated. Thx! -bill! [EMAIL PROTECTED] Have you visited the Linux Users' Group http://newbreedsoftware.com/bill/of Davis yet!? http://www.lugod.org/ ___ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech -- * * Matt Roper [EMAIL PROTECTED]* * http://www.mattrope.com * * PGP Key: http://www.mattrope.com/mattrope.asc * * ___ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech
Re: [vox-tech] Make question: headers depending on other headers
On Wed, Mar 31, 2004 at 03:15:58PM -0800, Matt Roper wrote: I think in general you want to use a tool like 'makedepend' or 'gcc -M' instead of trying to write your Makefile dependencies yourself. These track down the headers used by a .c file and output the appropriate Makefile dependency line. I haven't really done this much, but there's a good page of information about it at http://make.paulandlesley.org/autodep.html Sadly, I'm not using GCC. Not even using GNU Make. :^( Fortunately, I've got Cygwin handy, so I can see what it might have available. In the meantime, though, I'm hacking my Makefile manually, so... :^) -bill! ___ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech
Re: [vox-tech] Make question: headers depending on other headers
On Wednesday 31 March 2004 02:56 pm, Bill Kendrick wrote: ... Should I make bar.h depend on zzz.h? Or foo.o depend on it? Or...? No, bar.h is not a build target so you don't want to list it as dependent on other stuff. So do: foo.o: foo.c foo.h bar.h zzz.h etc. Or if lots of things depend on bar.h then you may want to do something like this: BAR_DEPS = bar.h zzz.h foo.o: foo.c foo.h $(BAR_DEPS) etc. -- Rod ___ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech
Re: [vox-tech] Make question: headers depending on other headers
On Wed, Mar 31, 2004 at 03:19:25PM -0800, Rod Roark wrote: Or if lots of things depend on bar.h then you may want to do something like this: BAR_DEPS = bar.h zzz.h foo.o: foo.c foo.h $(BAR_DEPS) etc. Hey, that's a good idea! I'll try that. Thanks! -bill! [EMAIL PROTECTED] Have you visited the Linux Users' Group http://newbreedsoftware.com/bill/of Davis yet!? http://www.lugod.org/ ___ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech
Re: [vox-tech] Make question: headers depending on other headers
On Wed, 31 Mar 2004, Bill Kendrick wrote: I have some source files that depend on some other sources' headers. In turn, some of THOSE headers depend on other headers (e.g., a header defining a structure might depend on another header that defines some other structures). Is it useful to list these 'dependencies' within the Makefile? That is what a makefile is all about. For example, consider foo.c: /* foo.c I do foo things */ #include foo.h /* My header */ #include bar.h /* bar.c's header, so I can get to its function(s) and/or typedefs... */ ... In Makefile, I'd do: foo.o: foo.c foo.h bar.h ...compile foo.c into foo.o... However, say in bar.h, I have: /* bar.h I do things with alcohol (get it? bar? hahaha...) */ #include bar.h /* My header */ #include zzz.h /* Contains some #define's for compile-time options */ ... Should I make bar.h depend on zzz.h? Or foo.o depend on it? Or...? You have bar.h including bar.h... not a good idea. I am not really sure where your question was leading... assuming we omit the recursion... * the foo.c dependency should include foo.h, bar.h, and zzz.h * any bar.c dependency should include bar.h and zzz.h I just want to make sure that in case I touch something somewhere, that everybody who needs to get update GETS updated. In general, for a given .c.o dependency, you need to include all of the quoted includes that it depends on... directly OR indirectly. This is generally not done for includes (library headers). --- Jeff NewmillerThe . . Go Live... DCN:[EMAIL PROTECTED]Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...2k --- ___ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech
Re: [vox-tech] Make question: headers depending on other headers
On Wed, 31 Mar 2004, Bill Kendrick wrote: Is it useful to list these 'dependencies' within the Makefile? I do it, 'cuz I've seen it handled incorrectly at times. But there are some caveats... (see below) For example, consider foo.c: /* foo.c I do foo things */ #include foo.h /* My header */ #include bar.h /* bar.c's header, so I can get to its function(s) and/or typedefs... */ ... In Makefile, I'd do: foo.o: foo.c foo.h bar.h ...compile foo.c into foo.o... However, say in bar.h, I have: /* bar.h I do things with alcohol (get it? bar? hahaha...) */ #include bar.h /* My header */ #include zzz.h /* Contains some #define's for compile-time options */ ... Should I make bar.h depend on zzz.h? Or foo.o depend on it? Or...? Since bar.h depends on zzz.h, you wanna do: bar.h: zzz.h touch bar.h But if you Ctrl-C while `make` is running `touch bar.h`, make will erase bar.h. Make's reasoning is that bar.h depends on zzz.h, which probably means bar.h can be recreated from zzz.h, and since you interrupted the creation of bar.h mid-way (although you're really just touching it) bar.h is probably only half-created, so it'll need to be fully-recreated later when you run `make` again - so just remove the file so it doesn't mess up dependencies later. This is a fine rule for most cases, but not if you're just touching a file simply because there is a depency. So what I do this tell `make` not to remove bar.h if I Ctrl-C: .PRECIOUS: bar.h Or if you want all header files marked precious: .PRECIOUS: %.h which is fine unless you got a *.h file that does get recreated from another file (usually okay.) .PRECIOUS is supported by another make implementation I've used in the past (besides GNU Make), so I'm guessing it's a pretty standard built-in target name. -Mark -- Mark K. Kim AIM: markus kimius Homepage: http://www.cbreak.org/ Xanga: http://www.xanga.com/vindaci Friendster: http://www.friendster.com/user.jsp?id=13046 PGP key fingerprint: 7324 BACA 53AD E504 A76E 5167 6822 94F0 F298 5DCE PGP key available on the homepage ___ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech
Re: [vox-tech] Make question: headers depending on other headers
On Wed, Mar 31, 2004 at 03:22:11PM -0800, Jeff Newmiller wrote: /* bar.h I do things with alcohol (get it? bar? hahaha...) */ #include bar.h /* My header */ #include zzz.h /* Contains some #define's for compile-time options */ ... Should I make bar.h depend on zzz.h? Or foo.o depend on it? Or...? You have bar.h including bar.h... not a good idea. I am not really sure where your question was leading... assuming we omit the recursion... Heh, whoops, no ignore that, sorry. I thought I was doing 'bar.c', but yeah... bar.h #include's zzz.h, but NOT bar.h itself. :) No recursion. Sorry for the typo... * the foo.c dependency should include foo.h, bar.h, and zzz.h * any bar.c dependency should include bar.h and zzz.h Okay, so Rod's idea for a Makefile variable seems best, since there will be .h files that include other .h's, and are themselves included by other .c files... snip In general, for a given .c.o dependency, you need to include all of the quoted includes that it depends on... directly OR indirectly. This is generally not done for includes (library headers). Heh, in the environment I'm coding for, there ARE no includes. Lame. :^P -bill! [EMAIL PROTECTED] Have you visited the Linux Users' Group http://newbreedsoftware.com/bill/of Davis yet!? http://www.lugod.org/ ___ vox-tech mailing list [EMAIL PROTECTED] http://lists.lugod.org/mailman/listinfo/vox-tech