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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
#!/usr/bin/make -f
# This file is in the public domain.
# You may freely use, modify, distribute, and relicense it.
export GOROOT := $(CURDIR)
export GOROOT_FINAL := /usr/lib/go
export GOHOSTOS := $(shell ./debian/helpers/goenv.sh echo '$$GOHOSTOS')
export GOHOSTARCH := $(shell ./debian/helpers/goenv.sh echo '$$GOHOSTARCH')
%:
+dh --parallel $(opt_no_act) $@
# We loop over supported operating systems and architectures multiple times,
# so these two variables contain a centralized version of that code.
# The variables $$os and $$arch can be used inside such a loop.
FOR_GO_ARCH := set -ex; \
for os in $$(echo linux freebsd windows darwin netbsd); do \
archs="amd64 386"; \
[ "$$os" = "linux" ] || [ "$$os" = "freebsd" ] && archs="amd64 arm 386"; \
for arch in $$(echo $$archs); do
FOR_GO_ARCH_END := done; done
override_dh_auto_clean:
# golang-go-$os-$arch.install files are auto-generated in override_dh_install
rm -f debian/golang-go-*-*.install
# remove autogenerated files
rm -f \
src/cmd/cgo/zdefaultcc.go \
src/cmd/gc/opnames.h \
src/cmd/go/zdefaultcc.go \
src/liblink/anames*.c \
src/runtime/zaexperiment.h \
src/runtime/zasm_*_*.h \
src/runtime/zgoarch_*.go \
src/runtime/zgoos_*.go \
src/runtime/zruntime_defs_*_*.go \
src/runtime/zsys_*_*.s \
src/runtime/zversion.go
# remove built objects
rm -rf bin pkg
override_dh_auto_test-arch:
set -ex; \
cd src; \
export PATH="$(GOROOT)/bin:$$PATH"; \
eval "$$(go tool dist env)"; \
bash run.bash --no-rebuild;
# remove test artifacts
rm -f \
test/bench/shootout/6.out \
test/bench/shootout/*.6
override_dh_compress-indep:
dh_compress -Xusr/share/doc/golang-doc/html -Xusr/share/doc/golang-doc/godoc
# Generates debian/control from debian/control.base and debian/control.cross.
# In the latter, @OS@ and @ARCH@ are replaced with every supported combination
# of operating system and architecture (e.g. linux_amd64, linux_386, …).
gencontrol:
echo "# DO NOT EDIT THIS FILE. EDIT debian/control.* instead!" > debian/control.tmp
cat debian/control.base >> debian/control.tmp
${FOR_GO_ARCH} \
BUILDARCHS=all; \
[ "$$os" = "linux" ] && BUILDARCHS="amd64 armel armhf i386"; \
sed -e "s,@OS@,$$os,g; s,@ARCH@,$$arch,g; s,@BUILDARCHS@,$$BUILDARCHS,g" debian/control.cross >> debian/control.tmp; \
${FOR_GO_ARCH_END}
mv debian/control.tmp debian/control
install-overrides:
# go install: -race is only supported on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64
${FOR_GO_ARCH} \
echo "pkg/$${os}_$${arch} /usr/lib/go/pkg/" > debian/golang-go-$$os-$$arch.install; \
[ "$$arch" = '$(GOHOSTARCH)' -a "$$arch" = 'amd64' -a "$$os" = '$(GOHOSTOS)' -a "$$os" = 'linux' ] \
&& echo "pkg/$${os}_$${arch}_race /usr/lib/go/pkg/" >> debian/golang-go-$$os-$$arch.install; \
echo "golang-go-$$os-$$arch: arch-independent-package-contains-binary-or-object" > debian/golang-go-$$os-$$arch.lintian-overrides; \
${FOR_GO_ARCH_END}
override_dh_install-indep:
./debian/rules install-overrides
dh_install --fail-missing
override_dh_install-arch:
./debian/rules install-overrides
# Install the native runtime/cgo.a to the golang-go package.
# runtime/cgo is only built for the native architecture, but the
# golang-go-OS-ARCH packages are built on one particular buildd, which
# might either be i386 or amd64.
for file in pkg/*/runtime/cgo.a; do \
mkdir -p debian/golang-go/usr/lib/go/$$(dirname $$file); \
mv $$file debian/golang-go/usr/lib/go/$$file; \
done
dh_install --fail-missing
# Remove .syso files of the race detector; it is not used yet and the files are arch-dependent.
find debian/golang-src/usr/share/go/src/runtime/race -type f -name '*.syso' -delete
# Remove Plan9 rc(1) scripts
find debian/golang-src/usr/share/go/src -type f -name '*.rc' -delete
# Remove empty /usr/share/go/src from golang-go, it is provided by golang-src
find debian/golang-go/usr/share/go/src -type d -delete
# Subsequently, /usr/share/go is empty, too, so remove
find debian/golang-go/usr/share/go -type d -delete
# For some reason, Go cross-compiles a handful of tools: {yacc,fix,api,vet,cgo}.
# Delete those, as they cannot be ran anyway.
# This is tracked upstream at https://code.google.com/p/go/issues/detail?id=5667
(cd debian/golang-go/usr/lib/go/pkg/tool && find . -depth -path "./$(GOHOSTOS)_$(GOHOSTARCH)*" -prune -o -delete)
# Touch built and installed files and directories to have same timestamp
touch debian/golang-go/usr/lib/go/pkg
find debian/golang-go/usr/lib/go/pkg -exec touch -r $(CURDIR)/debian/golang-go/usr/lib/go/pkg {} \;
override_dh_strip:
# strip disabled as golang upstream doesn't support it and it makes go
# crash. See http://bugs.debian.org/717172
override_dh_prep:
dh_prep
echo 'go:Hostarch=$(GOHOSTARCH)' >> debian/golang-go.substvars
override_dh_shlibdeps:
dh_shlibdeps -Xtestdata -Xtest
override_dh_auto_build:
[ -f VERSION ] || echo "debian snapshot +$$(dpkg-parsechangelog -SVersion)" > VERSION
# Build native tools first, then bootstrap all other GOOS/GOARCH combinations.
cd src \
&& $(CURDIR)/debian/helpers/goenv.sh \
bash ./make.bash --no-banner
# For the race detector to work (go test -race), we need to install the
# std library with the race detector enabled. This will result in
# having an additional “architecture” directory, e.g. linux_amd64_race.
#
# The race detector currently only works on linux/amd64. The check within
# the following loop works precisely the same way src/race.bash does.
#
# go install: -race is only supported on linux/amd64, freebsd/amd64, darwin/amd64 and windows/amd64
${FOR_GO_ARCH} \
cd src \
&& $(CURDIR)/debian/helpers/goenv.sh \
GOARCH=$$arch GOOS=$$os \
bash ./make.bash --no-clean --no-banner; \
if [ "$$arch" = '$(GOHOSTARCH)' -a "$$arch" = 'amd64' -a "$$os" = "$(GOHOSTOS)" -a "$$os" = 'linux' ]; then \
$(CURDIR)/debian/helpers/goenv.sh \
GOARCH=$$arch GOOS=$$os \
$(GOROOT)/bin/go install -race std; \
fi; \
cd ..; \
${FOR_GO_ARCH_END}
opt_no_act :=
ifneq (,$(findstring n,$(MAKEFLAGS)))
opt_no_act := --no-act
endif
|