-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
44 lines (37 loc) · 1.62 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
VERSION=$(shell git describe --tags --always)
go_flags = -ldflags "-w -s -X 'main.Version=$(version)' -X 'main.BuildTime=`date "+%Y-%m-%d %H:%M:%S"`' -X 'main.GoVersion=`go version`' -X 'main.GitRevision=`git rev-parse HEAD`'"
ARMS = 5 6 7
MIPSS = mips mipsle
.PHONY: i b c install build compile clean docker
# short comment
i: install
b: build
c: clean
install:
@go install ${go_flags}
build:
@go build ${go_flags} -o ./bin/gox
compile:
# mac
@GOOS=darwin GOARCH=amd64 go build $(go_flags) -o ./bin/gox_darwin_amd64_${version}
# windows
@GOOS=windows GOARCH=amd64 go build $(go_flags) -o ./bin/gox_windows_amd64_${version}.exe
@GOOS=windows GOARCH=386 go build $(go_flags) -o ./bin/gox_windows_386_${version}.exe
# freebsd
@GOOS=freebsd GOARCH=amd64 go build $(go_flags) -o ./bin/gox_freebsd_amd64_${version}
@GOOS=freebsd GOARCH=386 go build $(go_flags) -o ./bin/gox_freebsd_386_${version}
# linux
@GOOS=linux GOARCH=amd64 go build $(go_flags) -o ./bin/gox_linux_amd64_${version}
@GOOS=linux GOARCH=386 go build $(go_flags) -o ./bin/gox_linux_386_${version}
@for v in ${ARMS}; do \
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=$$v go build $(go_flags) -o ./bin/gox_linux_arm$${v}_${version}; \
done;
@CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build $(go_flags) -o ./bin/gox_linux_arm64_${version}
@for v in ${MIPSS}; do \
CGO_ENABLED=0 GOOS=linux GOARCH=$$v go build $(go_flags) -o ./bin/gox_linux_$${v}_${version}; \
CGO_ENABLED=0 GOOS=linux GOARCH=$$v GOMIPS=softfloat go build $(go_flags) -o ./bin/gox_linux_$${v}_sf_${version}; \
done
clean:
@rm -rf ./bin
docker:
@docker build --build-arg version=$(VERSION) -t gox:$(VERSION) .