clean up top

This commit is contained in:
hathach 2023-03-06 13:03:55 +07:00
parent 9930863b41
commit b6404d143e
No known key found for this signature in database
GPG Key ID: F5D50C6D51D17CBA

View File

@ -16,31 +16,14 @@ CMDEXE := 1
SHELL := cmd.exe
endif
#$(info top.mk: SHELL=$(SHELL))
#$(info top.mk: CMDEXE=$(CMDEXE))
# 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.
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
# strip off /tools/top.mk to get for example ../../..
TOP := $(subst /tools/top.mk,,$(THIS_MAKEFILE))
$(info top.mk: Initial TOP=$(TOP))
# Set TOP to an absolute path, for example /tinyUSB (from ../../..)
ifeq ($(CMDEXE),1)
TOP := $(subst \,/,$(shell for %%i in ( $(TOP) ) do echo %%~fi))
else
TOP := $(abspath $(TOP))
endif
$(info top.mk: Top directory is $(TOP))
# and Set TOP to an absolute path
TOP = $(abspath $(subst /tools/top.mk,,$(THIS_MAKEFILE)))
# Set CURRENT_PATH to the relative path from TOP to the current directory, ie examples/device/cdc_msc_freertos
ifeq ($(CMDEXE),1)
CURRENT_PATH := $(subst $(TOP)/,,$(subst \,/,$(shell echo %CD%)))
else
CURRENT_PATH = $(subst $(TOP)/,,$(abspath .))
endif
$(info top.mk: CURRENT_PATH = $(CURRENT_PATH))