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 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 25 | ## [TODO] Replace ${GO_SH} $(quote-single) .. with $(call quoted,cmd-text) |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 26 | ## ----------------------------------------------------------------------- |
| 27 | release-build : |
| 28 | |
| 29 | @echo |
| 30 | @echo "** -----------------------------------------------------------------------" |
| 31 | @echo "** $(MAKE): processing target [$@]" |
| 32 | @echo "** Sandbox: $(shell /bin/pwd)" |
| 33 | @echo "** -----------------------------------------------------------------------" |
| 34 | |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 35 | # [DEBUG] Yes this will take a while but where-4-art-thou-golang-in-docker-image-(?) |
| 36 | @echo -e "\n** golang interpreter" |
| 37 | # find '/usr/local' '/go' '/usr/bin' '/bin' -name 'go' ! -type d -ls; |
| 38 | ${GO_SH} $(quote-single) find / -name 'go' ! -type d -print $(quote-single) |
| 39 | |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 40 | $(HIDE)${GO_SH} $(call quoted,which$(space)-a$(space)go) |
| 41 | $(HIDE)${GO_SH} $(call quoted,go$(space)version) |
| 42 | |
| 43 | @echo -e "\n** Create filesystem target for docker volume: $(RELEASE_DIR)" |
| 44 | $(RM) -r "./$(RELEASE_DIR)" |
| 45 | mkdir -vp "$(RELEASE_DIR)" |
| 46 | |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 47 | $(MAKE) docker-debug |
| 48 | |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 49 | @echo |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 50 | @echo '** -----------------------------------------------------------------------' |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 51 | @echo '** Docker builds bins into mounted filesystem:' |
| 52 | @echo '** container:/app/relase' |
| 53 | @echo '** localhost:{pwd}/release' |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 54 | @echo '** -----------------------------------------------------------------------' |
| 55 | $(HIDE)${GO_SH} $(quote-single) \ |
| 56 | echo ;\ |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 57 | set -e -o pipefail; \ |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 58 | set -x ; \ |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 59 | for x in ${RELEASE_OS_ARCH}; do \ |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 60 | echo ;\ |
| 61 | echo "** RELEASE_OS_ARCH: Build arch is $$x"; \ |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 62 | OUT_PATH="$(RELEASE_DIR)/$(RELEASE_NAME)-$(subst -dev,_dev,$(VERSION))-$$x"; \ |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 63 | echo ;\ |
| 64 | echo "** Building: $$OUT_PATH (ENTER)"; \ |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 65 | GOOS=$${x%-*} GOARCH=$${x#*-} go build -mod=vendor -v $(LDFLAGS) -o "$$OUT_PATH" cmd/voltctl/voltctl.go; \ |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 66 | echo "** Building: $$OUT_PATH (LEAVE)"; \ |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 67 | done \ |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 68 | $(quote-single) |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 69 | |
| 70 | @echo |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 71 | @echo "** -----------------------------------------------------------------------" |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 72 | @echo '** Post-build, files to release' |
Joey Armstrong | 9c6e808 | 2023-04-03 12:19:06 -0400 | [diff] [blame] | 73 | @echo "** -----------------------------------------------------------------------" |
| 74 | find "$(RELEASE_DIR)" ! -type d -print |
| 75 | @echo |
| 76 | |
| 77 | ## ----------------------------------------------------------------------- |
| 78 | ## Intent: Why is go not found reported after |
| 79 | ## ----------------------------------------------------------------------- |
| 80 | docker-debug: |
| 81 | |
| 82 | @echo |
| 83 | @echo "** -----------------------------------------------------------------------" |
| 84 | @echo "** [TARGET] $@" |
| 85 | @echo "** -----------------------------------------------------------------------" |
| 86 | |
| 87 | @echo |
| 88 | docker images |
| 89 | |
| 90 | @echo |
| 91 | docker ps --all |
| 92 | |
| 93 | @echo |
Joey Armstrong | f863afb | 2023-03-29 12:08:38 -0400 | [diff] [blame] | 94 | |
| 95 | ## ----------------------------------------------------------------------- |
| 96 | ## ----------------------------------------------------------------------- |
| 97 | clean :: |
| 98 | $(RM) -r "./$(RELEASE_DIR)" |
| 99 | |
| 100 | ## ----------------------------------------------------------------------- |
| 101 | ## ----------------------------------------------------------------------- |
| 102 | help :: |
| 103 | @echo ' release-build Cross-compile binaries into a docker mounted filesystem' |
| 104 | |
| 105 | $(if $(DEBUG),$(warning LEAVE)) |
| 106 | |
| 107 | # [EOF] |