mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-22 14:42:25 +00:00
added support for cmd.exe as a shell on make.
This commit is contained in:
parent
05728e2b18
commit
8fa083d79e
@ -34,9 +34,14 @@ CXX = $(CROSS_COMPILE)g++
|
|||||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||||
SIZE = $(CROSS_COMPILE)size
|
SIZE = $(CROSS_COMPILE)size
|
||||||
MKDIR = mkdir
|
MKDIR = mkdir
|
||||||
|
ifeq ($(UNAME),Windows)
|
||||||
|
CP = copy
|
||||||
|
RM = del
|
||||||
|
else
|
||||||
SED = sed
|
SED = sed
|
||||||
CP = cp
|
CP = cp
|
||||||
RM = rm
|
RM = rm
|
||||||
|
endif
|
||||||
|
|
||||||
#-------------- Source files and compiler flags --------------
|
#-------------- Source files and compiler flags --------------
|
||||||
|
|
||||||
|
@ -81,7 +81,11 @@ uf2: $(BUILD)/$(BOARD)-firmware.uf2
|
|||||||
OBJ_DIRS = $(sort $(dir $(OBJ)))
|
OBJ_DIRS = $(sort $(dir $(OBJ)))
|
||||||
$(OBJ): | $(OBJ_DIRS)
|
$(OBJ): | $(OBJ_DIRS)
|
||||||
$(OBJ_DIRS):
|
$(OBJ_DIRS):
|
||||||
|
ifeq ($(UNAME),Windows)
|
||||||
|
@$(MKDIR) $(subst /,\,$@)
|
||||||
|
else
|
||||||
@$(MKDIR) -p $@
|
@$(MKDIR) -p $@
|
||||||
|
endif
|
||||||
|
|
||||||
$(BUILD)/$(BOARD)-firmware.elf: $(OBJ)
|
$(BUILD)/$(BOARD)-firmware.elf: $(OBJ)
|
||||||
@echo LINK $@
|
@echo LINK $@
|
||||||
@ -107,6 +111,7 @@ vpath %.c . $(TOP)
|
|||||||
$(BUILD)/obj/%.o: %.c
|
$(BUILD)/obj/%.o: %.c
|
||||||
@echo CC $(notdir $@)
|
@echo CC $(notdir $@)
|
||||||
@$(CC) $(CFLAGS) -c -MD -o $@ $<
|
@$(CC) $(CFLAGS) -c -MD -o $@ $<
|
||||||
|
ifneq ($(UNAME),Windows)
|
||||||
@# The following fixes the dependency file.
|
@# The following fixes the dependency file.
|
||||||
@# See http://make.paulandlesley.org/autodep.html for details.
|
@# See http://make.paulandlesley.org/autodep.html for details.
|
||||||
@# Regex adjusted from the above to play better with Windows paths, etc.
|
@# 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/ *\\$$//' \
|
$(SED) -e 's/#.*//' -e 's/^.*: *//' -e 's/ *\\$$//' \
|
||||||
-e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \
|
-e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \
|
||||||
$(RM) $(@:.o=.d)
|
$(RM) $(@:.o=.d)
|
||||||
|
endif
|
||||||
|
|
||||||
# ASM sources lower case .s
|
# ASM sources lower case .s
|
||||||
vpath %.s . $(TOP)
|
vpath %.s . $(TOP)
|
||||||
@ -134,7 +140,11 @@ size: $(BUILD)/$(BOARD)-firmware.elf
|
|||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
ifeq ($(UNAME),Windows)
|
||||||
|
rd /S /Q $(subst /,\,$(BUILD))
|
||||||
|
else
|
||||||
$(RM) -rf $(BUILD)
|
$(RM) -rf $(BUILD)
|
||||||
|
endif
|
||||||
|
|
||||||
# Print out the value of a make variable.
|
# Print out the value of a make variable.
|
||||||
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
|
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
|
||||||
|
15
tools/top.mk
15
tools/top.mk
@ -2,6 +2,12 @@ ifneq ($(lastword a b),b)
|
|||||||
$(error This Makefile require make 3.81 or newer)
|
$(error This Makefile require make 3.81 or newer)
|
||||||
endif
|
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
|
# 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
|
# invoked) to the top of the tree. $(lastword $(MAKEFILE_LIST)) returns
|
||||||
# the name of this makefile relative to where make was invoked.
|
# the name of this makefile relative to where make was invoked.
|
||||||
@ -9,9 +15,16 @@ endif
|
|||||||
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||||
TOP := $(patsubst %/tools/top.mk,%,$(THIS_MAKEFILE))
|
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))
|
TOP := $(shell realpath $(TOP))
|
||||||
|
endif
|
||||||
#$(info Top directory is $(TOP))
|
#$(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`)
|
CURRENT_PATH := $(shell realpath --relative-to=$(TOP) `pwd`)
|
||||||
|
endif
|
||||||
#$(info Path from top is $(CURRENT_PATH))
|
#$(info Path from top is $(CURRENT_PATH))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user