summaryrefslogtreecommitdiff
path: root/include/depends.mk
blob: 4819d6dfc1c4015e651d7d5b9c33e160e4c04587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 
# 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: directory
#	2: directory dependency
#	3: tempfile for file listings
#	4: find options

DEP_FINDPARAMS := -type f -not -name ".*" -and -not -path "*.svn*" -type f -not -name ".*" -and -not -path "*.svn*" -and -not -path "*:*" -and -not -path "*!*" -and -not -path "* *" -and -not -path "*\\\#*"
define rdep
  $(foreach file,$(shell find $(1) $(DEP_FINDPARAMS) $(4)),
    $(2): $(file)
    $(file): ;
  )

  ifneq ($(3),)
    ifneq ($$(shell find $(1) $(DEP_FINDPARAMS) $(4) 2>/dev/null | md5s),$(if $(3),$(shell cat $(3) || touch $(3) 2>/dev/null)))
      $(2): $(3)
    endif
  
  endif

  $(3): FORCE
	  @-find $(1) $(DEP_FINDPARAMS) $(4) 2>/dev/null | md5s > $$@
  .PRECIOUS: $(3)
endef