psm@manta.NOSC.MIL (Scot Mcintosh) (01/17/90)
In a makefile, how should one handle the case where some
of the .h files include other .h files? I see two
possibilities: make dependencies for them, and 'touch'
the dependent ones, thus causing the .c files that depend on
them to be made. Or, examine all of the .h files, figure out
the nesting and then put all of the pertinent ones in
the .c file's dependency.
Neither of these is particularly appealing. How does
the Unix world handle this kind of thing? (If you haven't
guessed, I'm not that experienced with Unix yet). Thanks.
--
----
Scot McIntosh
Internet: psm@helios.nosc.mil
UUCP: {ihnp4,akgua,decvax,decwest,ucbvax}!sdscvax!nosc!psmjik@athena.mit.edu (Jonathan I. Kamens) (01/17/90)
In article <997@manta.NOSC.MIL>, psm@manta.NOSC.MIL (Scot Mcintosh) writes: > In a makefile, how should one handle the case where some > of the .h files include other .h files? I see two > possibilities: make dependencies for them, and 'touch' > the dependent ones, thus causing the .c files that depend on > them to be made. Or, examine all of the .h files, figure out > the nesting and then put all of the pertinent ones in > the .c file's dependency. Various shell scripts and binary programs have been written to do automatically what you described in your second possibility (but the dependency would be associated with the .o file, not the .c file). Typically, they use either the -E or -M flag of the compiler. The -E flag, on compilers that have it (most of them), outputs the pre-processed text that would be compiled, without actually compiling it. Interspersed in this text is various lines like # 1 "main.c" # 1 "./xsaver.h" # 1 "/usr/include/X11/Intrinsic.h" which are used later by the preprocessor to build the symbol tables into the binaries. These lines can be played with using sed et al to generate a dependency list suitable for inclusion in a makefile. The -M flag, con compilers that have it (fewer than have the -E flag, I think) actually outputs a dependency list. The shell script versions tend to be slow -- a binary dedicated to figuring out dependencies by reading the preprocessor directives tends to do it faster. Such a binary (called "makedepend") is released as part of the standard X window system distribution -- if you have X at your site, then you have the binary (or its sources) somewhere, or you can ftp it from an X archive site. Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8495 Home: 617-782-0710