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