#!/bin/sh
echo "OS type detected: "`uname`
case `uname` in
	"SunOS") if [  -d /proc ]; then
			SO_EXT=so
			X_CFLAGS="-O -KPIC"
			X_LD_FLAGS=-G
		fi
	;;
	"HP-UX")
		SO_EXT=sl
		X_CFLAGS="+z -Aa -D_HPUX_SOURCE"
		X_LD_FLAGS=-b;;
	"IRIX" )
		SO_EXT=so
		X_CFLAGS="-32 -KPIC"
		X_LD_FLAGS="-shared -32";;
	"IRIX64" )
		SO_EXT=so
		X_CFLAGS="-32 -KPIC"
		X_LD_FLAGS="-shared -32";;
	"OSF1" )
		SO_EXT=so
		X_LD_FLAGS="-S -shared";;
        "Darwin" )
                F77=g77
                SO_EXT=so
                X_LD_FLAGS="-bundle /usr/lib/bundle1.o -L/usr/lib -lc"
# The following two lines should be equivalent to the above line
#               LD=libtool
#               X_LD_FLAGS="-dynamic -L/usr/lib -lc -lcc_dynamic"
                X_CFLAGS="-g -Wall -dynamic -DDARWIN";;
	"Linux" )
		SO_EXT=so
	        "LD=g77"
		X_CFLAGS="-O -Wall"
#		X_CFLAGS="-fPIC -g -Wall"
		X_LD_FLAGS="-shared" ;;
	*) echo "This system is not supported" >&2
		exit 1;;
esac

# Always optimize when building with "evilmake"
# Our Makefile's always build with $(SDSS_CFLAGS), so we can use that
# variable to set optimization.
# Comment this out since it seems to fail on an SGI platform...
# SDSS_CFLAGS=-O3

export SO_EXT X_CFLAGS X_LD_FLAGS SDSS_CFLAGS

make "$@"
