From 751cb03639699f08345e8280b78bcec07c7a27a5 Mon Sep 17 00:00:00 2001 From: Javier Ruano <34353851+JavierRuano@users.noreply.github.com> Date: Sun, 30 Jun 2024 22:08:09 +0200 Subject: [PATCH] Update Makefile fix make uninstall is very destructive and coreutils https://github.com/rockymadden/somafm-cli/issues/20#issue-1473944332 --- Makefile | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 50b5bdd..0e5e205 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,22 @@ .DEFAULT_GOAL := stub +#### Installation directories bindir ?= ./build/bin logdir ?= ./build/var/log + uname := $(shell uname -s) +coreutils := $(shell brew list coreutils 2>/dev/null) clean: | uninstall install: | stub @rsync -a src/ ${bindir}/ -ifeq (${uname}, Darwin) + + +ifeq (${uname}, Darwin) +ifndef coreutils + $(error The 'coreutils' package is required for this operation. https://www.gnu.org/software/coreutils/. \ + Please install it. brew install coretutils)); +endif @$(eval _bindir := $(shell greadlink -f ${bindir})) @$(eval _logdir := $(shell greadlink -f ${logdir})) @sed -i '' "s|bindir=|bindir=${_bindir}|g" ${bindir}/somafm @@ -32,7 +41,9 @@ test-unit: | install @bats test/unit uninstall: - @rm -rf ${bindir} - @rm -rf ${logdir} + @if test -f ${bindir}/somafm; then rm ${bindir}/somafm; fi + @if test -f ${logdir}/somafm.bats.logs; then rm ${logdir}/somafm.bats.logs; fi + @if [ "$(ls -A $bindir)" ]; then rm -rf ${bindir}; fi + @if [ "$(ls -A $logdir)" ]; then rm -rf ${logdir}; fi .PHONY: clean install stub test test-integration test-unit uninstall