summaryrefslogtreecommitdiffstats
path: root/linux/what-architecture-am-i-using
blob: 646c9e7dcf2b9001b8827bff29cad858297e02fe (plain) (blame)
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
#!/bin/sh

set -e

# TODO complete this list

if uname -s | grep -i linux > /dev/null; then
	arch="$(uname -m)"
	if test "$arch" = x86_64; then
		printf '%s\n' AMD64
		if test $# = 0 || "$@"; then
			if test ! -f /proc/config.gz; then
				printf '%s\n' '/proc/config.gz is missing' >&2
				exit 1
			elif test ! -r /proc/config.gz; then
				printf '%s\n' '/proc/config.gz is not readable' >&2
				exit 1
			fi
			if test $# = 0 || gunzip < /proc/config.gz | grep '^CONFIG_X86_X32_ABI=y$' > /dev/null; then
				printf '%s\n' AMD64_X32
			fi
			if test $# = 0 || gunzip < /proc/config.gz | grep '^CONFIG_X86=y$' > /dev/null; then
				printf '%s\n' I386
			fi
		fi
	elif test "$arch" = i686 || test "$arch" = i386; then
		printf '%s\n' I386
	else
		exit 1
	fi
else
	exit 2
fi