blob: da48255a7e458d787a87f03f006099bead8fc31f [file] [log] [blame]
Joey Armstrongf863afb2023-03-29 12:08:38 -04001# -*- makefile -*-
2# -----------------------------------------------------------------------
Joey Armstrong903c69d2024-02-01 19:46:39 -05003# Copyright 2019-2024 Open Networking Foundation (ONF) and the ONF Contributors
Joey Armstrongf863afb2023-03-29 12:08:38 -04004#
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"
Joey Armstrongdd2a0782023-04-04 09:29:48 -040037 # find '/usr/local' '/go' '/usr/bin' '/bin' -name 'go' ! -type d -print;
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 Armstrongdd2a0782023-04-04 09:29:48 -040051 @echo '** Filesystem: docker-container::/app (wanted: release/)'
52 @echo '** -----------------------------------------------------------------------'
53 ${GO_SH} $(quote-single)find /app \( -name ".git" -o -name "vendor" -o -name "makefiles" -o -name "internal" -o -name "pkg" \) -prune -o -print$(quote-single)
54 @echo
55 @echo '** /app/release permissions'
56# ${GO_SH} $(quote-single)umask 022 && chmod 700 /app/release $(quote-single)
57 ${GO_SH} $(quote-single)/bin/ls -ld /app/release $(quote-single)
58
59 @echo
60 @echo '** -----------------------------------------------------------------------'
Joey Armstrongf863afb2023-03-29 12:08:38 -040061 @echo '** Docker builds bins into mounted filesystem:'
62 @echo '** container:/app/relase'
63 @echo '** localhost:{pwd}/release'
Joey Armstrong9c6e8082023-04-03 12:19:06 -040064 @echo '** -----------------------------------------------------------------------'
Joey Armstrongdd2a0782023-04-04 09:29:48 -040065
66# NOTE: Use double quotes in echo strings else command breakage
Joey Armstrong173f2552023-04-04 08:44:21 -040067 ${GO_SH} $(quote-single) \
Joey Armstrongdd2a0782023-04-04 09:29:48 -040068 echo ;\
69 echo "build: ENTER" ;\
Joey Armstrongf863afb2023-03-29 12:08:38 -040070 set -e -o pipefail; \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040071 set -x ; \
Joey Armstrongf863afb2023-03-29 12:08:38 -040072 for x in ${RELEASE_OS_ARCH}; do \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040073 echo ;\
74 echo "** RELEASE_OS_ARCH: Build arch is $$x"; \
Joey Armstrongf863afb2023-03-29 12:08:38 -040075 OUT_PATH="$(RELEASE_DIR)/$(RELEASE_NAME)-$(subst -dev,_dev,$(VERSION))-$$x"; \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040076 echo ;\
77 echo "** Building: $$OUT_PATH (ENTER)"; \
Joey Armstrongf863afb2023-03-29 12:08:38 -040078 GOOS=$${x%-*} GOARCH=$${x#*-} go build -mod=vendor -v $(LDFLAGS) -o "$$OUT_PATH" cmd/voltctl/voltctl.go; \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040079 echo "** Building: $$OUT_PATH (LEAVE)"; \
Joey Armstrongdd2a0782023-04-04 09:29:48 -040080 done ;\
81 echo "build: LEAVE" \
Joey Armstrong9c6e8082023-04-03 12:19:06 -040082$(quote-single)
Joey Armstrongf863afb2023-03-29 12:08:38 -040083
84 @echo
Joey Armstrong9c6e8082023-04-03 12:19:06 -040085 @echo "** -----------------------------------------------------------------------"
Joey Armstrongf863afb2023-03-29 12:08:38 -040086 @echo '** Post-build, files to release'
Joey Armstrong9c6e8082023-04-03 12:19:06 -040087 @echo "** -----------------------------------------------------------------------"
Joey Armstrong9088c892023-04-04 08:07:23 -040088 -find "$(RELEASE_DIR)" ! -type d -print
Joey Armstrong9c6e8082023-04-03 12:19:06 -040089 @echo
90
91## -----------------------------------------------------------------------
92## Intent: Why is go not found reported after
93## -----------------------------------------------------------------------
94docker-debug:
95
96 @echo
97 @echo "** -----------------------------------------------------------------------"
98 @echo "** [TARGET] $@"
99 @echo "** -----------------------------------------------------------------------"
100
101 @echo
102 docker images
103
104 @echo
105 docker ps --all
106
107 @echo
Joey Armstrongf863afb2023-03-29 12:08:38 -0400108
109## -----------------------------------------------------------------------
110## -----------------------------------------------------------------------
111clean ::
112 $(RM) -r "./$(RELEASE_DIR)"
113
114## -----------------------------------------------------------------------
115## -----------------------------------------------------------------------
116help ::
117 @echo ' release-build Cross-compile binaries into a docker mounted filesystem'
118
119$(if $(DEBUG),$(warning LEAVE))
120
121# [EOF]