summaryrefslogtreecommitdiff
path: root/src/Make.pkg
blob: 2098e2ed9c6275ef229935d4a54d55591f8e3ef2 (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
# Copyright 2009 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

package: _obj/$(TARG).a
testpackage: _test/$(TARG).a

elem=$(lastword $(subst /, ,$(TARG)))
dir=$(patsubst %/$(elem),%,$(TARG))

pkgdir=$(GOROOT)/pkg/$(GOOS)_$(GOARCH)

coverage:
	gotest
	6cov -g $(shell pwd) | grep -v '_test\.go:'

clean:
	rm -rf *.[$(OS)] *.a [$(OS)].out _obj _test _testmain.go

test:
	gotest

nuke: clean
	rm -f $(pkgdir)/$(TARG).a

testpackage-clean:
	rm -f _test/$(TARG).a _gotest_.$O

install: $(pkgdir)/$(TARG).a

$(pkgdir)/$(TARG).a: package
	test -d $(GOROOT)/pkg && mkdir -p $(pkgdir)/$(dir)
	cp _obj/$(TARG).a $(pkgdir)/$(TARG).a

_go_.$O: $(GOFILES)
	$(GC) -o $@ $(GOFILES)

_gotest_.$O: $(GOFILES) $(GOTESTFILES)
	$(GC) -o $@ $(GOFILES) $(GOTESTFILES)

%.$O: %.c
	$(CC) $*.c

%.$O: %.s
	$(AS) $*.s

%.$O: $(HFILES)

_obj/$(TARG).a: _go_.$O $(OFILES)
	mkdir -p _obj/$(dir)
	rm -f _obj/$(TARG).a
	gopack grc $@ _go_.$O $(OFILES)

_test/$(TARG).a: _gotest_.$O $(OFILES)
	mkdir -p _test/$(dir)
	rm -f _test/$(TARG).a
	gopack grc $@ _gotest_.$O $(OFILES)

importpath:
	@echo $(TARG)