summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-01-22 11:17:10 +0700
committerhathach <[email protected]>2021-01-22 11:17:10 +0700
commit0cf2b02791bee41583f58b65c57bdac4ca1faf45 (patch)
tree712d223dd102497b8d4764db50d9b3eaa7f82fef /tools
parent4cd8a95ef71fa351af1ec7144301b2736a80c75d (diff)
parent388abe9d9cc0a7c360fd902e01461a53bb7b3f42 (diff)
Merge branch 'master' into group-boards-into-family
Diffstat (limited to 'tools')
-rw-r--r--tools/top.mk15
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/top.mk b/tools/top.mk
index be51b3f4f..84523a557 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 whether shell style is windows or not
+# https://stackoverflow.com/questions/714100/os-detecting-makefile/52062069#52062069
+ifeq '$(findstring ;,$(PATH))' ';'
+CMDEXE := 1
+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 ($(CMDEXE),1)
+TOP := $(subst \,/,$(shell for %%i in ( $(TOP) ) do echo %%~fi))
+else
TOP := $(shell realpath $(TOP))
-
+endif
#$(info Top directory is $(TOP))
+ifeq ($(CMDEXE),1)
+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))