-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
56 lines (44 loc) · 1.32 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
BUILDPATH=$(CURDIR)
BINPATH=$(BUILDPATH)/bin
PKGPATH=$(BUILDPATH)/pkg
GO=$(shell which go)
GOGET=$(GO) get
PLATFORMS := darwin/386 darwin/amd64 linux/386 linux/amd64 windows/386 windows/amd64 freebsd/386
PLATFORM = $(subst /, ,$@)
OS = $(word 1, $(PLATFORM))
ARCH = $(word 2, $(PLATFORM))
EXENAME=slit
CMDSOURCES = $(wildcard cmd/slit/*.go)
GOBUILD=$(GO) build
.PHONY: makedir build test clean prepare default all $(PLATFORMS)
.DEFAULT_GOAL := default
makedir:
@echo -n "make directories... "
@if [ ! -d $(BINPATH) ] ; then mkdir -p $(BINPATH) ; fi
@if [ ! -d $(PKGPATH) ] ; then mkdir -p $(PKGPATH) ; fi
@echo ok
build:
@echo -n "run build... "
@$(GOBUILD) -o $(BINPATH)/$(EXENAME) -ldflags="-w -s" $(CMDSOURCES)
@echo ok
test:
@echo -n "Validating with go fmt..."
@go fmt $$(go list ./... | grep -v /vendor/)
@echo ok
@echo -n "Validating with go vet..."
@go vet $$(go list ./... | grep -v /vendor/)
@echo ok
clean:
@echo -n "clean directories... "
@rm -rf $(BINPATH)
@rm -rf $(PKGPATH)
@rm -rf $(BUILDPATH)/src
@echo ok
prepare: test makedir
default: prepare build
$(PLATFORMS):
@echo -n "build $(OS)/$(ARCH)... "
$(eval EXT := $(shell if [ "$(OS)" = "windows" ]; then echo .exe; fi))
@GOOS=$(OS) GOARCH=$(ARCH) $(GOBUILD) -o $(BINPATH)/$(EXENAME)_$(OS)_$(ARCH)$(EXT) $(CMDSOURCES)
@echo ok
all: default $(PLATFORMS)