Sophie

Sophie

distrib > Mandriva > 2007.0 > i586 > media > contrib-release > by-pkgid > 8079d983ecf371717db799dd75bd56c2 > files > 97

libopenrm1-1.5.2-2mdv2007.0.i586.rpm

#!/bin/sh -f

# $Revision: 1.15 $
# $Name: OpenRM-1-5-2-RC1 $
# $Log: configure,v $
# Revision 1.15  2004/04/09 14:49:47  wes
# Major overhaul to support builds on a wider variety of platforms.
# - Retired the -irixarch=[abi spec] command line argument.
# - Added a -abi=[abi spec] command line argument to aid in user spec of
# arch-specific build parms.
# - Streamlined internal processing to reduce the amount of code to maintain.
#
# Revision 1.14  2004/03/31 15:05:09  wes
# Updates for Darwin/MacOS-X.
#
# Revision 1.13  2004/03/28 01:53:17  wes
# Updated for 1.5.2.
#
# Revision 1.12  2004/01/17 03:16:25  wes
# Changed default version to 1.5.1.
#
# Revision 1.11  2003/05/04 15:57:02  wes
# Fixed syntax error in new usage statement that prevented correct operation.
#
# Revision 1.10  2003/04/13 18:13:07  wes
# Mods for initial Chromium support. Works on Linux platforms only.
#
# Revision 1.9  2003/04/12 21:03:31  wes
# Mods for v1.5.0.
#
# Revision 1.8  2002/09/22 22:58:34  wes
# Updates for v1.4.3 distribution.
#
# Revision 1.7  2002/06/17 00:49:06  wes
# Updated to use rm142 as default version.
#
# Revision 1.6  2001/06/04 01:53:07  wes
# Added warning msg concerning deficiency wrt JPEG.
#
# Revision 1.5  2001/06/03 20:16:41  wes
# Better support for IRIX ABIs, default is -64. Added -jpeg=/dir/to/jpeg-stuff
# command line flag.
#
# Revision 1.4  2000/12/03 23:30:55  wes
# Added -lposix4 to default X11 libs on Solaris.
#
# Revision 1.3  2000/11/17 03:20:48  wes
# Added -lpthread to the default list of X11 libraries. Starting with
# OpenRM 1.3.1, this library is needed for semaphores and thread ops.
#
# Revision 1.2  2000/08/31 02:15:59  wes
# Linux platforms: it is now assumed that OpenGL includes are located
# in /usr/include (like SGIs), and libraries in /usr/lib (also like SGIs).
#
# Revision 1.1.1.1  2000/02/28 21:55:30  wes
# OpenRM 1.2 Release
#
# Revision 1.3  2000/02/28 17:21:54  wes
# RM 1.2, pre-OpenRM
#
# Revision 1.2  1999/12/09 16:32:44  wes
# Architecture specific flags added to support the various IRIX species.
#
# Revision 1.1  1999/11/21 17:35:49  wes
# Initial entry.
#

#
# usage: configure [-opengl=/opengl/home/dir] [-rm=/rm/home/dir] [-x11=/x11/home/dir] [-opt=flag (eg: -g, -O2, etc.)] [-jpeg=/dir/to/jpeg-stuff] [-cr=/dir/to/chromium] [-abi=[irix6-o32|irix6-n32-mips3|irix6-n32-mips4|irix6-64|x86_64|x86_32]]
#

#
# the purpose of this script is to generate a file included by
# a Makefile in the rmdemo distribution. the included file contains
# definitions that locate several components needed to build
# the demos. these components include:
#
# 1. RM Scene Graph: the location of the RM Scene Graph distribution
#    (includes & libs), compile-time flags
# 2. OpenGL: where does OpenGL live? 
# 3. X11: Where is X11?
# 4. Compiler information: optimization and arch specific flags
# 5. Location of libjpeg and JPEG header files on your system. We assume that
#    if you have to specify a location for the JPEG hdrs and libs, that 
#    you've downloaded the jpeg-6b src distribution, and that the hdrs
#    and libs live in the same directory.
# 6. (Optional - location of Chromium on your machine)
#

#
# names of the files modified by this script:
#
MakeIncFName="makeinclude"
MakeIncFNameBackup="makeinclude.bak"


RMHOME=""
OPENGLHOME=""
X11HOME=""
JPEGHOME=""
CRHOME=""

#
# internally-used variables
#
OSversion=""

#
# RM stuff
#
# the following are the default values used for RM Scene Graph.
# stuff prefixed with "const" is what the developer should change
# or add to if different libararies are needed.
#
constRMLibs="-lrm -lrmaux -lrmv -lrmi"
constRMCFlags="-DRM_X"

# the default values that will be written to the makeinclude
# file unless overridden by command line args to this script
RMHome=""
RMLibs=""
RMCFlags=""

#
# OpenGL stuff
#
#
# the following are the default values used for OpenGL
# stuff prefixed with "const" is what the developer should change
# or add to if different libararies are needed.
#
constOpenGLLibs="-lGL -lGLU"
constOpenGLCFlags=""

# the default values that will be written to the makeinclude
# file unless overridden by command line args to this script
OpenGLHome=""
OpenGLLibs=""
OpenGLCFlags=""

#
# X Stuff
#
constX11Libs="-lX11 -lpthread -lm"
constX11CFlags=""
X11Home=""
X11Include=""
X11Libs=""

constX11LinuxLibs="-lXmu"

#
# Compile flags
#
# default optimization flag is -g. this default value may be 
# overridden by a command line argument.

constOptFlag="-g"
compileOptFlag=""

#
# ABI stuff. used to hold arch-specific compile/link flags.
#
abiFlags=""
archCompileLinkFlags=""

#
# JPEG stuff
#
JPEGLibs=""
JPEGInc=""

#
# Chromium stuff
#
constCRLibs="-lcrfaker -lcrutil -lcrmothership -lspuload"
CRHome=""


#
# support subroutines
#

print_error()
{
    echo " $*" 2>&1;
    echo usage: configure options 
    echo "     Where options are as follows: "
    echo "     [-opengl=/opengl/home/dir] "
    echo "     [-rm=/rm/home/dir]"
    echo "     [-x11=/x11/home/dir] "
    echo "     [-abi=[irix6-o32 | irix6-n32-mips3 | irix6-n32-mips4 | irix6-64 | linux-x86_64 | linux-x86_32 ]] "
    echo "     [-opt=flag (eg: -g, -O2, etc.)] "
    echo "     [-jpeg=/dir/to/jpeg-stuff] "
    echo "     [-cr=/dir/to/Chromium] (note - regarding Chromium, this config file works correctly ONLY on Linux platforms. On other platforms, you MUST edit makeinclude to update the path to the Chromium library directory. Sorry.) "
}

doPreamble()
{
    echo "# " >> $MakeIncFName
    echo "# autogenerated by configure" >> $MakeIncFName
    echo "# on `date`" >> $MakeIncFName
    echo "# " >> $MakeIncFName
}

doChromium()
{
# input parms:
# $1 - $CRHOME
# want $2 = arch, for now, assume Linux
    echo configuring for Chromium..
    CRHome=`echo $1`
    CRLibs=`echo -L$1/lib/Linux $constCRLibs`
    CRInc=`echo -I$1/include`
# remove -lGL, it is provided by Chromium
    constOpenGLLibs=`echo -lGLU`
}

doOpenGL()
{
    case $1 in

    Linux )
    {
	if [ "$OPENGLHOME" = "" ] ; then
	    OPENGLHOME=/usr
	fi

	case $2 in
	    *x86_64 )
		oglLibDir=`echo $OPENGLHOME`/lib64
		;;

	    * )
		oglLibDir=`echo $OPENGLHOME`/lib
		;;
	esac
    }
    ;;

    Darwin )
    {
	if [ "$OPENGLHOME" = ""  ] ; then
	    OPENGLHOME=/usr/X11R6
	fi
	oglLibDir=`echo $OPENGLHOME`/lib
    }
    ;;

    SunOS )
    {
	if [ "$OPENGLHOME" = "" ] ; then
	    OPENGLHOME=/usr/openwin
	fi
	oglLibDir=`echo $OPENGLHOME`/lib
    }
    ;;


    IRIX* )
    {
	if [ "$OPENGLHOME" = "" ] ; then
	    OPENGLHOME=/usr
	fi
	case $2 in
	    *-o32 )
		oglLibDir=`echo $OPENGLHOME`/lib
		;;

	    *-n32* )
		oglLibDir=`echo $OPENGLHOME`/lib32
		;;

	    * )
		oglLibDir=`echo $OPENGLHOME`/lib64
		;;
	esac
    }
    ;;

    *)
      ;;

    esac

    echo configuring for OpenGL..
    OpenGLHome=`echo $OPENGLHOME`
    OpenGLLibs=`echo -L$oglLibDir $constOpenGLLibs`
    OpenGLCFlags=`echo $constOpenGLCFlags -I$OPENGLHOME/include`
}

doRM()
{
#
# configure for RM.
# no input parms.
# globals: $RMHOME
#

#    if  [ ! $RMHOME ]  ; then
# $RMHOME not defined, assign a default value

    if [ "$RMHOME" = "" ] ; then
	RMHOME="/usr/local/rm152"
    fi

    echo configuring for RM..
    RMHome=`echo $RMHOME`
    RMLibs=`echo -L$RMHOME/lib $constRMLibs`
    RMCFlags=`echo $constRMCFlags -I$RMHOME/include`
}

doX11 ()
{
# set the default values for all the X11 stuff
# input:
# 1. OSversion : uname -s
# 2. abiFlags
# globals: $X11HOME
#

    case $1 in

    Linux )
    {
	if [ "$X11HOME" = "" ] ; then
	    X11HOME=/usr/X11R6 
	fi

	case $2 in
	    *x86_64 )
		x11LibDir=`echo $X11HOME`/lib64
		;;

	    * )
		x11LibDir=`echo $X11HOME`/lib
		;;
	esac
        archX11Libs="-lXmu"
    }
    ;;

    Darwin )
    {
	if [ "$X11HOME" = "" ] ; then
	    X11HOME=/usr/X11R6
	fi
	x11LibDir=`echo $X11HOME`/lib
	archX11Libs="-lXmu"
    }
    ;;

    SunOS )
    {
	if [ "$X11HOME" = "" ] ; then
	    X11HOME=/usr/openwin
	fi
	archX11Libs="-lposix4"
    }
    ;;


    IRIX* )
    {
	if [ "$X11HOME" = "" ] ; then
	    X11HOME=/usr
	fi
	case $2 in
	    *-o32 )
		x11LibDir=`echo $X11HOME`/lib
		;;

	    *-n32* )
		x11LibDir=`echo $X11HOME`/lib32
		;;

	    * )
		x11LibDir=`echo $X11HOME`/lib64
		;;
	esac
    }
    ;;

    *)
      ;;

    esac

    echo configuring for X11..
    X11Home=`echo $X11HOME`
    X11Libs=`echo -L$x11LibDir $archX11Libs $constX11Libs`
    X11CFlags=`echo $constX11CFlags -I$X11HOME/include`
}

doOpenGLDefaults ()
{
    case $1 in

    Linux )
    OPENGLHOME=/usr
    ;;

    Darwin )
    OPENGLHOME=/usr/X11R6
    ;;

    SunOS )
    OPENGLHOME=/usr/openwin
    ;;

    IRIX* )
    OPENGLHOME=/usr
    ;;

    *)
      ;;

    esac
}


doCompileOpt ()
{
    if [ "$USEROPT" == "" ]; then
	compileOptFlag=$1
    else
	compileOptFlag=$USEROPT
    fi
}


doJPEG ()
{
# input: 
# 1. OSversion : uname -s
# 2. abiFlags

# assume that if JPEGHOME is defined, that the user has built and
# installed the jpeg6 library into $JPEGHOME such that it has
# a directory structure containing $JPEGHOME/include and $JPEGHOME/lib
#
# otherwise, if no JPEGHOME is defined, then we assume /usr/lib and
# /usr/include are the normal places containing the libs.

    if [ "$JPEGHOME" = "" ] ; then

# if we're here, then no $JPEGHOME is defined, and we'll use default
# values. In some cases, we will bark at the user for not setting
# JPEGHOME for arch's where we know there is no default jpeg library.

	case $1 in
	    Linux )
            {
		JPEGInc="-I/usr/include" 
		case $2 in
		    *x86_64 )
			JPEGLibs="-L/usr/lib64 -ljpeg"
			;;
		    * )
			JPEGLibs="-L/usr/lib -ljpeg"
			;;
		esac
	    }
	    ;;

	    IRIX* )
            {
		JPEGInc="-I/usr/include" 
		case $2 in
		    *o32 )
			JPEGLibs="-L/usr/lib -ljpeg"
			;;
		    *n32* )
			JPEGLibs="-L/usr/lib32 -ljpeg"
			;;
		    * )
			JPEGLibs="-L/usr/lib64 -ljpeg"
			;;
		esac
	    }
	    ;;

	    * )
		echo ""
		echo " JPEG warning: you are running this script on a platform known to "
		echo " not supply the jpeg libraries. Since I'm not sure what to do,  "
		echo " no JPEG support will be configured into the makeinclude file."
		echo ""
		;;

	esac
    else
# JPEGHOME is defined
	JPEGinc="-I$JPEGINC/include"
	JPEGlibs="-L$JPEGHOME/lib -ljpeg"
	echo "Warning: you will probably have to edit the makeinclude file by hand in order to resolve deficiencies in this script wrt JPEG hdrs and libs. Sorry."
    fi
}

validateABIFlags ()
{
#
# check that the input parameter is one of the supported ABI flags. if
# not, issue an error message and exit.
#
    case $1 in
	linux-x86_64 )
	    ;;
        linux-x86_32 )
	    ;;
	irix6-o32 )
	    ;;
	irix6-n32-mips3 )
	    ;;
	irix6-n32-mips4 )
	    ;;
	irix6-64 )
	    ;;
 
        * )
	echo "bogus value of " $abiFlags " for the -abi= argument. Bye!"
	exit 1;
    esac
}

doABIDefaults ()
{
# input:
# 1. OSversion : uname -s
# 2. CPU type: uname -p
# globals: $USERABIFLAGS
#
#

# first, test if the user has requested a specific set abi. If so, attempt
# honor it.

    if [ $USERABIFLAGS ] ; then
#	echo "user has defined ABI flags, they are" $USERABIFLAGS
	abiFlags=$USERABIFLAGS
	validateABIFlags $abiFlags
    else

      case $1 in

	  IRIX64 )
#default on IRIX platforms is 64-bit
	      abiFlags="irix6-64"
	      ;;

	  Linux )
	  {
# only set the -64 flag on opterons (don't have access to any
# IA64 boxes to test at this time)
	      case $2 in
		  x86_64 )
		      abiFlags="linux-x86_64"
		      ;;
#		    
	      esac
	  }
	  ;;

# nothing to do on SunOS.
#	SunOS )
#	    ;;

# nothing to do on Darwin.
#	Darwin )
#	    ;;
    esac

    fi
}

doArchFlags ()
{
#
# set the compile flags needed for the arch specified in $abiFlags
#
# input: 
# $1 : OSname: uname -s
# $2 : $abiFlags
#
# to set: $archCompileLinkFlags
#

    case $1 in

    Linux )
    {
	case $2 in
	    *x86_64 )
		archCompileLinkFlags="-m64"
		;;

	    * )
		archCompileLinkFlags="-m32"
		;;
	esac
    }
    ;;

# finish tuning from here down..got sidetracked 

    Darwin )
# no special flags needed for Darwin
    ;;

    SunOS )
# no special flags needed for SunOS
    ;;


    IRIX* )
    {
	case $2 in
	    *-o32 )
		archCompileLinkFlags="-32"
		;;

	    *-n32-mips3 )
		archCompileLinkFlags="-n32 -mips3"
		;;

	    *-n32-mips4 )
		archCompileLinkFlags="-n32 -mips4"
		;;

	    * )
		archCompileLinkFlags="-64"
		;;
	esac
    }
    ;;

    *)
      ;;

    esac

    echo configuring arch-specific compile and link flags...
}


#############################
#
# main
#
#############################

# set the OSversion
OSversion=`uname -s`
CPU=`uname -p`

# process the command line args

for arg do
    case $arg in

    -opengl=* )
# strip off any -foo= stuff before the real args
    OPENGLHOME=`echo $arg | sed 's/[-a-z]*=//'` 
    ;;

    -rm=* )
# strip off any -foo= stuff before the real args
    RMHOME=`echo $arg | sed 's/[-a-z]*=//'` 
    ;;

    -x11=* )
# strip off any -foo= stuff before the real args
    X11HOME=`echo $arg | sed 's/[-a-z,0-9]*=//'` 
    ;;

    -opt=* )
# strip off any -foo= stuff before the real args
    USEROPT=`echo $arg | sed 's/[-a-z,0-9]*=//'` 
    ;;

#    -irixarch=* )
# strip off any -foo= stuff before the real args
#    IRIXARCH=`echo $arg | sed 's/[-a-z,0-9]*=//'` 
#    ;;
    -abi=* )
     USERABIFLAGS=`echo $arg | sed 's/[-a-z,0-9]*=//'` 
     ;;

    -jpeg=* )
# strip off any -foo= stuff before the real args
    JPEGHOME=`echo $arg | sed 's/[-a-z,0-9]*=//'` 
    ;;

    -cr=* )
# strip off any -foo= stuff before the real args
    CRHOME=`echo $arg | sed 's/[-a-z]*=//'` 
    ;;

    *)
    print_error "unrecognized config option $arg"
    exit 1
    ;;

    esac

done

#
# check to see if the incfile exists, move it to .bak if so
#
if test -r $MakeIncFName ; then
    cp $MakeIncFName $MakeIncFNameBackup
    rm $MakeIncFName
fi

touch  $MakeIncFName


doABIDefaults $OSversion $CPU

doRM
doX11 $OSversion $abiFlags
doOpenGL $OSversion $abiFlags
doJPEG $OSversion $abiFlags
doCompileOpt $constOptFlag
doArchFlags $OSversion $abiFlags


#
# each of the following routines is invoked to set 
# flags and settings stored in a file included into a Makefile.
# in the list below, only those items specified on the command line will
# invoke a subroutine to override the defaults established earlier in
# the script.
#

if [ $CRHOME ] ; then
    doChromium $CRHOME
fi

#
# now dump the variables into the makeinclude file
#

doPreamble

echo RMHOME=$RMHome >> $MakeIncFName
echo RMLIBS=$RMLibs >> $MakeIncFName
echo RMCFLAGS=$RMCFlags >> $MakeIncFName
echo "#  " >> $MakeIncFName

echo OPENGLHOME=$OpenGLHome >> $MakeIncFName
echo OPENGLLIBS=$OpenGLLibs >> $MakeIncFName
echo OPENGLCFLAGS=$OpenGLCFlags >> $MakeIncFName
echo "#  " >> $MakeIncFName

echo X11HOME=$X11Home >> $MakeIncFName
echo X11LIBS=$X11Libs >> $MakeIncFName
echo X11CFLAGS=$X11CFlags >> $MakeIncFName
echo "#  " >> $MakeIncFName

echo OPTFLAGS=$compileOptFlag >> $MakeIncFName
echo ARCHFLAGS=$archCompileLinkFlags >> $MakeIncFName
echo "#  " >> $MakeIncFName

echo "# Location of JPEG stuff on your machine " >> $MakeIncFName
echo JPEGLIB=$JPEGLibs >> $MakeIncFName
echo JPEGINC=$JPEGInc >> $MakeIncFName

if test -n "`echo $CRHOME`" ; then
    echo "# Location of Chromium on your machine " >> $MakeIncFName
    echo CRHOME=$CRHOME >> $MakeIncFName
    echo CRLIBS=$CRLibs >> $MakeIncFName
    echo CRINC=$CRInc >> $MakeIncFName
fi
echo "all done, created a new $MakeIncFName"

#############################
#
# end main
#
#############################