Makefile.xtras 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #
  2. # Makefile.xtras - non-build targets
  3. # Resist the urge to fill this with miscellaneous junk
  4. # We are not building here (shouldn't be), so no meta mode.
  5. .MAKE.MODE = normal
  6. _here := ${_PARSEDIR}
  7. .MAIN: no-default
  8. .if !empty(SB_NAME)
  9. # mk wrapper
  10. MAKE_CMD= mk
  11. MAKE_MACHINE_CMD= mk --machine <machine>
  12. .else
  13. # not using 'mk'
  14. MAKE_CMD= ${.MAKE:T}
  15. MAKE_MACHINE_CMD= env MACHINE=<machine> ${.MAKE:T}
  16. .endif
  17. no-default:
  18. @echo "ERROR: there is no supported default target."; \
  19. echo "Try '${MAKE_CMD} help'"
  20. .if make(show-valid-targets)
  21. OTHER_TARGETS = \
  22. destroy \
  23. destroy-arch \
  24. destroy-host \
  25. destroy-stage \
  26. BUILD_TARGETS_${MACHINE:tu} != cd ${_here} && \
  27. find . \( ${${.MAKE.DEPENDFILE:T} ${.MAKE.DEPENDFILE_PREFIX}:L:O:u:@m@-name $m -o@:tW:S,-o$,,} \) | \
  28. sed 's,/Makefile.*,,;s,^./,,' | sort -u
  29. .for _machine in ${ALL_MACHINE_LIST}
  30. _targets_${_machine} != cd ${_here} && \
  31. find . \( ${.MAKE.DEPENDFILE_PREFERENCE:T:M*${MACHINE}*:S,${MACHINE},${_machine},g:O:u:@m@-name $m -o@:tW:S,-o$,,} \) | \
  32. sed 's,/Makefile.*,,;s,^./,,' | sort -u
  33. BUILD_TARGETS_${_machine:tu} += ${_targets_${_machine}}
  34. .endfor
  35. show-valid-targets:
  36. .for _machine in ${ALL_MACHINE_LIST:O}
  37. .if !empty(BUILD_TARGETS_${_machine:tu})
  38. @echo "Build targets for ${_machine} (leave out the ${DIRDEPS_TARGETS_DIRS:S,${_here:T},,:S,^/,,:S,$,/,}):"
  39. @echo -e "${BUILD_TARGETS_${_machine:tu}:O:ts\n}" | sed -e 's,^, ,'
  40. @echo
  41. .endif
  42. .endfor
  43. @echo "Other targets:"; echo "${OTHER_TARGETS:O:ts\n}" | sed -e 's,^, ,'
  44. .endif
  45. help: show-help
  46. show-help:
  47. @echo; \
  48. echo "You can see the targets which are valid for a given machine"; \
  49. echo "by running '${MAKE_MACHINE_CMD} show-valid-targets'"; \
  50. echo "For other information, read: ${HELP_DOCS:@d@${.newline}$d@}"; \
  51. echo
  52. not-valid-target:
  53. @echo "ERROR: '${_TARGETS}' is not a valid target for ${MACHINE}."
  54. .if make(destroy*)
  55. .include <bsd.obj.mk>
  56. .endif
  57. .for t in ${_TARGETS:Nlove}
  58. .if !target($t)
  59. $t: not-valid-target show-help
  60. .endif
  61. .endfor