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 := /
ifeq ($(OS),Windows_NT)
COPY := copy
RM := del
PATH_SEP := \\
# When SHELL=sh.exe and this actually exists, make will silently
# switch to using that instead of cmd.exe. Unfortunately, there's
# 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
BASE_DIR := .

View File

@ -16,9 +16,17 @@ COPY := cp -a
PATH_SEP := /
ifeq ($(OS),Windows_NT)
COPY := copy
RM := del
PATH_SEP := \\
# When SHELL=sh.exe and this actually exists, make will silently
# switch to using that instead of cmd.exe. Unfortunately, there's
# 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
BASE_DIR := .
@ -63,7 +71,7 @@ ALL := all
TARGET := $(PACKAGE).elf
CLEAN := clean
$(ALL): $(TARGET) $(PACKAGE).bin $(PACKAGE).ihex
$(ALL): $(TARGET) $(PACKAGE).bin $(PACKAGE).ihex $(PACKAGE).dfu
$(OBJECTS): | $(OBJ_DIR)

View File

@ -16,18 +16,18 @@ RM = rm -rf
COPY = cp -a
PATH_SEP = /
ifeq ($(OS),Windows_NT)
# When SHELL=sh.exe and this actually exists, we're able to run
# the `which` command. Under these circumstances, the cmd.exe
# equivalents "copy" and "del" don't work. Additionally, the
# path separator can mess things up.
# Therefore, if we're running under Windows but have a valid `sh.exe`,
# don't use the Windows equivalents.
ifneq (, $(shell which $(SHELL)))
# When SHELL=sh.exe and this actually exists, make will silently
# switch to using that instead of cmd.exe. Unfortunately, there's
# 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
ifeq ($(FOMU_REV),evt3)
PCF ?= $(PCF_PATH)/fomu-evt3.pcf