895 endif 896 897 ################################################################################ 898 # Write to and read from file 899 900 # Param 1 - File to read 901 ReadFile = \ 902 $(shell $(CAT) $1) 903 904 # Param 1 - Text to write 905 # Param 2 - File to write to 906 ifeq ($(HAS_FILE_FUNCTION), true) 907 WriteFile = \ 908 $(file >$2,$(strip $1)) 909 else 910 # Use printf to get consistent behavior on all platforms. 911 WriteFile = \ 912 $(shell $(PRINTF) "%s" $(call ShellQuote, $1) > $2) 913 endif 914 915 ################################################################################ 916 # DependOnVariable 917 # 918 # This macro takes a variable name and puts the value in a file only if the 919 # value has changed since last. The name of the file is returned. This can be 920 # used to create rule dependencies on make variable values. The following 921 # example would get rebuilt if the value of SOME_VAR was changed: 922 # 923 # path/to/some-file: $(call DependOnVariable, SOME_VAR) 924 # echo $(SOME_VAR) > $@ 925 # 926 # Note that leading and trailing white space in the value is ignored. 927 # 928 929 # Defines the sub directory structure to store variable value file in 930 DependOnVariableDirName = \ 931 $(strip $(addsuffix $(if $(MODULE),/$(MODULE)), \ 932 $(subst $(TOPDIR)/,, $(if $(filter /%, $(firstword $(MAKEFILE_LIST))), \ 933 $(firstword $(MAKEFILE_LIST)), \ 934 $(CURDIR)/$(firstword $(MAKEFILE_LIST)))))) | 895 endif 896 897 ################################################################################ 898 # Write to and read from file 899 900 # Param 1 - File to read 901 ReadFile = \ 902 $(shell $(CAT) $1) 903 904 # Param 1 - Text to write 905 # Param 2 - File to write to 906 ifeq ($(HAS_FILE_FUNCTION), true) 907 WriteFile = \ 908 $(file >$2,$(strip $1)) 909 else 910 # Use printf to get consistent behavior on all platforms. 911 WriteFile = \ 912 $(shell $(PRINTF) "%s" $(call ShellQuote, $1) > $2) 913 endif 914 915 # Param 1 - Text to write 916 # Param 2 - File to write to 917 ifeq ($(HAS_FILE_FUNCTION), true) 918 AppendFile = \ 919 $(file >>$2,$(strip $1)) 920 else 921 # Use printf to get consistent behavior on all platforms. 922 AppendFile = \ 923 $(shell $(PRINTF) "%s" $(call ShellQuote, $1) >> $2) 924 endif 925 926 ################################################################################ 927 # DependOnVariable 928 # 929 # This macro takes a variable name and puts the value in a file only if the 930 # value has changed since last. The name of the file is returned. This can be 931 # used to create rule dependencies on make variable values. The following 932 # example would get rebuilt if the value of SOME_VAR was changed: 933 # 934 # path/to/some-file: $(call DependOnVariable, SOME_VAR) 935 # echo $(SOME_VAR) > $@ 936 # 937 # Note that leading and trailing white space in the value is ignored. 938 # 939 940 # Defines the sub directory structure to store variable value file in 941 DependOnVariableDirName = \ 942 $(strip $(addsuffix $(if $(MODULE),/$(MODULE)), \ 943 $(subst $(TOPDIR)/,, $(if $(filter /%, $(firstword $(MAKEFILE_LIST))), \ 944 $(firstword $(MAKEFILE_LIST)), \ 945 $(CURDIR)/$(firstword $(MAKEFILE_LIST)))))) |