makefiles: fix build under cygwin/msys2 on windows

This forces SHELL to be cmd.exe under these platforms.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2019-12-14 03:44:11 +08:00
parent 3538ebf81a
commit 7f16658435
3 changed files with 31 additions and 15 deletions

View File

@ -16,9 +16,17 @@ COPY := cp -a
PATH_SEP := / PATH_SEP := /
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
COPY := copy # When SHELL=sh.exe and this actually exists, make will silently
RM := del # switch to using that instead of cmd.exe. Unfortunately, there's
PATH_SEP := \\ # no way to tell which environment we're running under without either
# (1) printing out an error message, or (2) finding something that
# works everywhere.
# As a result, we force the shell to be cmd.exe, so it works both
# under cygwin and normal Windows.
SHELL = cmd.exe
COPY = copy
RM = del
PATH_SEP = \\
endif endif
BASE_DIR := . BASE_DIR := .

View File

@ -16,9 +16,17 @@ COPY := cp -a
PATH_SEP := / PATH_SEP := /
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
COPY := copy # When SHELL=sh.exe and this actually exists, make will silently
RM := del # switch to using that instead of cmd.exe. Unfortunately, there's
PATH_SEP := \\ # no way to tell which environment we're running under without either
# (1) printing out an error message, or (2) finding something that
# works everywhere.
# As a result, we force the shell to be cmd.exe, so it works both
# under cygwin and normal Windows.
SHELL = cmd.exe
COPY = copy
RM = del
PATH_SEP = \\
endif endif
BASE_DIR := . BASE_DIR := .
@ -63,7 +71,7 @@ ALL := all
TARGET := $(PACKAGE).elf TARGET := $(PACKAGE).elf
CLEAN := clean CLEAN := clean
$(ALL): $(TARGET) $(PACKAGE).bin $(PACKAGE).ihex $(ALL): $(TARGET) $(PACKAGE).bin $(PACKAGE).ihex $(PACKAGE).dfu
$(OBJECTS): | $(OBJ_DIR) $(OBJECTS): | $(OBJ_DIR)

View File

@ -16,18 +16,18 @@ RM = rm -rf
COPY = cp -a COPY = cp -a
PATH_SEP = / PATH_SEP = /
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
# When SHELL=sh.exe and this actually exists, we're able to run # When SHELL=sh.exe and this actually exists, make will silently
# the `which` command. Under these circumstances, the cmd.exe # switch to using that instead of cmd.exe. Unfortunately, there's
# equivalents "copy" and "del" don't work. Additionally, the # no way to tell which environment we're running under without either
# path separator can mess things up. # (1) printing out an error message, or (2) finding something that
# Therefore, if we're running under Windows but have a valid `sh.exe`, # works everywhere.
# don't use the Windows equivalents. # As a result, we force the shell to be cmd.exe, so it works both
ifneq (, $(shell which $(SHELL))) # under cygwin and normal Windows.
SHELL = cmd.exe
COPY = copy COPY = copy
RM = del RM = del
PATH_SEP = \\ PATH_SEP = \\
endif endif
endif
ifeq ($(FOMU_REV),evt3) ifeq ($(FOMU_REV),evt3)
PCF ?= $(PCF_PATH)/fomu-evt3.pcf PCF ?= $(PCF_PATH)/fomu-evt3.pcf