#!/bin/sh
# Return architecture name

os=`uname -s | tr '[A-Z]' '[a-z]'`

case "$os" in

linux)
    # use libc version
    release=`ldd --version | sed -n '1s/.* //p'`
;;

aix)
   # 5 1 -> 5.1
    release=`uname -v`.`uname -r`
;;

hp-ux)
    os=hpux
    # B.11.11 -> 11.11
    release=`uname -r | sed 's/[^.]*.[0B]*//'`
;;

cygwin_nt-*-wow64*)
    echo "win64" && exit
;;

cygwin_nt-*)
    echo "win32" && exit
;;

mingw*)
    echo "win32" && exit
;;

*)
    release=`uname -r`
;;

esac


case "$os" in

sunos | aix | irix64)
    chip=`uname -p`
    case "$chip" in
      i386)
      chip=`uname -m`
      ;;
    esac
;;


*)
    chip=`uname -m`
;;

esac

case "$chip" in

i?86)
    chip=x86
;;

i86pc)
    chip=x86_64
;;

9000/[678][0-9][0-9])
    chip=hppa
;;

esac


if [ $# -eq 2 ]; then
    echo ${os}
elif [ $# -eq 1 ]; then
    echo ${os}-${chip}
else
    echo ${os}-${chip}-${release}
fi

