mirror of
git://git.openwrt.org/openwrt/openwrt.git
synced 2024-12-27 17:12:46 +00:00
36e0268aa6
It was observed that the MD5 would not change after source files had been modified, looking deeper into the build process it was discovered that find_md5 build function makes a list of the files being built and then passes the list to a summing utility on stdin. The resultant MD5 is of the file list, not the contents of the files. The MD5 would change if the ordering of the list changed, or items were removed or deleted. The proposed fix is to add the modification time after the filename and then sort the list to prevent find returning files in a different order falsely re-triggering a rebuild. The MD5 will now change when a file is modified or files are added/removed from the list. Using 'T@' to show time in epoch for timezone independent behaviour. Signed-off-by: John Beckett <john.beckett@net2edge.com>
55 lines
1.4 KiB
Makefile
55 lines
1.4 KiB
Makefile
#
|
|
# Copyright (C) 2007 OpenWrt.org
|
|
#
|
|
# This is free software, licensed under the GNU General Public License v2.
|
|
# See /LICENSE for more information.
|
|
#
|
|
# define a dependency on a subtree
|
|
# parameters:
|
|
# 1: directories/files
|
|
# 2: directory dependency
|
|
# 3: tempfile for file listings
|
|
# 4: find options
|
|
|
|
DEP_FINDPARAMS := -x "*/.svn*" -x ".*" -x "*:*" -x "*\!*" -x "* *" -x "*\\\#*" -x "*/.*_check" -x "*/.*.swp" -x "*/.pkgdir*"
|
|
|
|
find_md5=find $(wildcard $(1)) -type f $(patsubst -x,-and -not -path,$(DEP_FINDPARAMS) $(2)) -printf "%p%T@\n" | sort | mkhash md5
|
|
|
|
define rdep
|
|
.PRECIOUS: $(2)
|
|
.SILENT: $(2)_check
|
|
|
|
$(2): $(2)_check
|
|
check-depends: $(2)_check
|
|
|
|
ifneq ($(wildcard $(2)),)
|
|
$(2)_check::
|
|
$(if $(3), \
|
|
$(call find_md5,$(1),$(4)) > $(3).1; \
|
|
{ [ \! -f "$(3)" ] || diff $(3) $(3).1 >/dev/null; } && \
|
|
) \
|
|
{ \
|
|
[ -f "$(2)_check.1" ] && mv "$(2)_check.1"; \
|
|
$(TOPDIR)/scripts/timestamp.pl $(DEP_FINDPARAMS) $(4) -n $(2) $(1) && { \
|
|
$(call debug_eval,$(SUBDIR),r,echo "No need to rebuild $(2)";) \
|
|
touch -r "$(2)" "$(2)_check"; \
|
|
} \
|
|
} || { \
|
|
$(call debug_eval,$(SUBDIR),r,echo "Need to rebuild $(2)";) \
|
|
touch "$(2)_check"; \
|
|
}
|
|
$(if $(3), mv $(3).1 $(3))
|
|
else
|
|
$(2)_check::
|
|
$(if $(3), rm -f $(3) $(3).1)
|
|
$(call debug_eval,$(SUBDIR),r,echo "Target $(2) not built")
|
|
endif
|
|
|
|
endef
|
|
|
|
ifeq ($(filter .%,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),$(MAKECMDGOALS),x))
|
|
define rdep
|
|
$(2): $(2)_check
|
|
endef
|
|
endif
|