Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
| 3 | # Copyright 2019-2023 Open Networking Foundation |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # ----------------------------------------------------------------------- |
| 17 | |
| 18 | $(if $(DEBUG),$(warning ENTER)) |
| 19 | |
| 20 | ## ----------------------------------------------------------------------- |
| 21 | ## Intent: |
| 22 | ## o Generate volctl binaries in a docker container container |
| 23 | ## o Copy container:/apps/release to localhost:{pwd}/release |
| 24 | ## ----------------------------------------------------------------------- |
| 25 | ## [TODO] Replace ${GO_SH} $(single-quote) .. with $(call quoted,cmd-text) |
| 26 | ## ----------------------------------------------------------------------- |
| 27 | release-build : |
| 28 | |
| 29 | @echo |
| 30 | @echo "** -----------------------------------------------------------------------" |
| 31 | @echo "** $(MAKE): processing target [$@]" |
| 32 | @echo "** Sandbox: $(shell /bin/pwd)" |
| 33 | @echo "** -----------------------------------------------------------------------" |
| 34 | |
| 35 | @echo -e "\n** golang attributes" |
| 36 | $(HIDE)${GO_SH} $(call quoted,which$(space)-a$(space)go) |
| 37 | $(HIDE)${GO_SH} $(call quoted,go$(space)version) |
| 38 | |
| 39 | @echo -e "\n** Create filesystem target for docker volume: $(RELEASE_DIR)" |
| 40 | $(RM) -r "./$(RELEASE_DIR)" |
| 41 | mkdir -vp "$(RELEASE_DIR)" |
| 42 | |
| 43 | @echo |
| 44 | @echo '** Docker builds bins into mounted filesystem:' |
| 45 | @echo '** container:/app/relase' |
| 46 | @echo '** localhost:{pwd}/release' |
| 47 | @${GO_SH} $(single-quote) \ |
| 48 | set -e -o pipefail; \ |
| 49 | for x in ${RELEASE_OS_ARCH}; do \ |
| 50 | OUT_PATH="$(RELEASE_DIR)/$(RELEASE_NAME)-$(subst -dev,_dev,$(VERSION))-$$x"; \ |
| 51 | echo "$$OUT_PATH"; \ |
| 52 | GOOS=$${x%-*} GOARCH=$${x#*-} go build -mod=vendor -v $(LDFLAGS) -o "$$OUT_PATH" cmd/voltctl/voltctl.go; \ |
| 53 | done \ |
| 54 | $(single-quote) |
| 55 | |
| 56 | @echo |
| 57 | @echo '** Post-build, files to release' |
| 58 | $(HIDE)find "$(RELEASE_DIR)" ! -type d -print |
| 59 | |
| 60 | ## ----------------------------------------------------------------------- |
| 61 | ## ----------------------------------------------------------------------- |
| 62 | clean :: |
| 63 | $(RM) -r "./$(RELEASE_DIR)" |
| 64 | |
| 65 | ## ----------------------------------------------------------------------- |
| 66 | ## ----------------------------------------------------------------------- |
| 67 | help :: |
| 68 | @echo ' release-build Cross-compile binaries into a docker mounted filesystem' |
| 69 | |
| 70 | $(if $(DEBUG),$(warning LEAVE)) |
| 71 | |
| 72 | # [EOF] |