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