[BACK]Return to Makefile.makedev CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / distrib / common

File: [cvs.NetBSD.org] / src / distrib / common / Makefile.makedev (download)

Revision 1.8, Sun Dec 21 17:37:26 2003 UTC (15 years, 9 months ago) by lukem
Branch: MAIN
Changes since 1.7: +4 -8 lines

Rework MAKEDEV:

    *	Use "mknod -F netbsd -r" to create nodes, instead of
	"rm ; mknod; chmod; chown".
	This means permissions & ownership of existing nodes will
	not be changed.
	This is up to 30% faster when populating an empty /dev,
	and nearly 2x faster when re-running on an existing /dev.

    *	New options:
    	-f		force change of permission & ownership of existing
			devices
    	-m mknod	override name/path of mknod program
			(which defaults to $TOOL_MKNOD, then "mknod").
	-s		generate mtree(8) specfile instead of creating devices

    *	Remove /usr/etc from $PATH; not needed anymore.

    *	Provide functions to create devices & directories:
	    mkdev name [b|c] major minor [mode{=600} [gid{=0} [uid{=0}]]]
		create device node `name' with the appropriate permissions
	    lndev src target
		create a symlink from src to target
	    makedir dir mode
		create directory with appropriate mode

    *	UIDs and GIDs are hardcoded in at MAKEDEV generation time.
	(Unfortunately there's not a simple way of determining a GID
	a la "id -n user" for determining a UID).

This was tested by generating MAKEDEV for each MACHINE,MACHINE_ARCH
combination and comparing the results of "MAKEDEV all" from the
previous version to the new one.
(This testing actually highlighted mistakes in the previous configuration!)


Simplify distrib/common/Makefile.makedev to use "MAKEDEV -s"

#	$NetBSD: Makefile.makedev,v 1.8 2003/12/21 17:37:26 lukem Exp $
#
# Makefile snippet to add ${MAKEDEVTARGETS} devices to the mtree list
# (if set), otherwise copy .OJBDIR-of-etc/MAKEDEV to ./dev
#
# If this is to be used with Makefile.image, then this file should be
# .include-d first.
#
# Required variables:
#	NETBSDSRCDIR	top level of src tree (set by <bsd.own.mk>)
#	MACHINE		machine name (set externally by build framework)
#
# Optional variables:
#	MAKEDEVTARGETS	targets to create with .OBJDIR-of-etc/MAKEDEV
#
# Variables modified by this:
#	MAKEDEVSCRIPT	path to .OBJDIR-of-etc/MAKEDEV
#	MTREECONF	may get "devices.spec" added
#	LISTS		may get "list.makedev" added
#	IMAGEDEPENDS	may get ${MAKEDEVSCRIPT} added
#	PARSELISTENV	may get MAKEDEVSCRIPT=... added
#

.if !defined(_MAKEFILE_MAKEDEV_)
_MAKEFILE_MAKEDEV_=1


MAKEDEVSPEC?=	devices.spec

_MAKEDEVOBJDIR!=cd ${NETBSDSRCDIR}/etc && ${PRINTOBJDIR}
MAKEDEVSCRIPT=	${_MAKEDEVOBJDIR}/MAKEDEV

CLEANFILES+=	${MAKEDEVSPEC} ${MAKEDEVSPEC}.tmp


.if defined(MAKEDEVTARGETS)

#
#	MAKEDEVTARGETS is set; add those devices to the mtree spec that's
#	used to build the file system
#
MTREECONF+=	${MAKEDEVSPEC}

${MAKEDEVSPEC}:	${MAKEDEVSCRIPT}
	-rm -f ${.TARGET} ${.TARGET}.tmp
	MACHINE=${MACHINE:Q} MACHINE_ARCH=${MACHINE_ARCH:Q} \
	    ${HOST_SH} ${MAKEDEVSCRIPT} -s ${MAKEDEVTARGETS} > ${.TARGET}.tmp \
	&& sort -o ${.TARGET} ${.TARGET}.tmp

.else	# ! MAKEDEVTARGETS

#
#	MAKEDEVTARGETS isn't set; copy in /dev/MAKEDEV and rely upon
#	init(8) to mount an mfs /dev and recreate the devices by
#	(effectively) running "cd /dev ; ./MAKEDEV all"
#
LISTS+=		${DISTRIBDIR}/common/list.makedev
IMAGEDEPENDS+=	${MAKEDEVSCRIPT}
PARSELISTENV+=	MAKEDEVSCRIPT=${MAKEDEVSCRIPT:Q}

${MAKEDEVSPEC}:	.PHONY

.endif	# ! MAKEDEVTARGETS


.endif	# _MAKEFILE_MAKEDEV_