enable go-build on multi-platform
@@ -37,6 +37,23 @@ else
args=$@
fi
+PLATFORM=$(uname -m)
+case ${PLATFORM} in
+x86_64* | i?86_64* | amd64*)
+ ARCH="amd64"
+ ;;
+ppc64le)
+ ARCH="ppc64le"
+ ;;
+aarch64* | arm64*)
+ ARCH="arm64"
+ ;;
+*)
+ echo "invalid Arch, only support x86_64, ppc64le, aarch64"
+ exit 1
+ ;;
+esac
+
# forward all commands to all packages if no specific one was requested
# TODO finetune this a little bit more
if [ $# -eq 0 ]; then
@@ -98,19 +115,19 @@ for arg in $args; do
cd $arg
- # always build and link the linux/amd64 binary
- LINUX_NAME=${ARCH_BASENAME}-linux-amd64
+ # always build and link the binary based on CPU Architecture
+ LINUX_NAME=${ARCH_BASENAME}-linux-${ARCH}
echo "building dynamic binary $BIN_NAME"
- GOOS=linux GOARCH=amd64 go_build -tags selinux -i -o ${CMD_OUT_DIR}/${BIN_NAME}/${LINUX_NAME} -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir linux amd64)
+ GOOS=linux GOARCH=${ARCH} go_build -tags selinux -i -o ${CMD_OUT_DIR}/${BIN_NAME}/${LINUX_NAME} -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir linux ${ARCH})
(cd ${CMD_OUT_DIR}/${BIN_NAME} && ln -sf ${LINUX_NAME} ${BIN_NAME})
kubevirt::version::get_version_vars
echo "$KUBEVIRT_GIT_VERSION" >${CMD_OUT_DIR}/${BIN_NAME}/.version
- # build virtctl also for darwin and windows
- if [ "${BIN_NAME}" = "virtctl" ]; then
+ # build virtctl also for darwin and windows on amd64
+ if [ "${BIN_NAME}" = "virtctl" -a "${ARCH}" = "amd64" ]; then
GOOS=darwin GOARCH=amd64 go_build -i -o ${CMD_OUT_DIR}/${BIN_NAME}/${ARCH_BASENAME}-darwin-amd64 -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir darwin amd64)
GOOS=windows GOARCH=amd64 go_build -i -o ${CMD_OUT_DIR}/${BIN_NAME}/${ARCH_BASENAME}-windows-amd64.exe -ldflags "$(kubevirt::version::ldflags)" $(pkg_dir windows amd64)
# Create symlinks to the latest binary of each architecture
