Makefile.makedev revision 1.6
1#	$NetBSD: Makefile.makedev,v 1.6 2003/05/08 13:04:37 christos Exp $
2#
3# Makefile snippet to add ${MAKEDEVTARGETS} devices to the mtree list
4# (if set), otherwise copy etc.${MACHINE}/MAKEDEV to ./dev
5#
6# If this is to be used with Makefile.image, then this file should be
7# .include-d first.
8#
9# Required variables:
10#	NETBSDSRCDIR	top level of src tree (set by <bsd.own.mk>)
11#	MACHINE		machine name (set externally by build framework)
12#
13# Optional variables:
14#	MAKEDEVTARGETS	targets to create with etc/etc.${MACHINE}/MAKEDEV
15#
16# Variables modified by this:
17#	MTREECONF	may get "devices.spec" added to it
18#
19
20.if !defined(_MAKEFILE_MAKEDEV_)
21_MAKEFILE_MAKEDEV_=1
22
23
24MAKEDEVSPEC?=	devices.spec
25
26CLEANFILES+=	${MAKEDEVSPEC} ${MAKEDEVSPEC}.tmp
27
28
29.if defined(MAKEDEVTARGETS)
30
31#
32#	MAKEDEVTARGETS is set; add those devices to the mtree spec that's
33#	used to build the file system
34#
35_MAKEDEVSCRIPT=	${NETBSDSRCDIR}/etc/etc.${MACHINE}/MAKEDEV
36_MAKEDEVWRAP=	${DISTRIBDIR}/common/MAKEDEV.wrapper
37_MAKEDEV2SPEC=	${DISTRIBDIR}/common/makedev2spec.awk
38
39MTREECONF+=	${MAKEDEVSPEC}
40
41${MAKEDEVSPEC}:	${_MAKEDEVSCRIPT} ${_MAKEDEVWRAP} ${_MAKEDEV2SPEC}
42	-rm -f ${.TARGET} ${.TARGET}.tmp
43	MAKEDEVSCRIPT=${_MAKEDEVSCRIPT:Q} \
44	    ${HOST_SH} ${_MAKEDEVWRAP} ${MAKEDEVTARGETS} | \
45	    awk -f ${_MAKEDEV2SPEC} > ${.TARGET}.tmp \
46	&& sort -o ${.TARGET} ${.TARGET}.tmp
47
48.else	# ! MAKEDEVTARGETS
49
50#
51#	MAKEDEVTARGETS isn't set; copy in /dev/MAKEDEV and rely upon
52#	init(8) to mount an mfs /dev and recreate the devices by
53#	(effectively) running "cd /dev ; ./MAKEDEV all"
54#
55LISTS+=		${DISTRIBDIR}/common/list.makedev
56IMAGEDEPENDS+=	${NETBSDSRCDIR}/etc/etc.${MACHINE}/MAKEDEV
57
58${MAKEDEVSPEC}:	.PHONY
59
60.endif	# ! MAKEDEVTARGETS
61
62
63.endif	# _MAKEFILE_MAKEDEV_
64