-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
42 lines (32 loc) · 866 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
# Go parameters
GOCMD = go
GOBUILD = $(GOCMD) build -ldflags ${LDFLAGS}
GOCLEAN = $(GOCMD) clean
GOTEST = $(GOCMD) test
BINARY_NAME = binlog2sql_go
BINARY_UNIX = $(BINARY_NAME)
VERSION = $(shell git describe --tags --always)
GIT_COMMIT = $(shell git rev-parse --short HEAD)
BUILD_TIME = $(shell date -R)
define LDFLAGS
"-X 'binlog2sql_go/conf.version=${VERSION}'\
-X 'binlog2sql_go/conf.gitCommit=${GIT_COMMIT}'\
-X 'binlog2sql_go/conf.buildTime=$(BUILD_TIME)'"
endef
all: test build
build:
$(GOBUILD) -o $(BINARY_NAME) -v
build-macos-amd64:
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BINARY_NAME) -v
test:
$(GOTEST) -v ./...
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f $(BINARY_UNIX)
run:
$(GOBUILD) -o $(BINARY_NAME) -v ./...
./$(BINARY_NAME)
# Cross compilation
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -v