1 # $NetBSD: Makefile.mdset,v 1.40 2014/08/05 15:40:58 apb Exp $
3 # Makefile snippet to ${TOOL_MDSETIMAGE} file system images into kernels
8 # NETBSDSRCDIR Top level of src tree (set by <bsd.own.mk>)
9 # MDSETTARGETS List of images to ${TOOL_MDSETIMAGE} into kernels,
10 # containing one or more tuples of the form:
11 # KERNEL IMAGE FILENAME
13 # The kernel is ${TOOL_MDSETIMAGE} with ${IMAGE},
14 # ${STRIP}ped (after the symbols are stored in
15 # ${FILENAME}.symbols.gz), and gzipped into
18 # If KERNEL does not contain a `/', use
19 # ${KERNOBJDIR}/KERNEL/netbsd as the kernel.
21 # If FILENAME is "-", use "netbsd-${KERNEL}" as
22 # the target name. This may not be a sensible
23 # name if KERNEL contains a `/'.
26 # MDSET_RELEASEDIR Where to install release kernels.
28 # MDSET_NOGZIP If defined, don't gzip any kernels.
30 # MDSET_NOGZIP.${FILENAME} If defined, don't gzip ${FILENAME}
32 # MDSET_NOIMAGE.${FILENAME} If defined, don't add ${IMAGE} to
35 # MDSET_NOSTRIP If defined, don't strip any kernels.
37 # MDSET_NOSTRIP.${FILENAME} If defined, don't strip ${FILENAME}
39 # MDSET_NOSYMBOLS If defined, don't generate *.symbols.gz
41 # MDSET_NOSYMBOLS.${FILENAME} If defined, don't generate
42 # ${FILENAME}.symbols.gz
44 # MDSET_POST For each kernel,
45 # execute this after ${NM} / ${STRIP}.
46 # Kernel is available as "${.TARGET}"
48 # MDSET_POST.${FILENAME} For each kernel named ${FILENAME},
49 # execute this after ${NM} / ${STRIP}.
50 # Kernel is available as "${.TARGET}"
52 # MDSET_SUFFIXES.${FILENAME} List of extra install kernel suffixes
53 # and build commands to create from
54 # ${FILENAME} after its created by
55 # ${TOOL_MDSETIMAGE} ; ${NM} ; ${STRIP}:
57 # "${.TARGET}" is "${FILENAME}.${SUFFIX}"
58 # COMMANDVAR is the name of the variable
59 # containing the command to build
62 # Variables modified by this:
63 # KERNELS List of kernel .gz files to build
64 # KERNELSYMS List of kernel .symbol.gz files to build
67 .if !defined(_MAKEFILE_MDSET_)
70 .include <bsd.kernobj.mk>
72 # The default is to build for all MDSETTARGETS
75 .for _K _I _F in ${MDSETTARGETS} # {
76 .for currentsel in ${ALL_KERNELS} # {
77 .if ${currentsel} == "+" || ${_K} == ${currentsel}
79 _KERNEL:=${_K} # (work around obscure issue in make(1))
80 .if (${_KERNEL:M*/*} != "")
81 _KERNNAME.${_K}.${_F}:= ${_K}
83 _KERNNAME.${_K}.${_F}:= ${KERNOBJDIR}/${_K}/netbsd
86 _FILENAME:=${_F} # (work around obscure issue in make(1))
87 .if ${_FILENAME} == "-"
88 _KERNEL.${_K}.${_F}:= netbsd-${_K}
89 _FILENAME:= ${_KERNEL.${_K}.${_F}}
91 _KERNEL.${_K}.${_F}:= ${_F}
94 .for _S _C in ${MDSET_SUFFIXES.${_F}} # {
95 CLEANFILES+= ${_KERNEL.${_K}.${_F}}.${_S}
97 ${_KERNEL.${_K}.${_F}}.${_S}: ${_KERNEL.${_K}.${_F}}
101 @echo "No such variable \"${_C}\""
105 .if defined(MDSET_NOGZIP.${_FILENAME}) && defined(MDSET_NOGZIP)
106 KERNELS+= ${_KERNEL.${_K}.${_F}}.${_S}
108 KERNELS+= ${_KERNEL.${_K}.${_F}}.${_S}.gz
110 ${_KERNEL.${_K}.${_F}}.${_S}.gz: ${_KERNEL.${_K}.${_F}}.${_S}
113 ${TOOL_GZIP_N} -9c ${.ALLSRC} > ${.TARGET}
118 .if !defined(MDSET_NOSYMBOLS.${_FILENAME}) && !defined(MDSET_NOSYMBOLS)
119 KERNELSYMS+= ${_KERNEL.${_K}.${_F}}.symbols.gz
122 .if defined(MDSET_POST.${_FILENAME})
123 _POST.${_KERNEL.${_K}.${_F}}:= ${MDSET_POST.${_FILENAME}}
124 .elif defined(MDSET_POST)
125 _POST.${_KERNEL.${_K}.${_F}}:= ${MDSET_POST}
129 CLEANFILES+= ${_KERNEL.${_K}.${_F}}
131 .if defined(MDSET_NOIMAGE.${_FILENAME})
135 # Darwin requires a special hack - this is documented in
136 # doc/HACKS, and just works around the problems described more
137 # fully in http://mail-index.netbsd.org/current-users/2008/06/27/msg003242.html
139 .if ${OPSYS} == "Darwin"
145 ${_KERNEL.${_K}.${_F}}: .NOTMAIN ${_KERNNAME.${_K}.${_F}} ${_I}
146 ${_MKTARGET_CREATE} "(from: ${.ALLSRC})"
147 @rm -f ${.TARGET} ${.TARGET}.tmp ${.TARGET}.symbols.gz
148 @cp ${_KERNNAME.${_K}.${_F}} ${.TARGET}.tmp
149 .if !defined(MDSET_NOIMAGE.${_FILENAME})
150 ${TOOL_MDSETIMAGE} ${MDSETIMAGEFLAGS} ${.TARGET}.tmp ${_I}
152 .if !defined(MDSET_NOSYMBOLS.${_FILENAME}) && !defined(MDSET_NOSYMBOLS)
153 ${NM} ${.TARGET}.tmp | ${TOOL_GZIP_N} -9 > ${.TARGET}.symbols.gz
155 .if !defined(MDSET_NOSTRIP.${_FILENAME}) && !defined(MDSET_NOSTRIP)
156 ${STRIP} -R .eh_frame -R .eh_frame_hdr -R .comment -R .ident ${.TARGET}.tmp
158 @mv ${.TARGET}.tmp ${.TARGET}
159 .if defined(MDSET_POST.${_FILENAME}) || defined(MDSET_POST)
163 .if defined(MDSET_NOGZIP.${_FILENAME}) || defined(MDSET_NOGZIP)
164 KERNELS+= ${_KERNEL.${_K}.${_F}}
166 KERNELS+= ${_KERNEL.${_K}.${_F}}.gz
168 ${_KERNEL.${_K}.${_F}}.gz: ${_KERNEL.${_K}.${_F}}
171 ${TOOL_GZIP_N} -9c ${.ALLSRC} > ${.TARGET}
178 CLEANFILES+= ${KERNELS} ${KERNELSYMS}
182 .if defined(MDSET_RELEASEDIR)
183 release:: check_RELEASEDIR .WAIT ${KERNELS}
184 test -z "${KERNELS}" || \
185 ${RELEASE_INSTALL} ${KERNELS} ${KERNELSYMS} \
186 ${RELEASEDIR}/${RELEASEMACHINEDIR}/${MDSET_RELEASEDIR}
190 .endif # _MAKEFILE_MDSET_