[OpenAFS-devel] make and adventures with *.a files

Harald Barth haba@pdc.kth.se
Fri, 23 Aug 2002 10:56:53 +0200 (CEST)


Today I compiled current and was very puzzled because make tried to
install libafsrpc.a again - but it already was up to date:

tunnbrodrulle# make all
/afs/pdc.kth.se/home/h/haba/src/openafs/src/pinstall/pinstall  /afs/pdc.kth.se/home/h/haba/src/openafs/lib/libafsrpc.a
Not enough file names
*** Error code 1

The src/libafsrpc/Makefile contains

${DEST}/lib/libafsrpc.a: libafsrpc.a
        ${INSTALL} $? $@

and pinstall was run but $? had no value.

Then I discovered that FreeBSD make is looking _into_ .a files for
dates. And the date in the .a file was 1 second older than the file
modification date. The evil thing is that make is looking at the dates
in the .a file to consider _if_ it should run ${INSTALL} $? $@, but it
is looking at the modification date of the files to coinsider if $?
should have a value. This can lead to the evil result that 
${INSTALL} $? $@ is run without a value in $?. So either rewrite 
with $< (which allways should have the name of the first prerequisite 
in it) like this

${DEST}/lib/libafsrpc.a: libafsrpc.a
        ${INSTALL} $< $@

or do some ar magic

${DEST}/lib/libafsrpc.a: libafsrpc.a
        ${INSTALL} $? $@
        ar s $@

to update the date inside the .a file. And in all other places where
.a files are installed like this.

Harald.