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