Skip to content

Commit 06079dc

Browse files
authored
Merge branch 'hathach:master' into port-ft90x
2 parents 6dd4060 + 8681dbb commit 06079dc

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

tools/top.mk

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,45 @@
11
ifneq ($(lastword a b),b)
2-
$(error This Makefile require make 3.81 or newer)
2+
$(error This Makefile requires make 3.81 or newer)
33
endif
44

55
# Detect whether shell style is windows or not
66
# https://stackoverflow.com/questions/714100/os-detecting-makefile/52062069#52062069
77
ifeq '$(findstring ;,$(PATH))' ';'
8+
# PATH contains semicolon - so we're definitely on Windows.
89
CMDEXE := 1
10+
11+
# makefile shell commands should use syntax for DOS CMD, not unix sh
12+
# Unfortunately, SHELL may point to sh or bash, which can't accept DOS syntax.
13+
# We can't just use sh, because while sh and/or bash shell may be available,
14+
# many Windows environments won't have utilities like realpath used below, so...
15+
# Force DOS command shell on Windows.
16+
SHELL := cmd.exe
917
endif
1018

19+
#$(info top.mk: SHELL=$(SHELL))
20+
#$(info top.mk: CMDEXE=$(CMDEXE))
21+
1122
# Set TOP to be the path to get from the current directory (where make was
1223
# invoked) to the top of the tree. $(lastword $(MAKEFILE_LIST)) returns
1324
# the name of this makefile relative to where make was invoked.
14-
1525
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
26+
27+
# strip off /tools/top.mk to get for example ../../..
1628
TOP := $(patsubst %/tools/top.mk,%,$(THIS_MAKEFILE))
29+
#$(info top.mk: Initial TOP=$(TOP))
1730

31+
# Set TOP to an absolute path, for example /tinyUSB (from ../../..)
1832
ifeq ($(CMDEXE),1)
1933
TOP := $(subst \,/,$(shell for %%i in ( $(TOP) ) do echo %%~fi))
2034
else
2135
TOP := $(shell realpath $(TOP))
2236
endif
23-
#$(info Top directory is $(TOP))
37+
#$(info top.mk: Top directory is $(TOP))
2438

39+
# Set CURRENT_PATH to the relative path from TOP to the current directory, ie examples/device/cdc_msc_freertos
2540
ifeq ($(CMDEXE),1)
2641
CURRENT_PATH := $(subst $(TOP)/,,$(subst \,/,$(shell echo %CD%)))
2742
else
2843
CURRENT_PATH := $(shell realpath --relative-to=$(TOP) `pwd`)
2944
endif
30-
#$(info Path from top is $(CURRENT_PATH))
45+
#$(info top.mk: Path from top is $(CURRENT_PATH))

0 commit comments

Comments
 (0)