-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
28 lines (22 loc) · 1.18 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
SHELL := /bin/bash
BASEDIR = $(shell pwd)
export GO111MODULE=on
export GOPROXY=https://goproxy.io
# build with verison infos
versionDir = "github.com/cheerego/docker-wrapper/cmd"
gitTag = $(shell if [ "`git describe --tags --abbrev=0 2>/dev/null`" != "" ];then git describe --tags --abbrev=0; else git log --pretty=format:'%h' -n 1; fi)
buildDate = $(shell TZ=Asia/Shanghai date +%FT%T%z)
gitCommit = $(shell git log --pretty=format:'%H' -n 1)
gitTreeState = $(shell if git status|grep -q 'clean';then echo clean; else echo dirty; fi)
ldflags="-w -X ${versionDir}.GitTag=${gitTag} -X ${versionDir}.BuildDate=${buildDate} -X ${versionDir}.GitCommit=${gitCommit} -X ${versionDir}.GitTreeState=${gitTreeState}"
all:clean fmt
@CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o dist/amd64/darwin/docker-wrapper -v -ldflags ${ldflags} .
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o dist/amd64/linux/docker-wrapper -v -ldflags ${ldflags} .
@CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o dist/amd64/windows/docker-wrapper.exe -v -ldflags ${ldflags} .
clean:
rm -rf dist
fmt:
gofmt -w .
help:
@echo "make - compile the source code"
@echo "make clean - remove binary file and vim swp files"