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