Debian Codegraph @

debian/dekencpu

raw
1 #!/bin/sh
2
3 # get the "Deken CPU" for the given arch.
4 # This is mainly targetted at Debian's ${DEB_HOST_ARCH}
5 # it works for many cases of ${DEB_HOST_ARCH_CPU} resp
6 # ${DEB_HOST_GNU_CPU}, but not for all
7 # (notably the 'x32' Debian architecture has both
8 # DEB_HOST_(ARCH|GNU)_CPU set to some x86_64 value)
9
10 archmap_() {
11 cat <<EOF
12 # x86 family
13 i386 i386
14 i486 i386
15 i586 i386
16 i686 i386
17 x86 i386
18 x32 i386 # x86_64 CPU, but 32bit pointers
19 amd64 amd64
20 x64 amd64
21 x86_64 amd64
22 hurd-i386 i386
23 hurd-amd64 amd64
24 kfreebsd-i386 i386
25 kfreebsd-amd64 amd64
26
27 # arm family
28 arm armv5
29 armel armv6
30 armeb armv6b
31 armhf armv7
32 aarch64 arm64
33 arm64 arm64
34 arm64ilp32 arm64 # ???
35
36 # PowerPC family
37 powerpc ppc
38 powerpcel ppcl
39 powerpcspe ppc # ?
40 powerpc64 ppc64
41 ppwerpc64el ppc64l
42 powerpc64le ppc64l
43 ppc64el ppc64l
44
45 # MIPS family
46 mips mips
47 mipsel mipsel
48 mips64 mips64
49 mips64el mips64el
50
51 # others
52 # (we just map the original arch to same name
53 # so no need to enumerate all of them)
54 EOF
55 }
56 archmap() {
57 archmap_ | sed -e 's|#.*||' -e 's|[[:space:]]*$||' -e '/^$/d'
58 }
59
60 usage() {
61 cat >/dev/stderr <<EOF
62 usage: $0 <cpu>
63
64 Prints the 'deken CPU' (as used in the filename for Pd-externals) for the given Debian (or GNU) architecture.
65
66 Examples:
67 $0 \$(dpkg-architecture -qDEB_HOST_ARCH)
68 $0 \${DEB_HOST_ARCH}
69 EOF
70 }
71
72 cpu="$1"
73
74 if [ -z "${cpu}" ]; then
75 usage
76 exit 1
77 fi
78
79 dekcpu=$(archmap | grep -E "^${cpu}\b" | awk '{print $2}')
80
81 echo "${dekcpu:-$cpu}"
82