No empty .Rs/.Re
[netbsd-mini2440.git] / distrib / common / Makefile.mdset
blobc2fe55757bb0dee9d91a30f3da3aa05ca09abbff
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
7 # Required variables:
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
16 #                       ${FILENAME}.gz.
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 `/'.
25 # Optional variables:
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}:
53 #                                               SUFFIX  COMMANDVAR
54 #                                       "${.TARGET}" is "${FILENAME}.${SUFFIX}"
55 #                                       COMMANDVAR is the name of the variable
56 #                                       containing the command to build
57 #                                       ${.TARGET}.
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_)
65 _MAKEFILE_MDSET_=1
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}
74 .else
75 _KERNNAME.${_K}.${_F}:= ${KERNOBJDIR}/${_K}/netbsd
76 .endif
78 _FILENAME:=${_F}                # (work around obscure issue in make(1))
79 .if ${_FILENAME} == "-"
80 _KERNEL.${_K}.${_F}:=   netbsd-${_K}
81 _FILENAME:=             ${_KERNEL.${_K}.${_F}}
82 .else
83 _KERNEL.${_K}.${_F}:=   ${_F}
84 .endif
86 .for _S _C in ${MDSET_SUFFIXES.${_F}}           # {
87 CLEANFILES+=    ${_KERNEL.${_K}.${_F}}.${_S}
89 ${_KERNEL.${_K}.${_F}}.${_S}: ${_KERNEL.${_K}.${_F}}
90 .if defined(${_C})
91         ${${_C}}
92 .else
93         @echo "No such variable \"${_C}\""
94         false
95 .endif
97 .if defined(MDSET_NOGZIP.${_FILENAME}) && defined(MDSET_NOGZIP)
98 KERNELS+=       ${_KERNEL.${_K}.${_F}}.${_S}
99 .else                                                   # {
100 KERNELS+=       ${_KERNEL.${_K}.${_F}}.${_S}.gz
102 ${_KERNEL.${_K}.${_F}}.${_S}.gz: ${_KERNEL.${_K}.${_F}}.${_S}
103         ${_MKTARGET_CREATE}
104         -rm -f ${.TARGET}
105         gzip -9nc ${.ALLSRC} > ${.TARGET}
106 .endif                                                  # }
108 .endfor                                                 # }
110 .if !defined(MDSET_NOSYMBOLS.${_FILENAME}) && !defined(MDSET_NOSYMBOLS)
111 KERNELSYMS+=    ${_KERNEL.${_K}.${_F}}.symbols.gz
112 .endif
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}
118 .endif
121 CLEANFILES+=    ${_KERNEL.${_K}.${_F}}
123 .if defined(MDSET_NOIMAGE.${_FILENAME})
124 ${_I}=
125 .endif
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
130 OPSYS!= uname -s
131 .if ${OPSYS} == "Darwin"
132 MDSETIMAGEFLAGS=
133 .else
134 MDSETIMAGEFLAGS=-v
135 .endif
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}
143 .endif
144 .if !defined(MDSET_NOSYMBOLS.${_FILENAME}) && !defined(MDSET_NOSYMBOLS)
145         ${NM} ${.TARGET}.tmp | gzip -9n > ${.TARGET}.symbols.gz
146 .endif
147 .if !defined(MDSET_NOSTRIP.${_FILENAME}) && !defined(MDSET_NOSTRIP)
148         ${STRIP} -R .comment -R .ident ${.TARGET}.tmp
149 .endif
150         @mv ${.TARGET}.tmp ${.TARGET}
151 .if defined(MDSET_POST.${_FILENAME}) || defined(MDSET_POST)
152         ${_POST.${.TARGET}}
153 .endif
155 .if defined(MDSET_NOGZIP.${_FILENAME}) || defined(MDSET_NOGZIP)
156 KERNELS+=       ${_KERNEL.${_K}.${_F}}
157 .else                                                   # {
158 KERNELS+=       ${_KERNEL.${_K}.${_F}}.gz
160 ${_KERNEL.${_K}.${_F}}.gz: ${_KERNEL.${_K}.${_F}}
161         ${_MKTARGET_CREATE}
162         -rm -f ${.TARGET}
163         gzip -9nc ${.ALLSRC} > ${.TARGET}
164 .endif                                                  # }
166 .endfor                                                 # }
168 CLEANFILES+=    ${KERNELS} ${KERNELSYMS}
170 realall: ${KERNELS}
172 .if defined(MDSET_RELEASEDIR)
173 release:: check_RELEASEDIR .WAIT ${KERNELS}
174         ${RELEASE_INSTALL} ${KERNELS} ${KERNELSYMS} \
175             ${RELEASEDIR}/${RELEASEMACHINEDIR}/${MDSET_RELEASEDIR}
176 .endif
179 .endif  # _MAKEFILE_MDSET_