SHARE
TWEET

awful architecture/OS hack for unix platforms

a guest Sep 14th, 2013 547 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. case `hostname` in
  3.   timberwolf*) PATH=/usr/bin:$PATH; export PATH ;;
  4. esac
  5.  
  6. if uname -p >/dev/null 2>/dev/null; then
  7.   PROC=`uname -p`
  8. else
  9.   PROC=unknown
  10. fi
  11.  
  12. if [ "x$PROC" != xunknown ]; then
  13.   : do nothing
  14. elif [ -x /bin/arch ]; then
  15.   PROC=`/bin/arch`
  16. elif uname >/dev/null 2>/dev/null; then
  17.   case `uname` in
  18.     AIX) echo rs6000-aix ;;
  19.     FreeBSD)
  20.       OS=bsd
  21.       if uname -m >/dev/null 2>/dev/null; then
  22.         PROC=`uname -m`
  23.       else
  24.         PROC=unknown
  25.       fi
  26.       echo $PROC-$OS ;;
  27.     Linux)
  28.       OS=linux;
  29.       if uname -m >/dev/null 2>/dev/null; then
  30.         case `uname -m` in
  31.           i586|i486|i386) PROC=x86 ;;
  32.           *) PROC=`uname -m` ;;
  33.         esac
  34.       else
  35.         PROC=unknown
  36.       fi
  37.       echo $PROC-$OS ;;
  38.     *) echo unknown ;;
  39.   esac
  40.   exit 0
  41. fi
  42.  
  43. case $PROC in
  44.   sun4) PROC=sparc ;;
  45.   powerpc) PROC=ppc ;;
  46.   i386|i486|i586|i686|Pentium*|AMD?Athlon*) PROC=x86 ;;
  47.   x86_64|amd64) PROC=amd64 ;;
  48. esac
  49.  
  50. case $PROC in
  51.   sparc) case `uname -r` in
  52.            4.*)      OS=sunos ;;
  53.            [5-9].*)  OS=solaris ;;
  54.            *)        echo "unknown-OS" 1>&2; exit 1 ;;
  55.          esac ;;
  56.   ppc)  case `uname` in
  57.            Darwin) OS=darwin ;;
  58.            *)        echo "unknown-OS" 1>&2; exit 1 ;;
  59.         esac ;;
  60.   mips) case `uname -s` in
  61.           IRIX)
  62.             case `uname -r` in
  63.               5.*) OS=irix5 ;;
  64.               *)        echo "unknown-OS" 1>&2; exit 1 ;;
  65.             esac ;;
  66.           Linux) OS=linux ;;
  67.           *)        echo "unknown-OS" 1>&2; exit 1 ;;
  68.          esac ;;
  69.   x86|amd64)   case `uname` in
  70.             FreeBSD) OS=bsd ;;
  71.             Linux) OS=linux ;;
  72.             Darwin) OS=darwin ;;
  73.             *) OS=unknown ;;
  74.          esac ;;
  75.   alpha) case `uname` in
  76.            OSF1) OS=osf1 ;;
  77.            Linux|linux) OS=linux ;;
  78.            *) OS=unknown ;;
  79.          esac ;;
  80.   *) echo "unknown-OS" 1>&2; exit 1 ;;
  81. esac
  82. echo $PROC-$OS
  83.  
  84.  
  85. exit 0
  86.  
  87. for i in /usr/local/bin/bintype /bin/arch /usr/ucb/arch /usr/local/bin/cputype
  88. do
  89.   if [ -x $i ]; then export CPU=`$i` ; break; fi
  90. done
  91.  
  92. if [ "$CPU" = "i586" ]; then
  93.   CPU=i486
  94. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top