-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
43 lines (32 loc) · 1.14 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
# Go parameters
TOPDIR=$(PWD)
MODULE_PATH ?= ~/.ga/middlewares
GOCMD=go
GOBUILD=$(GOCMD) build -mod=mod
GOCLEAN=$(GOCMD) clean
GOINSTALL=$(GOCMD) install
GOTEST=$(GOCMD) test
GODEP=$(GOTEST) -i
GOFMT=gofmt -w
BUILD_DATE := "$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')"
GIT_COMMIT := "$(shell git rev-parse HEAD)"
VERSION :="$(shell git describe --tags --abbrev=0 | tr -d '\n')"
VERSION_COMMIT :="$(shell git describe --tags --abbrev=0 | tr -d '\n')-$(shell git rev-parse HEAD | tr -d '\n')"
# LDFLAGS=-ldflags "-s"
LDFLAGS=-ldflags "-s -X github.com/ooclab/ga/version.buildDate=$(BUILD_DATE) -X github.com/ooclab/ga/version.gitCommit=$(VERSION_COMMIT) -X github.com/ooclab/ga/version.gitVersion=$(VERSION)"
STATIC_LDFLAGS=-a -installsuffix cgo $(LDFLAGS)"
PROGRAM_NAME=ga
SUBDIRS := $(wildcard middlewares/*/.)
all: build $(SUBDIRS)
build:
$(GOBUILD) -v $(LDFLAGS) -o $(PROGRAM_NAME)
$(SUBDIRS):
mkdir -pv $(MODULE_PATH)
cd $@ && go build -buildmode=plugin && cp -v *.so $(MODULE_PATH)
build-static:
CGO_ENABLED=0 $(GOBUILD) -v $(STATIC_LDFLAGS) -o $(PROGRAM_NAME)
test:
go test -v --cover ./...
clean:
rm -f *.so ga
.PHONY: all $(SUBDIRS) build test