-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
40 lines (28 loc) · 863 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
GOPATH=$(shell pwd)/vendor:$(shell pwd)
GOBIN=$(shell pwd)/bin
GOFILES=$(wildcard *.go)
GONAME=$(shell basename "$(PWD)")
PID=/tmp/go-$(GONAME).pid
all: watch
build:
@echo "Building $(GOFILES) to ./bin"
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build -o bin/$(GONAME) $(GOFILES)
get:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get .
install:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go install $(GOFILES)
run:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go run $(GOFILES)
watch: get build stop start
@fswatch -o *.go src/**/*.go | xargs -n1 -I{} make restart || make stop
restart: stop clean build start
start:
@echo "Starting bin/$(GONAME)"
@./bin/$(GONAME) & echo $$! > $(PID)
stop:
@echo "Stopping bin/$(GONAME)"
@-kill `cat $(PID)` || true
clean:
@echo "Cleaning"
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go clean
.PHONY: build get install run watch start stop restart clean