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