home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fchek284.zip / test / Makefile < prev    next >
Makefile  |  1995-06-02  |  11KB  |  357 lines

  1. #  Makefile for smoke-testing ftnchek.  Say ``make'' to make all checks.
  2. #
  3. #
  4.  
  5. # This defn uses version of dcl2inc.awk in the parent directory.
  6. DCL2INC        = $(NAWK) -f ../dcl2inc.awk
  7.  
  8. # This defn uses version of ftnchek in the parent directory.
  9. FTNCHEK        = ../ftnchek
  10.  
  11. # OKAY subdirectory is where the correct output files are stored.
  12. OKAY        = Okay
  13.  
  14. # VARY subdirectory is where the varying output files are stored.
  15. VARY        = Vary
  16.  
  17.  
  18. # COMPARE invokes the comparison script to check new vs archive.
  19. COMPARE        = ./Compare.sh $(OKAY) $(VARY)
  20.  
  21. # DEFAULT_FLAGS is the set of Ftnchek flags used by the default rule.
  22. # Note: The default rule also sets -f77 via the environment mechanism
  23. # in order to check that mechanism.
  24. DEFAULT_FLAGS    = -list -symt -port
  25.  
  26. MAKE        = make FTNCHEK=$(FTNCHEK) OKAY=$(OKAY) VARY=$(VARY)
  27.  
  28. CP              = /bin/cp
  29. MV        = /bin/mv
  30. # We need new awk, either AT&T nawk or GNU gawk.  However, IBM RS/6000 AIX
  31. # calls it awk.
  32. #NAWK        = awk
  33. #NAWK        = gawk
  34. NAWK        = nawk
  35. RM        = /bin/rm -f
  36. CSH        = /bin/csh -f
  37. SHELL        = /bin/sh
  38.  
  39.  
  40. .SUFFIXES: .chk .f .prj .fcl .fc1 .fc2 .fc3 .fc4 .fc5 .fc6 .fc7 .fc8 .fc9 \
  41.  .fcA .fcB .fcC .fcD .fcE .fcF
  42.  
  43.  
  44. #=======================================================================
  45. #
  46. #                   Definitions of File Groups
  47. #
  48. #
  49. # LISTOUT programs are simple, and all use the default options or else the
  50. # options given in their .opt file.  These produce listing files *.fcl
  51. # Note: Those with .opt files may have associated routines in other
  52. # files that do not appear here.
  53.  
  54. LISTOUT= average.f backslash.f chestnuts.f comclash.f comcmp.f\
  55.  complex.f comtest.f comusage.f correct.f dims.f do_enddo.f\
  56.  help.f include.f namelist.f noblanks.f strings.f unixincluded.f\
  57.  dectab.f intrinstest.f
  58.  
  59. # set of files for testing -arguments setting
  60. ARGS= args01.f args02.f args03.f args04.f args05.f args06.f\
  61.  args07.f args08.f args09.f args10.f args11.f args12.f\
  62.  args13.f args14.f args15.f
  63.  
  64. # set of files for testing -array setting
  65. ARRAY= arrayclash.f
  66.  
  67. # Set of files for testing -trun -port -f77 options and -word setting
  68. EXPR= assign.f
  69.  
  70. # set of files for testing -common setting
  71. COMMON= comcmp.f comusage.f
  72.  
  73. # set of files for testing dcl2inc processing
  74. DCL2INCFILES= t208x.f
  75.  
  76. # set of files for testing -makedcls setting
  77. MAKEDCLS= dims.f namelist.f\
  78.  t208a.f t208b.f t208c.f t208d.f t208e.f t208f.f t208g.f t208h.f \
  79.  t208i.f t208j.f t208k.f t208l.f t208m.f t208n.f t208o.f t208p.f \
  80.  t208q.f t208r.f t208s.f t208t.f t208u.f t208v.f t208w.f t208x.f
  81.  
  82. # set of files for testing -usage setting
  83. USAGE= usage.f
  84.  
  85. # set of files for testing -vcg switch (use target checkvcg)
  86. VCGLIST= comcmp.f comusage.f
  87.  
  88. #=======================================================================
  89. #
  90. #                   Default Rules
  91. #
  92. # Rule for creating source code listing file, suffix .fcl.  Stdout and
  93. # stderr are merged and environment mechanism for setting command
  94. # options is tested.
  95.  
  96. .f.fcl:
  97.     @if [ -f $*.opt ] ; then \
  98.       FTNCHEK_F77=1; export FTNCHEK_F77; \
  99.       $(FTNCHEK) `cat $*.opt` > $@ 2>&1 ; \
  100.     else \
  101.       FTNCHEK_F77=1; export FTNCHEK_F77; \
  102.       $(FTNCHEK) $(DEFAULT_FLAGS) $< > $@ 2>&1 ; \
  103.     fi
  104.  
  105.  
  106. # Rule for creating project file.  The .fcl file is made as a side-effect.
  107. .f.prj:
  108.     if [ -f $*.opt ] ; then \
  109.        $(FTNCHEK) -project `cat $*.opt` > $*.fcl 2>&1 ; \
  110.     else \
  111.        $(FTNCHEK) -project $(DEFAULT_FLAGS) $< > $*.fcl 2>&1 ; \
  112.     fi
  113.  
  114.  
  115. # Rule for running checks on source code listing.  If OKAY directory does
  116. # not exist, it is created.  If OKAY code listing does not exist, it
  117. # is created and moved into OKAY.  Note: In this case, you must examine
  118. # the results to see if it is really OK!
  119. .f.chk:
  120.     @-$(RM) $*.fcl
  121.     @$(MAKE) FTNCHEK='$(FTNCHEK)' $*.fcl "DEFAULT_FLAGS=$(DEFAULT_FLAGS)"
  122.     @$(COMPARE) $*.fcl
  123.  
  124.  
  125.  
  126. #=======================================================================
  127. #
  128. #        Targets.
  129. #
  130. #
  131.  
  132. all:    check
  133.  
  134. check:    announce checkall
  135.     @echo "check done"
  136.  
  137. announce:
  138.     @echo "============================================================"
  139.     @echo "There should be no file differences reported by these tests."
  140.     @echo "Output files matching master output files will be removed,"
  141.     @echo "leaving any erroneous output files in directory $(VARY)"
  142.     @echo "for manual examination."
  143.     @echo "============================================================"
  144.  
  145. # To avoid problems later, see if invoked with wrong awk.  This target does
  146. # not verify that it is the right awk, but catches the situation where
  147. # make is using the default NAWK=nawk and nawk does not exist.
  148. testfornawk:
  149.     @if [ ! -x "`which $(NAWK)`" ]; \
  150.     then \
  151.       echo ; \
  152.       echo 'PROBLEM: $(NAWK) not found, dcl2inc will not work.  It';\
  153.       echo 'requires the new awk. If your system has new awk';\
  154.       echo 'under the name awk or gawk, invoke "make NAWK=awk"';\
  155.       echo 'or "make NAWK=gawk".  Otherwise obtain AT&T nawk or GNU gawk.';\
  156.       echo ; \
  157.       exit 1 ; \
  158.     fi
  159.  
  160. checkall:    checksyntax checksettings checkother
  161.  
  162. checksyntax:    checklistings checkexpr
  163. checksettings:    checkargs checkarray checkcommon checkoutput checkusage
  164. checkother:    checkproject checkmakedcls checkdcl2inc
  165. # the following check is not included in checkall since -vcg is optional
  166. checkoptional:    checkvcg
  167.  
  168. clean mostlyclean clobber distclean realclean spotless:
  169.     -$(RM) *.dc[ln0-9] *.fc[l0-9A-F] *.pcl *.prj *.inc *.vcg
  170.     -$(RM) *.i *.o
  171.     -$(RM) *~ \#*
  172.     -$(RM) a.out core
  173.     -$(RM) $(VARY)/*
  174.  
  175. # checklistings checks listing output on programs in LISTOUT
  176. checklistings: announcelistings $(LISTOUT:.f=.chk)
  177.     @-echo "done"
  178.  
  179. # Some systems do not have echo -n option, so to suppress newline
  180. # in a portable way, we use this `awk'ward kluge.
  181. announcelistings:
  182.     @-echo|awk '{printf("%s","checking listing output:");}'
  183.  
  184. # Next series of targets checks variations of output as options change.
  185. # The output files are named *.fc[1-9A-F] for different cases.  Note that
  186. # in some instances the same source file is also in a set that is used
  187. # to check source listing as usual, with output file named *.fcl
  188.  
  189. # checkexpr checks listing output for various size & type clashes in
  190. # expressions and assignment stmts
  191. checkexpr:
  192.     @-echo |awk '{printf("%s","checking size and type mismatch:");}'
  193.     @for f in $(EXPR:.f=) ; \
  194.     do \
  195.      $(FTNCHEK) -notrun -noport -nof77 -lis    $$f.f > $$f.fc1 ; \
  196.      $(COMPARE) $$f.fc1 ; \
  197.      $(FTNCHEK) -notrun -noport   -f77         $$f.f > $$f.fc2 ; \
  198.      $(COMPARE) $$f.fc2 ; \
  199.      $(FTNCHEK) -notrun   -port -nof77         $$f.f > $$f.fc3 ; \
  200.      $(COMPARE) $$f.fc3 ; \
  201.      $(FTNCHEK) -notrun   -port   -f77         $$f.f > $$f.fc4 ; \
  202.      $(COMPARE) $$f.fc4 ; \
  203.      $(FTNCHEK)   -trun -noport -nof77         $$f.f > $$f.fc5 ; \
  204.      $(COMPARE) $$f.fc5 ; \
  205.      $(FTNCHEK)   -trun -noport   -f77         $$f.f > $$f.fc6 ; \
  206.      $(COMPARE) $$f.fc6 ; \
  207.      $(FTNCHEK)   -trun   -port -nof77         $$f.f > $$f.fc7 ; \
  208.      $(COMPARE) $$f.fc7 ; \
  209.      $(FTNCHEK)   -trun   -port   -f77         $$f.f > $$f.fc8 ; \
  210.      $(COMPARE) $$f.fc8 ; \
  211.      $(FTNCHEK)   -trun   -port -nof77 -word=2 $$f.f > $$f.fcA ; \
  212.      $(COMPARE) $$f.fcA ; \
  213.      $(FTNCHEK)   -trun   -port -nof77 -word=4 $$f.f > $$f.fcB ; \
  214.      $(COMPARE) $$f.fcB ; \
  215.      $(FTNCHEK)   -trun   -port -nof77 -word=8 $$f.f > $$f.fcC ; \
  216.      $(COMPARE) $$f.fcC ; \
  217.     done
  218.     @-echo "done"
  219.  
  220. # checkargs checks the -args=n setting
  221. checkargs:
  222.     @-echo |awk '{printf("%s","checking -args setting:");}'
  223.     @$(MAKE) FTNCHEK='$(FTNCHEK)' \
  224.         CheckSetting "SETTING=-args" "RANGE=0 1 2 3" \
  225.         "FLIST=$(ARGS)" "FLAGS="
  226.     @-echo "done"
  227.  
  228. # checkarray checks the -array=n setting
  229. checkarray:
  230.     @-echo |awk '{printf("%s","checking -array setting:");}'
  231.     @$(MAKE) FTNCHEK='$(FTNCHEK)' \
  232.         CheckSetting "SETTING=-array" "RANGE=0 1 2 3" \
  233.         "FLIST=$(ARRAY)" "FLAGS=-port"
  234.     @-echo "done"
  235.  
  236. #checkcommon checks the -common=n setting
  237. checkcommon:
  238.     @-echo |awk '{printf("%s","checking -common setting:");}'
  239.     @$(MAKE) FTNCHEK='$(FTNCHEK)' \
  240.         CheckSetting "SETTING=-common" "RANGE=0 1 2 3" \
  241.         "FLIST=$(COMMON)" "FLAGS=-nof77"
  242.     @-echo "done"
  243.  
  244. checkdcl2inc: testfornawk
  245.     @-echo |awk '{printf("%s","checking dcl2inc processing:");}'
  246.     @for f in $(DCL2INCFILES) ; \
  247.     do \
  248.         b=`basename $$f .f` ; \
  249.         $(RM) $$b.dcl $$b.dcn $$b.err $$b.mak ; \
  250.         $(RM) *.inc ; \
  251.         $(FTNCHEK) -makedcls=1 $$f 1>/dev/null 2>/dev/null ; \
  252.         $(DCL2INC) $$b.dcl >$$b.mak 2>$$b.err ; \
  253.         for g in $$b.dcl $$b.dcn $$b.mak $$b.err *.inc ; \
  254.         do \
  255.             $(COMPARE) $$g ; \
  256.         done ; \
  257.     done
  258.     @-echo "done"
  259.  
  260. # checkoutput checks the -output=file string setting
  261. checkoutput:
  262.     @-echo |awk '{printf("%s","checking -output setting:");}'
  263.     @$(FTNCHEK) -symt -list -port -out=average.out average.f 2> average.fc2
  264.     @-$(COMPARE) average.out
  265.     @-$(COMPARE) average.fc2
  266.     @-echo "done"
  267.  
  268. # checkusage checks the -usage=n setting
  269. checkusage:
  270.     @-echo |awk '{printf("%s","checking -usage setting:");}'
  271.     @$(MAKE) FTNCHEK='$(FTNCHEK)' \
  272.         CheckSetting "SETTING=-usage" "RANGE=0 1 2 3" \
  273.         "FLIST=$(USAGE)" "FLAGS="
  274.     @-echo "done"
  275.  
  276. # checkproject checks creation and use of project files
  277. # Note that correct.f is used in LISTOUT also, but with default
  278. # compilation options.  So we make listing file suffix .fc1 here
  279.  
  280. checkproject:
  281.     @-echo |awk '{printf("%s","checking project files:");}'
  282.     @$(RM) correct.prj correct.fc1 correct.pcl
  283.     @$(MAKE) FTNCHEK='$(FTNCHEK)' correct.prj
  284.     @$(MAKE) FTNCHEK='$(FTNCHEK)' correct.pcl
  285.     @-for f in correct.fc1 correct.prj correct.pcl ; \
  286.     do \
  287.         $(COMPARE) $$f ; \
  288.     done
  289.     @-echo "done"
  290.  
  291.  
  292. # Need explicit rule since the default rule is used by listing-file check
  293. correct.prj: correct.f
  294.     @$(FTNCHEK) -project correct.f > correct.fc1 2>&1
  295.  
  296. #  This target creates output listing file from project file input
  297. correct.pcl: correct.f
  298.     @$(FTNCHEK) correct.prj > correct.pcl 2>&1
  299.  
  300. # Check the generation of declarations files.  Listing goes to /dev/null.
  301. # The values in MAKEDCLS_VALS are used as 3rd char in .fc? suffix.  They
  302. # are converted to -makedcls=num values by raising 2 to the power.  Thus
  303. # file.dc0 contains -makedcls=1, ... file.dc8 contains -makedcls=256.
  304. # There is also a test to be sure that empty .dcl files are removed
  305. # automatically as they should be.
  306. MAKEDCLS_VALS    = 0 1 2 3 4 5 6 7 8
  307. checkmakedcls:
  308.     @-echo |awk '{printf("%s","checking -makedcls setting:");}'
  309.     @for n in $(MAKEDCLS_VALS) ; \
  310.     do \
  311.         dcl=dc$$n ;\
  312.         val=`echo 2 \^ $$n | bc` ;\
  313.         for f in $(MAKEDCLS:.f=) ;\
  314.         do \
  315.         $(FTNCHEK) -makedcls=$$val $$f.f 1>/dev/null 2>/dev/null ; \
  316.         if [ -f $$f.dcl ] ; \
  317.         then \
  318.           if [ `wc -c $$f.dcl | awk '{printf("%s",$$1);}'` -eq 0 ] ; \
  319.           then \
  320.             $(CP) $$f.dcl $(VARY)/$$f.$$dcl ; \
  321.             echo ; echo "Empty declarations file" \
  322.              $(VARY)/$$f.$$dcl "should have been deleted" ; \
  323.           fi ; \
  324.         else \
  325.            touch $$f.dcl ; \
  326.         fi ; \
  327.         $(MV) $$f.dcl $$f.$$dcl ; \
  328.         $(COMPARE) $$f.$$dcl ; \
  329.         done ; \
  330.     done
  331.     @echo "done"
  332.  
  333.  
  334. checkvcg:
  335.     @-echo |awk '{printf("%s","checking -vcg setting:");}'
  336.     @-for f in $(VCGLIST:.f=) ; \
  337.     do \
  338.       $(FTNCHEK) -vcg $$f.f | fcl2vcg > $$f.vcg ; \
  339.       $(COMPARE) $$f.vcg ; \
  340.     done
  341.     @echo "done"
  342.  
  343. # CheckSetting is a "subroutine" with parameters SETTING=name of setting,
  344. # RANGE=list of setting values, FLIST=list of files to check, and
  345. # FLAGS=set of ftnchek flags to use for each case.  "Call" this routine
  346. # by invoking make with appropriate macro definitions on command line.
  347.  
  348. CheckSetting:
  349.     @for val in $(RANGE) ; \
  350.     do \
  351.       for f in $(FLIST:.f=) ; \
  352.       do \
  353.         $(FTNCHEK) $(SETTING)=$$val $(FLAGS) $$f.f > $$f.fc$$val ; \
  354.         $(COMPARE) $$f.fc$$val ; \
  355.       done ; \
  356.     done
  357.