-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (30 loc) · 877 Bytes
/
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
.PHONY: goimports gopath install run clean uninstall purge test
EXE=ebox
ARGS=
# building and installing stuff
$(GOPATH)/bin/$(EXE): $(EXE)
go install
$(EXE): goimports $(wildcard *.go)
go build -o "$(EXE)"
install: "/bin/$(EXE)"
"/bin/$(EXE)":
sudo -E install -m 0755 "$(GOPATH)/bin/$(EXE)" $@
# running stuff
run: $(GOPATH)/bin/$(EXE)
$(GOPATH)/bin/$(EXE) $(ARGS)
test: $(GOPATH)/bin/$(EXE) # depends on installed program since it's called from inside the tests via cmd.Run()
go test
# removing stuff
clean:
rm -f "$(EXE)"
uninstall:
sudo -E rm -f "/bin/$(EXE)"
# gopath is no dep of this target because empty gopath is effectively the same as /bin/$(EXE)
sudo -E rm -f "$(GOPATH)/bin/$(EXE)"
purge: uninstall clean
# depending on stuff
gopath:
if [ -z "$(GOPATH)" ]; then exit 1; fi
# other stuff
goimports: $(wildcard *.go)
goimports -w $+