Home | History | Annotate | Line # | Download | only in common
Makefile.minirootkmod revision 1.4
      1 #	$NetBSD: Makefile.minirootkmod,v 1.4 2020/04/04 19:50:53 christos Exp $
      2 #
      3 # Makefile snippet to build a miniroot kernel module (e.g. miniroot.kmod)
      4 #
      5 # Required variables:
      6 #	NETBSDSRCDIR	top level of src tree (set by <bsd.own.mk>)
      7 #
      8 # Optional variables:
      9 #	MINIROOT	Basename of the kernel module to be created.
     10 #			".kmod" will be appended to get the file name.
     11 #			[default: miniroot]
     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]
     17 #
     18 
     19 MINIROOT?=	miniroot
     20 RAMDISK?=	ramdisk
     21 
     22 .include <bsd.own.mk>
     23 .include "${.PARSEDIR}/Makefile.distrib"
     24 
     25 MKMAN=		no
     26 PROG=		${MINIROOT}.kmod
     27 
     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}.
     32 #
     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.
     35 #
     36 # RAMDISKFS is the ramdisk image to be included inside DSTMOD.  It should
     37 # already have been created by the Makefile in RAMDISKSRCDIR.
     38 #
     39 .if ${KERNEL_DIR:U*no} == "yes"
     40 SRCMOD=		${DESTDIR}/netbsd/modules/miniroot/miniroot.kmod
     41 .else
     42 SRCMOD=		${DESTDIR}/stand/${MACHINE}/${MODULEVER}/modules/miniroot/miniroot.kmod
     43 .endif
     44 DSTMOD=		${.OBJDIR}/${MINIROOT}.kmod
     45 RAMDISKSRCDIR=	${.CURDIR}/../ramdisks/${RAMDISK}
     46 RAMDISKOBJDIR!=	cd ${RAMDISKSRCDIR} && ${PRINTOBJDIR}
     47 RAMDISKFS=	${RAMDISKOBJDIR}/${RAMDISK}.fs
     48 
     49 ${MINIROOT}.kmod:	${RAMDISKFS} ${SRCMOD}
     50 		${OBJCOPY} --add-section miniroot=${RAMDISKFS} \
     51 		    --set-section-flags miniroot=alloc,contents,load,data \
     52 		    ${SRCMOD} ${DSTMOD}.tmp
     53 		${TOOL_GZIP_N} -9c < ${DSTMOD}.tmp > ${DSTMOD}
     54 		rm -f ${DSTMOD}.tmp
     55 
     56 .include <bsd.prog.mk>
     57 
     58 release:	${PROG}
     59 		${HOST_INSTALL_FILE} -m ${BINMODE} ${PROG}  \
     60 		    ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/miniroot/
     61