-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
45 lines (34 loc) · 1 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
GOPATH=$(shell pwd)/vendor:$(shell pwd)
GOBIN=$(shell pwd)/bin
GOFILES=$(wildcard *.go)
GONAME=$(shell basename "$(PWD)" | awk '{split($$0,a,"-"); print a[1]}' )
PID=/tmp/go-$(GONAME).pid
DESTDIR=$
PREFIX=/usr/local
build:
@echo "Building $(GOFILES) to $(GOBIN)"
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build -o $(GOBIN)/$(GONAME) $(GOFILES)
get:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get .
install:
$(MAKE) -C .
@install -d $(DESTDIR)$(PREFIX)/bin
@install -m 777 $(GOBIN)/trm $(DESTDIR)$(PREFIX)/bin
run:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go run $(GOFILES)
watch:
@$(MAKE) restart &
@fswatch -o . -e 'bin/.*' | xargs -n1 -I{} make restart
restart: clear stop clean build start
start:
@echo "Starting bin/$(GONAME)"
@./bin/$(GONAME) & echo $$! > $(PID)
stop:
@echo "Stopping bin/$(GONAME) if it's running"
@-kill `[[ -f $(PID) ]] && cat $(PID)` 2>/dev/null || true
clear:
@clear
clean:
@echo "Cleaning"
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go clean
.PHONY: build get install run watch start stop restart clean