kbuild: use assignment instead of define ... endef for filechk_* rules
[linux-2.6-block.git] / scripts / Kbuild.include
index 3d09844405c923c2d1a7fa04d6e1c15b6567180d..525bff667a528404ea887b57b4723096780d59bc 100644 (file)
@@ -41,11 +41,11 @@ kecho := $($(quiet)kecho)
 ###
 # filechk is used to check if the content of a generated file is updated.
 # Sample usage:
-# define filechk_sample
-#      echo $KERNELRELEASE
-# endef
-# version.h : Makefile
+#
+# filechk_sample = echo $(KERNELRELEASE)
+# version.h: FORCE
 #      $(call filechk,sample)
+#
 # The rule defined shall write to stdout the content of the new file.
 # The existing file will be compared with the new one.
 # - If no file exist it is created
@@ -56,7 +56,7 @@ kecho := $($(quiet)kecho)
 define filechk
        $(Q)set -e;                             \
        mkdir -p $(dir $@);                     \
-       $(filechk_$(1)) > $@.tmp;               \
+       { $(filechk_$(1)); } > $@.tmp;          \
        if [ -r $@ ] && cmp -s $@ $@.tmp; then  \
                rm -f $@.tmp;                   \
        else                                    \
@@ -213,7 +213,7 @@ echo-cmd = $(if $($(quiet)cmd_$(1)),\
        echo '  $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
 
 # printing commands
-cmd = @$(echo-cmd) $(cmd_$(1))
+cmd = @set -e; $(echo-cmd) $(cmd_$(1))
 
 # Add $(obj)/ for paths that are not absolute
 objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
@@ -249,56 +249,21 @@ any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
 
 # Execute command if command has changed or prerequisite(s) are updated.
 if_changed = $(if $(strip $(any-prereq) $(arg-check)),                       \
-       @set -e;                                                             \
-       $(echo-cmd) $(cmd_$(1));                                             \
+       $(cmd);                                                              \
        printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
 
 # Execute the command and also postprocess generated .d dependencies file.
-if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ),                  \
-       @set -e;                                                             \
-       $(cmd_and_fixdep), @:)
-
-ifndef CONFIG_TRIM_UNUSED_KSYMS
+if_changed_dep = $(if $(strip $(any-prereq) $(arg-check)),$(cmd_and_fixdep),@:)
 
 cmd_and_fixdep =                                                             \
-       $(echo-cmd) $(cmd_$(1));                                             \
-       scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
-       rm -f $(depfile);                                                    \
-       mv -f $(dot-target).tmp $(dot-target).cmd;
-
-else
-
-# Filter out exported kernel symbol names from the preprocessor output.
-# See also __KSYM_DEPS__ in include/linux/export.h.
-# We disable the depfile generation here, so as not to overwrite the existing
-# depfile while fixdep is parsing it.
-flags_nodeps = $(filter-out -Wp$(comma)-M%, $($(1)))
-ksym_dep_filter =                                                            \
-       case "$(1)" in                                                       \
-         cc_*_c|cpp_i_c)                                                    \
-           $(CPP) $(call flags_nodeps,c_flags) -D__KSYM_DEPS__ $< ;;        \
-         as_*_S|cpp_s_S)                                                    \
-           $(CPP) $(call flags_nodeps,a_flags) -D__KSYM_DEPS__ $< ;;        \
-         boot*|build*|cpp_its_S|*cpp_lds_S|dtc|host*|vdso*) : ;;            \
-         *) echo "Don't know how to preprocess $(1)" >&2; false ;;          \
-       esac | tr ";" "\n" | sed -n 's/^.*=== __KSYM_\(.*\) ===.*$$/_\1/p'
-
-cmd_and_fixdep =                                                             \
-       $(echo-cmd) $(cmd_$(1));                                             \
-       $(ksym_dep_filter) |                                                 \
-               scripts/basic/fixdep -e $(depfile) $@ '$(make-cmd)'          \
-                       > $(dot-target).tmp;                                 \
-       rm -f $(depfile);                                                    \
-       mv -f $(dot-target).tmp $(dot-target).cmd;
-
-endif
+       $(cmd);                                                              \
+       scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\
+       rm -f $(depfile)
 
 # Usage: $(call if_changed_rule,foo)
 # Will check if $(cmd_foo) or any of the prerequisites changed,
 # and if so will execute $(rule_foo).
-if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ),                 \
-       @set -e;                                                             \
-       $(rule_$(1)), @:)
+if_changed_rule = $(if $(strip $(any-prereq) $(arg-check)),$(rule_$(1)),@:)
 
 ###
 # why - tell why a target got built
@@ -391,3 +356,6 @@ endef
 
 # delete partially updated (i.e. corrupted) files on error
 .DELETE_ON_ERROR:
+
+# do not delete intermediate files automatically
+.SECONDARY: