Makefile.minirootkmod revision 1.3
11.3Sapb#	$NetBSD: Makefile.minirootkmod,v 1.3 2014/08/05 15:40:58 apb Exp $
21.1Sapb#
31.1Sapb# Makefile snippet to build a miniroot kernel module (e.g. miniroot.kmod)
41.1Sapb#
51.1Sapb# Required variables:
61.1Sapb#	NETBSDSRCDIR	top level of src tree (set by <bsd.own.mk>)
71.1Sapb#
81.1Sapb# Optional variables:
91.1Sapb#	MINIROOT	Basename of the kernel module to be created.
101.1Sapb#			".kmod" will be appended to get the file name.
111.1Sapb#			[default: miniroot]
121.1Sapb#	RAMDISK		Basename of the ramdisk to be embedded in the
131.1Sapb#			kernel module.  This is used as both a directory
141.1Sapb#			name (${.CURDIR}/../ramdisks/${RAMDISK}) and
151.1Sapb#			as a file name within the .OBJDIR of that
161.1Sapb#			directory (${RAMDISK}.fs).  [default: ramdisk]
171.1Sapb#
181.1Sapb
191.1SapbMINIROOT?=	miniroot
201.1SapbRAMDISK?=	ramdisk
211.1Sapb
221.1Sapb.include <bsd.own.mk>
231.1Sapb.include "${.PARSEDIR}/Makefile.distrib"
241.1Sapb
251.1SapbMKMAN=		no
261.1SapbPROG=		${MINIROOT}.kmod
271.1Sapb
281.1Sapb# SRCMOD is a skeleton version of miniroot.kmod, without an embedded ramdisk.
291.1Sapb# It should already have been created by "make install" in
301.1Sapb# .../sys/modules/miniroot, and its name includes literal "miniroot",
311.1Sapb# not variable ${MINIROOT}.
321.1Sapb#
331.1Sapb# DSTMOD is a copy of SRCMOD that is modified to include an embedded ramdisk.
341.1Sapb# It will be created by rules in this Makefile.
351.1Sapb#
361.1Sapb# RAMDISKFS is the ramdisk image to be included inside DSTMOD.  It should
371.1Sapb# already have been created by the Makefile in RAMDISKSRCDIR.
381.1Sapb#
391.1SapbSRCMOD=		${DESTDIR}/stand/${MACHINE}/${MODULEVER}/modules/miniroot/miniroot.kmod
401.1SapbDSTMOD=		${.OBJDIR}/${MINIROOT}.kmod
411.1SapbRAMDISKSRCDIR=	${.CURDIR}/../ramdisks/${RAMDISK}
421.1SapbRAMDISKOBJDIR!=	cd ${RAMDISKSRCDIR} && ${PRINTOBJDIR}
431.1SapbRAMDISKFS=	${RAMDISKOBJDIR}/${RAMDISK}.fs
441.1Sapb
451.1Sapb${MINIROOT}.kmod:	${RAMDISKFS} ${SRCMOD}
461.1Sapb		${OBJCOPY} --add-section miniroot=${RAMDISKFS} \
471.1Sapb		    --set-section-flags miniroot=alloc,contents,load,data \
481.1Sapb		    ${SRCMOD} ${DSTMOD}.tmp
491.3Sapb		${TOOL_GZIP_N} -9c < ${DSTMOD}.tmp > ${DSTMOD}
501.1Sapb		rm -f ${DSTMOD}.tmp
511.1Sapb
521.1Sapb.include <bsd.prog.mk>
531.1Sapb
541.1Sapbrelease:	${PROG}
551.1Sapb		${HOST_INSTALL_FILE} -m ${BINMODE} ${PROG}  \
561.1Sapb		    ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/miniroot/
57