|
| 1 | +####################################################################################### |
| 2 | +# |
| 3 | +# variables - mandatory: |
| 4 | +# ====================== |
| 5 | +# $(CHECKLOGFILE) where to put the results of gmake checksac2c |
| 6 | +# and gmake checkres |
| 7 | +# |
| 8 | +# variables - optional: |
| 9 | +# ===================== |
| 10 | +# $(CHECKDIR) .checkdir path to .clog and .res files |
| 11 | +# $(RT_FLAGS) undef run-time flags |
| 12 | +# $(INPSDIR) . path to .inp(s) files |
| 13 | +# |
| 14 | +# standard targets: |
| 15 | +# ================= |
| 16 | +# gmake checksac2c remake .clog files and compare to .clog.base |
| 17 | +# gmake checkres remake .res files and compare to .res.base |
| 18 | +# gmake checksac2c_base remake .clog.base |
| 19 | +# gmake checkres_base remake .res.base |
| 20 | +# |
| 21 | +####################################################################################### |
| 22 | + |
| 23 | +include $(SACBASE)/Makefiles/Makefile.standard |
| 24 | +include $(SACBASE)/Makefiles/Makefile.run |
| 25 | + |
| 26 | +.PHONY: result checksac2c checkres check_all_files |
| 27 | + |
| 28 | + |
| 29 | +# |
| 30 | +# Now, we implement a dirty trick for being able to mark pattern rules as phony. |
| 31 | +# The idea is to introduce a phony target "phony" which indeed does NOT do anything! |
| 32 | +# It can be used as a dependency for pattern rules which in fact renders all targets |
| 33 | +# that are built using those rules phony! |
| 34 | +# |
| 35 | +# In this Makefile, all pattern rules for *.clog and *.res files are extended |
| 36 | +# accordingly, making sure that these files will be rebuilt irrespective their |
| 37 | +# apriori existance. |
| 38 | +# |
| 39 | + |
| 40 | +.PHONY: phony |
| 41 | + |
| 42 | +phony: |
| 43 | + |
| 44 | + |
| 45 | +ifndef CLOG_FILES |
| 46 | +CLOG_FILES = $(patsubst %,$(CHECKDIR)/%.clog, $(notdir $(FILETARGETS)) \ |
| 47 | + $(notdir $(MODTARGETS)) \ |
| 48 | + $(VERSIONNAMES)) |
| 49 | +endif |
| 50 | + |
| 51 | +ifndef RES_FILES |
| 52 | +RES_FILES = $(patsubst %,$(CHECKDIR)/%.res,$(FILES) $(basename $(notdir $(VERSIONTARGETS)))) |
| 53 | +endif |
| 54 | + |
| 55 | +####################################################################################### |
| 56 | +# |
| 57 | +# preset optional pathes first: |
| 58 | +# - CHECKDIR : where to put XYZ.clog/ XYZ.res if XYZ.sac is in the actual directory |
| 59 | +# - INPSDIR : where to find XYZ.inp(s) if XYZ.sac is in the actual directory |
| 60 | +# |
| 61 | + |
| 62 | +ifndef CHECKDIR |
| 63 | +CHECKDIR = .checkdir |
| 64 | +endif |
| 65 | + |
| 66 | +ifndef INPSDIR |
| 67 | +INPSDIR = . |
| 68 | +endif |
| 69 | + |
| 70 | + |
| 71 | +####################################################################################### |
| 72 | +# |
| 73 | +# pattern rules for .clog files. |
| 74 | +# |
| 75 | + |
| 76 | +$(CHECKDIR)/%.clog: phony |
| 77 | + @ if [ ! -d $(CHECKDIR) ]; \ |
| 78 | + then $(MKDIR) $(CHECKDIR); \ |
| 79 | + $(ECHO) "$(MKDIR) $(CHECKDIR)"; \ |
| 80 | + fi |
| 81 | + $(RM) $(CHECKDIR)/$* $(CHECKDIR)/*.h |
| 82 | + $(MAKE) $(CHECKDIR)/$* "TARGETDIR=$(CHECKDIR)" \ |
| 83 | + "LIBTARGETDIR=$(CHECKDIR)" \ |
| 84 | + "INCTARGETDIR=$(CHECKDIR)" >$@ 2>&1 |
| 85 | + $(RM) $(CHECKDIR)/$* $(CHECKDIR)/*.h |
| 86 | + $(CLOCK_SKEW_ELIMINATION) $@ |
| 87 | + |
| 88 | + |
| 89 | +####################################################################################### |
| 90 | +# |
| 91 | +# pattern rule for .res files. It relies on the intermediate target .XYZ.r |
| 92 | +# which according to the existance of XYZ.inp / XYZ.inps contains all intended calls of |
| 93 | +# the executable XYZ. The pattern rules for .XYZ.r along with fuirther comments can be |
| 94 | +# found in $(SACBASE)/stdlib/Makefiles/Makefile.run . |
| 95 | +# |
| 96 | + |
| 97 | +$(CHECKDIR)/%.res: .%.r phony |
| 98 | + $(RM) $@ |
| 99 | + @ while read r; do \ |
| 100 | + $(MAKE) result FILE="$*" RUN="$${r}"; \ |
| 101 | + done < .$*.r |
| 102 | + $(CLOCK_SKEW_ELIMINATION) $@ |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | +####################################################################################### |
| 108 | +# |
| 109 | +# phony-rule "result". |
| 110 | +# "result" is used as universal "routine" for producing a program's result; |
| 111 | +# it is parameterized by the variables $(FILE) and $(RUN). |
| 112 | +# |
| 113 | + |
| 114 | +result: |
| 115 | + @ if [ ! -d $(CHECKDIR) ]; \ |
| 116 | + then $(MKDIR) $(CHECKDIR); \ |
| 117 | + $(ECHO) "$(MKDIR) $(CHECKDIR)"; \ |
| 118 | + fi |
| 119 | + $(RUN) >> $(CHECKDIR)/$(FILE).res 2>&1 |
| 120 | + |
| 121 | + |
| 122 | +####################################################################################### |
| 123 | +# |
| 124 | +# standard targets for checking the compiler |
| 125 | +# |
| 126 | + |
| 127 | +checksac2c: |
| 128 | + @ $(MAKE) check_all_files FILES_TO_BE_DONE="$(CLOG_FILES)" COMPARE="yes" |
| 129 | + @ $(MAKE) subdirs TARGET="checksac2c" |
| 130 | + |
| 131 | +checkres: |
| 132 | + @ $(MAKE) check_all_files FILES_TO_BE_DONE="$(RES_FILES)" COMPARE="yes" |
| 133 | + @ $(MAKE) subdirs TARGET="checkres" |
| 134 | + |
| 135 | +checksac2c_base: |
| 136 | + @ $(MAKE) check_all_files FILES_TO_BE_DONE="$(CLOG_FILES)" |
| 137 | + @ $(MAKE) subdirs TARGET="checksac2c_base" |
| 138 | + |
| 139 | +checkres_base: |
| 140 | + @ $(MAKE) check_all_files FILES_TO_BE_DONE="$(RES_FILES)" |
| 141 | + @ $(MAKE) subdirs TARGET="checkres_base" |
| 142 | + |
| 143 | +####################################################################################### |
| 144 | +# |
| 145 | +# phony-rule "check_all_files". |
| 146 | +# "check_all_files" runs diff on an old and a new version and catalogs the |
| 147 | +# result in the log file $(CHECKLOGFILE). |
| 148 | +# It is parameterized by $(FILES_TO_BE_DONE) and $(COMPARE). |
| 149 | +# |
| 150 | + |
| 151 | +check_all_files: |
| 152 | + @ if [ "$(CHECKLOGFILE)" = "" ]; \ |
| 153 | + then $(ECHO) CHECKLOGFILE not defined! >&2; \ |
| 154 | + exit 1 ; \ |
| 155 | + fi |
| 156 | + @ if [ "$(FILES_TO_BE_DONE)x" != "x" ]; then \ |
| 157 | + if [ ! -d $(CHECKDIR) ]; then \ |
| 158 | + $(MKDIR) $(CHECKDIR); \ |
| 159 | + $(ECHO) "$(MKDIR) $(CHECKDIR)"; \ |
| 160 | + fi; \ |
| 161 | + for f in $(FILES_TO_BE_DONE)"" ; do \ |
| 162 | + $(ECHO) `$(DATE)`'>>>>>'`pwd`/$${f}: >> $(CHECKLOGFILE); \ |
| 163 | + if [ "$(COMPARE)" = "yes" -a -f $${f}.base ] ; then \ |
| 164 | + $(MAKE) -i $${f}; \ |
| 165 | + $(DIFF) $${f} $${f}.base >>$(CHECKLOGFILE) 2>&1; \ |
| 166 | + $(ECHO) '">" : base; "<" : actual' >> $(CHECKLOGFILE); \ |
| 167 | + else \ |
| 168 | + $(MAKE) $${f}; \ |
| 169 | + $(MV) $${f} $${f}.base; \ |
| 170 | + $(ECHO) "base version created!" >> $(CHECKLOGFILE); \ |
| 171 | + fi; \ |
| 172 | + done; \ |
| 173 | + fi |
0 commit comments