From 8fa083d79e1325c19f2bc0af894fdf7f8ab5e84c Mon Sep 17 00:00:00 2001 From: kkitayam <45088311+kkitayam@users.noreply.github.com> Date: Sun, 10 Jan 2021 20:46:29 +0900 Subject: [PATCH 1/3] added support for cmd.exe as a shell on make. --- examples/make.mk | 5 +++++ examples/rules.mk | 10 ++++++++++ tools/top.mk | 15 ++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/examples/make.mk b/examples/make.mk index 6743044f..ee4ed640 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -34,9 +34,14 @@ CXX = $(CROSS_COMPILE)g++ OBJCOPY = $(CROSS_COMPILE)objcopy SIZE = $(CROSS_COMPILE)size MKDIR = mkdir +ifeq ($(UNAME),Windows) +CP = copy +RM = del +else SED = sed CP = cp RM = rm +endif #-------------- Source files and compiler flags -------------- diff --git a/examples/rules.mk b/examples/rules.mk index 37e0e7a1..a445f033 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -81,7 +81,11 @@ uf2: $(BUILD)/$(BOARD)-firmware.uf2 OBJ_DIRS = $(sort $(dir $(OBJ))) $(OBJ): | $(OBJ_DIRS) $(OBJ_DIRS): +ifeq ($(UNAME),Windows) + @$(MKDIR) $(subst /,\,$@) +else @$(MKDIR) -p $@ +endif $(BUILD)/$(BOARD)-firmware.elf: $(OBJ) @echo LINK $@ @@ -107,6 +111,7 @@ vpath %.c . $(TOP) $(BUILD)/obj/%.o: %.c @echo CC $(notdir $@) @$(CC) $(CFLAGS) -c -MD -o $@ $< +ifneq ($(UNAME),Windows) @# The following fixes the dependency file. @# See http://make.paulandlesley.org/autodep.html for details. @# Regex adjusted from the above to play better with Windows paths, etc. @@ -114,6 +119,7 @@ $(BUILD)/obj/%.o: %.c $(SED) -e 's/#.*//' -e 's/^.*: *//' -e 's/ *\\$$//' \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \ $(RM) $(@:.o=.d) +endif # ASM sources lower case .s vpath %.s . $(TOP) @@ -134,7 +140,11 @@ size: $(BUILD)/$(BOARD)-firmware.elf .PHONY: clean clean: +ifeq ($(UNAME),Windows) + rd /S /Q $(subst /,\,$(BUILD)) +else $(RM) -rf $(BUILD) +endif # Print out the value of a make variable. # https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile diff --git a/tools/top.mk b/tools/top.mk index be51b3f4..d276f581 100644 --- a/tools/top.mk +++ b/tools/top.mk @@ -2,6 +2,12 @@ ifneq ($(lastword a b),b) $(error This Makefile require make 3.81 or newer) endif +# Detect windows or not +# https://stackoverflow.com/questions/714100/os-detecting-makefile/52062069#52062069 +ifeq '$(findstring ;,$(PATH))' ';' +UNAME := Windows +endif + # Set TOP to be the path to get from the current directory (where make was # invoked) to the top of the tree. $(lastword $(MAKEFILE_LIST)) returns # the name of this makefile relative to where make was invoked. @@ -9,9 +15,16 @@ endif THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) TOP := $(patsubst %/tools/top.mk,%,$(THIS_MAKEFILE)) +ifeq ($(UNAME),Windows) +TOP := $(subst \,/,$(shell for %%i in ( $(TOP) ) do echo %%~fi)) +else TOP := $(shell realpath $(TOP)) - +endif #$(info Top directory is $(TOP)) +ifeq ($(UNAME),Windows) +CURRENT_PATH := $(subst $(TOP)/,,$(subst \,/,$(shell echo %CD%))) +else CURRENT_PATH := $(shell realpath --relative-to=$(TOP) `pwd`) +endif #$(info Path from top is $(CURRENT_PATH)) From fc69dd70cf3c669308240bb0a6bb05d6eda51487 Mon Sep 17 00:00:00 2001 From: kkitayam <45088311+kkitayam@users.noreply.github.com> Date: Tue, 12 Jan 2021 01:02:17 +0900 Subject: [PATCH 2/3] Changed some source file paths for SRC_C to relative paths. Added statements to validate GCCVERSION on Windows Command Prompt. --- hw/bsp/adafruit_clue/board.mk | 6 ++++++ hw/bsp/arduino_nano33_ble/board.mk | 6 ++++++ hw/bsp/circuitplayground_bluefruit/board.mk | 6 ++++++ hw/bsp/da14695_dk_usb/board.mk | 2 +- hw/bsp/da1469x_dk_pro/board.mk | 2 +- hw/bsp/double_m33_express/board.mk | 2 +- hw/bsp/feather_nrf52840_express/board.mk | 6 ++++++ hw/bsp/feather_nrf52840_sense/board.mk | 6 ++++++ hw/bsp/itsybitsy_nrf52840/board.mk | 6 ++++++ hw/bsp/nrf52840_mdk_dongle/board.mk | 6 ++++++ hw/bsp/pca10056/board.mk | 6 ++++++ hw/bsp/pca10059/board.mk | 6 ++++++ hw/bsp/pca10100/board.mk | 6 ++++++ hw/bsp/raytac_mdbt50q_rx/board.mk | 6 ++++++ 14 files changed, 69 insertions(+), 3 deletions(-) diff --git a/hw/bsp/adafruit_clue/board.mk b/hw/bsp/adafruit_clue/board.mk index d5f7c7cd..ef6e093f 100644 --- a/hw/bsp/adafruit_clue/board.mk +++ b/hw/bsp/adafruit_clue/board.mk @@ -14,9 +14,15 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(UNAME),Windows) +ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) +CFLAGS += -Wno-error=cast-function-type +endif +else ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type endif +endif # All source paths should be relative to the top level. LD_FILE = hw/bsp/$(BOARD)/nrf52840_s140_v6.ld diff --git a/hw/bsp/arduino_nano33_ble/board.mk b/hw/bsp/arduino_nano33_ble/board.mk index d1d62bdf..63d1550d 100644 --- a/hw/bsp/arduino_nano33_ble/board.mk +++ b/hw/bsp/arduino_nano33_ble/board.mk @@ -14,9 +14,15 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(UNAME),Windows) +ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) +CFLAGS += -Wno-error=cast-function-type +endif +else ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type endif +endif # All source paths should be relative to the top level. #LD_FILE = hw/bsp/$(BOARD)/linker_script.ld diff --git a/hw/bsp/circuitplayground_bluefruit/board.mk b/hw/bsp/circuitplayground_bluefruit/board.mk index d5f7c7cd..ef6e093f 100644 --- a/hw/bsp/circuitplayground_bluefruit/board.mk +++ b/hw/bsp/circuitplayground_bluefruit/board.mk @@ -14,9 +14,15 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(UNAME),Windows) +ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) +CFLAGS += -Wno-error=cast-function-type +endif +else ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type endif +endif # All source paths should be relative to the top level. LD_FILE = hw/bsp/$(BOARD)/nrf52840_s140_v6.ld diff --git a/hw/bsp/da14695_dk_usb/board.mk b/hw/bsp/da14695_dk_usb/board.mk index 8fef7d10..b097262d 100644 --- a/hw/bsp/da14695_dk_usb/board.mk +++ b/hw/bsp/da14695_dk_usb/board.mk @@ -21,7 +21,7 @@ SRC_C += \ $(MCU_FAMILY_DIR)/src/da1469x_clock.c \ $(MCU_FAMILY_DIR)/src/hal_gpio.c \ -SRC_S += $(TOP)/hw/bsp/$(BOARD)/gcc_startup_da1469x.S +SRC_S += hw/bsp/$(BOARD)/gcc_startup_da1469x.S INC += \ $(TOP)/hw/bsp/$(BOARD) \ diff --git a/hw/bsp/da1469x_dk_pro/board.mk b/hw/bsp/da1469x_dk_pro/board.mk index 60a62378..16bd6de6 100644 --- a/hw/bsp/da1469x_dk_pro/board.mk +++ b/hw/bsp/da1469x_dk_pro/board.mk @@ -21,7 +21,7 @@ SRC_C += \ $(MCU_FAMILY_DIR)/src/da1469x_clock.c \ $(MCU_FAMILY_DIR)/src/hal_gpio.c \ -SRC_S += $(TOP)/hw/bsp/$(BOARD)/gcc_startup_da1469x.S +SRC_S += hw/bsp/$(BOARD)/gcc_startup_da1469x.S INC += \ $(TOP)/hw/bsp/$(BOARD) \ diff --git a/hw/bsp/double_m33_express/board.mk b/hw/bsp/double_m33_express/board.mk index 6cc2495d..c3401e5b 100644 --- a/hw/bsp/double_m33_express/board.mk +++ b/hw/bsp/double_m33_express/board.mk @@ -26,7 +26,7 @@ SRC_C += \ $(MCU_DIR)/drivers/fsl_reset.c \ $(MCU_DIR)/drivers/fsl_usart.c \ $(MCU_DIR)/drivers/fsl_flexcomm.c \ - $(TOP)/lib/sct_neopixel/sct_neopixel.c + lib/sct_neopixel/sct_neopixel.c INC += \ $(TOP)/hw/bsp/ \ diff --git a/hw/bsp/feather_nrf52840_express/board.mk b/hw/bsp/feather_nrf52840_express/board.mk index 6cc97283..2feb070a 100644 --- a/hw/bsp/feather_nrf52840_express/board.mk +++ b/hw/bsp/feather_nrf52840_express/board.mk @@ -14,9 +14,15 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(UNAME),Windows) +ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) +CFLAGS += -Wno-error=cast-function-type +endif +else ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type endif +endif # All source paths should be relative to the top level. LD_FILE = hw/bsp/$(BOARD)/nrf52840_s140_v6.ld diff --git a/hw/bsp/feather_nrf52840_sense/board.mk b/hw/bsp/feather_nrf52840_sense/board.mk index d5f7c7cd..ef6e093f 100644 --- a/hw/bsp/feather_nrf52840_sense/board.mk +++ b/hw/bsp/feather_nrf52840_sense/board.mk @@ -14,9 +14,15 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(UNAME),Windows) +ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) +CFLAGS += -Wno-error=cast-function-type +endif +else ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type endif +endif # All source paths should be relative to the top level. LD_FILE = hw/bsp/$(BOARD)/nrf52840_s140_v6.ld diff --git a/hw/bsp/itsybitsy_nrf52840/board.mk b/hw/bsp/itsybitsy_nrf52840/board.mk index 6cc97283..2feb070a 100644 --- a/hw/bsp/itsybitsy_nrf52840/board.mk +++ b/hw/bsp/itsybitsy_nrf52840/board.mk @@ -14,9 +14,15 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(UNAME),Windows) +ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) +CFLAGS += -Wno-error=cast-function-type +endif +else ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type endif +endif # All source paths should be relative to the top level. LD_FILE = hw/bsp/$(BOARD)/nrf52840_s140_v6.ld diff --git a/hw/bsp/nrf52840_mdk_dongle/board.mk b/hw/bsp/nrf52840_mdk_dongle/board.mk index 8ce8929b..baa4cc22 100644 --- a/hw/bsp/nrf52840_mdk_dongle/board.mk +++ b/hw/bsp/nrf52840_mdk_dongle/board.mk @@ -13,9 +13,15 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(UNAME),Windows) +ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) +CFLAGS += -Wno-error=cast-function-type +endif +else ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type endif +endif # All source paths should be relative to the top level. LD_FILE = hw/bsp/$(BOARD)/$(BOARD).ld diff --git a/hw/bsp/pca10056/board.mk b/hw/bsp/pca10056/board.mk index 8f4887dc..3ea85983 100644 --- a/hw/bsp/pca10056/board.mk +++ b/hw/bsp/pca10056/board.mk @@ -14,9 +14,15 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(UNAME),Windows) +ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) +CFLAGS += -Wno-error=cast-function-type +endif +else ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type endif +endif # All source paths should be relative to the top level. LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52840_xxaa.ld diff --git a/hw/bsp/pca10059/board.mk b/hw/bsp/pca10059/board.mk index bd7a80c0..e9bc890c 100644 --- a/hw/bsp/pca10059/board.mk +++ b/hw/bsp/pca10059/board.mk @@ -14,9 +14,15 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(UNAME),Windows) +ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) +CFLAGS += -Wno-error=cast-function-type +endif +else ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type endif +endif # All source paths should be relative to the top level. LD_FILE = hw/bsp/$(BOARD)/$(BOARD).ld diff --git a/hw/bsp/pca10100/board.mk b/hw/bsp/pca10100/board.mk index 4b5be082..0b4d42f2 100644 --- a/hw/bsp/pca10100/board.mk +++ b/hw/bsp/pca10100/board.mk @@ -14,9 +14,15 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(UNAME),Windows) +ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) +CFLAGS += -Wno-error=cast-function-type +endif +else ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type endif +endif # All source paths should be relative to the top level. LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52833_xxaa.ld diff --git a/hw/bsp/raytac_mdbt50q_rx/board.mk b/hw/bsp/raytac_mdbt50q_rx/board.mk index e153aab0..6ff079dd 100644 --- a/hw/bsp/raytac_mdbt50q_rx/board.mk +++ b/hw/bsp/raytac_mdbt50q_rx/board.mk @@ -13,9 +13,15 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) +ifeq ($(UNAME),Windows) +ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) +CFLAGS += -Wno-error=cast-function-type +endif +else ifeq ($(shell expr $(GCCVERSION) \>= 8), 1) CFLAGS += -Wno-error=cast-function-type endif +endif # All source paths should be relative to the top level. LD_FILE = hw/mcu/nordic/nrfx/mdk/nrf52840_xxaa.ld From d7cfd8b91db127459d61aa8b8d091cb08e732208 Mon Sep 17 00:00:00 2001 From: kkitayam <45088311+kkitayam@users.noreply.github.com> Date: Thu, 14 Jan 2021 01:19:43 +0900 Subject: [PATCH 3/3] replaced variable name to CMDEXE from UNAME. removed the rule that .d files are converted to .P files. --- examples/make.mk | 2 +- examples/rules.mk | 13 ++----------- hw/bsp/adafruit_clue/board.mk | 2 +- hw/bsp/arduino_nano33_ble/board.mk | 2 +- hw/bsp/circuitplayground_bluefruit/board.mk | 2 +- hw/bsp/feather_nrf52840_express/board.mk | 2 +- hw/bsp/feather_nrf52840_sense/board.mk | 2 +- hw/bsp/itsybitsy_nrf52840/board.mk | 2 +- hw/bsp/nrf52840_mdk_dongle/board.mk | 2 +- hw/bsp/pca10056/board.mk | 2 +- hw/bsp/pca10059/board.mk | 2 +- hw/bsp/pca10100/board.mk | 2 +- hw/bsp/raytac_mdbt50q_rx/board.mk | 2 +- tools/top.mk | 8 ++++---- 14 files changed, 18 insertions(+), 27 deletions(-) diff --git a/examples/make.mk b/examples/make.mk index ee4ed640..992a4e60 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -34,7 +34,7 @@ CXX = $(CROSS_COMPILE)g++ OBJCOPY = $(CROSS_COMPILE)objcopy SIZE = $(CROSS_COMPILE)size MKDIR = mkdir -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) CP = copy RM = del else diff --git a/examples/rules.mk b/examples/rules.mk index a445f033..2274d1cd 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -81,7 +81,7 @@ uf2: $(BUILD)/$(BOARD)-firmware.uf2 OBJ_DIRS = $(sort $(dir $(OBJ))) $(OBJ): | $(OBJ_DIRS) $(OBJ_DIRS): -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) @$(MKDIR) $(subst /,\,$@) else @$(MKDIR) -p $@ @@ -111,15 +111,6 @@ vpath %.c . $(TOP) $(BUILD)/obj/%.o: %.c @echo CC $(notdir $@) @$(CC) $(CFLAGS) -c -MD -o $@ $< -ifneq ($(UNAME),Windows) - @# The following fixes the dependency file. - @# See http://make.paulandlesley.org/autodep.html for details. - @# Regex adjusted from the above to play better with Windows paths, etc. - @$(CP) $(@:.o=.d) $(@:.o=.P); \ - $(SED) -e 's/#.*//' -e 's/^.*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \ - $(RM) $(@:.o=.d) -endif # ASM sources lower case .s vpath %.s . $(TOP) @@ -140,7 +131,7 @@ size: $(BUILD)/$(BOARD)-firmware.elf .PHONY: clean clean: -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) rd /S /Q $(subst /,\,$(BUILD)) else $(RM) -rf $(BUILD) diff --git a/hw/bsp/adafruit_clue/board.mk b/hw/bsp/adafruit_clue/board.mk index ef6e093f..3db045ac 100644 --- a/hw/bsp/adafruit_clue/board.mk +++ b/hw/bsp/adafruit_clue/board.mk @@ -14,7 +14,7 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) CFLAGS += -Wno-error=cast-function-type endif diff --git a/hw/bsp/arduino_nano33_ble/board.mk b/hw/bsp/arduino_nano33_ble/board.mk index 63d1550d..1ee8867e 100644 --- a/hw/bsp/arduino_nano33_ble/board.mk +++ b/hw/bsp/arduino_nano33_ble/board.mk @@ -14,7 +14,7 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) CFLAGS += -Wno-error=cast-function-type endif diff --git a/hw/bsp/circuitplayground_bluefruit/board.mk b/hw/bsp/circuitplayground_bluefruit/board.mk index ef6e093f..3db045ac 100644 --- a/hw/bsp/circuitplayground_bluefruit/board.mk +++ b/hw/bsp/circuitplayground_bluefruit/board.mk @@ -14,7 +14,7 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) CFLAGS += -Wno-error=cast-function-type endif diff --git a/hw/bsp/feather_nrf52840_express/board.mk b/hw/bsp/feather_nrf52840_express/board.mk index 2feb070a..059e55df 100644 --- a/hw/bsp/feather_nrf52840_express/board.mk +++ b/hw/bsp/feather_nrf52840_express/board.mk @@ -14,7 +14,7 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) CFLAGS += -Wno-error=cast-function-type endif diff --git a/hw/bsp/feather_nrf52840_sense/board.mk b/hw/bsp/feather_nrf52840_sense/board.mk index ef6e093f..3db045ac 100644 --- a/hw/bsp/feather_nrf52840_sense/board.mk +++ b/hw/bsp/feather_nrf52840_sense/board.mk @@ -14,7 +14,7 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) CFLAGS += -Wno-error=cast-function-type endif diff --git a/hw/bsp/itsybitsy_nrf52840/board.mk b/hw/bsp/itsybitsy_nrf52840/board.mk index 2feb070a..059e55df 100644 --- a/hw/bsp/itsybitsy_nrf52840/board.mk +++ b/hw/bsp/itsybitsy_nrf52840/board.mk @@ -14,7 +14,7 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) CFLAGS += -Wno-error=cast-function-type endif diff --git a/hw/bsp/nrf52840_mdk_dongle/board.mk b/hw/bsp/nrf52840_mdk_dongle/board.mk index baa4cc22..3c44e402 100644 --- a/hw/bsp/nrf52840_mdk_dongle/board.mk +++ b/hw/bsp/nrf52840_mdk_dongle/board.mk @@ -13,7 +13,7 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) CFLAGS += -Wno-error=cast-function-type endif diff --git a/hw/bsp/pca10056/board.mk b/hw/bsp/pca10056/board.mk index 3ea85983..b8691525 100644 --- a/hw/bsp/pca10056/board.mk +++ b/hw/bsp/pca10056/board.mk @@ -14,7 +14,7 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) CFLAGS += -Wno-error=cast-function-type endif diff --git a/hw/bsp/pca10059/board.mk b/hw/bsp/pca10059/board.mk index e9bc890c..178f0947 100644 --- a/hw/bsp/pca10059/board.mk +++ b/hw/bsp/pca10059/board.mk @@ -14,7 +14,7 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) CFLAGS += -Wno-error=cast-function-type endif diff --git a/hw/bsp/pca10100/board.mk b/hw/bsp/pca10100/board.mk index 0b4d42f2..8ada94ba 100644 --- a/hw/bsp/pca10100/board.mk +++ b/hw/bsp/pca10100/board.mk @@ -14,7 +14,7 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) CFLAGS += -Wno-error=cast-function-type endif diff --git a/hw/bsp/raytac_mdbt50q_rx/board.mk b/hw/bsp/raytac_mdbt50q_rx/board.mk index 6ff079dd..2c29acfa 100644 --- a/hw/bsp/raytac_mdbt50q_rx/board.mk +++ b/hw/bsp/raytac_mdbt50q_rx/board.mk @@ -13,7 +13,7 @@ CFLAGS += -Wno-error=undef -Wno-error=unused-parameter -Wno-error=cast-align # due to tusb_hal_nrf_power_event GCCVERSION = $(firstword $(subst ., ,$(shell arm-none-eabi-gcc -dumpversion))) -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) ifeq ($(shell if $(GCCVERSION) geq 8 echo 1), 1) CFLAGS += -Wno-error=cast-function-type endif diff --git a/tools/top.mk b/tools/top.mk index d276f581..84523a55 100644 --- a/tools/top.mk +++ b/tools/top.mk @@ -2,10 +2,10 @@ ifneq ($(lastword a b),b) $(error This Makefile require make 3.81 or newer) endif -# Detect windows or not +# Detect whether shell style is windows or not # https://stackoverflow.com/questions/714100/os-detecting-makefile/52062069#52062069 ifeq '$(findstring ;,$(PATH))' ';' -UNAME := Windows +CMDEXE := 1 endif # Set TOP to be the path to get from the current directory (where make was @@ -15,14 +15,14 @@ endif THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) TOP := $(patsubst %/tools/top.mk,%,$(THIS_MAKEFILE)) -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) TOP := $(subst \,/,$(shell for %%i in ( $(TOP) ) do echo %%~fi)) else TOP := $(shell realpath $(TOP)) endif #$(info Top directory is $(TOP)) -ifeq ($(UNAME),Windows) +ifeq ($(CMDEXE),1) CURRENT_PATH := $(subst $(TOP)/,,$(subst \,/,$(shell echo %CD%))) else CURRENT_PATH := $(shell realpath --relative-to=$(TOP) `pwd`)