Makefile.minirootkmod revision 1.3 1 # $NetBSD: Makefile.minirootkmod,v 1.3 2014/08/05 15:40:58 apb 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 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
44
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}
50 rm -f ${DSTMOD}.tmp
51
52 .include <bsd.prog.mk>
53
54 release: ${PROG}
55 ${HOST_INSTALL_FILE} -m ${BINMODE} ${PROG} \
56 ${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/miniroot/
57