From fa0a8c0301d82d792770c6edeb8b8d51f5b3da75 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 13 May 2023 18:02:53 +0200 Subject: [PATCH] Fix building on macOS The Makefile was hard-coded to some GNU/Linux specific commands and arguments: - `cp -u` does not exist on macOS (and possible BSD either). Likely, the rsync is already used in other steps, so we can use it in place of `co -u` as well. - On macOS there is no sma256sum command. Not by default, anyway. While it is probably available via installing core utils via brew, this is quite big package which could cause other issues, so it is not really no-brainer to install. This is solved by detecting availability of sha256sum command and using `shasum -a 256` if the former is not available. --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 284eb3a..611ebc6 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,11 @@ STATIC_OUT := ${OUT}-${VERSION} PACKAGE_PATH := dist/${OUT}-${VERSION} BUILDOPTS := +SHA256_CMD = sha256sum +ifeq (, $(shell which $(SHA256_CMD))) + SHA256_CMD = shasum -a 256 +endif + server: go build -v -o ${OUT} -ldflags="-X main.applicationVersion=${VERSION}" ${BUILDOPTS} ${PKG} @@ -84,12 +89,12 @@ _prepare_package: rm -rf ${PACKAGE_PATH} mkdir -p ${PACKAGE_PATH} rsync ui json_schemas ${PACKAGE_PATH}/ -a --delete-after - cp -ua README.md LICENSE.txt ${PACKAGE_PATH}/ + rsync -ua README.md LICENSE.txt ${PACKAGE_PATH}/ _finish_package: rm -r ${PACKAGE_PATH} rm -f ${PACKAGE_PATH}.sha256 - sha256sum ${PACKAGE_PATH}* | tee ${PACKAGE_PATH}.sha256 + $(SHA256_CMD) ${PACKAGE_PATH}* | tee ${PACKAGE_PATH}.sha256 _package_tar: static tar -C $(dir ${PACKAGE_PATH}) -zcf $(PWD)/${PACKAGE_PATH}-${GOOS}.tar.gz $(notdir ${PACKAGE_PATH}) -- 2.30.2