home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fchk294s.zip / ftnchek-2.9.4 / test / Makefile.os2 < prev    next >
Makefile  |  1996-10-04  |  14KB  |  414 lines

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