jwt/Makefile

55 lines
1.5 KiB
Makefile
Raw Normal View History

2018-04-13 14:39:01 +00:00
.PHONY: default init build install release dep get_deps clean build_amd64 build_386 upx
2018-03-27 08:18:23 +00:00
# https://golang.org/doc/install/source#environment
GOOS := $(shell go env | awk -F= '$$1=="GOOS" {print $$2}' | awk -F '"' '{print $$2}') # 此处 awk 需使用两个 $
GOARCH := $(shell go env | awk -F= '$$1=="GOARCH" {print $$2}' | awk -F '"' '{print $$2}')
OSS = darwin dragonfly freebsd linux netbsd openbsd plan9 solaris windows
PKG =
# ifeq ($(strip $(GOOS)), windows)
# GOARCH := $(strip $(GOARCH)).exe
# endif
2018-04-13 14:39:01 +00:00
default:
@echo "JWT info: please choose a target for 'make'"
@echo "available target: init build install release dep get_deps clean build_amd64 build_386 upx"
init: get-deps dep clean
go install -ldflags "-s -w"
2018-03-27 08:18:23 +00:00
build:
@ go build -ldflags "-s -w" -o dist/jwt_$(strip $(GOOS))_$(strip $(if \
$(findstring windows,$(GOOS)),\
$(strip $(GOARCH)).exe,\
$(strip $(GOARCH))\
))
2018-04-13 14:39:01 +00:00
install:
go install -ldflags "-s -w"
2018-07-31 09:13:00 +00:00
release: build_amd64 build_386 upx
2018-04-13 14:39:01 +00:00
dep:
dep ensure
get_deps:
go get -u github.com/golang/dep/cmd/dep
clean:
go clean -i
2018-07-31 09:13:00 +00:00
rm -rf dist/jwt* jwt*
2018-04-13 14:39:01 +00:00
build_amd64:
2018-03-27 08:18:23 +00:00
@ $(foreach OS,\
$(OSS),\
$(shell CGO_ENABLED=0 GOOS=$(OS) GOARCH=amd64 go build -ldflags "-s -w" -o dist/jwt_$(OS)_amd64$(if $(findstring windows,$(OS)),.exe)))
@ echo done
2018-04-13 14:39:01 +00:00
build_386:
2018-03-27 08:18:23 +00:00
@ $(foreach OS,\
$(OSS),\
$(shell CGO_ENABLED=0 GOOS=$(OS) GOARCH=386 go build -ldflags "-s -w" -o dist/jwt_$(OS)_386$(if $(findstring windows,$(OS)),.exe)))
@ echo done
# 压缩。需要安装 https://github.com/upx/upx
upx:
2018-04-13 14:39:01 +00:00
upx $(if $(PKG),$(PKG),dist/jwt*)