os161.subdir.mk 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #
  2. # OS/161 build environment: recurse into subdirectories
  3. #
  4. # Usage:
  5. # TOP=../..
  6. # .include "$(TOP)/mk/os161.config.mk"
  7. # [defs go here]
  8. # .include "$(TOP)/mk/os161.subdir.mk"
  9. # [any extra rules go here]
  10. #
  11. # Variables controlling this file:
  12. #
  13. # SUBDIRS Directories to recurse into.
  14. # EXTRATARGETS Additional targets to define.
  15. #
  16. # BASETARGETS may also be set to empty to suppress the usual targets.
  17. #
  18. # Note: SUBDIRS may contain .WAIT, which is treated as a parallelism
  19. # barrier like in the right hand side of a make rule.
  20. #
  21. # Further note: if combining os161.subdir.mk with other os161.*.mk
  22. # files (other than os161.config.mk), include os161.subdir.mk first;
  23. # then the ordering of things will cause recursion to happen
  24. # first. Also, .WAIT is inserted so that the recursion will finish
  25. # before anything else happens, which is almost always desirable.
  26. #
  27. BASETARGETS?=\
  28. all depend install install-staging clean distclean tags \
  29. cleandir stage dependall build rebuild fullrebuild
  30. # first, make each target depend on its -subdirs target,
  31. # and declare both PHONY.
  32. .for _T_ in $(BASETARGETS) $(EXTRATARGETS)
  33. $(_T_): $(_T_)-subdirs .WAIT
  34. .PHONY: $(_T_) $(_T_)-subdirs
  35. .endfor
  36. # now, make each -subdirs target depend on a rule for each subdir.
  37. .for _D_ in $(SUBDIRS)
  38. .for _T_ in $(BASETARGETS) $(EXTRATARGETS)
  39. .if "$(_D_)" == ".WAIT"
  40. $(_T_)-subdirs: .WAIT
  41. .else
  42. $(_T_)-subdirs: $(_T_)-subdirs-$(_D_)
  43. .PHONY: $(_T_)-subdirs-$(_D_)
  44. $(_T_)-subdirs-$(_D_):
  45. (cd $(_D_) && $(MAKE) $(_T_))
  46. .endif
  47. .endfor
  48. .endfor