1# 2# Makefile gnucobol/tests/cobol85 3# 4# Copyright (C) 2003-2012, 2015-2020 Free Software Foundation, Inc. 5# Written by Keisuke Nishida, Roger While, Simon Sobisch 6# 7# This file is part of GnuCOBOL. 8# 9# The GnuCOBOL compiler is free software: you can redistribute it 10# and/or modify it under the terms of the GNU General Public License 11# as published by the Free Software Foundation, either version 3 of the 12# License, or (at your option) any later version. 13# 14# GnuCOBOL is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU General Public License for more details. 18# 19# You should have received a copy of the GNU General Public License 20# along with GnuCOBOL. If not, see <https://www.gnu.org/licenses/>. 21 22# FIXME: doesn't work when EXEC85$(EXEEXT) exists in sourcedir but not 23# in builddir 24 25RM = rm -rf 26 27MODULES_ALL = NC SM IC SQ RL ST SG OB IF RW DB IX DBNOIX CM 28 29# currently untested modules: CM 30if COB_MAKE_IX 31MODULES = NC SM IC SQ RL ST SG OB IF RW DB IX 32MODULES_RUN = NC_RUN SM_RUN IC_RUN SQ_RUN RL_RUN \ 33 ST_RUN SG_RUN OB_RUN IF_RUN RW_RUN DB_RUN IX_RUN 34SUMMARY = summary.txt 35else 36MODULES = NC SM IC SQ RL ST SG OB IF RW DBNOIX 37MODULES_RUN = NC_RUN SM_RUN IC_RUN SQ_RUN RL_RUN \ 38 ST_RUN SG_RUN OB_RUN IF_RUN RW_RUN DBNOIX_RUN 39SUMMARY = summarynoix.txt 40endif 41 42URL_NEWCOB_Z = https://www.itl.nist.gov/div897/ctg/suites/newcob.val.Z 43URL_NEWCOB_TAR_GZ = https://sourceforge.net/projects/gnucobol/files/nist/newcob.val.tar.gz/download 44 45EXTRA_DIST = EXEC85.conf.in expand.pl report.pl summary.pl summary.txt \ 46 summarynoix.txt NC.txt SM.txt IC.txt SQ.txt RL.txt IX.txt \ 47 ST.txt SG.txt OB.txt IF.txt RW.txt DB.txt DBNOIX.txt Makefile.module.in 48 49#CLEANFILES = EXEC85$(EXEEXT) summary.log 50 51CURL_FLAGS = 52WGET_FLAGS = -t1 -T5 53DIFF_FLAGS = @DIFF_FLAGS@ 54COBC_FLAGS = -std=cobol85 -debug 55 56# MAKEFLAGS = --no-print-directory 57 58# targets that are only logical targets instead of files 59.PHONY: test diff-summary diff summary.log $(MODULES_RUN) unpack-Z unpack-gz 60 61NC_RUN: NC 62 @cd NC && $(MAKE) -k 63 64SM_RUN: SM 65 @cd SM && $(MAKE) -k 66 67IC_RUN: IC 68 @cd IC && $(MAKE) -k 69 70SQ_RUN: SQ 71 @cd SQ && $(MAKE) -k 72 73RL_RUN: RL 74 @cd RL && $(MAKE) -k 75 76ST_RUN: ST 77 @cd ST && $(MAKE) -k 78 79SG_RUN: SG 80 @cd SG && $(MAKE) -k 81 82OB_RUN: OB 83 @cd OB && $(MAKE) -k 84 85IF_RUN: IF 86 @cd IF && $(MAKE) -k 87 88RW_RUN: RW 89 @cd RW && $(MAKE) -k 90 91DB_RUN: DB 92 @cd DB && $(MAKE) -k 93 94IX_RUN: IX 95 @cd IX && $(MAKE) -k 96 97DBNOIX_RUN: DBNOIX 98 @cd DBNOIX && $(MAKE) -k 99 100CM_RUN: CM 101 @cd CM && $(MAKE) -k 102 103modules: $(MODULES_ALL) 104 105duration.log: 106 @echo "Collecting durations for each module..." 107 @echo "Duration for modules: $(MODULES)" > $@ 108 @echo "" >> $@ 109 @for m in $(MODULES); do \ 110 cat "$$m/duration.txt" >> $@; \ 111 done 112 @echo Done 113 114test: $(MODULES_RUN) 115 @echo 116 $(MAKE) diff-summary 117 118summary.log: 119 @echo "Computing total test results..." 120 @perl "$(srcdir)/summary.pl" $(MODULES) > $@ 121 122diff: 123 @echo "Comparing test results for each module" 124 @retd=0; for m in $(MODULES); do \ 125 echo "diff $$m/report.txt..."; \ 126 diff $(DIFF_FLAGS) "$(srcdir)/$$m.txt" "$$m/report.txt"; \ 127 ret=$$? && if test $$ret -gt $$retd; then retd=$$ret; fi \ 128 done; \ 129 if test $$retd -gt 1; then exit $$retd; fi 130 @echo Done 131 $(MAKE) diff-summary 132 133diff-summary: 134 $(MAKE) summary.log 135 @echo "Comparing total test results..." 136 @echo "diff $(SUMMARY)..." 137 @diff $(DIFF_FLAGS) "$(srcdir)/$(SUMMARY)" "summary.log" 138 @echo Done 139 140newcob.val.Z: 141 @echo "Trying to download newcob.val.Z..." 142 @(which curl 1>/dev/null && curl $(CURL_FLAGS) "$(URL_NEWCOB_Z)" -o $@) || \ 143 wget $(WGET_FLAGS) "$(URL_NEWCOB_Z)" || \ 144 (rm -rf $@; echo "Downloading $@ failed"; false) 145 146newcob.val.tar.gz: 147 @echo "Trying to download newcob.val.tar.gz..." 148 @(which curl 1>/dev/null && curl $(CURL_FLAGS) "$(URL_NEWCOB_TAR_GZ)" -o $@) || \ 149 wget $(WGET_FLAGS) -O $@ "$(URL_NEWCOB_TAR_GZ)" || \ 150 (rm -rf $@; echo "Downloading $@ failed"; false) 151 152unpack-Z: newcob.val.Z 153 @echo "Unpacking $<..." 154 @gunzip -f "$<" || gzip -d -f "$<" || uncompress "$<" 155 156unpack-gz: newcob.val.tar.gz 157 @echo "Unpacking $<..." 158 @tar -xf "$<" 159 160# always copy pack from srcdir for in-place unpack, if possible 161newcob.val: 162 @if test -f "$(srcdir)/newcob.val.tar.gz"; then \ 163 if test ! -f "$(abs_builddir)/newcob.val.tar.gz"; then \ 164 export pack=newcob.val.tar.gz && \ 165 echo "Copying $$pack to current directory..." && \ 166 cp "$(srcdir)/$$pack" . ; \ 167 fi; \ 168 $(MAKE) unpack-gz; \ 169 else \ 170 if test -f "$(srcdir)/newcob.val.Z"; then \ 171 if test ! -f "$(abs_builddir)/newcob.val.Z"; then \ 172 export pack=newcob.val.Z && \ 173 echo "Copying $$pack to current directory..." && \ 174 cp "$(srcdir)/$$pack" . ; \ 175 fi; \ 176 $(MAKE) unpack-Z; \ 177 else \ 178 ($(MAKE) newcob.val.Z && $(MAKE) unpack-Z) || \ 179 (echo Fallback to sourceforge.net && \ 180 $(MAKE) newcob.val.tar.gz && $(MAKE) unpack-gz); \ 181 fi; \ 182 fi 183 @if ! test -f "newcob.val"; then \ 184 echo "newcob.val missing, automatic download and uncompress did not work"; \ 185 exit 1; \ 186 fi 187 188clean-local: 189 $(RM) copy copyalt $(MODULES_ALL) EXEC85$(EXEEXT) summary.log EXEC85.cob 190 191$(MODULES_ALL): newcob.val EXEC85$(EXEEXT) $(srcdir)/EXEC85.conf.in Makefile.module.in 192 @echo "Building module directory $@ ..." 193 @mkdir -p ./$@ 194 @echo "*SELECT-MODULE `echo $@ | $(SED) 's/\(..\).*/\1/'`" > ./$@/EXEC85.conf 195 @cat $(srcdir)/EXEC85.conf.in >> ./$@/EXEC85.conf 196# setting NEWCOB_VAL to the full name for EXEC85 197 @if test -f "$(abs_builddir)/newcob.val"; then \ 198 export NEWCOB_VAL=$(abs_builddir)/newcob.val; \ 199 else \ 200 export NEWCOB_VAL=$(abs_srcdir)/newcob.val; \ 201 fi; \ 202 cd $@ && "$(abs_top_builddir)/pre-inst-env" ../EXEC85$(EXEEXT) 203 @perl $(srcdir)/expand.pl $@/newcob.tmp $@ 204# @$(RM) ./$@/newcob.tmp ./$@/newcob.log ./$@/EXEC85.conf 205 @export CBL_LIST="`ls $@/*.CBL | cut -f2 -d/ | tr '\n' ' '`" && \ 206 $(SED) -e 's/##MODULE##/'"$@"'/' \ 207 -e 's|##COB85DIR##|'$(abs_srcdir)'|' \ 208 -e 's|##DIFF_FLAGS##|'"$(DIFF_FLAGS)"'|' \ 209 -e 's|##TESTS##|'"` echo $$CBL_LIST | $(SED) -e 's/\.CBL//g'`"'|' \ 210 -e 's|##TESTS_LOCAL##|'"`echo $$CBL_LIST | $(SED) -e 's/\.CBL/-local/g'`"'|' \ 211 $(srcdir)/Makefile.module.in > $@/Makefile 212 @echo "Finished module directory $@." 213 214EXEC85.cob: newcob.val 215 @echo "Extracting EXEC85 program from newcob.val" 216# setting NEWCOB_VAL to the full name for the sed invocation 217 @if test -f "$(abs_builddir)/newcob.val"; then \ 218 NEWCOB_VAL=$(abs_builddir)/newcob.val; \ 219 else \ 220 NEWCOB_VAL=$(abs_srcdir)/newcob.val; \ 221 fi; \ 222 $(SED) -e '/^\*END/,$$d' \ 223 -e '1,/^\*HEADER/d' \ 224 -e 's/^002500.*/ SELECT POPULATION-FILE/' \ 225 -e 's/^002700.*/ "NEWCOB_VAL" ORGANIZATION LINE SEQUENTIAL./' \ 226 -e 's/^003000.*/ "newcob.tmp" ORGANIZATION LINE SEQUENTIAL./' \ 227 -e 's/^003100.*//' \ 228 -e 's/^003400.*/ "unused"./' \ 229 -e 's/^003700.*/ "newcob.log"./' \ 230 -e 's/^004000.*/ "EXEC85.conf" ORGANIZATION LINE SEQUENTIAL./' \ 231 "$$NEWCOB_VAL" > EXEC85.cob || ($(RM) EXEC85.cob && false) 232 233 234EXEC85$(EXEEXT): EXEC85.cob 235 @echo "Compiling EXEC85 program" 236 @if test -f "EXEC85.cob"; then EXEC_SRC="EXEC85.cob"; else EXEC_SRC="$(srcdir)/EXEC85.cob"; fi; \ 237 "$(top_builddir)/pre-inst-env" cobc$(EXEEXT) $(COBC_FLAGS) -x "$$EXEC_SRC" 238