NetBSD/distrib/common/Makefile.image

77 lines
2.2 KiB
Makefile
Raw Normal View History

# $NetBSD: Makefile.image,v 1.6 2002/03/14 22:26:09 lukem Exp $
#
# Makefile snippet to build a tree from the provided lists,
# and make an ffs file system image from that tree
#
#
# Required variables:
# _SRC_TOP_ top level of src tree (set by <bsd.own.mk>)
# CRUNCHBIN name of crunchgen(1)ed binary
# LISTS list file(s) to use
# IMAGE name of target image
# IMAGEDEPENDS depends for ${IMAGE}
# IMAGEENDIAN endianness of ${IMAGE}
# IMAGESIZE size of ${IMAGE}
# MTREECONF mtree specfiles to use to build a master specfile
#
# Optional variables:
# DESTDIR destination directory
# MAKEFS_FLAGS extra options to ${MAKEFS}
# PARSELISTENV environment variables to set for parselist.awk
# WORKDIR directory to build image in to
#
WORKDIR?= work
WORKSPEC?= work.spec
WORKBUILT?= work.built
PARSELISTENV+= _SRC_TOP_=${_SRC_TOP_:Q} \
CRUNCHBIN=${CRUNCHBIN:Q} \
CURDIR=${.CURDIR:Q} \
DESTDIR=${DESTDIR:Q} \
MACHINE=${MACHINE:Q} \
MACHINE_ARCH=${MACHINE_ARCH:Q} \
OBJDIR=${.OBJDIR:Q} \
TARGETDIR=${.OBJDIR}/${WORKDIR:Q}
_PARSELIST= ${_SRC_TOP_}/distrib/common/parselist.awk
${WORKBUILT}: ${IMAGEDEPENDS} ${WORKSPEC} ${_PARSELIST} ${LISTS}
@echo "Building tree into ${WORKDIR}"
-rm -rf ${WORKDIR} ${WORKBUILT}
mkdir -m 755 ${WORKDIR}
${MTREE} -def ${WORKSPEC} -p ${WORKDIR}/ -UW
${PARSELISTENV} awk -f ${_PARSELIST} -v mode=populate \
${LISTS} | sh -e ${POPULATE_DEBUG} \
&& touch ${WORKBUILT}
${WORKSPEC}: ${MTREECONF} ${LISTS} ${_PARSELIST}
-rm -f ${.TARGET} ${.TARGET}.tmp
( for i in ${MTREECONF}; do \
cat $$i ; \
echo "/unset all" ; \
done ) >> ${.TARGET}.tmp
${PARSELISTENV} awk -f ${_PARSELIST} -v mode=mtree \
${LISTS} >> ${.TARGET}.tmp \
&& mv ${.TARGET}.tmp ${.TARGET}
${IMAGE}: ${WORKBUILT} ${WORKSPEC} ${IMAGEDEPENDS}
@echo "Creating image into ${.TARGET}..."
-rm -f ${.TARGET} ${.TARGET}.tmp
${MAKEFS} -t ffs -B ${IMAGEENDIAN} -s ${IMAGESIZE} -F ${WORKSPEC} \
-N ${_SRC_TOP_}/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}
CLEANFILES+= ${IMAGE} ${IMAGE}.tmp ${WORKBUILT} ${WORKSPEC} ${WORKSPEC}.tmp
clean cleandir distclean: cleanfsimage
.PHONY: cleanfsimage
cleanfsimage:
-rm -rf ${WORKDIR}