]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
Makefile: Construct -DTARGET_<NAME> automatically
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 8 Jul 2015 17:01:58 +0000 (19:01 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 8 Jul 2015 17:06:35 +0000 (19:06 +0200)
This will help us when compiling documentation for rpp-test-sw commands.

build/Makefile.rules.arm
build/Makefile.rules.posix
build/posix/Makefile.config
build/rm48_hdk/Makefile.config
build/tms570_hdk/Makefile.config
build/tms570_hydctr/Makefile.config
build/tms570_rpp/Makefile.config
common.mk

index b818520605c70ebeacd13205d98b4d37b3c9e62e..cb4d9dd44baa09c976729356412ec0a390d53ee2 100644 (file)
@@ -40,9 +40,15 @@ LD=$(CC)
 # 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))
index a5d9e7691d010a0991c0ac83bb18d8de7b5f8ddd..ea9cbe3d565decfa6041bb79544e2a3560f38c1d 100644 (file)
@@ -15,7 +15,7 @@
 
 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
 
@@ -26,7 +26,10 @@ LD=$(CC)
 # 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 $@
index ea4b068b5b662c598a52697b2469ae155a2eb809..2db47a5006f80ebd10dac95c83d230cec77d02f5 100644 (file)
@@ -1,5 +1,5 @@
 rpp_lib_OS = 6.0.4_posix
 TARGET = posix
-TARGET_CFLAGS = -DTARGET_POSIX
+TARGET_CFLAGS =
 
 TARGET_HAS_DMM = n
index a5e60167ca7346b2f26ac3626a12db7b5731071c..f9bdf39dccb7d62627eb382ff77c52846d49727a 100644 (file)
@@ -1,5 +1,5 @@
 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
index 3782b55a7a3784b6a4ba8da2f29dc2331d4a8072..e68c9ee7974a69f24a29c0e425adab1c99cb7197 100644 (file)
@@ -1,5 +1,5 @@
 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
index 77366dd4de9c510af1385b61a88dea43ef209fea..6e6a3ba8bc7905d2fad0df47efc16c4eb6cc5cf0 100644 (file)
@@ -1,5 +1,5 @@
 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
index 34f3c674cfdffa825bbb901cfc8926daf4e9aa75..0726eaec7971a7593965d6a81eadaf49b032b836 100644 (file)
@@ -1,5 +1,5 @@
 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
index 4e08abedc03fdf52585853b2bf6e63ea0b70780c..ef3818d274be7521e9e1fa353e917cdadc71712b 100644 (file)
--- a/common.mk
+++ b/common.mk
@@ -64,3 +64,37 @@ $$(RELEASE_BASENAME):: .git/info/attributes
 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]))))