-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
46 lines (37 loc) · 999 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
GO = go
BINDIR := bin
BINARY := simple-httpd
PREFIX := /usr/local
VERSION = v0.5.0
GIT_SHA = $(shell git rev-parse HEAD)
LDFLAGS = -ldflags "-X main.gitSHA=$(GIT_SHA) -X main.version=$(VERSION) -X main.name=$(BINARY)"
OS := $(shell uname)
$(BINDIR)/$(BINARY): clean
$(GO) build $(LDFLAGS) -o $@
.PHONY: test
test:
$(GO) test -v .
.PHONY: clean
clean:
$(GO) clean
rm -f $(BINARY)
rm -f $(BINDIR)/*
.PHONY: install
install: clean
ifeq ($(OS),Darwin)
./build.sh darwin $(BINARY) $(VERSION) $(GIT_SHA)
cp -f $(BINDIR)/$(BINARY)-darwin $(PREFIX)/$(BINDIR)/$(BINARY)
endif
ifeq ($(OS),Linux)
./build.sh linux $(BINARY) $(VERSION) $(GIT_SHA)
cp -f $(BINDIR)/$(BINARY)-linux $(PREFIX)/$(BINDIR)/$(BINARY)
endif
ifeq ($(OS),FreeBSD)
./build.sh freebsd $(BINARY) $(VERSION) $(GIT_SHA)
cp -f $(BINDIR)/$(BINARY)-freebsd $(PREFIX)/$(BINDIR)/$(BINARY)
endif
uninstall:
rm -f $(PREFIX)/$(BINDIR)/$(BINARY)*
.PHONY: release
release: clean
./build.sh release $(BINARY) $(VERSION) $(GIT_SHA)