Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!snorkelwacker!paperboy!meissner From: meissner@osf.org (Michael Meissner) Newsgroups: comp.unix.wizards Subject: Re: rules for RCS in make Message-ID: Date: 15 Mar 90 21:55:31 GMT References: <1990Mar15.172216.4674@max.sunysb.edu> Sender: news@OSF.ORG Organization: Open Software Foundation Lines: 88 In-reply-to: rosalia@max.sunysb.edu's message of 15 Mar 90 17:22:16 GMT In article <1990Mar15.172216.4674@max.sunysb.edu> rosalia@max.sunysb.edu (Mark Galassi) writes: (I couldn't mail to the rosalia@max.sunysb.edu.... Also, questions like this really should be in comp.unix.questions): | Does anyone have a rule for make, so that any .c file will depend | on an RCS/file.c,v and it will be generated with "co file.c"? | | I can do it by hand, for every .c file, but I would much prefer to | have a rule. Unfortunately the rule cannot be a simple one like | the .c from .o rule, because of the RCS/ prefix. | | Many thanks from someone who is NOT a make expert. Switch to GNU-make, which has RCS rules builtin (including searching for a RCS/ directory). Gnu-make is in the normal gnu archives (FTP from prep.ai.mit.edu or uunet.uu.net, UUCP from uunet.uu..net or tut.cis.ohio-state.edu). Here are some sections from the Make.info manual: RCS Any file `N' will be extracted if necessary from an RCS file named either `N,v' or `RCS/N,v'. The precise command used is `$(CO) $(COFLAGS)'. ... Pattern Rule Examples --------------------- Here are some examples of pattern rules actually predefined in `make'. First, the rule that compiles `.c' files into `.o' files: %.o : %.c $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ defines a rule that can make any file `X.o' from `X.c'. The command uses the automatic variables `$@' and `$<' to substitute the names of the target file and the source file as they are in each case where the rule applies (*Note Automatic::). Here is a second built-in rule: % :: RCS/%,v $(CO) $(COFLAGS) $< defines a rule that can make any file `X' whatever from a corresponding file `X,v' in the subdirectory `RCS'. Since the target is `%', this rule will apply to any file whatever, provided the appropriate dependency file exists. The double colon makes the rule "terminal", which means that its dependency may not be an intermediate file (*Note Match-Anything Rules::). This pattern rule has two targets: %.tab.c %.tab.h: %.y bison -d $< This tells `make' that the command `bison -d X.y' will make both `X.tab.c' and `X.tab.h'. If the file `foo' depends on the files `parse.tab.o' and `scan.o' and `scan.o' depends on `parse.tab.h', when `parse.y' is changed, the command `bison -d parse.y' will be executed only once, and the dependencies of both `parse.tab.o' and `scan.o' will be satisfied. (Presumably, `parse.tab.o' will be recompiled from `parse.tab.c' and `scan.o' from `scan.c', and `foo' will be linked from `parse.tab.o', `scan.o', and its other dependencies, and it will execute happily ever after.) ... For example, the built-in implicit rules for extracting sources from RCS and SCCS files are terminal; as a result, if the file `foo.c,v' does not exist, `make' will not even consider trying to make it as an intermediate file from `foo.c,v.o' or from `RCS/SCCS/s.foo.c,v'. RCS and SCCS files are generally ultimate source files, which should not be remade from any other files; therefore, `make' can save time by not looking for ways to remake them. -- Michael Meissner email: meissner@osf.org phone: 617-621-8861 Open Software Foundation, 11 Cambridge Center, Cambridge, MA Catproof is an oxymoron, Childproof is nearly so