forked from noborus/trdsql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
118 lines (90 loc) · 3.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
VERSION=$(shell git describe --tags 2>/dev/null)
GOCMD=go
TAGS="sqlite_math_functions"
GOGET=$(GOCMD) get
GOCLEAN=$(GOCMD) clean
ifeq ($(strip $(VERSION)),)
LDFLAGS=""
else
LDFLAGS="-X github.com/noborus/trdsql.Version=$(VERSION)"
endif
GOVERSION="1.19.x"
BUILDFLAG=-tags $(TAGS) -ldflags=$(LDFLAGS)
GOBUILD=$(GOCMD) build $(BUILDFLAG)
GOTEST=$(GOCMD) test -tags $(TAGS) ./...
GOINSTALL=$(GOCMD) install $(BUILDFLAG)
XGOCMD=xgo -go $(GOVERSION) $(BUILDFLAG)
DIST_BIN=dist/bin
BINARY_NAME := trdsql
SRCS := $(shell git ls-files '*.go')
all: test build
.PHONY: test
test: $(SRCS)
$(GOTEST)
.PHONY: build
build: trdsql
$(BINARY_NAME): $(SRCS)
$(GOBUILD) -o $(BINARY_NAME) ./cmd/trdsql
.PHONY: install
install:
$(GOINSTALL) ./cmd/trdsql
.PHONY: clean
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -rf dist
dist-clean:
rm -Rf dist/trdsql_*
build-all:
-mkdir dist
-mkdir dist/tmp
-mkdir dist/bin
$(XGOCMD) -dest dist/tmp github.com/noborus/trdsql/cmd/trdsql
find dist/tmp -type f -exec cp {} $(DIST_BIN) \;
DIST_DIRS := find trdsql* -type d -exec
dist: dist-clean build-all linux-amd64 linux-386 linux-arm-5 linux-arm-6 linux-arm-7 linux-arm64 linux-mips linux-mips64 linux-mipsle windows-386 windows-amd64 darwin-amd64 darwin-arm64
cd dist && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../config.json.sample {} \; && \
$(DIST_DIRS) zip -r {}.zip {} \; && \
cd ..
linux-amd64:
mkdir dist/trdsql_$(VERSION)_linux_amd64
cp $(DIST_BIN)/$(BINARY_NAME)-linux-amd64 dist/trdsql_$(VERSION)_linux_amd64/$(BINARY_NAME)
linux-386:
mkdir dist/trdsql_$(VERSION)_linux_386
cp $(DIST_BIN)/$(BINARY_NAME)-linux-386 dist/trdsql_$(VERSION)_linux_386/$(BINARY_NAME)
linux-arm-5:
mkdir dist/trdsql_$(VERSION)_linux_arm5
cp $(DIST_BIN)/$(BINARY_NAME)-linux-arm-5 dist/trdsql_$(VERSION)_linux_arm5/$(BINARY_NAME)
linux-arm-6:
mkdir dist/trdsql_$(VERSION)_linux_arm6
cp $(DIST_BIN)/$(BINARY_NAME)-linux-arm-6 dist/trdsql_$(VERSION)_linux_arm6/$(BINARY_NAME)
linux-arm-7:
mkdir dist/trdsql_$(VERSION)_linux_arm7
cp $(DIST_BIN)/$(BINARY_NAME)-linux-arm-7 dist/trdsql_$(VERSION)_linux_arm7/$(BINARY_NAME)
linux-arm64:
mkdir dist/trdsql_$(VERSION)_linux_arm64
cp $(DIST_BIN)/$(BINARY_NAME)-linux-arm64 dist/trdsql_$(VERSION)_linux_arm64/$(BINARY_NAME)
linux-mips:
mkdir dist/trdsql_$(VERSION)_linux_mips
cp $(DIST_BIN)/$(BINARY_NAME)-linux-mips dist/trdsql_$(VERSION)_linux_mips/$(BINARY_NAME)
linux-mips64:
mkdir dist/trdsql_$(VERSION)_linux_mips64
cp $(DIST_BIN)/$(BINARY_NAME)-linux-mips64 dist/trdsql_$(VERSION)_linux_mips64/$(BINARY_NAME)
linux-mipsle:
mkdir dist/trdsql_$(VERSION)_linux_mipsle
cp $(DIST_BIN)/$(BINARY_NAME)-linux-mipsle dist/trdsql_$(VERSION)_linux_mipsle/$(BINARY_NAME)
windows-386:
mkdir dist/trdsql_$(VERSION)_windows_386
cp $(DIST_BIN)/$(BINARY_NAME)-windows-386.exe dist/trdsql_$(VERSION)_windows_386/$(BINARY_NAME).exe
windows-amd64:
mkdir dist/trdsql_$(VERSION)_windows_amd64
cp $(DIST_BIN)/$(BINARY_NAME)-windows-amd64.exe dist/trdsql_$(VERSION)_windows_amd64/$(BINARY_NAME).exe
darwin-amd64:
mkdir dist/trdsql_$(VERSION)_darwin_amd64
cp $(DIST_BIN)/$(BINARY_NAME)-darwin-amd64 dist/trdsql_$(VERSION)_darwin_amd64/$(BINARY_NAME)
darwin-arm64:
mkdir dist/trdsql_$(VERSION)_darwin_arm64
cp $(DIST_BIN)/$(BINARY_NAME)-darwin-arm64 dist/trdsql_$(VERSION)_darwin_arm64/$(BINARY_NAME)