depends.mk 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #
  2. # Copyright (C) 2007 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. # define a dependency on a subtree
  8. # parameters:
  9. # 1: directories/files
  10. # 2: directory dependency
  11. # 3: tempfile for file listings
  12. # 4: find options
  13. DEP_FINDPARAMS := -x "*/.svn*" -x ".*" -x "*:*" -x "*\!*" -x "* *" -x "*\\\#*" -x "*/.*_check"
  14. find_md5=find $(1) -type f $(patsubst -x,-and -not -path,$(DEP_FINDPARAMS) $(2)) | md5s
  15. define rdep
  16. .PRECIOUS: $(2)
  17. .SILENT: $(2)_check
  18. $(2): $(2)_check
  19. $(2)_check::
  20. if [ -f "$(2)" ]; then \
  21. $(if $(3), \
  22. $(call find_md5,$(1),$(4)) > $(3).1; \
  23. { [ \! -f "$(3)" ] || diff $(3) $(3).1 >/dev/null; } && \
  24. ) \
  25. { \
  26. [ -f "$(2)_check.1" ] && mv "$(2)_check.1"; \
  27. $(TOPDIR)/scripts/timestamp.pl $(DEP_FINDPARAMS) $(4) -n $(2) $(1) && { \
  28. $(call debug_eval,$(SUBDIR),r,echo "No need to rebuild $(2)";) \
  29. touch -r "$(2)" "$(2)_check"; \
  30. } \
  31. } || { \
  32. $(call debug_eval,$(SUBDIR),r,echo "Need to rebuild $(2)";) \
  33. touch "$(2)_check"; \
  34. }; \
  35. $(if $(3), mv $(3).1 $(3);) \
  36. else \
  37. $(if $(3), rm -f $(3) $(3).1;) \
  38. $(call debug_eval,$(SUBDIR),r,echo "Target $(2) not built";) \
  39. true; \
  40. fi
  41. endef