#!/bin/sh
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
# 
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
# 
# The Original Code is the Netscape Mailstone utility, 
# released March 17, 2000.
# 
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999-2000 Netscape Communications Corporation. All
# Rights Reserved.
# 
# Contributor(s):	Dan Christian <robodan@netscape.com>
#			Marcel DePaolis <marcel@netcape.com>
# 
# Alternatively, the contents of this file may be used under the
# terms of the GNU Public License (the "GPL"), in which case the
# provisions of the GPL are applicable instead of those above.
# If you wish to allow use of your version of this file only
# under the terms of the GPL and not to allow others to use your
# version of this file under the NPL, indicate your decision by
# deleting the provisions above and replace them with the notice
# and other provisions required by the GPL.  If you do not delete
# the provisions above, a recipient may use your version of this
# file under either the NPL or the GPL.
#####################################################

# Figure out standard system names

UNAME_REPORTS=`uname`
UNAME_OS_SYSTEM=`uname -s`
UNAME_OS_RELEASE=`uname -r`

OS_SYSTEM=${UNAME_OS_SYSTEM}
OS_RELEASE=${UNAME_OS_RELEASE}
OS_CONFIG=${OS_SYSTEM}${OS_RELEASE}

if [ "$UNAME_OS_SYSTEM" = "SunOS" ]; then
  PROCESSOR=`uname -p`
  if [ "$PROCESSOR" = "i386" ]; then
    BUILD_ARCH=x86
  else
    BUILD_ARCH=sparc
  fi
  BUILD_OS=Solaris
  if [ "$UNAME_OS_RELEASE" = "5.5" ]; then
    BUILD_VER=2.5
  elif [ "$UNAME_OS_RELEASE" = "5.5.1" ]; then
    BUILD_VER=2.5
  elif [ "$UNAME_OS_RELEASE" = "5.6" ]; then
    BUILD_VER=2.6
  elif [ "$UNAME_OS_RELEASE" = "5.7" ]; then
    BUILD_VER=7
  elif [ "$UNAME_OS_RELEASE" = "5.8" ]; then
    BUILD_VER=8
  elif [ "$UNAME_OS_RELEASE" = "5.9" ]; then
    BUILD_VER=9
  fi
  OS_CONFIG=${OS_SYSTEM}${OS_RELEASE}_${BUILD_ARCH}

elif [ "$UNAME_OS_SYSTEM" = "HP-UX" ]; then
  BUILD_ARCH=HPPA
  BUILD_OS=$UNAME_OS_SYSTEM
  BUILD_VER=$OS_RELEASE

elif [ "$UNAME_OS_SYSTEM" = "AIX" ]; then
  BUILD_ARCH=POWER
  BUILD_OS=$UNAME_OS_SYSTEM
  BUILD_VER=`uname -v`.`uname -r`
  OS_CONFIG=${BUILD_OS}${BUILD_VER}

elif [ "$UNAME_OS_SYSTEM" = "OSF1" ]; then
  BUILD_ARCH=ALPHA
  BUILD_OS=$UNAME_OS_SYSTEM
  BUILD_VER=$OS_RELEASE

elif [ "$UNAME_OS_SYSTEM" = "IRIX64" -o "$UNAME_OS_SYSTEM" = "IRIX" ]; then
  BUILD_ARCH=MIPS
  BUILD_OS=IRIX
  BUILD_VER=$OS_RELEASE
  OS_CONFIG=${BUILD_OS}${OS_RELEASE}

elif [ "$UNAME_OS_SYSTEM" = "BSD/386" ]; then
  BUILD_ARCH=x86
  BUILD_OS=BSDI
  BUILD_VER=$OS_RELEASE

elif [ "$UNAME_OS_ARCH" = "FreeBSD" ]; then
  BUILD_ARCH=`uname -p`
  BUILD_OS=$UNAME_OS_ARCH
  BUILD_VER=$UNAME_OS_RELEASE
  if [ "$BUILD_ARCH" = "i386" ]; then
    BUILD_ARCH=x86
  fi
  OS_CONFIG=${BUILD_OS}${BUILD_VER}_${BUILD_ARCH}

elif [ "$UNAME_OS_ARCH" = "SCO_SV" ]; then
  BUILD_ARCH=x86
  BUILD_OS=SCO
  BUILD_VER=$OS_RELEASE

elif [ "$UNAME_OS_SYSTEM" = "UNIX_SV" ]; then
  # Check for braindamage
  grep NCR /etc/bcheckrc > /dev/null 2>&1
  BUILD_ARCH=x86
  if [ $? = 0  ]; then
      BUILD_OS=NCR
  else
      BUILD_OS=UNIXWARE
  fi
  BUILD_VER=$OS_RELEASE

elif [ "$UNAME_OS_SYSTEM" = "NEWS-OS" ]; then
  BUILD_ARCH=`uname -p`
  BUILD_OS=SONY
  BUILD_VER=$OS_RELEASE

elif [ "$UNAME_OS_SYSTEM" = "UNIX_System_V" ]; then
  BUILD_ARCH=`uname -p`
  BUILD_OS=NEC
  BUILD_VER=$OS_RELEASE

elif [ $UNAME_OS_SYSTEM = Linux ]; then
  BUILD_ARCH=`uname -m`
  if [ -n "`echo $BUILD_ARCH | grep -e '86$'`" ] ; then
	  BUILD_ARCH=x86
  fi
  BUILD_OS=$UNAME_OS_SYSTEM
  BUILD_VER=`echo $OS_RELEASE | cut -f1,2 -d.`
  OS_CONFIG=${BUILD_OS}${BUILD_VER}_${BUILD_ARCH}
fi

case "$UNAME_OS_SYSTEM" in
SINIX*|ReliantUNIX*)
  BUILD_ARCH=`uname -p`
  BUILD_OS="ReliantUNIX"
  BUILD_VER=$OS_RELEASE
  ;;
esac

#PLATFORM=${BUILD_ARCH}_${BUILD_OS}_${BUILD_VER}
#echo $PLATFORM
echo $OS_CONFIG
