#	$NetBSD: Makefile.ramdisk,v 1.14.8.1 2024/03/25 15:18:22 martin Exp $

NOSANITIZER=	# defined

.include <bsd.own.mk>
.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"

I386COMMON=	${.CURDIR}/../common

.PATH:		${I386COMMON}

WARNS=		1
DBG=		-Os

CRUNCHBIN=	ramdiskbin

# Use ${.CURDIR}/list only if LISTS was not already defined by the caller.
LISTS?=		${.CURDIR}/list
LISTS+=		${I386COMMON}/list.ramdisk
MTREECONF=	${DISTRIBDIR}/common/mtree.common
IMAGEENDIAN=	le
IMAGEDEPENDS+= 	${CRUNCHBIN} \
		dot.profile \
		${DESTDIR}/usr/mdec/boot \
		${DESTDIR}/usr/mdec/bootxx_ffsv1 \
		${DESTDIR}/usr/mdec/mbr \
		${DESTDIR}/usr/mdec/mbr_ext \
		${DESTDIR}/usr/mdec/mbr_bootsel \
		${DESTDIR}/usr/mdec/gptmbr.bin \
		${NETBSDSRCDIR}/etc/group ${NETBSDSRCDIR}/etc/master.passwd \
		${NETBSDSRCDIR}/etc/netconfig ${DISTRIBDIR}/common/protocols \
		${DISTRIBDIR}/common/services
PARSELISTENV+=	BOOTMODEL=${BOOTMODEL:Q}

# This propogates through to the link of ramdiskbin
# The map file is useful when trying to prune the image
LDFLAGS+=	-Wl,-Map,${CRUNCHBIN}.map,--cref
CRUNCHENV+=	LDFLAGS=${LDFLAGS:Q}
CLEANFILES+=	${CRUNCHBIN}.map

.if defined(USE_SYSINST)
.if ${USE_SYSINST} != yes
LISTS+=		${DISTRIBDIR}/common/list.sysinst.${USE_SYSINST}
.else
LISTS+=		${DISTRIBDIR}/common/list.sysinst
.endif
MAKEFS_FLAGS+=	-f 14
.endif

# Use stubs to eliminate some large stuff from libc
HACKSRC=	${DISTRIBDIR}/utils/libhack
.include	"${HACKSRC}/Makefile.inc"
${CRUNCHBIN}:	libhack.o

.include "${DISTRIBDIR}/common/Makefile.crunch"
.include "${DISTRIBDIR}/common/Makefile.makedev"
.include "${DISTRIBDIR}/common/Makefile.image"

release:	${IMAGE}
	${HOST_INSTALL_FILE} -m ${NONBINMODE} ${IMAGE} \
		${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/ramdisk/

.include <bsd.prog.mk>