2018-01-23 05:53:31 +00:00
|
|
|
# https://golang.org/doc/install/source#environment
|
2018-01-22 09:17:38 +00:00
|
|
|
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}')
|
2018-01-23 05:53:31 +00:00
|
|
|
OSS = darwin dragonfly freebsd linux netbsd openbsd plan9 solaris windows
|
|
|
|
PKG =
|
|
|
|
# ifeq ($(strip $(GOOS)), windows)
|
|
|
|
# GOARCH := $(strip $(GOARCH)).exe
|
|
|
|
# endif
|
2018-01-22 09:17:38 +00:00
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
build:
|
2018-01-23 05:53:31 +00:00
|
|
|
@ go build -ldflags "-s -w" -o JetBrainsLicenseServer_$(strip $(GOOS))_$(strip $(if \
|
|
|
|
$(findstring windows,$(GOOS)),\
|
|
|
|
$(strip $(GOARCH)).exe,\
|
|
|
|
$(strip $(GOARCH))\
|
|
|
|
))
|
2018-01-22 09:17:38 +00:00
|
|
|
|
|
|
|
.PHONY: amd64
|
|
|
|
amd64:
|
2018-01-23 05:53:31 +00:00
|
|
|
@ $(foreach OS,\
|
|
|
|
$(OSS),\
|
|
|
|
$(shell CGO_ENABLED=0 GOOS=$(OS) GOARCH=amd64 go build -ldflags "-s -w" -o JetBrainsLicenseServer_$(OS)_amd64$(if $(findstring windows,$(OS)),.exe)))
|
|
|
|
@ echo done
|
2018-01-22 09:17:38 +00:00
|
|
|
|
|
|
|
.PHONY: 386
|
|
|
|
386:
|
2018-01-23 05:53:31 +00:00
|
|
|
@ $(foreach OS,\
|
|
|
|
$(OSS),\
|
|
|
|
$(shell CGO_ENABLED=0 GOOS=$(OS) GOARCH=386 go build -ldflags "-s -w" -o JetBrainsLicenseServer_$(OS)_386$(if $(findstring windows,$(OS)),.exe)))
|
|
|
|
@ echo done
|
2018-01-22 09:17:38 +00:00
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2018-01-23 07:59:55 +00:00
|
|
|
@ rm -rf JetBrainsLicenseServer* jbls
|
2018-01-22 09:17:38 +00:00
|
|
|
|
|
|
|
# 压缩。需要安装 https://github.com/upx/upx
|
|
|
|
.PHONY: upx
|
|
|
|
upx:
|
2018-01-23 05:53:31 +00:00
|
|
|
@ upx $(if $(PKG),$(PKG),JetBrainsLicenseServer*)
|