Subject: Re: install-if-change?
To: None <current-users@NetBSD.ORG>
From: Christos Zoulas <christos@deshaw.com>
List: current-users
Date: 07/07/1996 00:31:52
In article <Pine.BSD/.3.91.960706175837.584A-100000@gate.ene.UnB.br> netbsd@gate.ene.UnB.br (NetBSD) writes:
>
>
>On Sat, 6 Jul 1996, VaX#n8 wrote:
>
>> Has anyone written  a script like this that invokes the install
>> program only if the source contents != the target contents.
>> 
>> Does anyone think this would/wouldn't be a good patch to the install program?
>> 
>> I think this is a fairly common idiom and useful in both build environments,
>> as well as mtree/tripwire-style systems (the two environs I can think of
>> that really use mtimes).
>> 
>> I've written (well, stolen) "cp-if-change" and "mv-if-change" from some
>> GNU tools.  Trivial scripts, really, but they don't have the full
>> capabilities of their /bin counterparts (can't cp multiple files into
>> a dir, etc).
>> 
>
>FreeBSD has implemented this as install -C (capital C) which copies the 
>new file only if it is different from the existing one.

I'd like to see is make rules that check if the target is newer.

e.g. in bsd.prog.mk could be written as:

.if !target(realinstall)
.if defined(PROG)
.if !defined(FORCE)
realinstall:	${DESTDIR}${BINDIR}/${PROG}

${DESTDIR}${BINDIR}/${PROG}:	${PROG}
.else
realinstall:
.endif
	install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
	    ${PROG} ${DESTDIR}${BINDIR} 
.else
realinstall:
.endif
	
	
Basically the above (if FORCE is not defined) installs only if the program
is newer than the target. This avoids the problem where each 'make install'
installs new binaries. I think that there is a place for install -C, but
unfortunately install -C does not show me when the target has actually been
updated.

christos