Import Upstream version 20180207
[hcoop/debian/mlton.git] / bin / platform
CommitLineData
7f918cf1
CE
1#!/usr/bin/env bash
2
3set -e
4
5name=`basename "$0"`
6dir=`dirname "$0"`
7bin=`cd "$dir" && pwd`
8
9die () {
10 echo >&2 "$1"
11 exit 1
12}
13
14usage () {
15 die "usage: $name"
16}
17
18case "$#" in
190)
20;;
21*)
22 usage
23;;
24esac
25
26uname=`uname`
27arch=
28
29case "$uname" in
30AIX)
31 HOST_OS='aix'
32 arch=`/usr/sbin/lsattr -a type -F deflt -l proc0`
33 case $arch in
34 POWER) arch=powerpc64 ;;
35 esac
36;;
37CYGWIN*)
38 HOST_OS='cygwin'
39;;
40Darwin)
41 HOST_OS='darwin'
42;;
43*FreeBSD*)
44 HOST_OS='freebsd'
45;;
46GNU)
47 HOST_OS='hurd'
48;;
49HP-UX)
50 HOST_OS='hpux'
51;;
52Linux)
53 HOST_OS='linux'
54;;
55MINGW*)
56 HOST_OS='mingw'
57;;
58NetBSD*)
59 HOST_OS='netbsd'
60;;
61OpenBSD*)
62 HOST_OS='openbsd'
63;;
64SunOS)
65 HOST_OS='solaris'
66 for arch in sparc amd64 i386 `uname -m`; do
67 optisa $arch > /dev/null && break
68 done
69;;
70*)
71 die "Unknown OS $uname."
72;;
73esac
74
75if [ -z "$arch" ]; then
76 arch=`uname -m`
77fi
78
79case "$arch" in
80alpha*)
81# not certain about this one; no alpha access
82 HOST_ARCH=alpha
83;;
84x86_64*)
85 HOST_ARCH=amd64
86;;
87i?86_64)
88 HOST_ARCH=amd64
89;;
90amd64)
91 HOST_ARCH=amd64
92;;
93arm*)
94 HOST_ARCH=arm
95;;
96aarch64)
97 HOST_ARCH=arm64
98;;
99parisc*)
100 HOST_ARCH=hppa
101;;
1029000/*)
103 HOST_ARCH=hppa
104;;
105ia64*)
106 HOST_ARCH=ia64
107;;
108m68k*)
109 HOST_ARCH=m68k
110;;
111mips*)
112# big-endian and little-endian detect via headers
113 HOST_ARCH=mips
114;;
115powerpc64)
116 HOST_ARCH=powerpc64
117;;
118ppc64)
119 HOST_ARCH=powerpc64
120;;
121powerpc)
122 HOST_ARCH=powerpc
123;;
124ppc*)
125 HOST_ARCH=powerpc
126;;
127Power*)
128 HOST_ARCH=powerpc
129;;
130s390*)
131 HOST_ARCH=s390
132;;
133sparc*)
134 HOST_ARCH=sparc
135;;
136sun*)
137 HOST_ARCH=sparc
138;;
139i?86*)
140 HOST_ARCH=x86
141;;
142*)
143 die "Unknown arch $arch."
144;;
145esac
146
147echo "HOST_OS=$HOST_OS HOST_ARCH=$HOST_ARCH"