rosalia@max.sunysb.edu (Mark Galassi) (03/16/90)
[] 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. -- {These opinions are mine, and should be everybody else's :-)} Mark Galassi rosalia@dirac.sunysb.edu rosalia@mozart.UUCP rosalia@sunysbnp.BITNET
meissner@osf.org (Michael Meissner) (03/16/90)
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
bernhold@qtp.ufl.edu (David E. Bernholdt) (03/16/90)
In article <MEISSNER.90Mar15165531@curley.osf.org> meissner@osf.org (Michael Meissner) writes: >In article <1990Mar15.172216.4674@max.sunysb.edu> >rosalia@max.sunysb.edu (Mark Galassi) writes: >| 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"? > >Switch to GNU-make, which has RCS rules builtin GNU-make is very nice, but for some people it is not a simple matter to just switch to a totally different 'make'. My group uses probably a dozen different machines, most of which we do not have operational control over, and some of which have very strict limits on permanent file quotas, which would likely prohibit keeping the executable around. So we just use lowest common denominator 'make' at present, which is a royal pain. My question is will there be any standardization in the (near?) future on 'make' implementations in things like SysV.4, 4.4BSD, etc. which have "enhanced functionality", a la Sun or GNU, or mk, or any of the millions of make improvemnts out there? I don't want to hear all about the improved makes -- I've already looked into a lot of them. I just want to find out if any of them will become more prevalent due to their use in major new OS releases. Thanks. -- David Bernholdt bernhold@qtp.ufl.edu Quantum Theory Project bernhold@ufpine.bitnet University of Florida Gainesville, FL 32611 904/392 6365
cjsv@ccadfa.adfa.oz.au (Christopher JS Vance) (03/16/90)
rosalia@max.sunysb.edu (Mark Galassi) writes: >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. If you're happy to keep your RCS files in the same directory as your object code, rather than a separate directory, the answer is fairly straightforward. RCS does not insist that the ,v files be in a different directory. I've done this, and have been reasonably happy with the result. | .c,v.o: | $(CO) $(COFLAGS) $< | $(CC) $(CCFLAGS) -c $< | -rm -f $< Or somethining similar (i.e., this is from non-recent memory). If you do want to keep your files in a separate directory, you could check whether your make understands VPATH. I've not tried this with RCS. If the manual doesn't mention VPATH, it may still be there (try strings ...).