-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
49 lines (37 loc) · 1.01 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
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
FAQ_BIN = faq-$(GOOS)-$(GOARCH)
ifeq ($(GOOS), linux)
INSTALL=install
else
INSTALL=ginstall
endif
FAQ_LINK_STATIC=false
GO_EXT_LD_FLAGS=-v
ifeq ($(FAQ_LINK_STATIC), true)
GO_EXT_LD_FLAGS+= -static
endif
FAQ_VERSION=$(shell git describe --always --abbrev=40 --dirty)
GO_LD_FLAGS=-s -w -X github.com/jzelinskie/faq/internal/version.Version=$(FAQ_VERSION) -extldflags "$(GO_EXT_LD_FLAGS)"
GO=go
GO_BUILD_ARGS=-v -ldflags '$(GO_LD_FLAGS)' -tags netgo
GO_FILES:=$(shell find . -name '*.go' -type f)
prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
install: $(FAQ_BIN)
mkdir -p $(DESTDIR)$(bindir)
$(INSTALL) -m 0755 $(FAQ_BIN) $(DESTDIR)$(bindir)/faq
$(FAQ_BIN): $(GO_FILES)
CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO) build -o $(FAQ_BIN) $(GO_BUILD_ARGS) github.com/jzelinskie/faq/cmd/faq
PHONY: build
build: $(FAQ_BIN)
PHONY: test
test:
go test ./...
clean:
rm $(FAQ_BIN)
PHONY: lint
lint:
golint ./...
all: lint test build