[BACK]Return to Makefile.image CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / distrib / common

File: [cvs.NetBSD.org] / src / distrib / common / Makefile.image (download)

Revision 1.17, Thu May 9 09:21:25 2002 UTC (17 years, 7 months ago) by lukem
Branch: MAIN
CVS Tags: netbsd-1-6-base, netbsd-1-6-RELEASE, netbsd-1-6-RC3, netbsd-1-6-RC2, netbsd-1-6-RC1, netbsd-1-6-PATCH002-RELEASE, netbsd-1-6-PATCH002-RC4, netbsd-1-6-PATCH002-RC3, netbsd-1-6-PATCH002-RC2, netbsd-1-6-PATCH002-RC1, netbsd-1-6-PATCH002, netbsd-1-6-PATCH001-RELEASE, netbsd-1-6-PATCH001-RC3, netbsd-1-6-PATCH001-RC2, netbsd-1-6-PATCH001-RC1, netbsd-1-6-PATCH001, netbsd-1-6
Changes since 1.16: +18 -12 lines

only provide targets for ${WORKSPEC} and ${WORKBUILT} if non are provided.
this allows custom specfiles to be generated or custom WORKDIRS to be used,
whilst still allowing use of IMAGE or IMAGETAR rules.

#	$NetBSD: Makefile.image,v 1.17 2002/05/09 09:21:25 lukem Exp $
#
# Makefile snippet to build a tree from the provided lists,
# and make an ffs file system image from that tree
#

#
# Required variables:
#	NETBSDSRCDIR	top level of src tree (set by <bsd.own.mk>)
#	CRUNCHBIN	name of crunchgen(1)ed binary
#	LISTS		list file(s) to use
#	IMAGEDEPENDS	depends for ${IMAGE}
#	IMAGEENDIAN	endianness of ${IMAGE}
#	IMAGESIZE	size of ${IMAGE}
#	MTREECONF	mtree specfiles to use to build a master specfile
#
# Optional variables:
#	IMAGE		name of target image
#	IMAGEPOSTBUILD	operation to run on ${IMAGE} ${.TARGET} after its built
#			(if this returns non zero, ${.TARGET} is removed)
#	DESTDIR		destination directory
#	MAKEFS_FLAGS	extra options to ${MAKEFS}
#	PARSELISTENV	environment variables to set for parselist.awk
#	WORKDIR		directory to build image in to 
#	IMAGETAR	tar.gz file to create containing ${IMAGE}'s contents
#
#	IMAGE_RELEASEDIR	where to install ${IMAGE}.gz
#	IMAGETAR_RELEASEDIR	where to install ${IMAGETAR}
#

WORKDIR?=	work
WORKSPEC?=	work.spec
WORKBUILT?=	work.built

.include "${DISTRIBDIR}/common/Makefile.parselist"

PARSELISTENV+=	TARGETDIR=${.OBJDIR}/${WORKDIR:Q}


.if !target(${WORKBUILT})					# {
${WORKBUILT}: ${IMAGEDEPENDS} ${WORKSPEC} ${PARSELISTDEP} ${LISTS}
	@echo "Building tree into ${WORKDIR}"
	-rm -rf ${WORKDIR} ${WORKBUILT}
	mkdir -m 755 ${WORKDIR}
	${MTREE} -def ${WORKSPEC} -p ${WORKDIR}/ -UW
	${PARSELIST} -v mode=populate ${LISTS} | sh -e ${POPULATE_DEBUG} \
	&& touch ${WORKBUILT}

CLEANFILES+=	${WORKBUILT}

clean cleandir distclean: cleanfsimage

.PHONY: cleanfsimage

cleanfsimage:
	-rm -rf ${WORKDIR}

.endif	# ! target (${WORKBUILT})				# }

.if !target(${WORKSPEC})					# {
${WORKSPEC}: ${MTREECONF} ${LISTS} ${PARSELISTDEP}
	-rm -f ${.TARGET} ${.TARGET}.tmp
	( for i in ${MTREECONF}; do	\
		cat $$i ;		\
		echo "/unset all" ;	\
	done ) >> ${.TARGET}.tmp
	${PARSELIST} -v mode=mtree ${LISTS} >> ${.TARGET}.tmp \
	&& mv ${.TARGET}.tmp ${.TARGET}

CLEANFILES+=	${WORKSPEC} ${WORKSPEC}.tmp
.endif	# ! target (${WORKSPEC})				# }

.if defined(IMAGE)						# {
${IMAGE}: ${WORKBUILT} ${WORKSPEC} ${IMAGEDEPENDS}
	@echo "Creating image into ${.TARGET}..."
	-rm -f ${.TARGET} ${.TARGET}.tmp
	${MAKEFS} -t ffs -B ${IMAGEENDIAN} -s ${IMAGESIZE} -F ${WORKSPEC} \
	    -N ${NETBSDSRCDIR}/etc -o bsize=4096,fsize=512 \
	    -o optimization=space,minfree=0,nsectors=1,ntracks=128 \
	    ${MAKEFS_FLAGS} ${.TARGET}.tmp ${WORKDIR} \
	&& mv -f ${.TARGET}.tmp ${.TARGET}
.if defined(IMAGEPOSTBUILD)
	${IMAGEPOSTBUILD} || { rm -f ${.TARGET} ; false; }
.endif

${IMAGE}.gz: ${IMAGE}
	-rm -f ${.TARGET}
	gzip -9c ${.ALLSRC} > ${.TARGET}

realall: ${IMAGE}

.if defined(IMAGE_RELEASEDIR)
release:: check_RELEASEDIR .WAIT ${IMAGE}.gz
	${RELEASE_INSTALL} ${IMAGE}.gz ${RELEASEDIR}/${IMAGE_RELEASEDIR}
.endif

CLEANFILES+=	${IMAGE} ${IMAGE}.gz ${IMAGE}.tmp
.endif	# ! defined(IMAGE)					# }


.if defined(IMAGETAR)						# {
${IMAGETAR}: ${WORKBUILT} ${WORKSPEC} ${IMAGEDEPENDS}
	( cd ${WORKDIR}; \
	  GZIP=-9 ${PAX} -N ${NETBSDSRCDIR}/etc -wdzM < ${.OBJDIR}/${WORKSPEC} \
	) > ${.TARGET}.tmp \
	&& mv ${.TARGET}.tmp ${.TARGET}

realall: ${IMAGETAR}

CLEANFILES+=	${IMAGETAR} ${IMAGETAR}.tmp

.if defined(IMAGETAR_RELEASEDIR)
release:: check_RELEASEDIR .WAIT ${IMAGETAR}
	${RELEASE_INSTALL} ${IMAGETAR} ${RELEASEDIR}/${IMAGETAR_RELEASEDIR}
.endif

.endif	# ! defined(IMAGETAR)					# }