From 5758a96da702242a347548563647c3be49e2002b Mon Sep 17 00:00:00 2001 From: Tronje Krop Date: Wed, 30 Oct 2024 16:48:54 +0100 Subject: [PATCH] fix: macos compatibility (#111) Signed-off-by: Tronje Krop --- .github/workflows/build.yaml | 28 +++++++++++++++++++++++++--- config/Makefile.base | 26 +++++++++++++++----------- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index fea9c11..1c74345 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -62,11 +62,32 @@ jobs: version: 9 - name: Run Bash compatibility tests + run: |- + make --version; + make --file=config/Makefile.base --trace test-self; + + macos: + runs-on: macos-latest + steps: + # - name: Set up Docker + # uses: crazy-max/ghaction-setup-docker@v3 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.23.2 + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run MacOS compatibility tests + env: + BASH_COMPAT: 3.2 run: |- make --version - make --file=config/Makefile.base --trace test-self + make --file=config/Makefile.base test-self - macos: + macos-updated: runs-on: macos-latest steps: # - name: Set up Docker @@ -87,7 +108,8 @@ jobs: brew install make; export PATH="/opt/homebrew/opt/make/libexec/gnubin:${PATH}"; make --version; - make --file=config/Makefile.base --trace test-self + make --file=config/Makefile.base --trace test-self; + release: runs-on: ubuntu-latest diff --git a/config/Makefile.base b/config/Makefile.base index 26ec690..fe81b4b 100644 --- a/config/Makefile.base +++ b/config/Makefile.base @@ -2,10 +2,9 @@ SHELL := /bin/bash # Setup variables for special purposes. -NULL := COMMA := , -SPACE := $(NULL) $(NULL) -TAB := $(NULL) $(NULL) +SPACE := $(SPACE) $(SPACE) +TAB := $(TAB) $(TAB) define NEWLINE @@ -46,14 +45,14 @@ endif # System depdendent helper functions. ifeq ("$(shell uname)","Linux") - MAKESHELL := PATH=$(PATH) /bin/bash else ifeq ($(shell uname),Darwin) path-setup = $(shell \ if [ "$(1)" == "opt" ]; then \ XPATH="$(shell brew --prefix)/$(1)/$(2)/libexec/gnubin"; \ else XPATH="$(shell brew --prefix)/$(1)"; fi; \ test ! -e "$${XPATH}/$(3)" && brew install $(2) >&2; \ - echo -n "$${XPATH}:$(4)") + if [ -n "$(4)" ]; then echo -n "$${XPATH}:$(4)"; \ + else echo -n "$${XPATH}"; fi) export PATH := $(call path-setup,opt,coreutils,ls,$(PATH)) export PATH := $(call path-setup,opt,findutils,find,$(PATH)) export PATH := $(call path-setup,bin,bash,bash,$(PATH)) @@ -62,7 +61,10 @@ else ifeq ($(shell uname),Darwin) export PATH := $(call path-setup,opt,gsed,sed,$(PATH)) export PATH := $(call path-setup,opt,make,make,$(PATH)) # Ensure export of path to $(shell ...) in gmake 3.81. - MAKESHELL := PATH=$(PATH) /bin/bash +# ifeq (3.81,$(MAKE_VERSION)) + export MAKESHELL := PATH="$(PATH)" $(shell brew --prefix)/bin/bash + export SHELL := $(shell brew --prefix)/bin/bash +# endif else $(call cerror,unsupported operating system [$(shell uname --all)]) endif @@ -70,7 +72,8 @@ endif # Log execution environment for debugging. $(call cdebug,$(shell uname --all)) $(call cdebug,using BASH [$${0} - $${BASH_VERSION}]) -$(call cdebug,using PATH [$(shell echo -n "$${PATH}")]) +$(call cdebug,using PATH [$${PATH}]) +$(call cdebug,using SHELL [$${SHELL}]) # Helper function to find and remove source files. find-all = find $(1) ! -path "./run/*" ! -path "./build/*" \( $(2) \) 2>/dev/null | \ @@ -130,9 +133,10 @@ INSTALL_FLAGS ?= $(strip $(mod-readonly) -buildvcs=auto $(INSTALLFLAGS)) # Function to ensure compatibility of gawk and mawk. -ifneq ($(shell echo "false" | \ - awk '{ print gensub("false","true","g") }' 2>/dev/null),true) - awk-gensub := function gensub(r, s, h, t) { \ +awk-gensub = $(shell echo "false" | \ + awk '{ print gensub("false","true","g") }' 2>/dev/null) +ifneq ($(awk-gensub),true) + awk-gensub = function gensub(r, s, h, t) { \ if (t == 0) { t = $$0 } \ if (h ~ "^[gG]") { gsub(r, s, t) } \ else if (int(h) != 0) { \ @@ -145,7 +149,7 @@ ifneq ($(shell echo "false" | \ return t \ } else - awk-gensub := + awk-gensub = endif