Makefile.makedev revision 1.12
1#	$NetBSD: Makefile.makedev,v 1.12 2007/03/01 09:20:59 apb Exp $
2#
3# Makefile snippet to add ${MAKEDEVTARGETS} devices to the mtree list
4# (if set), otherwise copy .OJBDIR-of-etc/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 .OBJDIR-of-etc/MAKEDEV
15#
16# Variables modified by this:
17#	MAKEDEVSCRIPT	path to .OBJDIR-of-etc/MAKEDEV
18#	MAKEDEVSUBR	path to .OBJDIR-of-etc/MAKEDEV.subr
19#	MTREECONF	may get "devices.spec" added
20#	LISTS		may get "list.makedev" added
21#	IMAGEDEPENDS	may get ${MAKEDEVSCRIPT} and ${MAKEDEVSUBR} added
22#	PARSELISTENV	may get MAKEDEVSCRIPT=... and MAKEDEVSUBR=... added
23#
24
25.if !defined(_MAKEFILE_MAKEDEV_)
26_MAKEFILE_MAKEDEV_=1
27
28
29MAKEDEVSPEC?=	devices.spec
30
31_MAKEDEVOBJDIR!=cd ${NETBSDSRCDIR}/etc && ${PRINTOBJDIR}
32MAKEDEVSCRIPT=	${_MAKEDEVOBJDIR}/MAKEDEV
33MAKEDEVSUBR=	${_MAKEDEVOBJDIR}/MAKEDEV.subr
34
35CLEANFILES+=	${MAKEDEVSPEC} ${MAKEDEVSPEC}.tmp
36
37
38.if defined(MAKEDEVTARGETS)
39
40#
41#	MAKEDEVTARGETS is set; add those devices to the mtree spec that's
42#	used to build the file system
43#
44MTREECONF+=	${MAKEDEVSPEC}
45
46${MAKEDEVSPEC}:	${MAKEDEVSCRIPT} ${MAKEDEVSUBR}
47	${_MKTARGET_CREATE}
48	-rm -f ${.TARGET} ${.TARGET}.tmp
49	MACHINE=${MACHINE:Q} MACHINE_ARCH=${MACHINE_ARCH:Q} \
50	    ${HOST_SH} ${MAKEDEVSCRIPT} -s ${MAKEDEVTARGETS} \
51	    | sed -e '/^\. type=dir/d' -e 's,^\.,./dev,' > ${.TARGET}.tmp \
52	&& sort -o ${.TARGET} ${.TARGET}.tmp
53
54.else	# ! MAKEDEVTARGETS
55
56#
57#	MAKEDEVTARGETS isn't set; copy in /dev/MAKEDEV and rely upon
58#	init(8) to mount an mfs /dev and recreate the devices by
59#	(effectively) running "cd /dev ; ./MAKEDEV all"
60#
61LISTS+=		${DISTRIBDIR}/common/list.makedev
62IMAGEDEPENDS+=	${MAKEDEVSCRIPT} ${MAKEDEVSUBR}
63PARSELISTENV+=	MAKEDEVSCRIPT=${MAKEDEVSCRIPT:Q}
64PARSELISTENV+=	MAKEDEVSUBR=${MAKEDEVSUBR:Q}
65
66${MAKEDEVSPEC}:	.PHONY
67
68.endif	# ! MAKEDEVTARGETS
69
70
71.endif	# _MAKEFILE_MAKEDEV_
72