Problem 930

Summary: Makefiles including common.gmk remake dependencies during `make clean`
Product: Geant4 Reporter: mmarino
Component: configAssignee: Gabriele Cosmo <Gabriele.Cosmo>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 8.1   
Hardware: PC   
OS: Linux   

Description mmarino 2007-02-27 03:33:13 CET
Our software package uses the very nice set of make tools Geant4 provides to
build and link.  However, we have noticed one issue in particular:

When `make clean` is run, make recreates depencies and this leads to an
exceedingly long make clean process.  This generally happens when `make clean`
is run twice or for some reason a particular dependency file doesn't exist (i.e.
after an update of code).  The reason this occurs is because of the following
lines in common.gmk:105

$(G4TMPDIR)/%.d: src/%.cc
        @echo Making dependency for file $< ...
        @if [ ! -d $(G4TMPDIR) ] ; then mkdir -p $(G4TMPDIR)  ;fi
        @set -e;\
        g++ $(GPPFLAGS) $(CPPFLAGS) -w $< |\
        sed 's!$*\.o!$(G4TMPDIR)/& $@!' >$@;\
        [ -s $@ ] || rm -f $@
ifneq ($(dependencies),)
-include $(dependencies)
endif

make will remake an included file if it doesn't exist, but this shouldn't be
done doing the `make clean` process (just to have them deleted again!).

To get around this, the last lines should be changed to:

ifneq ($(dependencies),)
  ifneq ($(MAKECMDGOALS),clean)
-include $(dependencies)
  endif
endif

This disables including dependency files during the clean process.

Thanks.
Comment 1 mmarino 2007-02-27 03:47:59 CET
Since we are using G4EXLIB, we don't have problems with binmake.gmk, but there
is also a similar place in binmake.gmk which will include dependencies during
`make clean`.

Thanks!
Comment 2 Gabriele Cosmo 2007-02-28 07:47:59 CET
Thanks for the hint!  We'll certainly include this protection in the next
version, we just have to make sure that it is compatible with the most common
versions of 'make', since MAKECMDGOALS is a variable which has been introduced
relatively recently in 'make'.
Comment 3 Gabriele Cosmo 2007-03-02 01:12:59 CET
The protection has been added in both common.gmk and binmake.gmk scripts.
Included in tag "config-V08-02-00", will be included in next release or patch.
Thanks.