From 26e34cd6f2471f04ba097001a215caed12a8574a Mon Sep 17 00:00:00 2001 From: John Whittington Date: Tue, 4 Aug 2020 11:51:35 +0200 Subject: [PATCH] detect and use GNU grep on macOS --- Common.mk | 13 +++++++++++-- Sam.mk | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Common.mk b/Common.mk index 0c1f92c..27d2135 100644 --- a/Common.mk +++ b/Common.mk @@ -8,8 +8,8 @@ dir_if_exists = $(if $(wildcard $(1)$(2)),$(1)) # result = $(call READ_BOARD_TXT, 'boardname', 'parameter') PARSE_BOARD = $(shell if [ -f $(BOARDS_TXT) ]; \ then \ - grep -Ev '^\#' $(BOARDS_TXT) | \ - grep -E "^[ \t]*$(1).$(2)=" | \ + $(GREP) -Ev '^\#' $(BOARDS_TXT) | \ + $(GREP) -E "^[ \t]*$(1).$(2)=" | \ cut -d = -f 2- | \ cut -d : -f 2; \ fi) @@ -45,15 +45,24 @@ $(call arduino_output,$(call ardmk_include) Configuration:) ######################################################################## # # Detect OS + ifeq ($(OS),Windows_NT) CURRENT_OS = WINDOWS + GREP := grep else UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Linux) CURRENT_OS = LINUX + GREP := grep endif ifeq ($(UNAME_S),Darwin) CURRENT_OS = MAC + ifeq (, $(shell which ggrep)) + echo $(info Using macOS BSD grep, please install GNU grep to avoid warnings) + GREP := grep + else + GREP := ggrep + endif endif endif $(call show_config_variable,CURRENT_OS,[AUTODETECTED]) diff --git a/Sam.mk b/Sam.mk index 7f3cd2b..f11554f 100644 --- a/Sam.mk +++ b/Sam.mk @@ -404,7 +404,7 @@ CFLAGS_STD += -std=gnu11 CPPFLAGS += -DMD -D$(USB_TYPE) '-DUSB_PRODUCT=$(USB_PRODUCT)' '-DUSB_MANUFACTURER=$(USB_MANUFACTURER)' # Get extra define flags from boards.txt -EXFLAGS := $(shell echo $(call PARSE_BOARD,$(BOARD_TAG),build.extra_flags) | grep -oE '(-D)\w+') +EXFLAGS := $(shell echo $(call PARSE_BOARD,$(BOARD_TAG),build.extra_flags) | $(GREP) -oE '(-D)\w+') # Strip only defines from extra flags as boards file appends user {build.usb} CPPFLAGS += $(EXFLAGS)