1 # $NetBSD: Makefile.minirootkmod,v 1.3 2014/08/05 15:40:58 apb Exp $
3 # Makefile snippet to build a miniroot kernel module (e.g. miniroot.kmod)
6 # NETBSDSRCDIR top level of src tree (set by <bsd.own.mk>)
9 # MINIROOT Basename of the kernel module to be created.
10 # ".kmod" will be appended to get the file name.
12 # RAMDISK Basename of the ramdisk to be embedded in the
13 # kernel module. This is used as both a directory
14 # name (${.CURDIR}/../ramdisks/${RAMDISK}) and
15 # as a file name within the .OBJDIR of that
16 # directory (${RAMDISK}.fs). [default: ramdisk]
23 .include "${.PARSEDIR}/Makefile.distrib"
26 PROG= ${MINIROOT}.kmod
28 # SRCMOD is a skeleton version of miniroot.kmod, without an embedded ramdisk.
29 # It should already have been created by "make install" in
30 # .../sys/modules/miniroot, and its name includes literal "miniroot",
31 # not variable ${MINIROOT}.
33 # DSTMOD is a copy of SRCMOD that is modified to include an embedded ramdisk.
34 # It will be created by rules in this Makefile.
36 # RAMDISKFS is the ramdisk image to be included inside DSTMOD. It should
37 # already have been created by the Makefile in RAMDISKSRCDIR.
39 SRCMOD= ${DESTDIR}/stand/${MACHINE}/${MODULEVER}/modules/miniroot/miniroot.kmod
40 DSTMOD= ${.OBJDIR}/${MINIROOT}.kmod
41 RAMDISKSRCDIR= ${.CURDIR}/../ramdisks/${RAMDISK}
42 RAMDISKOBJDIR!= cd ${RAMDISKSRCDIR} && ${PRINTOBJDIR}
43 RAMDISKFS= ${RAMDISKOBJDIR}/${RAMDISK}.fs
45 ${MINIROOT}.kmod: ${RAMDISKFS} ${SRCMOD}
46 ${OBJCOPY} --add-section miniroot=${RAMDISKFS} \
47 --set-section-flags miniroot=alloc,contents,load,data \
48 ${SRCMOD} ${DSTMOD}.tmp
49 ${TOOL_GZIP_N} -9c < ${DSTMOD}.tmp > ${DSTMOD}
52 .include <bsd.prog.mk>
55 ${HOST_INSTALL_FILE} -m ${BINMODE} ${PROG} \
56 ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/miniroot/