Home | History | Annotate | Line # | Download | only in common
      1  1.5     lukem #	$NetBSD: Makefile.minirootkmod,v 1.5 2020/07/02 08:48:10 lukem Exp $
      2  1.1       apb #
      3  1.1       apb # Makefile snippet to build a miniroot kernel module (e.g. miniroot.kmod)
      4  1.1       apb #
      5  1.1       apb # Required variables:
      6  1.1       apb #	NETBSDSRCDIR	top level of src tree (set by <bsd.own.mk>)
      7  1.1       apb #
      8  1.1       apb # Optional variables:
      9  1.1       apb #	MINIROOT	Basename of the kernel module to be created.
     10  1.1       apb #			".kmod" will be appended to get the file name.
     11  1.1       apb #			[default: miniroot]
     12  1.1       apb #	RAMDISK		Basename of the ramdisk to be embedded in the
     13  1.1       apb #			kernel module.  This is used as both a directory
     14  1.1       apb #			name (${.CURDIR}/../ramdisks/${RAMDISK}) and
     15  1.1       apb #			as a file name within the .OBJDIR of that
     16  1.1       apb #			directory (${RAMDISK}.fs).  [default: ramdisk]
     17  1.1       apb #
     18  1.1       apb 
     19  1.1       apb MINIROOT?=	miniroot
     20  1.1       apb RAMDISK?=	ramdisk
     21  1.1       apb 
     22  1.1       apb .include <bsd.own.mk>
     23  1.1       apb .include "${.PARSEDIR}/Makefile.distrib"
     24  1.1       apb 
     25  1.1       apb MKMAN=		no
     26  1.1       apb PROG=		${MINIROOT}.kmod
     27  1.1       apb 
     28  1.5     lukem # Not a real PROG; doesn't actually have source
     29  1.5     lukem SRCS.${PROG}=
     30  1.5     lukem 
     31  1.1       apb # SRCMOD is a skeleton version of miniroot.kmod, without an embedded ramdisk.
     32  1.1       apb # It should already have been created by "make install" in
     33  1.1       apb # .../sys/modules/miniroot, and its name includes literal "miniroot",
     34  1.1       apb # not variable ${MINIROOT}.
     35  1.1       apb #
     36  1.1       apb # DSTMOD is a copy of SRCMOD that is modified to include an embedded ramdisk.
     37  1.1       apb # It will be created by rules in this Makefile.
     38  1.1       apb #
     39  1.1       apb # RAMDISKFS is the ramdisk image to be included inside DSTMOD.  It should
     40  1.1       apb # already have been created by the Makefile in RAMDISKSRCDIR.
     41  1.1       apb #
     42  1.4  christos .if ${KERNEL_DIR:U*no} == "yes"
     43  1.4  christos SRCMOD=		${DESTDIR}/netbsd/modules/miniroot/miniroot.kmod
     44  1.4  christos .else
     45  1.1       apb SRCMOD=		${DESTDIR}/stand/${MACHINE}/${MODULEVER}/modules/miniroot/miniroot.kmod
     46  1.4  christos .endif
     47  1.1       apb DSTMOD=		${.OBJDIR}/${MINIROOT}.kmod
     48  1.1       apb RAMDISKSRCDIR=	${.CURDIR}/../ramdisks/${RAMDISK}
     49  1.1       apb RAMDISKOBJDIR!=	cd ${RAMDISKSRCDIR} && ${PRINTOBJDIR}
     50  1.1       apb RAMDISKFS=	${RAMDISKOBJDIR}/${RAMDISK}.fs
     51  1.1       apb 
     52  1.1       apb ${MINIROOT}.kmod:	${RAMDISKFS} ${SRCMOD}
     53  1.1       apb 		${OBJCOPY} --add-section miniroot=${RAMDISKFS} \
     54  1.1       apb 		    --set-section-flags miniroot=alloc,contents,load,data \
     55  1.1       apb 		    ${SRCMOD} ${DSTMOD}.tmp
     56  1.3       apb 		${TOOL_GZIP_N} -9c < ${DSTMOD}.tmp > ${DSTMOD}
     57  1.1       apb 		rm -f ${DSTMOD}.tmp
     58  1.1       apb 
     59  1.1       apb .include <bsd.prog.mk>
     60  1.1       apb 
     61  1.1       apb release:	${PROG}
     62  1.1       apb 		${HOST_INSTALL_FILE} -m ${BINMODE} ${PROG}  \
     63  1.1       apb 		    ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/miniroot/
     64