-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
81 lines (70 loc) · 1.99 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
flags=-ldflags="-s -w"
# flags=-ldflags="-s -w -extldflags -static"
TAG := $(shell git tag | sed -e "s,v,,g" | sort -r | head -n 1)
all: build
build:
ifdef TAG
sed -i -e "s,{{VERSION}},$(TAG),g" main.go
endif
go clean; rm -rf pkg; go build -o mongotools ${flags}
ifdef TAG
sed -i -e "s,$(TAG),{{VERSION}},g" main.go
endif
build_all: build_darwin_amd64 build_darwin_arm64 build_amd64 build_arm64 build_power8 build_windows
build_darwin_amd64:
ifdef TAG
sed -i -e "s,{{VERSION}},$(TAG),g" main.go
endif
go clean; rm -rf pkg mongotools_darwin; GOOS=darwin go build -o mongotools ${flags}
mv mongotools mongotools_darwin_amd64
ifdef TAG
sed -i -e "s,$(TAG),{{VERSION}},g" main.go
endif
build_darwin_arm64:
ifdef TAG
sed -i -e "s,{{VERSION}},$(TAG),g" main.go
endif
go clean; rm -rf pkg mongotools_darwin; GOARCH=arm64 GOOS=darwin go build -o mongotools ${flags}
mv mongotools mongotools_darwin_arm64
ifdef TAG
sed -i -e "s,$(TAG),{{VERSION}},g" main.go
endif
build_amd64:
ifdef TAG
sed -i -e "s,{{VERSION}},$(TAG),g" main.go
endif
go clean; rm -rf pkg mongotools_linux; GOOS=linux go build -o mongotools ${flags}
mv mongotools mongotools_amd64
ifdef TAG
sed -i -e "s,$(TAG),{{VERSION}},g" main.go
endif
build_power8:
ifdef TAG
sed -i -e "s,{{VERSION}},$(TAG),g" main.go
endif
go clean; rm -rf pkg mongotools_power8; GOARCH=ppc64le GOOS=linux go build -o mongotools ${flags}
ifdef TAG
sed -i -e "s,$(TAG),{{VERSION}},g" main.go
endif
mv mongotools mongotools_power8
build_arm64:
ifdef TAG
sed -i -e "s,{{VERSION}},$(TAG),g" main.go
endif
go clean; rm -rf pkg mongotools_arm64; GOARCH=arm64 GOOS=linux go build -o mongotools ${flags}
ifdef TAG
sed -i -e "s,$(TAG),{{VERSION}},g" main.go
endif
mv mongotools mongotools_arm64
build_windows:
ifdef TAG
sed -i -e "s,{{VERSION}},$(TAG),g" main.go
endif
go clean; rm -rf pkg mongotools.exe; GOARCH=amd64 GOOS=windows go build -o mongotools.exe ${flags}
ifdef TAG
sed -i -e "s,$(TAG),{{VERSION}},g" main.go
endif
install:
go install
clean:
go clean; rm -rf pkg