summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 4e1f7ad2351d01df575d46cd85b149ff26d3cd16 (plain)
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
#!/usr/bin/make -f
# This file is in the public domain.
# You may freely use, modify, distribute, and relicense it.

PACKAGE = golang

libexecdir := /usr/lib/go
datadir := /usr/share/go
bindir := /bin

build-arch build-indep build clean install binary-arch binary-indep binary: debian/control
	+dh --parallel $(opt_no_act) $@

override_dh_auto_clean:
	rm -rf bin pkg
	rm -f debian/*+
	rm -f debian/build.stamp
	rm -f test/pass.out test/run.out test/times.out
	rm -rf debian/home

override_dh_auto_build: debian/build.stamp

override_dh_auto_test:
ifeq ($(RUN_TEST), true)
	cd $(CURDIR)/src && \
	$(CURDIR)/debian/test.bash $(GOROOT)/pkg/tool/$(GOHOSTOS)_$(GOHOSTARCH);
else
	:
endif

override_dh_compress:
	dh_compress -Xusr/share/doc/$(PACKAGE)-doc/html -Xusr/share/doc/$(PACKAGE)-doc/godoc

override_dh_install:
	dh_install --fail-missing
	# Remove binary from documentation
	-rm $(CURDIR)/debian/golang-doc/usr/share/doc/golang-doc/html/articles/wiki/get.bin
	# Make scripts executable
	chmod +x $(CURDIR)/debian/golang-src/usr/share/go/src/cmd/godoc/setup-godoc-app.bash
	# Remove testdata and tests from installed src directory
	find $(CURDIR)/debian/golang-src/usr/share/go/src -type d -name testdata -prune -execdir rm -rf {} \;
	find $(CURDIR)/debian/golang-src/usr/share/go/src -type f -name '*_test.go' -delete
	# Touch built and installed files and directories to have same timestamp
	touch $(CURDIR)/debian/golang-go/usr/lib/go/pkg
	find $(CURDIR)/debian/golang-go/usr/lib/go/pkg -exec touch -r $(CURDIR)/debian/golang-go/usr/lib/go/pkg {} \;

override_dh_strip:
	dh_strip -X".a" -Xgoinstall -Xgodoc -Xgoyacc -Xbin/cgo -Xebnflint -Xgofix -Xgofmt -Xgovet -Xgotest --dbg-package=$(PACKAGE)-dbg

debian/build.stamp:
	rm -f debian/build.stamp
	mkdir -p $(GOBIN)
	+cd src && bash ./make.bash --no-banner
	>debian/build.stamp

opt_no_act =
RUN_TEST := true

ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
    $(warning no support for disabling optimization)
endif

ifneq (,$(findstring n,$(MAKEFLAGS)))
    opt_no_act = --no-act
endif

ifneq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
    RUN_TEST := false
endif

GOROOT := $(CURDIR)
GOROOT_FINAL := $(libexecdir)
GOBIN := $(CURDIR)$(bindir)
GOARM :=

DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH 2>/dev/null)
DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS 2>/dev/null)
DEB_HOST_ARCH_CPU := $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU 2>/dev/null)
DEB_BUILD_ARCH_OS := $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS 2>/dev/null)
DEB_BUILD_ARCH_CPU := $(shell dpkg-architecture -qDEB_BUILD_ARCH_CPU 2>/dev/null)

ifeq ($(DEB_BUILD_ARCH_OS), kfreebsd)
    RUN_TEST := false
    GOHOSTOS := freebsd
else ifeq ($(DEB_BUILD_ARCH_OS), linux)
    GOHOSTOS := linux
else
    $(error unrecongized build host kernel $(DEB_BUILD_ARCH_OS)!)
endif

ifeq ($(DEB_HOST_ARCH_OS), kfreebsd)
    RUN_TEST := false
    GOOS := freebsd
else ifeq ($(DEB_HOST_ARCH_OS), linux)
    GOOS := linux
else
    $(error unrecognized kernel $(DEB_HOST_ARCH_OS)!)
endif

ifeq ($(DEB_BUILD_ARCH_CPU), i386)
    GOHOSTARCH := 386
else ifeq ($(DEB_BUILD_ARCH_CPU), amd64)
    GOHOSTARCH := amd64
else ifeq ($(DEB_BUILD_ARCH_CPU), arm)
    GOHOSTARCH := arm
else ifeq ($(DEB_BUILD_ARCH_CPU), armhf)
    GOHOSTARCH := arm
else
    $(error unrecognized build host instruction set $(DEB_HOST_ARCH_CPU)!)
endif

ifeq ($(DEB_HOST_ARCH_CPU), i386)
    GOARCH := 386
    GOPREFIX := 8
else ifeq ($(DEB_HOST_ARCH_CPU), amd64)
    GOARCH := amd64
    GOPREFIX := 6
else ifeq ($(DEB_HOST_ARCH_CPU), arm)
    GOARCH := arm
    GOPREFIX := 5
ifeq ($(DEB_HOST_ARCH), armel)
    RUN_TEST := false
    GOARM := 5
else ifeq ($(DEB_HOST_ARCH), armhf)
    GOARM := 6
else
    $(error unrecognized arm architecture $(DEB_HOST_ARCH)!)
endif
else
    $(error unrecognized instruction set $(DEB_HOST_ARCH_CPU)!)
endif

export GOROOT GOROOT_FINAL GOOS GOARCH GOARM GOBIN GOHOSTARCH GOHOSTOS

.PHONY: build clean install binary-arch binary-indep binary