99# =============================================================
1010# OS-specific definitions
1111# =============================================================
12+ COMMA =,
13+ OPEN_PAREN =(
14+ CLOSE_PAREN =)
15+ BACKSLASH =\$(nullstring )
1216ifneq ($(ComSpec )$(COMSPEC ) ,)
1317 O_SYS =Windows
1418 RM =del /F /Q
1519 MKDIR =mkdir
1620 CP =copy /Y
1721 TYPE =type
18- PS =\ $( nullstring )
22+ PS =$( BACKSLASH )
1923 Q =
2024 coQ =\$(nullstring )
2125 fix_platform_path = $(subst /,$(PS ) , $(1 ) )
2731 CP =cp
2832 TYPE =cat
2933 PS =/
30- Q =\ $( nullstring )
31- coQ =^
34+ Q =$( BACKSLASH )
35+ coQ =
3236 fix_platform_path =$(1 )
3337 DEV_NULL =/dev/null
3438endif
3539
36- COMMA =,
37- OPEN_PAREN =(
38- CLOSE_PAREN =)
39- quote =$(subst $(coQ ) ,$(Q )$(coQ ) , \
40- $(subst % ,$(Q ) % , \
40+ # Note: Windows escaping rules is very combersome
41+ # initially I tried to use Q=^, but this depends on the context and (looks like) on Win version.
42+ # Also expecially ugly thing is that in quoted strings the quotes the same are remain.
43+ # Batch has special parameter expansion syntax to remove quotes,
44+ # but many tools themselves remove quotes (unless escaped with backslash)
45+ # So finally we've found that in our use cases we may not escaping any symbols but prepend backslashes before quotes.
46+
47+ quote =$(subst % ,$(Q ) % , \
4148 $(subst &,$(Q ) &, \
4249 $(subst <,$(Q ) <, \
4350 $(subst >,$(Q ) >, \
@@ -48,9 +55,9 @@ quote=$(subst $(coQ),$(Q)$(coQ), \
4855 $(subst $(OPEN_PAREN ) ,$(Q )$(OPEN_PAREN ) , \
4956 $(subst $(CLOSE_PAREN ) ,$(Q )$(CLOSE_PAREN ) , \
5057 $(subst !,$(Q ) !, \
51- $(subst ",$(Q ) ", \
58+ $(subst ",$(BACKSLASH ) ", \
5259 $(subst $(Q ) ,$(Q )$(Q ) , \
53- $(1 ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
60+ $(1 ) ) ) ) ) ) ) ) ) ) ) ) ) )
5461
5562
5663# =============================================================
@@ -118,15 +125,15 @@ ifeq ($(TOOLCHAIN),mwdt)
118125 LD = ccac
119126 AR = arac
120127 AS = ccac
121- CFLAGS += -tcf=$(TCF_FILE ) -tcf_core_config
128+ TCF_CFLAGS += -tcf=$(TCF_FILE ) -tcf_core_config
122129 LDFLAGS += -tcf=$(TCF_FILE ) $(LCF )
123130else
124131 CC = arc-elf32-gcc
125132 LD = arc-elf32-ld
126133 AR = arc-elf32-ar
127134 AS = arc-elf32-as
128135 CFLAGS += $(addprefix -I, $(HEADER_DIRS ) )
129- CFLAGS += -D_Interrupt=__attribute__((interrupt(\ "ilink\ ")))
136+ CFLAGS += -D_Interrupt=__attribute__((interrupt("ilink")))
130137 CFLAGS += -D_lr=__builtin_arc_lr
131138 CFLAGS += -D_sr=__builtin_arc_sr
132139 CFLAGS += -D_seti=__builtin_arc_seti
152159 endif
153160endif
154161
155- CFLAGS := $(call quote, $(CFLAGS ) )
162+ # TCF file needs to be the in front of the other CFLAGS
163+ CFLAGS := $(TCF_CFLAGS ) $(call quote, $(CFLAGS ) )
156164LDFLAGS := $(call quote, $(LDFLAGS ) )
157165
158166vpath % .c $(SRC_DIRS )
@@ -216,6 +224,9 @@ endif
216224ifneq ($(CPP_DEPENDS ) ,)
217225-include $(CPP_DEPENDS )
218226endif
227+ ifneq ($(CC_DEPENDS ) ,)
228+ -include $(CC_DEPENDS )
229+ endif
219230
220231# =================================================================
221232# Applications rules
0 commit comments