1 # $NetBSD: Makefile.mdset,v 1.33 2008/07/21 10:00:52 agc 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_NOSTRIP If defined, don't strip any kernels.
34 # MDSET_NOSTRIP.${FILENAME} If defined, don't strip ${FILENAME}
36 # MDSET_NOSYMBOLS If defined, don't generate *.symbols.gz
38 # MDSET_NOSYMBOLS.${FILENAME} If defined, don't generate
39 # ${FILENAME}.symbols.gz
41 # MDSET_POST For each kernel,
42 # execute this after ${NM} / ${STRIP}.
43 # Kernel is available as "${.TARGET}"
45 # MDSET_POST.${FILENAME} For each kernel named ${FILENAME},
46 # execute this after ${NM} / ${STRIP}.
47 # Kernel is available as "${.TARGET}"
49 # MDSET_SUFFIXES.${FILENAME} List of extra install kernel suffixes
50 # and build commands to create from
51 # ${FILENAME} after its created by
52 # ${TOOL_MDSETIMAGE} ; ${NM} ; ${STRIP}:
54 # "${.TARGET}" is "${FILENAME}.${SUFFIX}"
55 # COMMANDVAR is the name of the variable
56 # containing the command to build
59 # Variables modified by this:
60 # KERNELS List of kernel .gz files to build
61 # KERNELSYMS List of kernel .symbol.gz files to build
64 .if !defined(_MAKEFILE_MDSET_)
67 .include <bsd.kernobj.mk>
69 .for _K _I _F in ${MDSETTARGETS} # {
71 _KERNEL:=${_K} # (work around obscure issue in make(1))
72 .if (${_KERNEL:M*/*} != "")
73 _KERNNAME.${_K}.${_F}:= ${_K}
75 _KERNNAME.${_K}.${_F}:= ${KERNOBJDIR}/${_K}/netbsd
78 _FILENAME:=${_F} # (work around obscure issue in make(1))
79 .if ${_FILENAME} == "-"
80 _KERNEL.${_K}.${_F}:= netbsd-${_K}
81 _FILENAME:= ${_KERNEL.${_K}.${_F}}
83 _KERNEL.${_K}.${_F}:= ${_F}
86 .for _S _C in ${MDSET_SUFFIXES.${_F}} # {
87 CLEANFILES+= ${_KERNEL.${_K}.${_F}}.${_S}
89 ${_KERNEL.${_K}.${_F}}.${_S}: ${_KERNEL.${_K}.${_F}}
93 @echo "No such variable \"${_C}\""
97 .if defined(MDSET_NOGZIP.${_FILENAME}) && defined(MDSET_NOGZIP)
98 KERNELS+= ${_KERNEL.${_K}.${_F}}.${_S}
100 KERNELS+= ${_KERNEL.${_K}.${_F}}.${_S}.gz
102 ${_KERNEL.${_K}.${_F}}.${_S}.gz: ${_KERNEL.${_K}.${_F}}.${_S}
105 gzip -9nc ${.ALLSRC} > ${.TARGET}
110 .if !defined(MDSET_NOSYMBOLS.${_FILENAME}) && !defined(MDSET_NOSYMBOLS)
111 KERNELSYMS+= ${_KERNEL.${_K}.${_F}}.symbols.gz
114 .if defined(MDSET_POST.${_FILENAME})
115 _POST.${_KERNEL.${_K}.${_F}}:= ${MDSET_POST.${_FILENAME}}
116 .elif defined(MDSET_POST)
117 _POST.${_KERNEL.${_K}.${_F}}:= ${MDSET_POST}
121 CLEANFILES+= ${_KERNEL.${_K}.${_F}}
123 .if defined(MDSET_NOIMAGE.${_FILENAME})
127 # Darwin requires a special hack - this is documented in
128 # doc/HACKS, and just works around the problems described more
129 # fully in http://mail-index.netbsd.org/current-users/2008/06/27/msg003242.html
131 .if ${OPSYS} == "Darwin"
137 ${_KERNEL.${_K}.${_F}}: .NOTMAIN ${_KERNNAME.${_K}.${_F}} ${_I}
138 ${_MKTARGET_CREATE} "(from: ${.ALLSRC})"
139 @rm -f ${.TARGET} ${.TARGET}.tmp ${.TARGET}.symbols.gz
140 @cp ${_KERNNAME.${_K}.${_F}} ${.TARGET}.tmp
141 .if !defined(MDSET_NOIMAGE.${_FILENAME})
142 ${TOOL_MDSETIMAGE} ${MDSETIMAGEFLAGS} ${.TARGET}.tmp ${_I}
144 .if !defined(MDSET_NOSYMBOLS.${_FILENAME}) && !defined(MDSET_NOSYMBOLS)
145 ${NM} ${.TARGET}.tmp | gzip -9n > ${.TARGET}.symbols.gz
147 .if !defined(MDSET_NOSTRIP.${_FILENAME}) && !defined(MDSET_NOSTRIP)
148 ${STRIP} -R .comment -R .ident ${.TARGET}.tmp
150 @mv ${.TARGET}.tmp ${.TARGET}
151 .if defined(MDSET_POST.${_FILENAME}) || defined(MDSET_POST)
155 .if defined(MDSET_NOGZIP.${_FILENAME}) || defined(MDSET_NOGZIP)
156 KERNELS+= ${_KERNEL.${_K}.${_F}}
158 KERNELS+= ${_KERNEL.${_K}.${_F}}.gz
160 ${_KERNEL.${_K}.${_F}}.gz: ${_KERNEL.${_K}.${_F}}
163 gzip -9nc ${.ALLSRC} > ${.TARGET}
168 CLEANFILES+= ${KERNELS} ${KERNELSYMS}
172 .if defined(MDSET_RELEASEDIR)
173 release:: check_RELEASEDIR .WAIT ${KERNELS}
174 ${RELEASE_INSTALL} ${KERNELS} ${KERNELSYMS} \
175 ${RELEASEDIR}/${RELEASEMACHINEDIR}/${MDSET_RELEASEDIR}
179 .endif # _MAKEFILE_MDSET_