1 1.4 christos # $NetBSD: Makefile.minirootkmod,v 1.4 2020/04/04 19:50:53 christos 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.1 apb # SRCMOD is a skeleton version of miniroot.kmod, without an embedded ramdisk. 29 1.1 apb # It should already have been created by "make install" in 30 1.1 apb # .../sys/modules/miniroot, and its name includes literal "miniroot", 31 1.1 apb # not variable ${MINIROOT}. 32 1.1 apb # 33 1.1 apb # DSTMOD is a copy of SRCMOD that is modified to include an embedded ramdisk. 34 1.1 apb # It will be created by rules in this Makefile. 35 1.1 apb # 36 1.1 apb # RAMDISKFS is the ramdisk image to be included inside DSTMOD. It should 37 1.1 apb # already have been created by the Makefile in RAMDISKSRCDIR. 38 1.1 apb # 39 1.4 christos .if ${KERNEL_DIR:U*no} == "yes" 40 1.4 christos SRCMOD= ${DESTDIR}/netbsd/modules/miniroot/miniroot.kmod 41 1.4 christos .else 42 1.1 apb SRCMOD= ${DESTDIR}/stand/${MACHINE}/${MODULEVER}/modules/miniroot/miniroot.kmod 43 1.4 christos .endif 44 1.1 apb DSTMOD= ${.OBJDIR}/${MINIROOT}.kmod 45 1.1 apb RAMDISKSRCDIR= ${.CURDIR}/../ramdisks/${RAMDISK} 46 1.1 apb RAMDISKOBJDIR!= cd ${RAMDISKSRCDIR} && ${PRINTOBJDIR} 47 1.1 apb RAMDISKFS= ${RAMDISKOBJDIR}/${RAMDISK}.fs 48 1.1 apb 49 1.1 apb ${MINIROOT}.kmod: ${RAMDISKFS} ${SRCMOD} 50 1.1 apb ${OBJCOPY} --add-section miniroot=${RAMDISKFS} \ 51 1.1 apb --set-section-flags miniroot=alloc,contents,load,data \ 52 1.1 apb ${SRCMOD} ${DSTMOD}.tmp 53 1.3 apb ${TOOL_GZIP_N} -9c < ${DSTMOD}.tmp > ${DSTMOD} 54 1.1 apb rm -f ${DSTMOD}.tmp 55 1.1 apb 56 1.1 apb .include <bsd.prog.mk> 57 1.1 apb 58 1.1 apb release: ${PROG} 59 1.1 apb ${HOST_INSTALL_FILE} -m ${BINMODE} ${PROG} \ 60 1.1 apb ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/miniroot/ 61