File: goenv.sh

package info (click to toggle)
golang-1.8 1.8.1-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 76,544 kB
  • sloc: asm: 55,864; ansic: 7,960; sh: 1,576; perl: 1,139; xml: 623; python: 286; javascript: 231; makefile: 109; cpp: 22; f90: 8; awk: 7
file content (55 lines) | stat: -rwxr-xr-x 1,668 bytes parent folder | download | duplicates (9)
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
#!/bin/sh
set -e

__goos__deb_arch_os() {
	case "$1" in
		kfreebsd) echo freebsd ;;
		linux) echo "$1" ;;
		*) echo >&2 "error: unrecongized DEB_*_ARCH_OS: $1"; exit 1 ;;
	esac
}

__goarch__deb_arch_cpu() {
	case "$1" in
		amd64|arm|arm64|ppc64|s390x) echo "$1" ;;
		i386) echo 386 ;;
		ppc64el) echo ppc64le ;;
		mips64el) echo mips64le ;;
		*) echo >&2 "error: unrecongized DEB_*_ARCH_CPU: $1"; exit 1 ;;
	esac
}

#       build machine
#           The machine the package is built on.
#
#       host machine
#           The machine the package is built for.

export GOHOSTOS="$(__goos__deb_arch_os "$(dpkg-architecture -qDEB_BUILD_ARCH_OS 2>/dev/null)")"
export GOOS="$(__goos__deb_arch_os "$(dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)")"

export GOHOSTARCH="$(__goarch__deb_arch_cpu "$(dpkg-architecture -qDEB_BUILD_ARCH_CPU 2>/dev/null)")"
export GOARCH="$(__goarch__deb_arch_cpu "$(dpkg-architecture -qDEB_HOST_ARCH_CPU 2>/dev/null)")"

if [ -z "$GOHOSTOS" -o -z "$GOOS" -o -z "$GOHOSTARCH" -o -z "$GOARCH" ]; then
	exit 1
fi

# Always use the 387 floating point unit instead of sse2. This is important to
# ensure that the binaries we build (both when compiling golang on the buildds
# and when users cross-compile for 386) can actually run on older CPUs (where
# old means e.g. an AMD Athlon XP 2400+). See http://bugs.debian.org/753160 and
# https://code.google.com/p/go/issues/detail?id=8152
export GO386=387

unset GOARM
if [ "$GOARCH" = 'arm' ]; then
	# start with GOARM=5 for maximum compatibility (see note about GO386 above)
	GOARM=5
	case "$(dpkg-architecture -qDEB_HOST_ARCH 2>/dev/null)" in
		armhf) GOARM=6 ;;
	esac
fi
export GOARM

eval "$@"