blob: 991b39d7ce4a40ece383f8ebdce6b0c2c1270eea [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;
38 ${GO_SH} $(quote-single) find / -name 'go' ! -type d -print $(quote-single)
39
Joey Armstrongf863afb2023-03-29 12:08:38 -040040 $(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 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 '** -----------------------------------------------------------------------'
55 $(HIDE)${GO_SH} $(quote-single) \
56 echo ;\
Joey Armstrongf863afb2023-03-29 12:08:38 -040057 set -e -o pipefail; \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040058 set -x ; \
Joey Armstrongf863afb2023-03-29 12:08:38 -040059 for x in ${RELEASE_OS_ARCH}; do \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040060 echo ;\
61 echo "** RELEASE_OS_ARCH: Build arch is $$x"; \
Joey Armstrongf863afb2023-03-29 12:08:38 -040062 OUT_PATH="$(RELEASE_DIR)/$(RELEASE_NAME)-$(subst -dev,_dev,$(VERSION))-$$x"; \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040063 echo ;\
64 echo "** Building: $$OUT_PATH (ENTER)"; \
Joey Armstrongf863afb2023-03-29 12:08:38 -040065 GOOS=$${x%-*} GOARCH=$${x#*-} go build -mod=vendor -v $(LDFLAGS) -o "$$OUT_PATH" cmd/voltctl/voltctl.go; \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040066 echo "** Building: $$OUT_PATH (LEAVE)"; \
Joey Armstrongf863afb2023-03-29 12:08:38 -040067 done \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040068$(quote-single)
Joey Armstrongf863afb2023-03-29 12:08:38 -040069
70 @echo
Joey Armstrong9c6e8082023-04-03 12:19:06 -040071 @echo "** -----------------------------------------------------------------------"
Joey Armstrongf863afb2023-03-29 12:08:38 -040072 @echo '** Post-build, files to release'
Joey Armstrong9c6e8082023-04-03 12:19:06 -040073 @echo "** -----------------------------------------------------------------------"
74 find "$(RELEASE_DIR)" ! -type d -print
75 @echo
76
77## -----------------------------------------------------------------------
78## Intent: Why is go not found reported after
79## -----------------------------------------------------------------------
80docker-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 Armstrongf863afb2023-03-29 12:08:38 -040094
95## -----------------------------------------------------------------------
96## -----------------------------------------------------------------------
97clean ::
98 $(RM) -r "./$(RELEASE_DIR)"
99
100## -----------------------------------------------------------------------
101## -----------------------------------------------------------------------
102help ::
103 @echo ' release-build Cross-compile binaries into a docker mounted filesystem'
104
105$(if $(DEBUG),$(warning LEAVE))
106
107# [EOF]