|
From: | Misha Dorman |
Subject: | When are make targets checked for up-to-date-ness? |
Date: | Thu, 8 Aug 2002 10:28:22 +0100 |
Two slants on the same question...
For everyone:
Am I correct in assuming that make will stat() $@ after executing a rule, rather than just assuming that $@ is now timestamped "now"?
If I am correct, this means that, for example, the body of a
%.o : %.c
$(CC) ...
rule can elect not to update $@ if no recompile is necessary -- say because the .c has changed but only to add a comment)
Can we thus avoid the normal cascade of $(LIB), $(LINK) rules from being triggered?
Of course, the cost is that if we re-make, the .o will still be seen as out-of-date by make, so it will run the rule again, which will presumably again choose not to compile. Thus this is only useful if the "do we really need to do something" test is much cheaper than the $(LIB), $(LINK) we are avoiding. Another alternative would be for the rule to touch $@ to have the latest timestamp of any of $?, which would avoid the re-compiles but would dramatically reduce the effectiveness of the "avoid $(LIB)/$(LINK)" aim.
For the make-w32 crowd in particular:
In the example below (which seems to work with gmake 3.79.1/cygwin), I am working towards a makefile for building VB6 COM DLLs. In particular, I am trying to handle the fact that the VB vbp can specify no compatibility or binary compatibility with a previous version of the DLL. In this case, the VB compiler will _sometimes_ generate a completely compatible DLL, will sometimes generate a DLL which has new IIDs (when the interface has been extended), and will sometimes generate a DLL with completely new IIDs and CLSIDs (no compat).
Has anyone else tried this approach?
Thanks in advance
Misha Dorman
# Test Makefile for VB COM DLL auto-build/auto-dep ideas
.PHONY : default
default : a.exe b.dll
.PHONY : clean
clean :
rm -f *.exe *.dll *.idl *.new
%.exe : %.vbp
echo -n "EXE built from VBP: " > address@hidden
cat $< >> address@hidden
mv address@hidden $@
# In a production makefile, the simple diff below would be replaced by a
# comparison of the IDL for the just-built DLL with that of the previous version
%.dll : %.vbp
echo "DLL built from VBP: " > address@hidden
cat $< >> address@hidden
diff -q $@ address@hidden > /dev/null 2>&1 || ( echo -n "IDL for: " > $(@:.dll=.idl); cat address@hidden >> $(@:.dll=.idl) )
mv address@hidden $@
%.idl : %.dll ; #NOP -- needed to
# In a production makefile these would be auto-generated and included
# (using some sedding of the .vbp file in a $MAKEDEPEND.VBP action)
a.exe : a.bas b.idl
b.dll b.idl : b.bas
[Prev in Thread] | Current Thread | [Next in Thread] |