-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
89 lines (72 loc) · 2.64 KB
/
Makefile
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
# This is just a dumb makefile that provides a few short-hand build targets and install
# destinations. It's not meant to be robust or efficient or even particularly flexible, but
# hopefully the simplicity makes it easy for you to use and modify to suit your own needs.
#
# This makefile also has a few examples of how to cross-compile the executables for other
# architectures, such as home routers.
daemondest=/usr/local/sbin
cmddest=/usr/local/bin
cmddirs=cmd/trustydns-dig cmd/trustydns-proxy cmd/trustydns-server
commands=cmd/trustydns-server/trustydns-server cmd/trustydns-proxy/trustydns-proxy cmd/trustydns-dig/trustydns-dig
targets:
@echo "Installation targets: 'clean', 'all', and 'install'"
@echo "Developer targets: 'clean', 'fmt' and 'test'"
@echo "Cross-platform targets: 'mips64', 'debian64', 'pi3b', 'freebsdarm64', 'freebsd64', 'windowsamd64' and 'windows386'"
.PHONY: all
all: $(commands)
cmd/trustydns-server/trustydns-server cmd/trustydns-proxy/trustydns-proxy cmd/trustydns-dig/trustydns-dig:
$(MAKE) -C `dirname $@` all
.PHONY: race
race:
@for dir in $(cmddirs); do echo $$dir; $(MAKE) -C $$dir $@; done
.PHONY: clean vet test
clean vet test:
go $@ ./...
.PHONY: testrace
testrace:
go test -race ./...
.PHONY: critic
critic:
gocritic check ./...
.PHONY: fmt
fmt:
gofmt -s -w `find . -name '*.go' -type f -print`
.PHONY: install
install: $(commands)
install -d -o 0 -g 0 -m a=rx $(daemondest) $(cmddest)
install -p -o 0 -g 0 -m a=rx cmd/trustydns-server/trustydns-server $(daemondest)
install -p -o 0 -g 0 -m a=rx cmd/trustydns-proxy/trustydns-proxy $(daemondest)
install -p -o 0 -g 0 -m a=rx cmd/trustydns-dig/trustydns-dig $(cmddest)
.PHONY: mips64
mips64: clean
@echo 'Building for mips64 Linux targets (particularly Ubiquiti er3 and er6)'
@GOOS=linux GOARCH=mips64 $(MAKE) all
@file $(commands)
.PHONY: debian64
debian64: clean
@echo 'Building for amd64 Debian (as the Debian go package is antideluvian)'
@GOOS=linux GOARCH=amd64 $(MAKE) all
@file $(commands)
.PHONY: pi3b
pi3b: clean
@echo 'Building for Raspberry Pi3 Model B (32-bit armv71)'
@GOOS=linux GOARCH=arm $(MAKE) all
@file $(commands)
.PHONY: freebsdarm64
freebsdarm64: clean
@echo 'Building for aarch64 Freebsd targets (particularly Pi4 Model B (64-bit armv8)'
@GOOS=freebsd GOARCH=arm64 $(MAKE) all
@file $(commands)
.PHONY: freebsd64
freebsd64: clean
@echo Building for amd64 FreeBSD
@GOOS=freebsd GOARCH=amd64 $(MAKE) all
@file $(commands)
.PHONY: windowsamd64
windowsamd64: clean
@echo Building for amd64 Windows
@GOOS=windows GOARCH=amd64 $(MAKE) all
.PHONY: windows386
windows386: clean
@echo Building for 386 Windows
@GOOS=windows GOARCH=386 $(MAKE) all