|
Packit Service |
973b1a |
#! /bin/sh
|
|
Packit Service |
973b1a |
# Validate gperf's operation on a given input file.
|
|
Packit Service |
973b1a |
# Usage: validate languages input.gperf [more gperf options]
|
|
Packit Service |
973b1a |
# Uses the environment variables GPERF, CC, CFLAGS, CXX, CXXFLAGS.
|
|
Packit Service |
973b1a |
# Supposes gcc and g++.
|
|
Packit Service |
973b1a |
|
|
Packit Service |
973b1a |
# Exit on error
|
|
Packit Service |
973b1a |
set -e
|
|
Packit Service |
973b1a |
|
|
Packit Service |
973b1a |
verbose () {
|
|
Packit Service |
973b1a |
echo "$@"
|
|
Packit Service |
973b1a |
"$@"
|
|
Packit Service |
973b1a |
}
|
|
Packit Service |
973b1a |
|
|
Packit Service |
973b1a |
languages=$1
|
|
Packit Service |
973b1a |
shift
|
|
Packit Service |
973b1a |
|
|
Packit Service |
973b1a |
# On old systems, it's worth trying gcc -traditional.
|
|
Packit Service |
973b1a |
# On glibc-2.1 systems, gcc -traditional doesn't work any more.
|
|
Packit Service |
973b1a |
use_traditional=false
|
|
Packit Service |
973b1a |
|
|
Packit Service |
973b1a |
for lang in `echo $languages | sed -e 's/,/ /g'`; do
|
|
Packit Service |
973b1a |
case "$lang" in
|
|
Packit Service |
973b1a |
KR-C )
|
|
Packit Service |
973b1a |
echo "${GPERF} -I -L KR-C $@ > valitest.c"
|
|
Packit Service |
973b1a |
${GPERF} -I -L KR-C "$@" > valitest.c
|
|
Packit Service |
973b1a |
grep -n ' const ' valitest.c /dev/null && exit 1
|
|
Packit Service |
973b1a |
if test $use_traditional = true; then
|
|
Packit Service |
973b1a |
verbose ${CC} ${CFLAGS} ${CPPFLAGS} -traditional valitest.c -o valitest
|
|
Packit Service |
973b1a |
./valitest
|
|
Packit Service |
973b1a |
fi
|
|
Packit Service |
973b1a |
verbose ${CC} ${CFLAGS} ${CPPFLAGS} -ansi -pedantic valitest.c -o valitest
|
|
Packit Service |
973b1a |
./valitest
|
|
Packit Service |
973b1a |
;;
|
|
Packit Service |
973b1a |
C )
|
|
Packit Service |
973b1a |
echo "${GPERF} -I -L C $@ > valitest.c"
|
|
Packit Service |
973b1a |
${GPERF} -I -L C "$@" > valitest.c
|
|
Packit Service |
973b1a |
if test $use_traditional = true; then
|
|
Packit Service |
973b1a |
verbose ${CC} ${CFLAGS} ${CPPFLAGS} -traditional -Dconst= valitest.c -o valitest
|
|
Packit Service |
973b1a |
./valitest
|
|
Packit Service |
973b1a |
fi
|
|
Packit Service |
973b1a |
verbose ${CC} ${CFLAGS} ${CPPFLAGS} -ansi -pedantic -pedantic-errors valitest.c -o valitest
|
|
Packit Service |
973b1a |
./valitest
|
|
Packit Service |
973b1a |
;;
|
|
Packit Service |
973b1a |
ANSI-C )
|
|
Packit Service |
973b1a |
echo "${GPERF} -I -L ANSI-C $@ > valitest.c"
|
|
Packit Service |
973b1a |
${GPERF} -I -L ANSI-C "$@" > valitest.c
|
|
Packit Service |
973b1a |
verbose ${CC} ${CFLAGS} ${CPPFLAGS} -ansi -pedantic -pedantic-errors valitest.c -o valitest
|
|
Packit Service |
973b1a |
./valitest
|
|
Packit Service |
973b1a |
verbose ${CXX} ${CXXFLAGS} ${CPPFLAGS} -ansi -pedantic -pedantic-errors valitest.c -o valitest
|
|
Packit Service |
973b1a |
./valitest
|
|
Packit Service |
973b1a |
;;
|
|
Packit Service |
973b1a |
"C++" )
|
|
Packit Service |
973b1a |
echo "${GPERF} -I -L C++ $@ > valitest.c"
|
|
Packit Service |
973b1a |
${GPERF} -I -L C++ "$@" > valitest.c
|
|
Packit Service |
973b1a |
verbose ${CXX} ${CXXFLAGS} ${CPPFLAGS} -ansi -pedantic -pedantic-errors -DCPLUSPLUS_TEST valitest.c -o valitest
|
|
Packit Service |
973b1a |
./valitest
|
|
Packit Service |
973b1a |
;;
|
|
Packit Service |
973b1a |
esac
|
|
Packit Service |
973b1a |
done
|
|
Packit Service |
973b1a |
|
|
Packit Service |
973b1a |
exit 0
|