You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
994 B

4 years ago
  1. .PHONY: build
  2. SERVICE := zinx
  3. CUR_PWD := $(shell pwd)
  4. SERVER_DEMO_PATH := $(CUR_PWD)/examples/zinx_server
  5. CLIENT_DEMO_PATH := $(CUR_PWD)/examples/zinx_client
  6. SERVER_DEMO_BIN := $(SERVER_DEMO_PATH)/server
  7. CLIENT_DEMO_BIN := $(CLIENT_DEMO_PATH)/client
  8. AUTHOR := $(shell git log --pretty=format:"%an"|head -n 1)
  9. VERSION := $(shell git rev-list HEAD | head -1)
  10. BUILD_INFO := $(shell git log --pretty=format:"%s" | head -1)
  11. BUILD_DATE := $(shell date +%Y-%m-%d\ %H:%M:%S)
  12. export GO111MODULE=on
  13. LD_FLAGS='-X "$(SERVICE)/version.TAG=$(TAG)" -X "$(SERVICE)/version.VERSION=$(VERSION)" -X "$(SERVICE)/version.AUTHOR=$(AUTHOR)" -X "$(SERVICE)/version.BUILD_INFO=$(BUILD_INFO)" -X "$(SERVICE)/version.BUILD_DATE=$(BUILD_DATE)"'
  14. default: build
  15. build:
  16. go build -ldflags $(LD_FLAGS) -gcflags "-N" -o $(SERVER_DEMO_BIN) $(SERVER_DEMO_PATH)/main.go
  17. go build -ldflags $(LD_FLAGS) -gcflags "-N" -o $(CLIENT_DEMO_BIN) $(CLIENT_DEMO_PATH)/main.go
  18. clean:
  19. rm $(SERVER_DEMO_BIN)
  20. rm $(CLIENT_DEMO_BIN)