Remove building with NOCRYPTO option
[minix3.git] / distrib / common / Makefile.image
blobaaec31041567cc901743efbd3f763a609ad52ee4
1 #       $NetBSD: Makefile.image,v 1.38 2014/08/12 11:48:22 martin Exp $
3 # Makefile snippet to build a tree from the provided lists,
4 # and make an ffs file system image from that tree
6 # Required variables:
7 #       NETBSDSRCDIR    top level of src tree (set by <bsd.own.mk>)
8 #       LISTS           list file(s) to use
9 #       IMAGEDEPENDS    depends for ${IMAGE}
10 #       IMAGEENDIAN     endianness of ${IMAGE}
11 #       IMAGESIZE       size of ${IMAGE}
12 #       MTREECONF       mtree specfiles to use to build a master specfile
14 # Optional variables:
15 #       IMAGE           name of target image
16 #       IMAGEPREBUILD   additional operations to run pre image creation
17 #       IMAGEPOSTBUILD  operation to run on ${IMAGE} ${.TARGET} after its built
18 #                       (if this returns non zero, ${.TARGET} is removed)
19 #       CRUNCHBIN       name of crunchgen(1)ed binary
20 #       DESTDIR         destination directory
21 #       MAKEFS_FLAGS    extra options to ${TOOL_MAKEFS}
22 #       PARSELISTENV    environment variables to set for parselist.awk
23 #       WORKDIR         directory to build image in to 
24 #       IMAGETAR        tar.gz file to create containing ${IMAGE}'s contents
26 #       IMAGE_RELEASEDIR        where to install ${IMAGE}.gz
27 #       IMAGETAR_RELEASEDIR     where to install ${IMAGETAR}
30 .if !defined(_MAKEFILE_IMAGE_)
31 _MAKEFILE_IMAGE_=1
34 WORKDIR?=       work
35 WORKSPEC?=      work.spec
36 WORKBUILT?=     work.built
38 .include "${DISTRIBDIR}/common/Makefile.parselist"
40 PARSELISTENV+=  TARGETDIR=${.OBJDIR}/${WORKDIR:Q}
42 GZIP_FLAGS= -9 ${GZIP_N_FLAG}
44 .if !target(${WORKBUILT})                                       # {
45 ${WORKBUILT}: ${IMAGEDEPENDS} ${WORKSPEC} ${PARSELISTDEP} ${LISTS}
46 #       There is a .PHONY ${CRUNCHBIN}, so check if out of date by hand
47 #       Default to `.' if ${CRUNCHBIN} isn't set, to always force a rebuild.
48         [ "${.OODATE}" = ${CRUNCHBIN:U.} -a -f ${WORKBUILT} -a ${WORKBUILT} -nt ${CRUNCHBIN:U.} ]  || { \
49         ${_MKSHMSG} "  build " ${.CURDIR:T}/${WORKDIR}; \
50         rm -rf ${WORKDIR} ${WORKBUILT}; \
51         mkdir -m 755 ${WORKDIR} &&  \
52         ${TOOL_MTREE} -def ${WORKSPEC} -p ${WORKDIR}/ -UW && \
53         ${PARSELIST} -v mode=populate ${LISTS} | \
54         ${HOST_SH} -e ${POPULATE_DEBUG} \
55         && touch ${WORKBUILT} ; \
56         }
58 CLEANFILES+=    ${WORKBUILT}
60 clean cleandir distclean: cleanfsimage
62 .PHONY: cleanfsimage
64 cleanfsimage:
65         -rm -rf ${WORKDIR} ${WORKBUILT}
67 .endif  # ! target (${WORKBUILT})                               # }
69 .if !target(${WORKSPEC})                                        # {
70 ${WORKSPEC}: ${MTREECONF} ${LISTS} ${PARSELISTDEP}
71         ${_MKTARGET_CREATE}
72         -rm -f ${.TARGET} ${.TARGET}.tmp
73         ( for i in ${MTREECONF}; do     \
74                 echo "# --" ; \
75                 echo "# entries from: $$i" ; \
76                 echo "#" ; \
77                 cat $$i ;               \
78                 echo "/unset all" ;     \
79         done ) >> ${.TARGET}.tmp
80         ${PARSELIST} -v mode=mtree ${LISTS} >> ${.TARGET}.tmp \
81         && mv ${.TARGET}.tmp ${.TARGET}
83 CLEANFILES+=    ${WORKSPEC} ${WORKSPEC}.tmp
84 .endif  # ! target (${WORKSPEC})                                # }
86 .if defined(IMAGE)                                              # {
87 IMGMAKEFSOPTIONS?= -o bsize=4096,fsize=512
88 ${IMAGE}: ${WORKBUILT}
89 .if defined(IMAGEPREBUILD)
90         ${IMAGEPREBUILD}
91 .endif
92         [ "${.OODATE}" = ${WORKBUILT} -a -f ${IMAGE} -a ! ${IMAGE} -ot ${WORKBUILT} ]  || { \
93         ${_MKSHMSG_CREATE} ${.CURDIR:T}/${.TARGET}; \
94         rm -f ${.TARGET} ${.TARGET}.tmp; \
95         ${TOOL_MAKEFS} -t ffs -B ${IMAGEENDIAN} -s ${IMAGESIZE} -F ${WORKSPEC} \
96             -N ${NETBSDSRCDIR}/etc ${IMGMAKEFSOPTIONS} \
97             -o optimization=space,minfree=0 \
98             ${MAKEFS_FLAGS} ${.TARGET}.tmp ${WORKDIR} \
99         && mv -f ${.TARGET}.tmp ${.TARGET}; \
100         }
101 .if defined(IMAGEPOSTBUILD)
102         ${IMAGEPOSTBUILD} || { rm -f ${.TARGET} ; false; }
103 .endif
105 .PHONY: fsimage
106 fsimage: ${IMAGE}
108 ${IMAGE}.gz: ${IMAGE}
109         ${_MKTARGET_CREATE}
110         -rm -f ${.TARGET}
111         ${TOOL_GZIP} ${GZIP_FLAGS} -c ${.ALLSRC} > ${.TARGET}
113 realall: ${IMAGE}
115 .if defined(IMAGE_RELEASEDIR)
116 release:: check_RELEASEDIR .WAIT ${IMAGE}.gz
117         ${RELEASE_INSTALL} ${IMAGE}.gz \
118             ${RELEASEDIR}/${RELEASEMACHINEDIR}/${IMAGE_RELEASEDIR}
119 .endif
121 CLEANFILES+=    ${IMAGE} ${IMAGE}.gz ${IMAGE}.tmp
122 .endif  # ! defined(IMAGE)                                      # }
125 .if defined(IMAGETAR)                                           # {
126 ${IMAGETAR}: ${WORKBUILT} ${WORKSPEC} ${IMAGEDEPENDS}
127         ${_MKTARGET_CREATE}
128         ( cd ${WORKDIR}; \
129           GZIP=${GZIP_FLAGS:Q} \
130           ${TOOL_PAX} --use-compress-program=${TOOL_GZIP:Q} \
131               -ON ${NETBSDSRCDIR}/etc -wdM <${.OBJDIR}/${WORKSPEC} \
132         ) > ${.TARGET}.tmp \
133         && mv ${.TARGET}.tmp ${.TARGET}
135 realall: ${IMAGETAR}
137 CLEANFILES+=    ${IMAGETAR} ${IMAGETAR}.tmp
139 .if defined(IMAGETAR_RELEASEDIR)
140 release:: check_RELEASEDIR .WAIT ${IMAGETAR}
141         ${RELEASE_INSTALL} ${IMAGETAR} \
142             ${RELEASEDIR}/${RELEASEMACHINEDIR}/${IMAGETAR_RELEASEDIR}
143 .endif
145 .endif  # ! defined(IMAGETAR)                                   # }
148 .endif  # _MAKEFILE_IMAGE_