summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 6fb8a464fab71809d1d80e7448da96237fd6e174 (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
#!/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/golang
datadir := /usr/share/golang
bindir := /bin

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

override_dh_auto_clean: debian/golang-src.install
	rm -f debian/*+
	rm -f debian/build.stamp
	: NEEDSWORK: update src/pkg/Makefile.
	#cd src/pkg && $(GOBIN)/gomake exp/ogle.clean
	rm -f src/pkg/Make.deps
	rm -f test/pass.out test/run.out test/times.out

override_dh_auto_build: debian/build.stamp

override_dh_auto_test:
	:
#	$(no_check) || { cd src && bash ./run.bash --no-rebuild; }

override_dh_compress:
	dh_compress -Xusr/share/doc/golang-doc/html -Xusr/share/doc/golang-doc/godoc

override_dh_auto_install: debian/golang-src.install
	for cmd in a c g l; do ln -s $(GOPREFIX)$$cmd $(CURDIR)$(bindir)/golang-$$cmd; done
	for cmd in nm cov prof; do ln -s 6$$cmd $(CURDIR)$(bindir)/golang-$$cmd; done
	# remove RUNPATH from go binaries
	for cmd in goyacc ebnflint godoc govet gofmt goinstall cgo; do chrpath -d $(CURDIR)$(bindir)/$$cmd; done

override_dh_install:
	dh_install --fail-missing

override_dh_strip:
	dh_strip -X".a" -Xgoinstall -Xgodoc -Xgoyacc -Xbin/cgo -Xebnflint -Xgofmt -Xgovet

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

opt_no_act =
no_check = ! :

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)))
    no_check = :
endif

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

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)

ifeq ($(DEB_HOST_ARCH_OS), kfreebsd)
    GOOS := freebsd
else
    ifeq (,$(findstring $(DEB_HOST_ARCH_OS), linux freebsd darwin))
        $(warning unrecognized kernel $(DEB_HOST_ARCH_OS)! continuing.)
    endif
    GOOS := $(DEB_HOST_ARCH_OS)
endif

ifeq ($(DEB_HOST_ARCH_CPU), i386)
    GOARCH := 386
    GOHOSTARCH := 386
    GOPREFIX := 8
else ifeq ($(DEB_HOST_ARCH_CPU), amd64)
    GOARCH := amd64
    GOHOSTARCH := amd64
    GOPREFIX := 6
else ifeq (,$(findstring $(DEB_HOST_ARCH_CPU), arm armeb armel))
    GOARCH := arm
    GOARM := 5
    GOPREFIX := 5
else
    $(warning unrecognized instruction set $(DEB_HOST_ARCH_CPU)! continuing.)
    GOARCH := $(DEB_HOST_ARCH_CPU)
endif

export GOROOT GOROOT_FINAL GOOS GOARCH GOARM GOBIN GOHOSTARCH GOHOSTOS

REPO = https://go.googlecode.com/hg/
REV = release
get-orig-source:
	mkdir debian-orig-source
	-set -e; cd debian-orig-source; \
	hg clone -U -r"$(REV)" "$(REPO)" go; \
	( \
		cd go; \
		hg pull; \
		VERSION=$$( \
			hg identify -t -r"$(REV)" | \
			perl -e '<> =~ /release\.(\d+)-(\d+)-(\d+)/; print "$$1.$$2.$$3"' \
		); \
		hg archive -ttgz -p"google-go-$$VERSION/" -r"$(REV)" -X'.hg*' \
			../../google-go_$$VERSION.orig.tar.gz; \
	)
	rm -fr debian-orig-source

debian/golang-src.install:
	# create golang-src.install list
	( \
		find src/cmd -name doc.go ; \
		find src/pkg -name \*.go ; \
	) | sed -e 's{\(.*/\).*$${\0 $(datadir)/\1{' > $(CURDIR)/debian/golang-src.install

.PHONY: build clean install binary-arch binary-indep binary debian/golang-src.install