hypre/tarch
2006-08-02 22:32:43 +00:00

107 lines
3.2 KiB
Bash
Executable File

#! /bin/sh
# set -x
#BHEADER**********************************************************************
# Copyright (c) 2006 The Regents of the University of California.
# Produced at the Lawrence Livermore National Laboratory.
# Written by the HYPRE team <hypre-users@llnl.gov>, UCRL-CODE-222953.
# All rights reserved.
#
# This file is part of HYPRE (see http://www.llnl.gov/CASC/hypre/).
# Please see the COPYRIGHT_and_LICENSE file for the copyright notice,
# disclaimer and the GNU Lesser General Public License.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License (as published by the Free
# Software Foundation) version 2.1 dated February 1999.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the terms and conditions of the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Revision$
#EHEADER**********************************************************************
#
# Returns the architecture of the host machine
#
#
# Try to find location of utility uname
for dir in /bin /usr/bin /usr/local/bin ; do
if [ -x $dir/uname ] ; then
UNAME="$dir/uname"
break
fi
done
#
# Get machine kernal and hardware names values
#
if [ -n "$UNAME" ] ; then
ARCHLIST="`uname -s`"
ARCHLIST="$ARCHLIST `uname -m`"
fi
#
# Get environment variable, ARCH, name if defined
if [ -n "$ARCH" ] ; then
ARCHLIST="$ARCHLIST $ARCH"
fi
#
# Get arch command and execute it to get host machine architecture
if [ -x /bin/arch ] ; then
ARCHLIST="$ARCHLIST `/bin/arch`"
elif [ -x /usr/local/bin/arch ] ; then
ARCHLIST="$ARCHLIST `/usr/local/bin/arch`"
fi
#
# GARCH is a guess for the host machine architecture
# LARCH is current value from list of architectures
# FARCH is the returned value
GARCH=
# search architecture list; removing blanks first
for LARCH in $ARCHLIST ; do
LARCH=`echo $LARCH | sed 's/ //g'`
case $LARCH in
AIX|RIOS|ppc64) FARCH=rs6000; break ;;
HP-UX) FARCH=hpux ; break ;;
IRIX64|IRIX) FARCH=$LARCH ; break ;;
Linux|LINUX) FARCH=LINUX ; break ;;
i586|i486|i86pc)
GARCH=$LARCH ;;
sun4*)
Version=`$UNAME -r`
MajorVersion=`expr "$Version" : "\(.\)"`
if [ "$MajorVersion" -ge 5 ] ; then
FARCH=solaris
else
FARCH=sun4
fi
break ;;
hp9000*|hp7000*) FARCH=hpux ; break ;;
mips|dec-5000) FARCH=dec5000 ; break ;;
IP12|iris-4d) GARCH=IRIX ;;
cray|CRAY*) GARCH=CRAY ;;
KSR1|KSR2) FARCH=ksr ; break ;;
FreeBSD) FARCH=freebsd ; break ;;
i386) GARCH=ipsc2 ;;
ULTRIX|RISC) GARCH=dec5000 ;;
esac
LLARCH=$LARCH
done
#
# Set return value if not already defined
if [ -z "$FARCH" ] ; then
FARCH=$GARCH
if [ -z "$FARCH" ] ; then
FARCH=$LLARCH
fi
if [ -z "$FARCH" ] ; then
FARCH=unknown
fi
fi
echo $FARCH
exit 0