blob: 41a1f418c299ce8f7bb9e833e611fb2b74e1be06 [file] [log] [blame]
Joey Armstrongf863afb2023-03-29 12:08:38 -04001# -*- 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 Armstrong9c6e8082023-04-03 12:19:06 -040025## [TODO] Replace ${GO_SH} $(quote-single) .. with $(call quoted,cmd-text)
Joey Armstrongf863afb2023-03-29 12:08:38 -040026## -----------------------------------------------------------------------
27release-build :
28
29 @echo
30 @echo "** -----------------------------------------------------------------------"
31 @echo "** $(MAKE): processing target [$@]"
32 @echo "** Sandbox: $(shell /bin/pwd)"
33 @echo "** -----------------------------------------------------------------------"
34
Joey Armstrong9c6e8082023-04-03 12:19:06 -040035 # [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;
Joey Armstrong9088c892023-04-04 08:07:23 -040038 # -${GO_SH} $(quote-single) find / -name 'go' ! -type d -print $(quote-single)
Joey Armstrong9c6e8082023-04-03 12:19:06 -040039
Joey Armstrong9088c892023-04-04 08:07:23 -040040 -$(HIDE)${GO_SH} $(call quoted,which$(space)-a$(space)go)
41 -$(HIDE)${GO_SH} $(call quoted,go$(space)version)
Joey Armstrongf863afb2023-03-29 12:08:38 -040042
43 @echo -e "\n** Create filesystem target for docker volume: $(RELEASE_DIR)"
44 $(RM) -r "./$(RELEASE_DIR)"
45 mkdir -vp "$(RELEASE_DIR)"
46
Joey Armstrong9c6e8082023-04-03 12:19:06 -040047 $(MAKE) docker-debug
48
Joey Armstrongf863afb2023-03-29 12:08:38 -040049 @echo
Joey Armstrong9c6e8082023-04-03 12:19:06 -040050 @echo '** -----------------------------------------------------------------------'
Joey Armstrongf863afb2023-03-29 12:08:38 -040051 @echo '** Docker builds bins into mounted filesystem:'
52 @echo '** container:/app/relase'
53 @echo '** localhost:{pwd}/release'
Joey Armstrong9c6e8082023-04-03 12:19:06 -040054 @echo '** -----------------------------------------------------------------------'
Joey Armstrong173f2552023-04-04 08:44:21 -040055 ${GO_SH} $(quote-single) \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040056 echo ;\
Joey Armstrong173f2552023-04-04 08:44:21 -040057 echo 'Building release binaries:' ;\
Joey Armstrongf863afb2023-03-29 12:08:38 -040058 set -e -o pipefail; \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040059 set -x ; \
Joey Armstrongf863afb2023-03-29 12:08:38 -040060 for x in ${RELEASE_OS_ARCH}; do \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040061 echo ;\
62 echo "** RELEASE_OS_ARCH: Build arch is $$x"; \
Joey Armstrongf863afb2023-03-29 12:08:38 -040063 OUT_PATH="$(RELEASE_DIR)/$(RELEASE_NAME)-$(subst -dev,_dev,$(VERSION))-$$x"; \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040064 echo ;\
65 echo "** Building: $$OUT_PATH (ENTER)"; \
Joey Armstrongf863afb2023-03-29 12:08:38 -040066 GOOS=$${x%-*} GOARCH=$${x#*-} go build -mod=vendor -v $(LDFLAGS) -o "$$OUT_PATH" cmd/voltctl/voltctl.go; \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040067 echo "** Building: $$OUT_PATH (LEAVE)"; \
Joey Armstrongf863afb2023-03-29 12:08:38 -040068 done \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040069$(quote-single)
Joey Armstrongf863afb2023-03-29 12:08:38 -040070
71 @echo
Joey Armstrong9c6e8082023-04-03 12:19:06 -040072 @echo "** -----------------------------------------------------------------------"
Joey Armstrongf863afb2023-03-29 12:08:38 -040073 @echo '** Post-build, files to release'
Joey Armstrong9c6e8082023-04-03 12:19:06 -040074 @echo "** -----------------------------------------------------------------------"
Joey Armstrong9088c892023-04-04 08:07:23 -040075 -find "$(RELEASE_DIR)" ! -type d -print
Joey Armstrong9c6e8082023-04-03 12:19:06 -040076 @echo
77
78## -----------------------------------------------------------------------
79## Intent: Why is go not found reported after
80## -----------------------------------------------------------------------
81docker-debug:
82
83 @echo
84 @echo "** -----------------------------------------------------------------------"
85 @echo "** [TARGET] $@"
86 @echo "** -----------------------------------------------------------------------"
87
88 @echo
89 docker images
90
91 @echo
92 docker ps --all
93
94 @echo
Joey Armstrongf863afb2023-03-29 12:08:38 -040095
96## -----------------------------------------------------------------------
97## -----------------------------------------------------------------------
98clean ::
99 $(RM) -r "./$(RELEASE_DIR)"
100
101## -----------------------------------------------------------------------
102## -----------------------------------------------------------------------
103help ::
104 @echo ' release-build Cross-compile binaries into a docker mounted filesystem'
105
106$(if $(DEBUG),$(warning LEAVE))
107
108# [EOF]