Makefile.makedev revision 1.7 1 # $NetBSD: Makefile.makedev,v 1.7 2003/10/25 04:29:24 lukem 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 # MTREECONF may get "devices.spec" added
19 # LISTS may get "list.makedev" added
20 # IMAGEDEPENDS may get ${MAKEDEVSCRIPT} added
21 # PARSELISTENV may get MAKEDEVSCRIPT=... added
22 #
23
24 .if !defined(_MAKEFILE_MAKEDEV_)
25 _MAKEFILE_MAKEDEV_=1
26
27
28 MAKEDEVSPEC?= devices.spec
29
30 _MAKEDEVOBJDIR!=cd ${NETBSDSRCDIR}/etc && ${PRINTOBJDIR}
31 MAKEDEVSCRIPT= ${_MAKEDEVOBJDIR}/MAKEDEV
32
33 CLEANFILES+= ${MAKEDEVSPEC} ${MAKEDEVSPEC}.tmp
34
35
36 .if defined(MAKEDEVTARGETS)
37
38 #
39 # MAKEDEVTARGETS is set; add those devices to the mtree spec that's
40 # used to build the file system
41 #
42 _MAKEDEVWRAP= ${DISTRIBDIR}/common/MAKEDEV.wrapper
43 _MAKEDEV2SPEC= ${DISTRIBDIR}/common/makedev2spec.awk
44
45 MTREECONF+= ${MAKEDEVSPEC}
46
47 ${MAKEDEVSPEC}: ${MAKEDEVSCRIPT} ${_MAKEDEVWRAP} ${_MAKEDEV2SPEC}
48 -rm -f ${.TARGET} ${.TARGET}.tmp
49 MAKEDEVSCRIPT=${MAKEDEVSCRIPT:Q} \
50 ${HOST_SH} ${_MAKEDEVWRAP} ${MAKEDEVTARGETS} | \
51 awk -f ${_MAKEDEV2SPEC} > ${.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 #
61 LISTS+= ${DISTRIBDIR}/common/list.makedev
62 IMAGEDEPENDS+= ${MAKEDEVSCRIPT}
63 PARSELISTENV+= MAKEDEVSCRIPT=${MAKEDEVSCRIPT:Q}
64
65 ${MAKEDEVSPEC}: .PHONY
66
67 .endif # ! MAKEDEVTARGETS
68
69
70 .endif # _MAKEFILE_MAKEDEV_
71