Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!ginosko!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.unix.questions Subject: Re: Make dependencies and nested include files Message-ID: <1266@virtech.UUCP> Date: 12 Oct 89 13:24:09 GMT References: <10115@encore.Encore.COM> Organization: Virtual Technologies Inc Lines: 56 In article <10115@encore.Encore.COM>, corbin@maxzilla.Encore.COM writes: > Does anyone have an idea of how to handle nexted include file > dependencies in make? Given that test includes test.h, test.h > include test1.h and test1.h include test2.h. When test2.h is > touched test.c will not get rebuilt given the follow make dependencies: > > test.c: test.h > test.h: test1.h > test1.h: test2.h > > Can this be done in make or is > > test.c: test.h test1.h test2.h There is a problem in both of these dependencies. A "dependency" is an item that is required to build the target. The *.h files are not dependencies for the .c file. The *.h files and the .c file are dependencies for the .o file (or executable, if there are no other .c files and you set up the makefile appropriatly). The first example has one include file dependent upon the other, but that is not a true dependency since test1.h is not needed to build test.h (it is necessary to interpret/process test.h, but that is in the build step for the object file, not the include file) > I have a grep/sed/awk script that will generate the first example by > scanning all the sources (.s .c .h). I'm just learning sed/awk and it > would probably take me weeks to figure out how to generate the second case. 2 points. 1. are you just hard coding the nested include, or are you actually parsing the files and only including the needed files. For example if your program runs int: #ifdef USE_SGTTY #include #else #include #endif do you properly interpret this as a single include of the appropriate file? 2. The imake program source (on the X11 release tape) does include a shell (I think) that uses cpp to parse the file and then scans the output to properly generate the dependency list. There probably are other PD/Shareware/FSF software to do the same. -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+