From: wolf Date: Wed, 24 Feb 1999 12:56:20 +0000 (+0000) Subject: Make forward declarations work much better than before. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d6279f690d63fcd2ad6425d3d98608dc6e35c4d;p=dealii-svn.git Make forward declarations work much better than before. git-svn-id: https://svn.dealii.org/trunk@890 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/Makefile b/deal.II/deal.II/Makefile index 568f6fe47a..e277543fe0 100644 --- a/deal.II/deal.II/Makefile +++ b/deal.II/deal.II/Makefile @@ -14,7 +14,7 @@ examples: cd examples ; make lib-clean: - -rm -f *~ include/*~ include/*/*~ + -rm -f *~ include/*~ include/*/*~ include/basic/forward-declarations.h* cd lib ; make clean examples-clean: diff --git a/deal.II/deal.II/source/Makefile b/deal.II/deal.II/source/Makefile index 2ddec2e403..607304eb6f 100644 --- a/deal.II/deal.II/source/Makefile +++ b/deal.II/deal.II/source/Makefile @@ -17,6 +17,8 @@ include $D/deal.II/Make.global_options cc-files = $(wildcard */*.cc) h-files = $(wildcard ../include/*/*.h) +forward-declarations = ../include/basic/forward-declarations.h + # strip subdirectories from cc file names, preprend a "../lib/[g]o" # and change the suffix. We place the object files with or without # debug info in different directories, since we want to use the @@ -46,9 +48,46 @@ all: 1d 2d 3d # rule how to make the file containing all the forward declarations -../include/basic/forward-declarations.h: $(filter-out %forward-declarations.h,$(h-files)) +# this rule is rather complicated, it works as follows: +# +# - if this is the outermost 'make', then create a file $@.old. +# if the forward declaration file $@ already exists, then copy +# it over, otherwise leave it empty. this way, we always have +# a file to run diff on +# - write the forward declarations for the presently available +# header files to $@.new +# - we would like to compare the output of the script generating +# the forward declarations with the old file, or the empty +# string if there is no such file; this is why we created $@.old +# - if the files differ, we would like to copy over the old file. +# - this can either be done using shell programming using 'if [...]' +# or using conditionals inside 'make'. the first way is not +# portable over different shells, however, and I also do not know +# how to write it. the second way has a problem also: conditionals +# are evaluated at the time the Makefile is read first, so we +# can't compare against $@.old, since this file does not exist at +# that time. +# - we therefore invoke a second 'make', which can compare the two +# files against each other in a preconditional clause and +# copy over the file if necessary. +# - delete the two temporary files +$(forward-declarations): $(filter-out $(forward-declarations),$(h-files)) +ifeq (0,${MAKELEVEL}) + @echo ============================ Checking $@ + @touch $@.old + -@cp $@ $@.old + @perl ../Make_forward_declarations $(filter-out $(forward-declarations),$(h-files)) > $@.new + @make --silent $@ + @rm $@.old $@.new +else + ifneq (,$(shell diff $(forward-declarations).old $(forward-declarations).new)) @echo ============================ Generating $@ - @perl ../Make_forward_declarations $(filter-out %forward-declarations.h,$(h-files)) > $@ + @cp $@.new $@ + else + @echo "============================ $@ needs no change" + endif +endif + @@ -141,7 +180,7 @@ clean: #programs which use the 2d *and* the 3d library; #if the files within these libraries had the same names, #we may get into trouble. -../lib/Makefile.dep: $(cc-files) $(h-files) Makefile ../Make.global_options +../lib/Makefile.dep: $(cc-files) $(filter-out $(forward-declarations),$(h-files)) Makefile ../Make.global_options @echo ============================ Remaking Makefile @echo "# This Makefile was automatically generated by ../source/Makefile" \ > ../lib/Makefile.dep