All pastes #194043 Raw Edit

Stuff

public shellscript v1 · immutable
·published 2006-10-07 13:54 UTC
rendered paste body
#!/bin/shECH=0DEBUG=0TDM=0TDMPATH=""MESAPATH=""MESADEFAULT=1XLIBPATH="/usr/X11R6/lib"TR=0TRINCL=""TRLIBS=""DLLIBS=""VRML97COMP=0VVCOMP=0PNG=0PNGINCL=""PNGLIBS=""GTK=0IRISGL=0D3D=0D3DINCL=""QT=0if [ $ECH = "1" ] ; then echo; echo Processing options; echo Options are `echo $* | sed 's/--/:/g'` ; fiIFS=:for i in `echo $* --fin | sed 's/--/:/g'`do     if [ "$i" != "" ] ; then     if [ $ECH = "1" ] ; then echo; echo Processing option $i ; fi    case $i in    "fin")	;;    "debug ")	if [ $ECH = "1" ] ; then echo Debug option detected ; fi	DEBUG=1;	;;    TDMLIBS*)	if [ $ECH = "1" ] ; then echo TDM library path detected ; fi	echo TDMLIBS option no longer applicable, use TDMPATH	exit	;;    TDMINCL*)	if [ $ECH = "1" ] ; then echo TDM include path detected ; fi	echo TDMINCL option no longer applicable, use TDMPATH	exit	;;    TDMPATH*)	if [ $ECH = "1" ] ; then echo TDM path detected ; fi	TDM=1	TDMPATH=`echo $i | cut -f2 -d"=" | awk '{print substr($0, 1, length-1)}'`	if [ $ECH = "1" ] ; then echo TDMPATH path set to "["TDMPATH"]" ; fi	;;    TRLIBS*)	if [ $ECH = "1" ] ; then echo TR library path detected ; fi	TR=1	TRLIBS=`echo $i | cut -f2 -d"=" | awk '{print substr($0, 1, length-1)}'`	if [ $ECH = "1" ] ; then echo TR library path set to "["$TRLIBS"]" ; fi	;;    TRINCL*)	if [ $ECH = "1" ] ; then echo TR include path detected ; fi	TR=1	TRINCL=`echo $i | cut -f2 -d"=" | awk '{print substr($0, 1, length-1)}'`	if [ $ECH = "1" ] ; then echo TR include path set to "["$TRINCL"]" ; fi	;;    MESAPATH*)	if [ $ECH = "1" ] ; then echo Mesa path detected ; fi	MESADEFAULT=0	MESAPATH=`echo $i | cut -f2 -d"=" | awk '{print substr($0, 1, length-1)}'`	if [ $ECH = "1" ] ; then echo Mesa path set to "["$MESAPATH"]" ; fi	echo Ensure location of Mesa library is present in your LD_LIBRARY_PATH	;;    XLIBPATH*)	if [ $ECH = "1" ] ; then echo X library path detected ; fi	XLIBPATH=`echo $i | cut -f2 -d"=" | awk '{print substr($0, 1, length-1)}'`	if [ $ECH = "1" ] ; then echo X library path set to "["$XLIBPATH"]" ; fi	;;    "VRML97 ")	if [ $ECH = "1" ] ; then echo VRML97 option detected ; fi	VRML97COMP=1	;;    "VV ")	if [ $ECH = "1" ] ; then echo ViaVoice option detected ; fi	VVCOMP=1	;;    "IrisGL ")	if [ $ECH = "1" ] ; then echo IrisGL option detected ; fi	IRISGL=1	;;     "QT ")	if [ $ECH = "1" ] ; then echo Qt option detected ; fi	QT=1	if [ ! -e ${QTDIR}/include/qt.h ] ; then	    echo Cant find Qt include file [${QTDIR}/include/qt.h] - QTDIR environment variable correctly set?	    exit 1	fi	;;    "GTK ")	if [ $ECH = "1" ] ; then echo GTK+ option detected ; fi	GTK=1	;;    "D3D ")	if [ $ECH = "1" ] ; then echo D3D option detected ; fi	D3D=1	;;    D3DINCL*)	if [ $ECH = "1" ] ; then echo D3D include path detected ; fi	D3D=1	D3DINCL=`echo $i | cut -f2 -d"=" | awk '{print substr($0, 1, length-1)}'`	if [ $ECH = "1" ] ; then echo D3D include path set to "["$D3DINCL"]" ; fi	;;     PNGLIBS*)       if [ $ECH = "1" ] ; then echo PNG library path detected ; fi       PNG=1       PNGLIBS=`echo $i | cut -f2 -d"=" | awk '{print substr($0, 1, length-1)}'`       if [ $ECH = "1" ] ; then echo PNG library path set to "["$PNGLIBS"]" ; fi       ;;      PNGINCL*)       if [ $ECH = "1" ] ; then echo PNG include path detected ; fi       PNG=1       PNGINCL=`echo $i | cut -f2 -d"=" | awk '{print substr($0, 1, length-1)}'`       if [ $ECH = "1" ] ; then echo PNG include path set to "["$PNGINCL"]" ; fi       ;;    "help ")	echo "Usage $0 [options]"	echo "Where options are:"	echo "  --debug"	echo "  --TDMPATH=<path> (e.g. /usr/local/TDM-2.1)"	echo "  --MESAPATH=<path> (e.g. /usr/local/Mesa)"	echo "  --XLIBPATH=<path> (e.g. /usr/X11R6/lib)"	echo "  --TRINCL=<include command> (e.g. -I/usr/local/tr-1.1)"	echo "  --TRLIBS=<link command> (e.g. -L/usr/local/tr-1.1 -ltr)"	echo "  --VRML97 (requires a C++ compiler, flex and bison)"	echo "  --VV (requires ViaVoice SDK)"	echo "  --GTK"	echo "  --QT"	echo "  --IrisGL"	echo "  --D3D"	echo "  --D3DINCL=<include command> (e.g. -I/usr/local/include)"	echo "  --PNGINCL=<include command> (e.g. -I/usr/include)"	echo "  --PNGLIBS=<link command> (e.g. -L/usr/lib -lpng)"	echo "     (PNG support requires png and zlib libraries)"	exit 1	;;    *)	echo Unknown option $i	echo Try $0 --help	exit 1	;;    esac    fidoneif [ $ECH = "1" ] ; then echo ; echo Determining machine, ABI etc... ; ficase `uname -s` inIRIX|IRIX64)    if [ $ECH = "1" ] ; then echo An SGI box ... ; fi    PRO=`hinv | grep CPU | awk '{print $3}'`    if [ $ECH = "1" ] ; then echo With a $PRO processor ... ; fi    case `uname -r` in    6*)	if [ $ECH = "1" ] ; then echo Running Irix 6.x ... ; fi	OS="-DMAV_IRIX6"	if [ "`uname -s`" = "IRIX" ] ; then		    if [ $ECH = "1" ] ; then echo Using n32 ABI ... ; fi	    ABI="-n32"	else	    if [ $ECH = "1" ] ; then echo Using n32 ABI ... ; fi	    ABI="-n32" 	fi	if [ $PRO = "R10000" ] ; then MIPS="-mips4 -r10000" ; fi	CXXFLAG=`echo -woff 1681,1682,1110`	;;    5*)	if [ $ECH = "1" ] ; then echo Running Irix 5.x ... ; fi	OS="-DMAV_IRIX5"	CXXFLAG=`echo -woff 3262,3203`       	;;    *)       	echo Dont know how to configure Irix `uname -r`, exiting	exit 1       	;;    esac    CC="cc"    if [ "$DEBUG" = "1" ] ; then 	OT="-g"	CXXFLAG=`echo -g ${CXXFLAG}`    else	OT="-O2"    fi    CFLAG=`echo $OS $ABI $MIPS $OT`    LD=`echo ld $ABI -shared`    LEX="flex"    YACC="bison -y"    CXX="CC"    CXXFLAG=`echo $OS $ABI $MIPS ${CXXFLAG}`    OPENGLLIBS="-lGL -lGLU"    ;;Linux|linux-gnu)    if [ $ECH = "1" ] ; then echo A Linux box...; fi    CC="gcc"    DLLIBS="-ldl"    if [ "$DEBUG" = "1" ] ; then 	OT="-Wall -ansi -g"    else	OT="-Wall -ansi -O2 -finline-functions -fomit-frame-pointer -funroll-loops -ffast-math -march=`uname -m`"    fi    if [ "`grep Alpha /proc/cpuinfo | awk '{print $3}'`" = "Alpha" ] ; then	OT=`echo $OT -mieee`    fi    OS="-DMAV_LINUX"    CFLAG=`echo $OS $OT`    LD="ld -shared"    LEX="flex"    YACC="bison -y"    CXX="g++"    CXXFLAG=`echo $OS $OT`    if [ "$MESADEFAULT" = "1" ] ; then	MESAPATH="/usr"    fi    OPENGLINCL="-I${MESAPATH}/include"    OPENGLLIBS="-L${MESAPATH}/lib -lGL -lGLU -L${XLIBPATH} -lX11 -lXext"    if [ $ECH = "1" ] ; then echo Looking for OpenGL include file in ${MESAPATH}/include/GL/gl.h ; fi    if [ ! -e ${MESAPATH}/include/GL/gl.h ] ; then	echo Cant find OpenGL include file [${MESAPATH}/include/GL/gl.h]	exit 1    fi    ;;FreeBSD)    if [ $ECH = "1" ] ; then echo A FreeBSD box...; fi    CC="gcc"    DLLIBS=""    if [ "$DEBUG" = "1" ] ; then         OT="-Wall -ansi -g"    else        OT="-Wall -ansi -O2 -finline-functions -fomit-frame-pointer -funroll-loops -ffast-math -march=`uname -m`"    fi    OS="-DMAV_LINUX -DMAV_FREEBSD" # The Linux defs also work for FreeBSD with a few exceptions    CFLAG=`echo $OS $OT`    LD="ld -shared"    LEX="flex"    YACC="bison -y"    CXX="g++"    CXXFLAG=`echo $OS $OT`    if [ "$MESADEFAULT" = "1" ] ; then	MESAPATH="/usr/X11R6"    fi    OPENGLINCL="-I${MESAPATH}/include"    OPENGLLIBS="-L${MESAPATH}/lib -lGL -lGLU -L${XLIBPATH} -lX11 -lXext"    if [ $ECH = "1" ] ; then echo Looking for OpenGL include file in ${MESAPATH}/include/GL/gl.h ; fi    if [ ! -e ${MESAPATH}/include/GL/gl.h ] ; then        echo Cant find OpenGL include file [${MESAPATH}/include/GL/gl.h]        exit 1    fi    ;;SunOS)    if [ $ECH = "1" ] ; then echo A SunOS box...; fi    case `uname -r` in    5*)	if [ $ECH = "1" ] ; then echo Running SunOS 5.x ... ; fi	CC="cc"	if [ "$DEBUG" = "1" ] ; then	    OT="-g"	else	    OT="-O"	fi	OS="-DMAV_SUNOS5"	CFLAG=`echo $OS $OT`	LD="ld -G"	LEX="flex"	YACC="bison -y"	CXX="CC"	CXXFLAG=`echo $OS $OT`	OPENGLINCL="-I/usr/openwin/include"	OPENGLLIBS="-L/usr/openwin/lib -lGL -lGLU -lX11 -lXext"	;;    *)       	echo Dont know how to configure SunOS `uname -r`, exiting	exit 1	;;    esac    ;;CYGWIN*)    if [ $ECH = "1" ] ; then echo A Windows box with Cygwin...; fi    CC="gcc"    if [ "$DEBUG" = "1" ] ; then 	OT="-Wall -g"    else	OT="-Wall -O2 -finline-functions -fomit-frame-pointer -funroll-loops"    fi    OS="-DMAV_CYGWIN -DWIN32"    CFLAG=`echo $OS $OT`    LEX="flex"    YACC="bison -y"    CXX="g++"    CXXFLAG=`echo $OS`    if [ -f .cygwin.tar.gz ] ; then tar zxf .cygwin.tar.gz ; /bin/rm -f .cygwin.tar.gz ; fi    cd demos    if [ -f .cygwin.tar.gz ] ; then tar zxf .cygwin.tar.gz ; /bin/rm -f .cygwin.tar.gz ; fi    cd ..    if [ -d src/extras/beta ] ; then	cd src/extras/beta	if [ -f .cygwin.tar.gz ] ; then tar zxf .cygwin.tar.gz ; /bin/rm -f .cygwin.tar.gz ; fi	cd ../../..    fi    ;;*)    echo Dont know about `uname -s`, exiting    exit 1    ;;esaccat << EOF >Makefileall:    platlibs:	cd src; makeegs:	cd examples; makedems:	cd demos; makeclean:	cd src; make clean	cd examples; make clean	cd demos; make cleanplat:	make libs \\	"CC= ${CC}" \\	"CFLAG= ${CFLAG}" \\	"LD= ${LD}" \\	"DLLIBS= ${DLLIBS}" \\	"LEX= ${LEX}" \\	"YACC= ${YACC}" \\	"CXX= ${CXX}" \\	"CXXFLAG= ${CXXFLAG}" \\	"VRML97COMP= ${VRML97COMP}" \\	"VVCOMP= ${VVCOMP}" \\EOFif [ $TDM = "1" ] ; thencat <<EOF >>Makefile	"TDMINCL= -DMAV_TDM -I${TDMPATH}/incl" \\EOFfiif [ $TR = "1" ] ; thencat <<EOF >>Makefile	"TRINCL= -DMAV_TR ${TRINCL}" \\	"TRLIBS= ${TRLIBS}" \\EOFfiif [ $GTK = "1" ] ; thencat <<EOF >>Makefile	"GTKLIB= ../../lib/libmav_gfxOpenGLGTK${OPT_EXT}.so" \\	"GTKINCL= \`gtk-config --cflags\`" \\	"GTKLIBS= \`gtk-config --libs | sed 's/-rdynamic//g'\` -lgtkgl" \\EOFfiif [ $QT = "1" ] ; thencat <<EOF >>Makefile	"QTLIB= ../../lib/libmav_gfxOpenGLQt${OPT_EXT}.so" \\	"QTINCL= -I${QTDIR}/include" \\	"QTLIBS= -L${QTDIR}/lib -lqt" \\EOFfiif [ $IRISGL = "1" ] ; thencat <<EOF >>Makefile	"IRISGLLIB= ../../lib/libmav_gfxIrisGLX11${OPT_EXT}.so" \\	"IRISGLINCL= " \\	"IRISGLLIBS= -lgl" \\EOFfiif [ $D3D = "1" ] ; thencat <<EOF >>Makefile	"D3DLIB= ../../lib/libmav_gfxDirect3D${OPT_EXT}.a" \\	"D3DINCL= ${D3DINCL}" \\EOFfiif [ $PNG = "1" ] ; thencat <<EOF >>Makefile	"PNGINCL= -DMAV_PNG ${PNGINCL}" \\	"PNGLIBS= ${PNGLIBS}" \\EOFficat <<EOF >>Makefile	"OPENGLINCL= ${OPENGLINCL}" \\	"OPENGLLIBS= ${OPENGLLIBS}"EOFcat <<EOF >>Makefile	make egs \\	MAV_HOME=\`pwd\` \\	"CC= ${CC} ${ABI} ${MIPS} ${OT}" \\	"CXX= ${CXX} ${ABI} ${MIPS} ${OT}" 	make dems \\	MAV_HOME=\`pwd\` \\	"CC= ${CC} ${ABI} ${MIPS} ${OT}" \\	"OPENGLINCL= ${OPENGLINCL}" \\	"OPENGLLIBS= ${OPENGLLIBS}"EOF