Commit 1c1072e6 authored by fogal1's avatar fogal1

Rework dependency and target snippets to utilize depcomp.

This uses depcomp instead of multiple compiler passes to implement
dependency tracking.  It is only enabled for building objects; we do
not use depcomp to link final binaries or shared objects.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@5148 18c085ea-50e0-402c-830e-de6fd14e8384
parent ea17ff3e
......@@ -11,81 +11,16 @@
## targets in the first pass, avoiding the need for sed. Also added a
## fail command that aborts the make, since with no -MG errors can occur.
##
## Tom Fogal, Fri Jun 8 11:25:35 PDT 2007
## Simplified dependency generation: we generate during compilation via
## depcomp. Now we just set the `depmode'; the rest is taken care of in
## make-targets.in
##
## Tom Fogal, Fri Jun 20 09:46:17 EDT 2008
## I changed hardcoded -DPARALLEL values to PARALLEL_CPPFLAGS, to pick up on
## the include dir additions I made for IceT.
## Notes:
## -MG is avoided, since when used with -MP it appears to sometimes create
## loops when generating dependencies when header files are missing
##
## -MP is used, as it generates dummy rules for headers to avoid the
## "deleted header file" problem
## -MT is used for two reasons: first, to make sure the basename of the .o
## is not used; we need to keep the path.... and second, so that
## we can have the .d and .o both depend on the same files
##
## For porting to a compiler where these flags are missing:
## -E may need to be added; not all compilers presume -M implies -E
## -MP can be dropped; developers can rm the erroneous .d files themselves
## -MT must be replaced with a postprocessing step, e.g.
## POSTCMD=sed 's,$*\.o[ :]*,$(@:.d=.o) $@ : ,g' < $@ > $@- && mv $@- $@
## and change the command to $(CC) ... $< && $(POSTCMD) || $(FAILCMD)
## ... but note that even this example might not fix the basename problem
CDEPFLAGS=-M -MP -MF $@ -MT "$(@:.d=.o) $@"
FAILCMD=(echo "error resolving dependencies; removing $@ and exiting" && rm -f $@ && exit 1)
.c.d:
@echo "updating $@"; rm -f $@; \
$(CC) $(CDEPFLAGS) $(CFLAGS) $(CPPFLAGS) $< || $(FAILCMD)
.c_mds.d:
@echo "updating $@"; rm -f $@; \
$(CC) $(CDEPFLAGS) $(CFLAGS) $(CPPFLAGS) -DMDSERVER $< || $(FAILCMD)
.c_par.d:
@echo "updating $@"; rm -f $@; \
$(CC) $(CDEPFLAGS) $(CFLAGS) $(CPPFLAGS) @PARALLEL_CPPFLAGS@ $< || $(FAILCMD)
.C.d:
@echo "updating $@"; rm -f $@; \
$(CXX) $(CDEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) $< || $(FAILCMD)
.C_eng.d:
@echo "updating $@"; rm -f $@; \
$(CXX) $(CDEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) -DENGINE $< || $(FAILCMD)
.C_mds.d:
@echo "updating $@"; rm -f $@; \
$(CXX) $(CDEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) -DMDSERVER $< || $(FAILCMD)
.C_par.d:
@echo "updating $@"; rm -f $@; \
$(CXX) $(CDEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) @PARALLEL_CPPFLAGS@ $< || $(FAILCMD)
.C_ogl.d:
@echo "updating $@"; rm -f $@; \
$(CXX) $(CDEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) $< || $(FAILCMD)
.C_mesa.d:
@echo "updating $@"; rm -f $@; \
$(CXX) $(CDEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(MESA_INCLUDE) $< || $(FAILCMD)
.C_par_eng.d:
@echo "updating $@"; rm -f $@; \
$(CXX) $(CDEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) -DENGINE @PARALLEL_CPPFLAGS@ $< || $(FAILCMD)
.C_par_ogl.d:
@echo "updating $@"; rm -f $@; \
$(CXX) $(CDEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) @PARALLEL_CPPFLAGS@ $< || $(FAILCMD)
.C_par_mesa.d:
@echo "updating $@"; rm -f $@; \
$(CXX) $(CDEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) @PARALLEL_CPPFLAGS@ $(MESA_INCLUDE) $< || $(FAILCMD)
.f.d:
@echo "can't create fortran dependencies; creating empty $@"; rm -f $@ ; touch $@
DEPMODE=depmode=gcc3
SERDEP:=\
$(ALLOBJ:.o=.d) \
......@@ -125,3 +60,8 @@ DEP=$(SERDEP) @PARDEP@
-include $(DEP)
depend: $(DEP)
clean-dep:
$(RM) -f $(DEP)
.PHONY: clean-dep depend
## -*- makefile -*-
## Dependencies.
## We can use `makedepend' to build a dependency list for all the
## sources and attach that dependency list to the end of the Makefile.
## If we don't know a better way to generate dependencies, `cpp' should
## always work.
##
## Tom Fogal, Fri Jun 8 11:24:10 PDT 2007
## Removed `.depend'-based dependency mechanism. Set `depmode' for depcomp
## pick up and do dependency information during compilation.
##
## Tom Fogal, Wed Sep 3 18:44:54 EDT 2008
## Use `cpp' depmode instead of `makedepend', which warnings on AIX. Thanks,
## Cyrus!
##
DEPMODE=depmode=cpp
depend:
makedepend ${CXXFLAGS} $(CPPFLAGS) $(SRC)
@> .depend
##
## The following rules try to make it easier to see when a source
## file is outdated.
##
## If the `.depend' file doesn't exist then dependency information is
## definitely outdated (`make depend' has never been run). Otherwise,
## any source file which is newer than the Makefile must have outdated
## dependencies.
##
checkdep:
@if test -f .depend; then \
> .depend; \
for src in $(SRC); do \
if test "`ls -1t $$src Makefile|sed -n 1p`" != "Makefile"; then \
echo $$src >> .depend; \
fi; \
done; \
if test -s .depend; then \
echo "Warning: dependency info for these files is outdated:"; \
cat .depend; \
fi; \
else \
echo "Please run 'make depend' first."; \
exit 1; \
fi
clean-dep:
$(RM) -f $(DEP)
......@@ -83,74 +83,119 @@ distclean: clean
## Cyrus Harrison, Fri Mar 9 08:38:37 PST 2007
## Added engine specific targets: "_eng.o", "_par_eng.o"
##
## Tom Fogal, Fri Jun 8 11:07:27 PDT 2007
## Use depcomp to build dependencies during compilation.
##
## Tom Fogal, Sun Jun 8 18:00:05 EDT 2008
## Added IceT specific targets. Wrapped long lines.
##
.C.a:
false
.c.o:
source='$<' object='$@' libtool=no \
depfile='./$*.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
.c_mds.o:
source='$<' object='$@' libtool=no \
depfile='./$*_mds.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CC) $(CFLAGS) $(CPPFLAGS) -DMDSERVER -c $< -o $@
.c_par.o:
source='$<' object='$@' libtool=no \
depfile='./$*_par.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CC) $(CFLAGS) $(CPPFLAGS) @PARALLEL_CPPFLAGS@ -c $< -o $@
# There cannot be a tab before the OS_RULE line. The rule contains its own
# tab character.
.C.o:
source='$<' object='$@' libtool=no \
depfile='./$*.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
@OS_RULE@
.C_eng.o:
source='$<' object='$@' libtool=no \
depfile='./$*_eng.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -DENGINE -c $< -o $@
@OS_RULE@
.C_mds.o:
source='$<' object='$@' libtool=no \
depfile='./$*_mds.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -DMDSERVER -c $< -o $@
@OS_RULE@
.C_par.o:
source='$<' object='$@' libtool=no \
depfile='./$*_par.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CXX) $(CXXFLAGS) $(CPPFLAGS) @PARALLEL_CPPFLAGS@ -c $< -o $@
@OS_RULE@
.C_ogl.o:
source='$<' object='$@' libtool=no \
depfile='./$*_ogl.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
@OS_RULE@
.C_mesa.o:
source='$<' object='$@' libtool=no \
depfile='./$*_mesa.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(MESA_INCLUDE) -c $< -o $@
@OS_RULE@
.C_par_eng.o:
source='$<' object='$@' libtool=no \
depfile='./$*_par_eng.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -DENGINE @PARALLEL_CPPFLAGS@ -c $< -o $@
@OS_RULE@
.C_par_ogl.o:
source='$<' object='$@' libtool=no \
depfile='./$*_par_ogl.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CXX) $(CXXFLAGS) $(CPPFLAGS) @PARALLEL_CPPFLAGS@ -c $< -o $@
@OS_RULE@
.C_par_mesa.o:
source='$<' object='$@' libtool=no \
depfile='./$*_par_mesa.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CXX) $(CXXFLAGS) $(CPPFLAGS) @PARALLEL_CPPFLAGS@ $(MESA_INCLUDE) \
-c $< -o $@
@OS_RULE@
# _icet implies parallel; the PARALLEL_CPPFLAGS are there on purpose.
.C_icet.o:
source='$<' object='$@' libtool=no \
depfile='./$*_icet.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CXX) $(CXXFLAGS) $(CPPFLAGS) \
@PARALLEL_CPPFLAGS@ @ICET_CXXFLAGS@ \
-c $< -o $@
@OS_RULE@
.C_mesa_icet.o:
source='$<' object='$@' libtool=no \
depfile='./$*_mesa_icet.d' tmpdepfile='./$*.tmp_d' \
$(DEPMODE) $(TOPDIR)/bin/depcomp \
$(CXX) $(CXXFLAGS) $(CPPFLAGS) \
@PARALLEL_CPPFLAGS@ @ICET_CXXFLAGS@ $(MESA_INCLUDE) \
-c $< -o $@
@OS_RULE@
.f.o:
$(F77) $(F77FLAGS) -c $<
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment