1#!/bin/sh 2# $Id: run_make.sh,v 1.9 2012/01/15 22:35:01 tom Exp $ 3# vi:ts=4 sw=4: 4 5# do a test-compile on each of the ".c" files in the test-directory 6 7BISON=`bison --version 2>/dev/null | head -n 1 | sed -e 's/^[^0-9.]*//' -e 's/[^0-9.]*$//'` 8 9if test $# = 1 10then 11 PROG_DIR=`pwd` 12 TEST_DIR=$1 13else 14 PROG_DIR=.. 15 TEST_DIR=. 16fi 17 18MY_MAKE="make -f $PROG_DIR/makefile srcdir=$PROG_DIR VPATH=$TEST_DIR" 19 20echo '** '`date` 21for input in ${TEST_DIR}/*.c 22do 23 test -f "$input" || continue 24 25 obj=`basename "$input" .c`.o 26 27 $MY_MAKE $obj C_FILES=$input 28 test -f $obj && rm $obj 29 30 DEFS= 31 case $input in #(vi 32 ${TEST_DIR}/pure_*) 33 # DEFS="-DYYLEX_PARAM=flag -DYYLEX_PARAM_TYPE=int" 34 ;; 35 esac 36 37 if test "x$DEFS" != "x" 38 then 39 $MY_MAKE $obj C_FILES=$input DEFINES="$DEFS" 40 test -f $obj && rm -f $obj 41 fi 42done 43 44if test -n "$BISON" 45then 46 echo "** compare with bison $BISON" 47 for input in ${TEST_DIR}/*.y 48 do 49 test -f "$input" || continue 50 51 # Bison does not support pure-parser from command-line. 52 # Also, its support for %expect is generally broken. 53 # Work around these issues using a temporary file. 54 55 echo "... testing $input" 56 rm -f run_make.[coy] 57 58 case $input in 59 pure_*) 60 if test -z `fgrep -l '%pure-parser' $input` 61 then 62 echo "%pure-parser" >>run_make.y 63 fi 64 ;; 65 esac 66 67 sed -e '/^%expect/s,%expect.*,,' $input >>run_make.y 68 69 bison -y run_make.y 70 sed -e '/^#line/s,"run_make.y","'$input'",' y.tab.c >run_make.c 71 72 rm -f y.tab.c 73 74 input=run_make.c 75 object=run_make.o 76 if test -f $input 77 then 78 $MY_MAKE $object DEFINES='-DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=1 -DYYSTACK_USE_ALLOCA=0 -DYYMAXDEPTH=0' 79 else 80 echo "?? $input not found" 81 fi 82 rm -f run_make.[coy] 83 done 84fi 85 86YACC= 87for name in /usr/ccs/bin/yacc 88do 89 if test -f $name 90 then 91 YACC=$name 92 fi 93done 94 95if test -n "$YACC" 96then 97 echo "** compare with $YACC" 98 for input in ${TEST_DIR}/*.y 99 do 100 test -f "$input" || continue 101 102 echo "... testing $input" 103 rm -f run_make.[coy] 104 105 case $input in 106 pure_*) 107 echo "... skipping $input" 108 continue; 109 ;; 110 *) 111 if fgrep '%pure-parser' $input >/dev/null || 112 fgrep '%parse-param' $input >/dev/null || 113 fgrep '%lex-param' $input >/dev/null || 114 fgrep 'YYLEX_PARAM' $input >/dev/null 115 then 116 echo "... skipping $input" 117 continue; 118 fi 119 ;; 120 esac 121 122 sed -e '/^%expect/s,%expect.*,,' $input >>run_make.y 123 124 $YACC run_make.y 125 sed -e '/^#line/s,"run_make.y","'$input'",' y.tab.c >run_make.c 126 127 rm -f y.tab.c 128 129 input=run_make.c 130 object=run_make.o 131 if test -f $input 132 then 133 $MY_MAKE $object 134 else 135 echo "?? $input not found" 136 fi 137 rm -f run_make.[coy] 138 done 139fi 140