2222# immunities granted to it by virtue of its status as an
2323# Intergovernmental Organization or submit itself to any jurisdiction.
2424
25- VERSION := 0.6
25+ include VERSION
26+
2627BUILD := ` git rev-parse --short HEAD `
2728
2829ROOT_DIR: =$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST ) ) ) )
@@ -37,11 +38,20 @@ VERBOSE_1 := -v
3738VERBOSE_2 := -v -x
3839
3940WHAT := o2control-core o2control-executor coconut peanut
41+ WHAT_o2control-core_BUILD_FLAGS =$(CGO_LDFLAGS ) $(BUILD_ENV_FLAGS )
42+ WHAT_o2control-executor_BUILD_FLAGS =$(CGO_LDFLAGS ) $(BUILD_ENV_FLAGS )
43+ WHAT_coconut_BUILD_FLAGS =$(CGO_LDFLAGS ) $(BUILD_ENV_FLAGS )
44+ WHAT_peanut_BUILD_FLAGS =$(CGO_LDFLAGS ) $(BUILD_ENV_FLAGS )
45+
46+ INSTALL_WHAT: =$(patsubst % , install_% , $(WHAT ) )
47+
48+
4049GENERATE_DIRS := ./core ./executor ./coconut/cmd
4150SRC_DIRS := ./cmd/* ./core ./coconut ./executor ./common ./configuration ./occ/peanut
4251
4352# Use linker flags to provide version/build settings to the target
44- LDFLAGS =-ldflags "-X=$(REPOPATH ) .Version=$(VERSION ) -X=$(REPOPATH ) .Build=$(BUILD ) "
53+ PROD :=-X=$(REPOPATH ) /common/product
54+ LDFLAGS =-ldflags "$(PROD ) .VERSION_MAJOR=$(VERSION_MAJOR ) $(PROD ) .VERSION_MINOR=$(VERSION_MINOR ) $(PROD ) .VERSION_PATCH=$(VERSION_PATCH ) $(PROD ) .BUILD=$(BUILD ) "
4555HAS_GOGOPROTO := $(shell command -v protoc-gen-gofast 2> /dev/null)
4656
4757GO_GET_U1 := $(addprefix github.com/gogo/protobuf/, proto protoc-gen-gofast protoc-gen-gogofast protoc-gen-gogofaster protoc-gen-gogoslick gogoproto)
@@ -54,16 +64,25 @@ build: $(WHAT)
5464
5565all : vendor generate build
5666
57- install :
58- @for w in $(WHAT ) ; do \
59- echo -e " \e[1;33mgo install\e[0m ./cmd/$$ w \e[1;33m==>\e[0m \e[1;34m$$ GOPATH/bin/$$ w\e[0m" ; \
60- $(BUILD_FLAGS ) go install $(VERBOSE_$(V ) ) $(LDFLAGS ) ./cmd/$$ w; \
61- done
67+ install : $(INSTALL_WHAT )
68+ # @for w in $(WHAT); do \
69+ # FLAGS="WHAT_$${w}_BUILD_FLAGS"; \
70+ # echo -e "${$${FLAGS}}"; \
71+ # echo -e "\e[1;33mgo install\e[0m ./cmd/$$w \e[1;33m==>\e[0m \e[1;34m$$GOPATH/bin/$$w\e[0m"; \
72+ # $(WHAT_$${w}_BUILD_FLAGS) go install $(VERBOSE_$(V)) $(LDFLAGS) ./cmd/$$w; \
73+ # done
6274
6375$(WHAT ) :
64- @echo -e " \e[1;33m$( BUILD_FLAGS) go build\e[0m ./cmd/$@ \e[1;33m==>\e[0m \e[1;34m./bin/$@ \e[0m"
76+ # @echo -e "WHAT_$@_BUILD_FLAGS $(WHAT_$@_BUILD_FLAGS)"
77+ @echo -e "\e[1;33m$(WHAT_$@_BUILD_FLAGS) go build\e[0m ./cmd/$@ \e[1;33m==>\e[0m \e[1;34m./bin/$@\e[0m"
78+ # @echo ${PWD}
79+ @$(WHAT_$@_BUILD_FLAGS) go build $(VERBOSE_$(V)) -o bin/$@ $(LDFLAGS) ./cmd/$@
80+
81+ $(INSTALL_WHAT ) :
82+ # @echo -e "WHAT_$(@:install_%=%)_BUILD_FLAGS $(WHAT_$(@:install_%=%)_BUILD_FLAGS)"
83+ @echo -e "\e[1;33m$(WHAT_$(@:install_%=%)_BUILD_FLAGS) go install\e[0m ./cmd/$(@:install_%=%) \e[1;33m==>\e[0m \e[1;34m$$GOPATH/bin/$(@:install_%=%)\e[0m"
6584# @echo ${PWD}
66- @$(BUILD_FLAGS) go build $(VERBOSE_$(V)) -o bin/$@ $ (LDFLAGS) ./cmd/$@
85+ @$(WHAT_$(@:install_%=%)_BUILD_FLAGS) go install $(VERBOSE_$(V)) $ (LDFLAGS) ./cmd/$(@:install_%=%)
6786
6887generate :
6988ifndef HAS_GOGOPROTO
0 commit comments