#!/bin/sh

# g++      ver. 2.8.1
# egcs g++ ver. 1.1.2
# g++      ver. 2.95.3
GXX_COMMAND=${GXX:-g++}

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

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


#
# -pedantic option
#
if [ X`uname` = X'Linux' ]; then
	gxx_pedantic_option=''
else
	gxx_pedantic_option='-pedantic'
fi

if [ -z `${GXX_COMMAND} --version | grep '^2\.96[^0-9]*'` ]; then
	GXXFLAGS="${gxx_ansi_option} \
		  ${gxx_pedantic_option} \
		  -Wall \
		  -W \
		  -Wundef \
		  -Wid-clash-31 \
		  -Wpointer-arith \
		  -Wcast-qual \
		  -Wwrite-strings \
		  -Wconversion \
		  -Wsign-compare \
		  -Wmissing-prototypes \
		  -Wmissing-declarations \
		  -Wnested-externs \
		  -Woverloaded-virtual \
		  -Wsign-promo \
		 "
else
	# ver. 2.96
	GXXFLAGS="${gxx_ansi_option} \
		  ${gxx_pedantic_option} \
		  -Wall \
		  -W \
		  -Wid-clash-31 \
		  -Wpointer-arith \
		  -Wcast-qual \
		  -Wwrite-strings \
		  -Wconversion \
		  -Wsign-compare \
		  -Wmissing-prototypes \
		  -Woverloaded-virtual \
		  -Wsign-promo \
		 "
fi

#	  -Wcast-align \

#	  -Wshadow \
#	  -Wredundant-decls \
#	  -fhonor-std \

#	  -Weffc++ \
#	  -Wold-style-cast \

# ver. 2.95
#	  -Wmissing-noreturn \

exec $GXX_COMMAND $GXXFLAGS $*
