X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=scripts%2FMakefile.lib;h=6e75ced8b583aebf5458403bf6456153378fff0d;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=3a7663b901f067ac1077d40fb1c3702935aa9959;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 3a7663b90..6e75ced8b 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -232,3 +232,30 @@ descend =$(Q)$(MAKE) -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build ob # Usage: # $(Q)$(MAKE) $(build)=dir build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj + +# 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 +# $(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 +# - If the content differ the new file is used +# - If they are equal no change, and no timestamp update + +define filechk + $(Q)set -e; \ + echo ' CHK $@'; \ + mkdir -p $(dir $@); \ + $(filechk_$(1)) $(2) > $@.tmp; \ + if [ -r $@ ] && cmp -s $@ $@.tmp; then \ + rm -f $@.tmp; \ + else \ + echo ' UPD $@'; \ + mv -f $@.tmp $@; \ + fi +endef +