/share/mk/bsd.subdir.mk

https://bitbucket.org/freebsd/freebsd-head/ · Makefile · 94 lines · 57 code · 7 blank · 30 comment · 6 complexity · 8d17443ba1a5fe914fa25cc3a1d05324 MD5 · raw file

  1. # from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
  2. # $FreeBSD$
  3. #
  4. # The include file <bsd.subdir.mk> contains the default targets
  5. # for building subdirectories.
  6. #
  7. # For all of the directories listed in the variable SUBDIRS, the
  8. # specified directory will be visited and the target made. There is
  9. # also a default target which allows the command "make subdir" where
  10. # subdir is any directory listed in the variable SUBDIRS.
  11. #
  12. #
  13. # +++ variables +++
  14. #
  15. # DISTRIBUTION Name of distribution. [base]
  16. #
  17. # SUBDIR A list of subdirectories that should be built as well.
  18. # Each of the targets will execute the same target in the
  19. # subdirectories.
  20. #
  21. # +++ targets +++
  22. #
  23. # distribute:
  24. # This is a variant of install, which will
  25. # put the stuff into the right "distribution".
  26. #
  27. # afterinstall, all, all-man, beforeinstall, checkdpadd, clean,
  28. # cleandepend, cleandir, cleanilinks depend, install, lint,
  29. # maninstall, manlint, obj, objlink, realinstall, regress, tags
  30. #
  31. .include <bsd.init.mk>
  32. DISTRIBUTION?= base
  33. .if !target(distribute)
  34. distribute:
  35. .for dist in ${DISTRIBUTION}
  36. ${_+_}cd ${.CURDIR}; \
  37. ${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies
  38. .endfor
  39. .endif
  40. _SUBDIR: .USE
  41. .if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR)
  42. @${_+_}set -e; for entry in ${SUBDIR}; do \
  43. if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
  44. ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH} (${.TARGET:realinstall=install})"; \
  45. edir=$${entry}.${MACHINE_ARCH}; \
  46. cd ${.CURDIR}/$${edir}; \
  47. else \
  48. ${ECHODIR} "===> ${DIRPRFX}$$entry (${.TARGET:realinstall=install})"; \
  49. edir=$${entry}; \
  50. cd ${.CURDIR}/$${edir}; \
  51. fi; \
  52. ${MAKE} ${.TARGET:realinstall=install} \
  53. DIRPRFX=${DIRPRFX}$$edir/; \
  54. done
  55. .endif
  56. ${SUBDIR}: .PHONY
  57. ${_+_}@if test -d ${.TARGET}.${MACHINE_ARCH}; then \
  58. cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
  59. else \
  60. cd ${.CURDIR}/${.TARGET}; \
  61. fi; \
  62. ${MAKE} all
  63. .for __target in all all-man checkdpadd clean cleandepend cleandir \
  64. cleanilinks depend distribute lint maninstall manlint obj objlink \
  65. realinstall regress tags ${SUBDIR_TARGETS}
  66. ${__target}: _SUBDIR
  67. .endfor
  68. .for __target in files includes
  69. .for __stage in build install
  70. ${__stage}${__target}:
  71. .if make(${__stage}${__target})
  72. ${__stage}${__target}: _SUBDIR
  73. .endif
  74. .endfor
  75. ${__target}:
  76. ${_+_}set -e; cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target}
  77. .endfor
  78. .if !target(install)
  79. .if !target(beforeinstall)
  80. beforeinstall:
  81. .endif
  82. .if !target(afterinstall)
  83. afterinstall:
  84. .endif
  85. install: beforeinstall realinstall afterinstall
  86. .ORDER: beforeinstall realinstall afterinstall
  87. .endif