xref: /freebsd/targets/Makefile.xtras (revision 3fc36ee018bb836bd1796067cf4ef8683f166ebc)
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 . \( -name Makefile.depend -o -name ${.MAKE.DEPENDFILE:T} \) | \
38	sed 's,/Makefile.*,,;s,^./,,' | sort -u
39
40.for _machine in ${all_machine_list}
41_targets_${_machine} != cd ${_here} && \
42	find . \( -name Makefile.depend.${_machine} -o \
43	    -name ${.MAKE.DEPENDFILE:T}.${_machine} \) | \
44	sed 's,/Makefile.*,,;s,^./,,' | sort -u
45BUILD_TARGETS_${_machine:tu} += ${_targets_${_machine}}
46.endfor
47
48show-valid-targets:
49.for _machine in ${all_machine_list:O}
50.if !empty(BUILD_TARGETS_${_machine:tu})
51	@echo "Build targets for ${_machine} (leave out the ${target_dirs:S,${_here:T},,:S,^/,,:S,$,/,}):"
52	@echo -e "${BUILD_TARGETS_${_machine:tu}:O:ts\n}" | sed -e 's,^,  ,'
53	@echo
54.endif
55.endfor
56	@echo "Other targets:"; echo "${OTHER_TARGETS:O:ts\n}" | sed -e 's,^,  ,'
57.endif
58
59help: show-help
60show-help:
61	@echo; \
62	echo "You can see the targets which are valid for a given machine"; \
63	echo "by running '${MAKE_MACHINE_CMD} show-valid-targets'"; \
64	echo "For other information, read: ${HELP_DOCS:@d@${.newline}$d@}"; \
65	echo
66
67not-valid-target:
68	@echo "ERROR: '${_TARGETS}' is not a valid target for ${MACHINE}."
69
70.if make(destroy*)
71.include <bsd.obj.mk>
72.endif
73
74.for t in ${_TARGETS:Nlove}
75.if !target($t)
76$t: not-valid-target show-help
77.endif
78.endfor
79