#!/bin/sh

# gcc      ver. 2.8.1
# egcs gcc ver. 1.1.2
# gcc      ver. 2.95.2
GCC_COMMAND=${GCC:-gcc}

#
# check for -ansi option
#
if [ X`uname` = X'FreeBSD' ]; then	# XXX
	GCC_ANSI_OPTION_OK='YES'
else
	GCC_ANSI_OPTION='NO'
fi

#
# -ansi option
#
if [ X"${GCC_ANSI_OPTION_OK}" = X'YES' ]; then
	gcc_ansi_option='-ansi'
else
	gcc_ansi_option=''
fi


if [ -z `${GXX_COMMAND} --version | grep '^2\.96[^0-9]*'` ]; then
	GCCFLAGS="${gcc_ansi_option} \
		  -pedantic \
		  -Wall \
		  -W \
		  -Wundef \
		  -Wshadow \
		  -Wid-clash-31 \
		  -Wpointer-arith \
		  -Wcast-qual \
		  -Wcast-align \
		  -Wwrite-strings \
		  -Wconversion \
		  -Wsign-compare \
		  -Wstrict-prototypes \
		  -Wmissing-prototypes \
		  -Wmissing-declarations \
		  -Wnested-externs \
		  -Wredundant-decls \
		 "
else
	# ver. 2.96
	GCCFLAGS="${gcc_ansi_option} \
		  -pedantic \
		  -Wall \
		  -W \
		  -Wshadow \
		  -Wid-clash-31 \
		  -Wpointer-arith \
		  -Wcast-qual \
		  -Wcast-align \
		  -Wwrite-strings \
		  -Wconversion \
		  -Wsign-compare \
		  -Wmissing-prototypes \
		  -Wredundant-decls \
		 "
fi

# ver. 2.95
#	  -Wmissing-noreturn \

exec $GCC_COMMAND $GCCFLAGS $*
