yunion.io/x/cloudmux@v0.3.10-0-alpha.1/Makefile (about) 1 ROOT_DIR := $(CURDIR) 2 BUILD_DIR := $(ROOT_DIR)/_output 3 BIN_DIR := $(BUILD_DIR)/bin 4 REPO_PREFIX := yunion.io/x/cloudmux 5 VERSION_PKG := yunion.io/x/pkg/util/version 6 7 output_dir: 8 @mkdir -p $(BUILD_DIR) 9 10 bin_dir: output_dir 11 @mkdir -p $(BUILD_DIR)/bin 12 13 prepare_dir: bin_dir 14 15 GIT_COMMIT := $(shell git rev-parse --short HEAD) 16 GIT_BRANCH := $(shell git branch -r --contains | head -1 | sed -E -e "s%(HEAD ->|origin|upstream)/?%%g" | xargs) 17 GIT_VERSION := $(shell git describe --always --tags --abbrev=14 $(GIT_COMMIT)^{commit}) 18 GIT_TREE_STATE := $(shell s=`git status --porcelain 2>/dev/null`; if [ -z "$$s" ]; then echo "clean"; else echo "dirty"; fi) 19 BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ') 20 21 LDFLAGS := "-w \ 22 -X $(VERSION_PKG).gitVersion=$(GIT_VERSION) \ 23 -X $(VERSION_PKG).gitCommit=$(GIT_COMMIT) \ 24 -X $(VERSION_PKG).gitBranch=$(GIT_BRANCH) \ 25 -X $(VERSION_PKG).buildDate=$(BUILD_DATE) \ 26 -X $(VERSION_PKG).gitTreeState=$(GIT_TREE_STATE) \ 27 -X $(VERSION_PKG).gitMajor=0 \ 28 -X $(VERSION_PKG).gitMinor=0" 29 30 ifneq ($(DLV),) 31 GO_BUILD_FLAGS += -gcflags "all=-N -l" 32 LDFLAGS = "" 33 endif 34 # GO_BUILD_FLAGS+=-mod vendor -ldflags $(LDFLAGS) 35 GO_BUILD_FLAGS+=-ldflags $(LDFLAGS) 36 GO_BUILD := go build $(GO_BUILD_FLAGS) 37 38 cmd/%: prepare_dir 39 $(GO_BUILD) -o $(BIN_DIR)/$(shell basename $@) $(REPO_PREFIX)/$@