aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Whittington <git@jbrengineering.co.uk>2020-08-04 11:51:35 +0200
committerJohn Whittington <git@jbrengineering.co.uk>2020-08-04 11:51:35 +0200
commit26e34cd6f2471f04ba097001a215caed12a8574a (patch)
treea2c27a5e9b9fa05bfa7ed8e4f00405cd022ef3b4
parent0c36c3489e1c4c48bf94a56138a5b5da52069682 (diff)
detect and use GNU grep on macOS
-rw-r--r--Common.mk13
-rw-r--r--Sam.mk2
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)