2002-05-09 13:21:25 +04:00
|
|
|
# $NetBSD: Makefile.image,v 1.17 2002/05/09 09:21:25 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:
|
2002-04-26 19:50:21 +04:00
|
|
|
# NETBSDSRCDIR top level of src tree (set by <bsd.own.mk>)
|
2002-02-03 18:24:43 +03:00
|
|
|
# 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}
|
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-05-02 17:05:49 +04:00
|
|
|
# IMAGE name of target image
|
2002-05-02 22:02:14 +04:00
|
|
|
# IMAGEPOSTBUILD operation to run on ${IMAGE} ${.TARGET} after its built
|
|
|
|
# (if this returns non zero, ${.TARGET} is removed)
|
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
|
2002-04-12 08:50:01 +04:00
|
|
|
# IMAGETAR tar.gz file to create containing ${IMAGE}'s contents
|
2002-02-03 18:24:43 +03:00
|
|
|
#
|
2002-05-02 22:02:14 +04:00
|
|
|
# IMAGE_RELEASEDIR where to install ${IMAGE}.gz
|
|
|
|
# IMAGETAR_RELEASEDIR where to install ${IMAGETAR}
|
|
|
|
#
|
2002-02-03 18:24:43 +03:00
|
|
|
|
|
|
|
WORKDIR?= work
|
|
|
|
WORKSPEC?= work.spec
|
|
|
|
WORKBUILT?= work.built
|
|
|
|
|
2002-04-12 05:59:45 +04:00
|
|
|
.include "${DISTRIBDIR}/common/Makefile.parselist"
|
2002-02-03 18:24:43 +03:00
|
|
|
|
2002-04-12 05:59:45 +04:00
|
|
|
PARSELISTENV+= TARGETDIR=${.OBJDIR}/${WORKDIR:Q}
|
2002-02-06 02:29:43 +03:00
|
|
|
|
2002-02-03 18:24:43 +03:00
|
|
|
|
2002-05-09 13:21:25 +04:00
|
|
|
.if !target(${WORKBUILT}) # {
|
2002-04-12 05:59:45 +04:00
|
|
|
${WORKBUILT}: ${IMAGEDEPENDS} ${WORKSPEC} ${PARSELISTDEP} ${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-04-12 05:59:45 +04:00
|
|
|
${PARSELIST} -v mode=populate ${LISTS} | sh -e ${POPULATE_DEBUG} \
|
2002-02-03 18:24:43 +03:00
|
|
|
&& touch ${WORKBUILT}
|
|
|
|
|
2002-05-09 13:21:25 +04:00
|
|
|
CLEANFILES+= ${WORKBUILT}
|
|
|
|
|
|
|
|
clean cleandir distclean: cleanfsimage
|
|
|
|
|
|
|
|
.PHONY: cleanfsimage
|
|
|
|
|
|
|
|
cleanfsimage:
|
|
|
|
-rm -rf ${WORKDIR}
|
|
|
|
|
|
|
|
.endif # ! target (${WORKBUILT}) # }
|
|
|
|
|
|
|
|
.if !target(${WORKSPEC}) # {
|
2002-04-12 05:59:45 +04:00
|
|
|
${WORKSPEC}: ${MTREECONF} ${LISTS} ${PARSELISTDEP}
|
2002-02-03 18:24:43 +03:00
|
|
|
-rm -f ${.TARGET} ${.TARGET}.tmp
|
2002-05-03 18:21:44 +04:00
|
|
|
( for i in ${MTREECONF}; do \
|
2002-02-06 02:29:43 +03:00
|
|
|
cat $$i ; \
|
|
|
|
echo "/unset all" ; \
|
|
|
|
done ) >> ${.TARGET}.tmp
|
2002-04-12 05:59:45 +04:00
|
|
|
${PARSELIST} -v mode=mtree ${LISTS} >> ${.TARGET}.tmp \
|
2002-02-03 18:24:43 +03:00
|
|
|
&& mv ${.TARGET}.tmp ${.TARGET}
|
|
|
|
|
2002-05-09 13:21:25 +04:00
|
|
|
CLEANFILES+= ${WORKSPEC} ${WORKSPEC}.tmp
|
|
|
|
.endif # ! target (${WORKSPEC}) # }
|
2002-05-02 17:05:49 +04:00
|
|
|
|
|
|
|
.if defined(IMAGE) # {
|
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} \
|
2002-04-26 19:50:21 +04:00
|
|
|
-N ${NETBSDSRCDIR}/etc -o bsize=4096,fsize=512 \
|
2002-02-03 18:24:43 +03:00
|
|
|
-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-05-02 22:02:14 +04:00
|
|
|
.if defined(IMAGEPOSTBUILD)
|
|
|
|
${IMAGEPOSTBUILD} || { rm -f ${.TARGET} ; false; }
|
|
|
|
.endif
|
2002-02-03 18:24:43 +03:00
|
|
|
|
2002-05-02 22:02:14 +04:00
|
|
|
${IMAGE}.gz: ${IMAGE}
|
2002-05-07 18:27:25 +04:00
|
|
|
-rm -f ${.TARGET}
|
|
|
|
gzip -9c ${.ALLSRC} > ${.TARGET}
|
2002-02-03 18:24:43 +03:00
|
|
|
|
2002-05-02 22:02:14 +04:00
|
|
|
realall: ${IMAGE}
|
|
|
|
|
|
|
|
.if defined(IMAGE_RELEASEDIR)
|
2002-05-07 07:34:16 +04:00
|
|
|
release:: check_RELEASEDIR .WAIT ${IMAGE}.gz
|
2002-05-02 22:02:14 +04:00
|
|
|
${RELEASE_INSTALL} ${IMAGE}.gz ${RELEASEDIR}/${IMAGE_RELEASEDIR}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
CLEANFILES+= ${IMAGE} ${IMAGE}.gz ${IMAGE}.tmp
|
2002-05-09 13:21:25 +04:00
|
|
|
.endif # ! defined(IMAGE) # }
|
2002-04-12 08:50:01 +04:00
|
|
|
|
|
|
|
|
2002-05-02 22:02:14 +04:00
|
|
|
.if defined(IMAGETAR) # {
|
2002-04-12 08:50:01 +04:00
|
|
|
${IMAGETAR}: ${WORKBUILT} ${WORKSPEC} ${IMAGEDEPENDS}
|
|
|
|
( cd ${WORKDIR}; \
|
2002-04-26 19:50:21 +04:00
|
|
|
GZIP=-9 ${PAX} -N ${NETBSDSRCDIR}/etc -wdzM < ${.OBJDIR}/${WORKSPEC} \
|
2002-04-12 08:50:01 +04:00
|
|
|
) > ${.TARGET}.tmp \
|
|
|
|
&& mv ${.TARGET}.tmp ${.TARGET}
|
|
|
|
|
2002-05-02 22:02:14 +04:00
|
|
|
realall: ${IMAGETAR}
|
|
|
|
|
2002-04-12 08:50:01 +04:00
|
|
|
CLEANFILES+= ${IMAGETAR} ${IMAGETAR}.tmp
|
2002-05-02 22:02:14 +04:00
|
|
|
|
|
|
|
.if defined(IMAGETAR_RELEASEDIR)
|
2002-05-07 07:34:16 +04:00
|
|
|
release:: check_RELEASEDIR .WAIT ${IMAGETAR}
|
2002-05-07 06:40:55 +04:00
|
|
|
${RELEASE_INSTALL} ${IMAGETAR} ${RELEASEDIR}/${IMAGETAR_RELEASEDIR}
|
2002-05-02 22:02:14 +04:00
|
|
|
.endif
|
|
|
|
|
2002-05-09 13:21:25 +04:00
|
|
|
.endif # ! defined(IMAGETAR) # }
|