forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-os-and-arch.sh
73 lines (61 loc) · 1.57 KB
/
init-os-and-arch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
# Use uname to determine what the OS is.
OSName=$(uname -s)
if command -v getprop && getprop ro.product.system.model 2>&1 | grep -qi android; then
OSName="Android"
fi
case "$OSName" in
FreeBSD|Linux|NetBSD|OpenBSD|SunOS|Android)
os="$OSName" ;;
Darwin)
os=OSX ;;
*)
echo "Unsupported OS $OSName detected, configuring as if for Linux"
os=Linux ;;
esac
# On Solaris, `uname -m` is discouraged, see https://docs.oracle.com/cd/E36784_01/html/E36870/uname-1.html
# and `uname -p` returns processor type (e.g. i386 on amd64).
# The appropriate tool to determine CPU is isainfo(1) https://docs.oracle.com/cd/E36784_01/html/E36870/isainfo-1.html.
if [ "$os" = "SunOS" ]; then
if uname -o 2>&1 | grep -q illumos; then
os="illumos"
else
os="Solaris"
fi
CPUName=$(isainfo -n)
else
# For the rest of the operating systems, use uname(1) to determine what the CPU is.
CPUName=$(uname -m)
fi
case "$CPUName" in
arm64|aarch64)
arch=arm64
;;
loongarch64)
arch=loongarch64
;;
amd64|x86_64)
arch=x64
;;
armv7l|armv8l)
if (NAME=""; . /etc/os-release; test "$NAME" = "Tizen"); then
arch=armel
else
arch=arm
fi
;;
armv6l)
arch=armv6
;;
i[3-6]86)
echo "Unsupported CPU $CPUName detected, build might not succeed!"
arch=x86
;;
s390x)
arch=s390x
;;
*)
echo "Unknown CPU $CPUName detected, configuring as if for x64"
arch=x64
;;
esac