ramips: remove factory image for TP-Link Archer C20 v1
[openwrt/openwrt.git] / include / depends.mk
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # Copyright (C) 2007-2020 OpenWrt.org
4
5 # define a dependency on a subtree
6 # parameters:
7 # 1: directories/files
8 # 2: directory dependency
9 # 3: tempfile for file listings
10 # 4: find options
11
12 DEP_FINDPARAMS := -x "*/.svn*" -x ".*" -x "*:*" -x "*\!*" -x "* *" -x "*\\\#*" -x "*/.*_check" -x "*/.*.swp" -x "*/.pkgdir*"
13
14 find_md5=find $(wildcard $(1)) -type f $(patsubst -x,-and -not -path,$(DEP_FINDPARAMS) $(2)) -printf "%p%T@\n" | sort | mkhash md5
15
16 define rdep
17 .PRECIOUS: $(2)
18 .SILENT: $(2)_check
19
20 $(2): $(2)_check
21 check-depends: $(2)_check
22
23 ifneq ($(wildcard $(2)),)
24 $(2)_check::
25 $(if $(3), \
26 $(call find_md5,$(1),$(4)) > $(3).1; \
27 { [ \! -f "$(3)" ] || diff $(3) $(3).1 >/dev/null; } && \
28 ) \
29 { \
30 [ -f "$(2)_check.1" ] && mv "$(2)_check.1"; \
31 $(TOPDIR)/scripts/timestamp.pl $(DEP_FINDPARAMS) $(4) -n $(2) $(1) && { \
32 $(call debug_eval,$(SUBDIR),r,echo "No need to rebuild $(2)";) \
33 touch -r "$(2)" "$(2)_check"; \
34 } \
35 } || { \
36 $(call debug_eval,$(SUBDIR),r,echo "Need to rebuild $(2)";) \
37 touch "$(2)_check"; \
38 }
39 $(if $(3), mv $(3).1 $(3))
40 else
41 $(2)_check::
42 $(if $(3), rm -f $(3) $(3).1)
43 $(call debug_eval,$(SUBDIR),r,echo "Target $(2) not built")
44 endif
45
46 endef
47
48 ifeq ($(filter .%,$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),$(MAKECMDGOALS),x))
49 define rdep
50 $(2): $(2)_check
51 endef
52 endif