1 # Common GNU Make definitions useful for multiple Makefiles
3 ECLIPSE=$(foreach file,\
4 /opt/ti/ccsv5/eclipse/eclipse \
5 C:/ti/ccsv5/eclipse/eclipsec.exe,\
6 $(if $(wildcard $(file)),$(file)))
8 ifeq ($(OS),Windows_NT)
9 TMP_WORKSPACE=$(TEMP)/_workspace
11 TMP_WORKSPACE:=$(shell mktemp --dry-run --tmpdir -d rpp-test-sw-workspace.XXXXXXXXXX)
15 ifeq ($(OS),Windows_NT)
16 pathconv=$(subst /,\,$1)
17 mkdir=-mkdir $(subst /,\,$1)
18 rm=-del /Q $(call pathconv,$1)
19 rmdir=-rmdir /S /Q $(call pathconv,$1)
20 cp=copy $(subst /,\,$1) $(subst /,\,$2)
21 # Always use cmd.exe, ignore sh.exe if there is one
31 # `make release` can ignore files without certain git attribute
32 RELEASE_IGNORE_FILES_CMD = $(strip $(if $(RELEASE_ATTR),\
33 etc/git-ls-files-attr --not $(RELEASE_ATTR),\
34 $(if $(filter RELEASE_ATTR,$(.VARIABLES)),,$(error Please specify RELEASE_ATTR variable (it can be empty)))))
36 # Usage: $(call release_rules,<release_prefix>)
40 $$(if $$(RELEASE_PREFIX),,$$(error Call release_rules with prefix as an argument))
41 ifneq ($(OS),Windows_NT)
42 RELEASE_VERSION := $$(shell git describe --always $$(RELEASE_COMMIT)|sed -e "s/^[-a-zA-Z_]*//")
44 RELEASE_BASENAME = $$(RELEASE_PREFIX)-$$(RELEASE_VERSION)
46 .PHONY: $$(RELEASE_BASENAME).zip .git/info/attributes
48 .git/info/attributes: A = $$(shell git rev-parse --git-dir)/info/attributes
50 # Ensure that attributes do not exist or are generated by us
51 test ! -e $$A || head -n 1 $$A | grep -F "Automatically generated (yoo9jei6Ee6Teiti)"
52 echo "# Automatically generated (yoo9jei6Ee6Teiti)" > $$A
53 # Write ignored files there
54 for i in `$$(RELEASE_IGNORE_FILES_CMD)`; do echo $$$$i export-ignore >> $$A; echo Not releasing $$$$i; done
56 $$(RELEASE_BASENAME).zip:
57 rm -rf $$@ $$(RELEASE_BASENAME)
58 $(MAKE) $$(RELEASE_BASENAME)
59 find $$(RELEASE_BASENAME) -type d -empty -print -delete
60 zip -r $$@ $$(RELEASE_BASENAME)
62 $$(RELEASE_BASENAME):: .git/info/attributes
63 git archive --worktree-attributes --prefix=$$@/ $$(RELEASE_COMMIT) | tar xf -
65 print-release-basename:
66 @echo $$(RELEASE_BASENAME)
69 # Case conversion macros. Taken from
70 # http://git.buildroot.net/buildroot/tree/package/pkg-utils.mk. This
71 # is inspired by the 'up' macro from gmsl (http://gmsl.sf.net). It is
72 # optimised very heavily because these macros are used a lot. It is
73 # about 5 times faster than forking a shell and tr.
75 # The caseconvert-helper creates a definition of the case conversion macro.
76 # After expansion by the outer $(eval ), the UPPERCASE macro is defined as:
77 # $(strip $(eval __tmp := $(1)) $(eval __tmp := $(subst a,A,$(__tmp))) ... )
78 # In other words, every letter is substituted one by one.
80 # The caseconvert-helper allows us to create this definition out of the
81 # [FROM] and [TO] lists, so we don't need to write down every substition
82 # manually. The uses of $ and $$ quoting are chosen in order to do as
83 # much expansion as possible up-front.
85 # Note that it would be possible to conceive a slightly more optimal
86 # implementation that avoids the use of __tmp, but that would be even
87 # more unreadable and is not worth the effort.
89 [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 - .
90 [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 _ _
92 define caseconvert-helper
94 $$(eval __tmp := $$(1))\
96 $$(eval __tmp := $$(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)),$$(__tmp))))\
100 $(eval $(call caseconvert-helper,UPPERCASE,$(join $(addsuffix :,$([FROM])),$([TO]))))
101 $(eval $(call caseconvert-helper,LOWERCASE,$(join $(addsuffix :,$([TO])),$([FROM]))))