Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site enea.UUCP Path: utzoo!linus!decvax!wivax!cadmus!harvard!seismo!mcvax!enea!kim From: kim@enea.UUCP (Kim Walden) Newsgroups: net.unix,net.unix-wizards Subject: Re: Make vs. source control Message-ID: <771@enea.UUCP> Date: Fri, 2-Nov-84 07:27:10 EST Article-I.D.: enea.771 Posted: Fri Nov 2 07:27:10 1984 Date-Received: Sun, 4-Nov-84 04:40:13 EST References: <2490@dartvax.UUCP> <765@ariel.UUCP> <61@pixutl.UUCP> Reply-To: kim@enea.UUCP ( Walden) Organization: ENEA DATA, Sweden Lines: 56 Xref: mcvax net.unix:680 net.unix-wizards:6506Summary: In article howard@cyb-eng.UUCP (Howard Johnson) writes: >[munch] >> The problem of overwriting source files if the SCCS parent file >> was modified can be helped a great deal by changing the $(GET) lines >> in rules.c from: >> >> "\t$(GET) $(GFLAGS) -p $< > $*.c", >> >> to: >> >> "\t$(GET) $(GFLAGS) $<", >> >> and let 'get' check if the file is writable. I have done this and >> prefer it to the original. > >The only problem with this suggestion is that $*.c is not necessarily in the >current directory, and 'get' places it's g-file in the current directory. >I'll admit that the first construct is dangerous, but there may be a better >fix for the problem: > > "\ttest -w $*.c || $(GET) $(GFLAGS) -p $< > $*.c", The standard System V built-in make rules for getting files from SCCS are certainly erroneous, but none of the replacements suggested so far are adequate. The command line above does not work for two reasons: 1. When $*.c already exists and is read-only, the > will fail. 2. When the $(GET) succeeds it leaves $*.c writable, which is not what we want. A subsequent "get -e" then fails with "writable 'file' exists". By the way, it is very dangerous to checkout changes to built-in make rules in superuser mode, because write permission is then silently granted even when all write bits are off. The following rule type seems to solve the problems: (the leading '-' prevents a premature make exit): ".c~.c:", "\t-test -w $@ || { rm -f $@ ; $(GET) $(GFLAGS) -p $< > $@ ; chmod 444 $@ ; }" Note that in multi-step rules, where g-files are obtained, processed, and removed, a simple get is sufficient, e.g.: ".c~:", "\t$(GET) $(GFLAGS) -p $< > $*.c", "\t$(CC) $(CFLAGS) $*.c $(LDFLAGS) -n -o $@", "\t-rm -f $*.c" Kim Walden ENEA DATA, Sweden ...decvax!mcvax!enea!kim