Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!bin From: bin@primate.wisc.edu (Brain in Neutral) Newsgroups: comp.windows.x Subject: Re: imake (and "unreferenced Makefile variables") Message-ID: <2775@uakari.primate.wisc.edu> Date: 19 Jul 90 06:21:57 GMT References: <1990Jul18.213435.7284@cbnewsl.att.com> Sender: bin@primate.wisc.edu Reply-To: bin@primate.wisc.edu Lines: 40 From article <1990Jul18.213435.7284@cbnewsl.att.com>, by siyt@cbnewsl.att.com (p.jayne): > I've been maintaining AT&T/USL's imake since X11R3. In R2, we > rewrote it as a shell script and a C program. Much of > the template and rules set were discarded to simplify things. > In R4, I put back most of the discarded stuff so that we > could use contributed Imakefiles w/o hacking. (And besides, > some people were unhappy with the changes we made.) > The shell script does mostly what imake.c from the tape does, > i.e. it runs cpp through the source tree's Imakefiles. The > C program handles the @@ stuff and additionally strips out > redundant and unreferenced Makefile variables and tosses extra > blank lines. This means you get readable Makefiles out of the deal. Stripping out "unreferenced" Makefile variables may not be such a good idea in certain contexts. A lot of the X stuff creates target files from templates by running them through cpp (using the CppScriptTarget() rule). That rule explicitly requires a -D for each variable you want substituted in the template to create the target, so you *do* know which Makefile variables are referenced in creating it. But that's not the only way to do it. The CppScriptTarget() is unwieldy if you want to use 10 or 20 of the Makefile variables, say. For that reason (among others) I use a thing called msub (substitute from Makefile) that looks through a Makefile, grabs all the variable definitions, expands them (so there are no $(other-makefile-variable) constructions in them), and then replaces any occurrances of any of those variables in the target file with the value. It works well enough that I rarely use CppScriptTarget() any more. But the implication for this discussion is: The rule for creating targets from msub templates doesn't name any of the Makefile variables to be substituted (doesn't have to, since any of them can be used in the template without prior arrangment). This means that you can't tell, by looking at the Makefile, which variables are referenced and which aren't! Paul DuBois dubois@primate.wisc.edu