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

Annotation of src/distrib/common/Makefile.image, Revision 1.31

1.31    ! perry       1: #      $NetBSD: Makefile.image,v 1.30 2008/06/23 02:16:53 matt Exp $
1.1       lukem       2: #
                      3: # Makefile snippet to build a tree from the provided lists,
                      4: # and make an ffs file system image from that tree
                      5: #
                      6: # Required variables:
1.9       lukem       7: #      NETBSDSRCDIR    top level of src tree (set by <bsd.own.mk>)
1.1       lukem       8: #      LISTS           list file(s) to use
                      9: #      IMAGEDEPENDS    depends for ${IMAGE}
                     10: #      IMAGEENDIAN     endianness of ${IMAGE}
                     11: #      IMAGESIZE       size of ${IMAGE}
1.2       lukem      12: #      MTREECONF       mtree specfiles to use to build a master specfile
1.1       lukem      13: #
                     14: # Optional variables:
1.10      lukem      15: #      IMAGE           name of target image
1.11      lukem      16: #      IMAGEPOSTBUILD  operation to run on ${IMAGE} ${.TARGET} after its built
                     17: #                      (if this returns non zero, ${.TARGET} is removed)
1.26      lukem      18: #      CRUNCHBIN       name of crunchgen(1)ed binary
1.5       lukem      19: #      DESTDIR         destination directory
1.25      lukem      20: #      MAKEFS_FLAGS    extra options to ${TOOL_MAKEFS}
1.6       lukem      21: #      PARSELISTENV    environment variables to set for parselist.awk
1.1       lukem      22: #      WORKDIR         directory to build image in to
1.8       lukem      23: #      IMAGETAR        tar.gz file to create containing ${IMAGE}'s contents
1.1       lukem      24: #
1.11      lukem      25: #      IMAGE_RELEASEDIR        where to install ${IMAGE}.gz
                     26: #      IMAGETAR_RELEASEDIR     where to install ${IMAGETAR}
                     27: #
1.1       lukem      28:
1.20      lukem      29: .if !defined(_MAKEFILE_IMAGE_)
                     30: _MAKEFILE_IMAGE_=1
                     31:
                     32:
1.1       lukem      33: WORKDIR?=      work
                     34: WORKSPEC?=     work.spec
                     35: WORKBUILT?=    work.built
                     36:
1.7       lukem      37: .include "${DISTRIBDIR}/common/Makefile.parselist"
1.1       lukem      38:
1.7       lukem      39: PARSELISTENV+= TARGETDIR=${.OBJDIR}/${WORKDIR:Q}
1.2       lukem      40:
1.1       lukem      41:
1.17      lukem      42: .if !target(${WORKBUILT})                                      # {
1.7       lukem      43: ${WORKBUILT}: ${IMAGEDEPENDS} ${WORKSPEC} ${PARSELISTDEP} ${LISTS}
1.26      lukem      44: #      There is a .PHONY ${CRUNCHBIN}, so check if out of date by hand
                     45: #      Default to `.' if ${CRUNCHBIN} isn't set, to always force a rebuild.
                     46:        [ "${.OODATE}" = ${CRUNCHBIN:U.} -a -f ${WORKBUILT} -a ${WORKBUILT} -nt ${CRUNCHBIN:U.} ]  || { \
1.28      lukem      47:        ${_MKSHMSG} "  build " ${.CURDIR:T}/${WORKDIR}; \
1.24      dsl        48:        rm -rf ${WORKDIR} ${WORKBUILT}; \
                     49:        mkdir -m 755 ${WORKDIR} &&  \
1.25      lukem      50:        ${TOOL_MTREE} -def ${WORKSPEC} -p ${WORKDIR}/ -UW && \
1.21      imp        51:        ${PARSELIST} -v mode=populate ${LISTS} | \
1.27      lukem      52:        ${HOST_SH} -e ${POPULATE_DEBUG} \
1.24      dsl        53:        && touch ${WORKBUILT} ; \
                     54:        }
1.1       lukem      55:
1.17      lukem      56: CLEANFILES+=   ${WORKBUILT}
                     57:
                     58: clean cleandir distclean: cleanfsimage
                     59:
                     60: .PHONY: cleanfsimage
                     61:
                     62: cleanfsimage:
1.29      dbj        63:        -rm -rf ${WORKDIR} ${WORKBUILT}
1.17      lukem      64:
                     65: .endif # ! target (${WORKBUILT})                               # }
                     66:
                     67: .if !target(${WORKSPEC})                                       # {
1.7       lukem      68: ${WORKSPEC}: ${MTREECONF} ${LISTS} ${PARSELISTDEP}
1.28      lukem      69:        ${_MKTARGET_CREATE}
1.1       lukem      70:        -rm -f ${.TARGET} ${.TARGET}.tmp
1.13      lukem      71:        ( for i in ${MTREECONF}; do     \
1.28      lukem      72:                echo "# --" ; \
                     73:                echo "# entries from: $$i" ; \
                     74:                echo "#" ; \
1.2       lukem      75:                cat $$i ;               \
                     76:                echo "/unset all" ;     \
                     77:        done ) >> ${.TARGET}.tmp
1.7       lukem      78:        ${PARSELIST} -v mode=mtree ${LISTS} >> ${.TARGET}.tmp \
1.1       lukem      79:        && mv ${.TARGET}.tmp ${.TARGET}
                     80:
1.17      lukem      81: CLEANFILES+=   ${WORKSPEC} ${WORKSPEC}.tmp
                     82: .endif # ! target (${WORKSPEC})                                # }
1.10      lukem      83:
                     84: .if defined(IMAGE)                                             # {
1.24      dsl        85: ${IMAGE}: ${WORKBUILT}
                     86:        [ "${.OODATE}" = ${WORKBUILT} -a -f ${IMAGE} -a ! ${IMAGE} -ot ${WORKBUILT} ]  || { \
1.28      lukem      87:        ${_MKSHMSG_CREATE} ${.CURDIR:T}/${.TARGET}; \
1.24      dsl        88:        rm -f ${.TARGET} ${.TARGET}.tmp; \
1.25      lukem      89:        ${TOOL_MAKEFS} -t ffs -B ${IMAGEENDIAN} -s ${IMAGESIZE} -F ${WORKSPEC} \
1.9       lukem      90:            -N ${NETBSDSRCDIR}/etc -o bsize=4096,fsize=512 \
1.23      fvdl       91:            -o optimization=space,minfree=0 \
1.2       lukem      92:            ${MAKEFS_FLAGS} ${.TARGET}.tmp ${WORKDIR} \
1.24      dsl        93:        && mv -f ${.TARGET}.tmp ${.TARGET}; \
                     94:        }
1.11      lukem      95: .if defined(IMAGEPOSTBUILD)
                     96:        ${IMAGEPOSTBUILD} || { rm -f ${.TARGET} ; false; }
                     97: .endif
                     98:
1.29      dbj        99: .PHONY: fsimage
                    100: fsimage: ${IMAGE}
                    101:
1.11      lukem     102: ${IMAGE}.gz: ${IMAGE}
1.28      lukem     103:        ${_MKTARGET_CREATE}
1.16      lukem     104:        -rm -f ${.TARGET}
1.31    ! perry     105:        gzip -9nc ${.ALLSRC} > ${.TARGET}
1.11      lukem     106:
                    107: realall: ${IMAGE}
                    108:
                    109: .if defined(IMAGE_RELEASEDIR)
1.15      lukem     110: release:: check_RELEASEDIR .WAIT ${IMAGE}.gz
1.19      lukem     111:        ${RELEASE_INSTALL} ${IMAGE}.gz \
1.30      matt      112:            ${RELEASEDIR}/${RELEASEMACHINEDIR}/${IMAGE_RELEASEDIR}
1.11      lukem     113: .endif
1.1       lukem     114:
1.11      lukem     115: CLEANFILES+=   ${IMAGE} ${IMAGE}.gz ${IMAGE}.tmp
1.17      lukem     116: .endif # ! defined(IMAGE)                                      # }
1.8       lukem     117:
                    118:
                    119: .if defined(IMAGETAR)                                          # {
                    120: ${IMAGETAR}: ${WORKBUILT} ${WORKSPEC} ${IMAGEDEPENDS}
1.28      lukem     121:        ${_MKTARGET_CREATE}
1.8       lukem     122:        ( cd ${WORKDIR}; \
1.31    ! perry     123:          GZIP=-9n ${TOOL_PAX} -ON ${NETBSDSRCDIR}/etc -wdzM <${.OBJDIR}/${WORKSPEC} \
1.8       lukem     124:        ) > ${.TARGET}.tmp \
                    125:        && mv ${.TARGET}.tmp ${.TARGET}
                    126:
1.11      lukem     127: realall: ${IMAGETAR}
                    128:
1.8       lukem     129: CLEANFILES+=   ${IMAGETAR} ${IMAGETAR}.tmp
1.11      lukem     130:
                    131: .if defined(IMAGETAR_RELEASEDIR)
1.15      lukem     132: release:: check_RELEASEDIR .WAIT ${IMAGETAR}
1.19      lukem     133:        ${RELEASE_INSTALL} ${IMAGETAR} \
1.30      matt      134:            ${RELEASEDIR}/${RELEASEMACHINEDIR}/${IMAGETAR_RELEASEDIR}
1.11      lukem     135: .endif
                    136:
1.17      lukem     137: .endif # ! defined(IMAGETAR)                                   # }
1.20      lukem     138:
                    139:
                    140: .endif # _MAKEFILE_IMAGE_

CVSweb <webmaster@jp.NetBSD.org>