Documentos de Académico
Documentos de Profesional
Documentos de Cultura
/bin/sh
# ******************************************************************************
# ******************************************************************************
# sysname
#
# Script to print a string describing the type of operating system being run.
# The string can currently be one of the following:
# sunos_57
# sunos_58
# sunos_510_stl4
# sunos_510_x86
# sunos_510_x86_stl4
# hpux_10
# hpux_11
# aix_41
# aix_43
# aix_51
# aix_53
# linux_rhel40_gcc44x
# win32
#
# A user may set the variable OA_UNSUPPORTED_PLAT to force the name of an
# unsupported platform to work. Specifically for Linux, if the type of
# Linux system is not recognized, the OA_UNSUPPORTED_PLAT variable is
# examined and used if set.
#
# ******************************************************************************
# Except as specified in the OpenAccess terms of use of Cadence or Silicon
# Integration Initiative, this material may not be copied, modified,
# re-published, uploaded, executed, or distributed in any way, in any medium,
# in whole or in part, without prior written permission from Cadence.
#
#
#
# $Author: icftcm $
# $Revision: #3 $
# $Date: 2012/07/09 $
# $State: Exp $
# *****************************************************************************
# *****************************************************************************
usage() {
echo "Usage: sysname [ -h | -m | -b | -v ]"
}
# *****************************************************************************
# check_sunos
#
# This routine sets the version, sysname, and sysnames variables for the
# Solaris operating system.
#
#
# *****************************************************************************
check_sunos() {
sysnames="sunos$compiler"
_rev=`/bin/uname -r`
longVersion="SunOS $_rev"
case $_rev in
5.7* )
sysname="sunos_57$compiler"; sysnames="$sysname $sysnames"
version=57
;;
5.8* | 5.9* )
sysname="sunos_58$compiler"; sysnames="$sysname sunos_57$compiler
$sysnames"
version=58
;;
5.10* )
cpuarch=`uname -m`
*)
check_global
esac
}
# *****************************************************************************
# check_hpux
#
# This routine sets the version, sysname, and sysnames variables for the
# HP-UX operating system.
#
#
# *****************************************************************************
check_hpux() {
sysnames="hpux$compiler"
_rev=`/bin/uname -r`
longVersion="HP-UX $_rev"
case $_rev in
*.10.* )
sysname="hpux_10$compiler"; sysnames="$sysname $sysnames"
version=10
;;
*.11.* )
sysname="hpux_11$compiler"; sysnames="$sysname hpux_10$compiler
$sysnames"
version=11
;;
*)
check_global
esac
}
# *****************************************************************************
# check_aix
#
# This routine sets the version, sysname, and sysnames variables for the
# AIX operating system.
#
#
# *****************************************************************************
check_aix() {
sysnames="aix$compiler"
mainVer=`/bin/uname -v`
subVer=`/bin/uname -r`
version="${mainVer}${subVer}"
longVersion="AIX ${mainVer}.${subVer}"
case $version in
41 )
sysname="aix_41$compiler"; sysnames="$sysname $sysnames";;
43 )
sysname="aix_43$compiler"; sysnames="$sysname aix_41$compiler
$sysnames";;
51 )
sysname="aix_51$compiler"; sysnames="$sysname $sysnames";;
53 )
sysname="aix_53$compiler"; sysnames="$sysname $sysnames";;
61 )
sysname="aix_53$compiler"; sysnames="$sysname $sysnames";;
*)
check_global
esac
}
# *****************************************************************************
# check_linux
#
# This routine sets the version, system, and sysname variables for the Linux
# operating system. If the version of Linux is unrecognized and
# OA_UNSUPPORTED_PLAT is set, then that is returned.
#
# linux-x86
# *****************************************************************************
check_linux() {
sysnames=$sysname
version=`uname -r`
machine=`uname -m`
if [ -f "/etc/redhat-release" ]
then
longVersion=`cat /etc/redhat-release`
elif [ -f "/etc/SuSE-release" ]
then
longVersion=`cat /etc/SuSE-release`
else
longVersion="UNKNOWN Linux"
fi
case $machine in
ia64 ) sysname="linux_rhas21_ia64$compiler"; sysnames="$sysname
$sysnames";;
*86 | *86_64 )
case $version in
2.4*) compiler="_gcc411"
sysname="linux_rhel30$compiler"; sysnames="$sysname
linux$compiler";;
2.6*|3.0*) compiler="_gcc44x"
sysname="linux_rhel40$compiler"; sysnames="$sysname
linux$compiler";;
*)
esac;;
check_global;;
*)
check_global;;
esac
# *****************************************************************************
# check_win
#
# This routine sets the version, system, and sysname variables for the Windows
# operating system.
# *****************************************************************************
check_win() {
_is64=`echo $basesysname | sed -e 's/cygwin_nt-5..-//'`
fi
}
# *****************************************************************************
# check_global
#
# This routine handles the sysname for an unsupported system. If a user
# wants to run on an unsupported system, they must set the environment
# variable OA_UNSUPPORTED_PLAT to the sysname they wish to utilize.
# Otherwise, the script will exit.
# *****************************************************************************
check_global() {
if [ -n "$OA_UNSUPPORTED_PLAT" ]
then
sysname=${OA_UNSUPPORTED_PLAT}
sysnames=$sysname
version="Unknown"
longVersion="Unknown"
else
echo "unknown"
exit 1
fi
}
# ******************************************************************************
# Start of the script
# ******************************************************************************
matching_sysnames=0
base_sysname=0
get_version=0
get_longVersion=0
if [ $# -eq 1 ];
then
case $1 in
-h )
usage; exit 0;;
-m )
matching_sysnames=1;;
-b )
base_sysname=1;;
-v )
get_version=1;;
-V )
get_longVersion=1;;
*)
usage; exit 1
esac
else
if [ -n "$OA_SYSNAME" ]; then
echo $OA_SYSNAME
exit 0
fi
fi
sysname="$sysname$compiler"
# Call the appropriate function to get the sysname. The sysname will embed
# information about the version of the operating system, processor type and
# architecture. It will be returned in the variable $sysname. A list of
# compatible sysnames will also be returned in $sysnames.
case $basesysname in
sunos ) check_sunos;;
hp-ux ) check_hpux;;
aix ) check_aix;;
linux ) check_linux;;
windows*|cygwin_nt* ) check_win;;
* ) check_global;;
esac
# If an error occured, this script already exited with a non-zero error code.
if [ $get_version -eq 1 ];
then
echo $version
exit 0