forked from bedrocklinux/bedrocklinux-userland
-
Notifications
You must be signed in to change notification settings - Fork 0
/
detect_arch.sh
executable file
·105 lines (103 loc) · 1.84 KB
/
detect_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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh
#
# detect_arch.sh
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
#
# Copyright (c) 2019 Daniel Thau <[email protected]>
#
# Detects which CPU architecture Bedrock Linux's build system is producing.
# Outputs two lines:
# - First line is Bedrock's name for the architecture. This is used, for
# example, in the output installer/updater file name.
# - Second line is context expected in `file` output on one of the binaries.
# This is used to sanity check the resulting binaries are in fact of the
# expected type.
# - Third line is CPU bit depth.
if ! gcc --version >/dev/null 2>&1; then
echo "ERROR: gcc not found" >&2
exit 1
fi
case "$(gcc -dumpmachine)" in
aarch64-*)
echo "aarch64"
echo "ARM aarch64"
echo "64"
;;
arm-*abi)
echo "armv7l"
echo "EABI5"
echo "32"
;;
arm-*abihf)
echo "armv7hl"
echo "EABI5"
echo "32"
;;
i386-*)
echo "i386"
echo "Intel 80386"
echo "32"
;;
i486-*)
echo "i486"
echo "Intel 80386"
echo "32"
;;
i586-*)
echo "i586"
echo "Intel 80386"
echo "32"
;;
i686-*)
echo "i686"
echo "Intel 80386"
echo "32"
;;
mips-*)
echo "mips"
echo "MIPS32"
echo "32"
;;
mipsel-*)
echo "mipsel"
echo "MIPS32"
echo "32"
;;
mips64el-*)
echo "mips64el"
echo "MIPS64"
echo "64"
;;
powerpc-*)
echo "ppc"
echo "32-bit.*PowerPC"
echo "32"
;;
powerpc64-*)
echo "ppc64"
echo "64-bit PowerPC"
echo "64"
;;
powerpc64le-*)
echo "ppc64le"
echo "64-bit PowerPC"
echo "64"
;;
s390x-*)
echo "s390x"
echo "IBM S/390"
echo "64" # the x in s390x indicates 64 bit
;;
x86_64-*)
echo "x86_64"
echo "x86-64"
echo "64"
;;
*)
echo "Unrecognized CPU architecture" >&2
exit 1
;;
esac