2002-03-15 01:26:08 +03:00
|
|
|
# $NetBSD: Makefile.image,v 1.6 2002/03/14 22:26:09 lukem Exp $
|
2002-02-03 18:24:43 +03:00
|
|
|
#
|
|
|
|
# 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}
|
2002-02-06 02:29:43 +03:00
|
|
|
# MTREECONF mtree specfiles to use to build a master specfile
|
2002-02-03 18:24:43 +03:00
|
|
|
#
|
|
|
|
# Optional variables:
|
2002-03-14 04:07:27 +03:00
|
|
|
# DESTDIR destination directory
|
2002-02-06 02:29:43 +03:00
|
|
|
# MAKEFS_FLAGS extra options to ${MAKEFS}
|
2002-03-15 01:26:08 +03:00
|
|
|
# PARSELISTENV environment variables to set for parselist.awk
|
2002-02-03 18:24:43 +03:00
|
|
|
# WORKDIR directory to build image in to
|
|
|
|
#
|
|
|
|
|
|
|
|
WORKDIR?= work
|
|
|
|
WORKSPEC?= work.spec
|
|
|
|
WORKBUILT?= work.built
|
|
|
|
|
2002-03-15 01:26:08 +03:00
|
|
|
PARSELISTENV+= _SRC_TOP_=${_SRC_TOP_:Q} \
|
2002-03-14 04:07:27 +03:00
|
|
|
CRUNCHBIN=${CRUNCHBIN:Q} \
|
2002-02-03 18:24:43 +03:00
|
|
|
CURDIR=${.CURDIR:Q} \
|
2002-03-15 01:26:08 +03:00
|
|
|
DESTDIR=${DESTDIR:Q} \
|
|
|
|
MACHINE=${MACHINE:Q} \
|
|
|
|
MACHINE_ARCH=${MACHINE_ARCH:Q} \
|
2002-02-03 18:24:43 +03:00
|
|
|
OBJDIR=${.OBJDIR:Q} \
|
2002-03-15 01:26:08 +03:00
|
|
|
TARGETDIR=${.OBJDIR}/${WORKDIR:Q}
|
2002-02-03 18:24:43 +03:00
|
|
|
|
2002-02-06 02:29:43 +03:00
|
|
|
_PARSELIST= ${_SRC_TOP_}/distrib/common/parselist.awk
|
|
|
|
|
2002-02-03 18:24:43 +03:00
|
|
|
|
2002-02-06 02:29:43 +03:00
|
|
|
${WORKBUILT}: ${IMAGEDEPENDS} ${WORKSPEC} ${_PARSELIST} ${LISTS}
|
2002-02-03 18:24:43 +03:00
|
|
|
@echo "Building tree into ${WORKDIR}"
|
|
|
|
-rm -rf ${WORKDIR} ${WORKBUILT}
|
|
|
|
mkdir -m 755 ${WORKDIR}
|
2002-02-06 02:29:43 +03:00
|
|
|
${MTREE} -def ${WORKSPEC} -p ${WORKDIR}/ -UW
|
2002-03-15 01:26:08 +03:00
|
|
|
${PARSELISTENV} awk -f ${_PARSELIST} -v mode=populate \
|
|
|
|
${LISTS} | sh -e ${POPULATE_DEBUG} \
|
2002-02-03 18:24:43 +03:00
|
|
|
&& touch ${WORKBUILT}
|
|
|
|
|
|
|
|
${WORKSPEC}: ${MTREECONF} ${LISTS} ${_PARSELIST}
|
|
|
|
-rm -f ${.TARGET} ${.TARGET}.tmp
|
2002-02-06 02:29:43 +03:00
|
|
|
( for i in ${MTREECONF}; do \
|
|
|
|
cat $$i ; \
|
|
|
|
echo "/unset all" ; \
|
|
|
|
done ) >> ${.TARGET}.tmp
|
2002-03-15 01:26:08 +03:00
|
|
|
${PARSELISTENV} awk -f ${_PARSELIST} -v mode=mtree \
|
2002-02-07 14:39:17 +03:00
|
|
|
${LISTS} >> ${.TARGET}.tmp \
|
2002-02-03 18:24:43 +03:00
|
|
|
&& mv ${.TARGET}.tmp ${.TARGET}
|
|
|
|
|
2002-02-07 14:39:17 +03:00
|
|
|
${IMAGE}: ${WORKBUILT} ${WORKSPEC} ${IMAGEDEPENDS}
|
2002-02-03 18:24:43 +03:00
|
|
|
@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 \
|
2002-02-06 02:29:43 +03:00
|
|
|
${MAKEFS_FLAGS} ${.TARGET}.tmp ${WORKDIR} \
|
2002-02-03 18:24:43 +03:00
|
|
|
&& mv -f ${.TARGET}.tmp ${.TARGET}
|
|
|
|
|
2002-02-06 02:29:43 +03:00
|
|
|
CLEANFILES+= ${IMAGE} ${IMAGE}.tmp ${WORKBUILT} ${WORKSPEC} ${WORKSPEC}.tmp
|
2002-02-03 18:24:43 +03:00
|
|
|
|
|
|
|
clean cleandir distclean: cleanfsimage
|
|
|
|
|
|
|
|
.PHONY: cleanfsimage
|
|
|
|
|
|
|
|
cleanfsimage:
|
|
|
|
-rm -rf ${WORKDIR}
|