Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site rtp47.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!harvard!godot!mit-eddie!genrad!decvax!mcnc!rti-sel!rtp47!throopw From: throopw@rtp47.UUCP (Wayne Throop) Newsgroups: net.lang.c,net.unix,net.unix-wizards Subject: Re: make depend Message-ID: <13@rtp47.UUCP> Date: Sun, 24-Mar-85 16:49:19 EST Article-I.D.: rtp47.13 Posted: Sun Mar 24 16:49:19 1985 Date-Received: Tue, 2-Apr-85 02:41:24 EST References: <841@enea.UUCP> Distribution: net Organization: Data General, RTP, NC Lines: 41 Xref: linus net.lang.c:4320 net.unix:3378 net.unix-wizards:9719 > > ... > > People don't keep their dependency lists up to date, things > > ... > > Guy Harris > > I agree entirely with Guy concerning the importance of automated > dependeny generators. > ... > The solution is to use ONLY source files as a basis for > dependency generation. > ... > Kim Walden Kim's solution seems quite good given the way make works. If you are willing to change make's model of the world, another solution becomes available. In particular, if a make-like tool allowed dependencies to be specified dynamically, the problem of intermediate files being needed before make is invoked (to allow dependencies to be discovered) becomes a non-problem. There are many ways for make to be modified to allow for dynamic inputs, but suppose a syntax something like foo.o: foo.c (foo.c; find_includes foo.c) cc -c foo.c foo.c: foo.x make_c_from_x foo.x The parenthesized text specifies a list of inputs to the "command" at the end of the list. The output of the command will be a list of include files, and the effect is as though that list of files had been supplied instead of the parenthesized text. What make would do for this makefile fragment would be to invoke make_c_from_x, then invoke find_includes (discovering any include file dependencies of foo.c), and then cc foo.c, producing foo.o. This is essentially an "incremental make-file generator". It has problems, such as what to do about include files that include other files, and so on, but these problems can be overcome. Note also that make would then need a database of already-run dynamic input lists, for efficency (otherwise it would need to re-run find_includes every time make runs, not just when foo.c changes).