This will help us when compiling documentation for rpp-test-sw commands.
# Include definition of $(rpp_lib_INCLUDES)
include $(makefile_rules_arm_dir)/../Makefile.var
+# Include UPPERCASE function
+include $(makefile_rules_dir)/../common.mk
+
# Construct target specific CFLAGS. Start from what's in Makefile.config.
RPP_TARGET_CFLAGS = $(TARGET_CFLAGS)
+# Add -DTARGET_<NAME>
+RPP_TARGET_CFLAGS += -DTARGET_$(call UPPERCASE,$(TARGET))
+
# Then add -DTARGET_HAS_xxx for each make variable named TARGET_HAS_*
# having value 'y'
TARGET_HAS_NAMES = $(filter TARGET_HAS_%,$(.VARIABLES))
makefile_rules_posix_dir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
-ifeq ($(TARGET_CFLAGS),)
+ifeq ($(filter TARGET_CFLAGS,$(.VARIABLES)),)
$(error "Makefile.config must be included before this file")
endif
# Include definition of $(rpp_lib_INCLUDES)
include $(makefile_rules_posix_dir)/../Makefile.var
-RPP_CFLAGS = $(rpp_lib_INCLUDES:%=-I$(makefile_rules_posix_dir)/../%) $(TARGET_CFLAGS)
+# Include UPPERCASE function
+include $(makefile_rules_dir)/../common.mk
+
+RPP_CFLAGS = $(rpp_lib_INCLUDES:%=-I$(makefile_rules_posix_dir)/../%) $(TARGET_CFLAGS) -DTARGET_$(call UPPERCASE,$(TARGET))
RPP_MAKE_CFLAGS = \
-MD -MF $@.dep -MP -MT $@
rpp_lib_OS = 6.0.4_posix
TARGET = posix
-TARGET_CFLAGS = -DTARGET_POSIX
+TARGET_CFLAGS =
TARGET_HAS_DMM = n
TARGET = rm48_hdk
-TARGET_CFLAGS = -mv7R4 --code_state=32 --float_support=VFPv3D16 --abi=eabi -me -DTARGET_RM48_HDK
+TARGET_CFLAGS = -mv7R4 --code_state=32 --float_support=VFPv3D16 --abi=eabi -me
TARGET_LDCMD = RM48L952FlashLnk.cmd
TARGET_LDLIBS = --library=rtsv7R4_T_le_v3D16_eabi.lib
TARGET_CCXML = RM48L952-XDS100v2.ccxml
TARGET = tms570_hdk
-TARGET_CFLAGS = -mv7R4 --code_state=32 --float_support=VFPv3D16 --abi=eabi -DTARGET_TMS570_HDK
+TARGET_CFLAGS = -mv7R4 --code_state=32 --float_support=VFPv3D16 --abi=eabi
TARGET_LDCMD = TMS570LS313xFlashLnk.cmd
TARGET_LDLIBS = --library="rtsv7R4_T_be_v3D16_eabi.lib"
TARGET_CCXML = TMS570LS3137.ccxml
TARGET = tms570_hydctr
-TARGET_CFLAGS = -mv7R4 --code_state=32 --float_support=VFPv3D16 --abi=eabi -DTARGET_TMS570_HYDCTR
+TARGET_CFLAGS = -mv7R4 --code_state=32 --float_support=VFPv3D16 --abi=eabi
TARGET_LDCMD = TMS570LS1227FlashLnk.cmd
TARGET_LDLIBS = --library="rtsv7R4_T_be_v3D16_eabi.lib"
TARGET_CCXML = TMS570LS1227.ccxml
TARGET = tms570_rpp
-TARGET_CFLAGS = -mv7R4 --code_state=32 --float_support=VFPv3D16 --abi=eabi -DTARGET_TMS570_RPP
+TARGET_CFLAGS = -mv7R4 --code_state=32 --float_support=VFPv3D16 --abi=eabi
TARGET_LDCMD = TMS570LS313xFlashLnk.cmd
TARGET_LDLIBS = --library="rtsv7R4_T_be_v3D16_eabi.lib"
TARGET_CCXML = TMS570LS3137.ccxml
print-release-basename:
@echo $$(RELEASE_BASENAME)
endef
+
+# Case conversion macros. Taken from
+# http://git.buildroot.net/buildroot/tree/package/pkg-utils.mk. This
+# is inspired by the 'up' macro from gmsl (http://gmsl.sf.net). It is
+# optimised very heavily because these macros are used a lot. It is
+# about 5 times faster than forking a shell and tr.
+#
+# The caseconvert-helper creates a definition of the case conversion macro.
+# After expansion by the outer $(eval ), the UPPERCASE macro is defined as:
+# $(strip $(eval __tmp := $(1)) $(eval __tmp := $(subst a,A,$(__tmp))) ... )
+# In other words, every letter is substituted one by one.
+#
+# The caseconvert-helper allows us to create this definition out of the
+# [FROM] and [TO] lists, so we don't need to write down every substition
+# manually. The uses of $ and $$ quoting are chosen in order to do as
+# much expansion as possible up-front.
+#
+# Note that it would be possible to conceive a slightly more optimal
+# implementation that avoids the use of __tmp, but that would be even
+# more unreadable and is not worth the effort.
+
+[FROM] := a b c d e f g h i j k l m n o p q r s t u v w x y z - .
+[TO] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _ _
+
+define caseconvert-helper
+$(1) = $$(strip \
+ $$(eval __tmp := $$(1))\
+ $(foreach c, $(2),\
+ $$(eval __tmp := $$(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)),$$(__tmp))))\
+ $$(__tmp))
+endef
+
+$(eval $(call caseconvert-helper,UPPERCASE,$(join $(addsuffix :,$([FROM])),$([TO]))))
+$(eval $(call caseconvert-helper,LOWERCASE,$(join $(addsuffix :,$([TO])),$([FROM]))))