detect and use GNU grep on macOS
This commit is contained in:
parent
0c36c3489e
commit
26e34cd6f2
2 changed files with 12 additions and 3 deletions
13
Common.mk
13
Common.mk
|
@ -8,8 +8,8 @@ dir_if_exists = $(if $(wildcard $(1)$(2)),$(1))
|
||||||
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
|
# result = $(call READ_BOARD_TXT, 'boardname', 'parameter')
|
||||||
PARSE_BOARD = $(shell if [ -f $(BOARDS_TXT) ]; \
|
PARSE_BOARD = $(shell if [ -f $(BOARDS_TXT) ]; \
|
||||||
then \
|
then \
|
||||||
grep -Ev '^\#' $(BOARDS_TXT) | \
|
$(GREP) -Ev '^\#' $(BOARDS_TXT) | \
|
||||||
grep -E "^[ \t]*$(1).$(2)=" | \
|
$(GREP) -E "^[ \t]*$(1).$(2)=" | \
|
||||||
cut -d = -f 2- | \
|
cut -d = -f 2- | \
|
||||||
cut -d : -f 2; \
|
cut -d : -f 2; \
|
||||||
fi)
|
fi)
|
||||||
|
@ -45,15 +45,24 @@ $(call arduino_output,$(call ardmk_include) Configuration:)
|
||||||
########################################################################
|
########################################################################
|
||||||
#
|
#
|
||||||
# Detect OS
|
# Detect OS
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
CURRENT_OS = WINDOWS
|
CURRENT_OS = WINDOWS
|
||||||
|
GREP := grep
|
||||||
else
|
else
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
ifeq ($(UNAME_S),Linux)
|
ifeq ($(UNAME_S),Linux)
|
||||||
CURRENT_OS = LINUX
|
CURRENT_OS = LINUX
|
||||||
|
GREP := grep
|
||||||
endif
|
endif
|
||||||
ifeq ($(UNAME_S),Darwin)
|
ifeq ($(UNAME_S),Darwin)
|
||||||
CURRENT_OS = MAC
|
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
|
||||||
endif
|
endif
|
||||||
$(call show_config_variable,CURRENT_OS,[AUTODETECTED])
|
$(call show_config_variable,CURRENT_OS,[AUTODETECTED])
|
||||||
|
|
2
Sam.mk
2
Sam.mk
|
@ -404,7 +404,7 @@ CFLAGS_STD += -std=gnu11
|
||||||
CPPFLAGS += -DMD -D$(USB_TYPE) '-DUSB_PRODUCT=$(USB_PRODUCT)' '-DUSB_MANUFACTURER=$(USB_MANUFACTURER)'
|
CPPFLAGS += -DMD -D$(USB_TYPE) '-DUSB_PRODUCT=$(USB_PRODUCT)' '-DUSB_MANUFACTURER=$(USB_MANUFACTURER)'
|
||||||
|
|
||||||
# Get extra define flags from boards.txt
|
# 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}
|
# Strip only defines from extra flags as boards file appends user {build.usb}
|
||||||
CPPFLAGS += $(EXFLAGS)
|
CPPFLAGS += $(EXFLAGS)
|
||||||
|
|
Loading…
Reference in a new issue