| @@ -1,189 +1,189 @@ | | | @@ -1,189 +1,189 @@ |
1 | # $NetBSD: Makefile.mdset,v 1.46 2019/08/12 08:04:28 martin Exp $ | | 1 | # $NetBSD: Makefile.mdset,v 1.47 2024/04/23 21:58:57 christos Exp $ |
2 | # | | 2 | # |
3 | # Makefile snippet to ${TOOL_MDSETIMAGE} file system images into kernels | | 3 | # Makefile snippet to ${TOOL_MDSETIMAGE} file system images into kernels |
4 | # | | 4 | # |
5 | | | 5 | |
6 | # | | 6 | # |
7 | # Required variables: | | 7 | # Required variables: |
8 | # NETBSDSRCDIR Top level of src tree (set by <bsd.own.mk>) | | 8 | # NETBSDSRCDIR Top level of src tree (set by <bsd.own.mk>) |
9 | # MDSETTARGETS List of images to ${TOOL_MDSETIMAGE} into kernels, | | 9 | # MDSETTARGETS List of images to ${TOOL_MDSETIMAGE} into kernels, |
10 | # containing one or more tuples of the form: | | 10 | # containing one or more tuples of the form: |
11 | # KERNEL IMAGE FILENAME | | 11 | # KERNEL IMAGE FILENAME |
12 | # | | 12 | # |
13 | # The kernel is ${TOOL_MDSETIMAGE} with ${IMAGE}, | | 13 | # The kernel is ${TOOL_MDSETIMAGE} with ${IMAGE}, |
14 | # ${STRIP}ped (after the symbols are stored in | | 14 | # ${STRIP}ped (after the symbols are stored in |
15 | # ${FILENAME}.symbols.gz), and gzipped into | | 15 | # ${FILENAME}.symbols.gz), and gzipped into |
16 | # ${FILENAME}.gz. | | 16 | # ${FILENAME}.gz. |
17 | # | | 17 | # |
18 | # If KERNEL does not contain a `/', use | | 18 | # If KERNEL does not contain a `/', use |
19 | # ${KERNOBJDIR}/KERNEL/netbsd as the kernel. | | 19 | # ${KERNOBJDIR}/KERNEL/netbsd as the kernel. |
20 | # | | 20 | # |
21 | # If FILENAME is "-", use "netbsd-${KERNEL}" as | | 21 | # If FILENAME is "-", use "netbsd-${KERNEL}" as |
22 | # the target name. This may not be a sensible | | 22 | # the target name. This may not be a sensible |
23 | # name if KERNEL contains a `/'. | | 23 | # name if KERNEL contains a `/'. |
24 | # | | 24 | # |
25 | # Optional variables: | | 25 | # Optional variables: |
26 | # MDSET_RELEASEDIR Where to install release kernels. | | 26 | # MDSET_RELEASEDIR Where to install release kernels. |
27 | # | | 27 | # |
28 | # MDSET_NOGZIP If defined, don't gzip any kernels. | | 28 | # MDSET_NOGZIP If defined, don't gzip any kernels. |
29 | # | | 29 | # |
30 | # MDSET_NOGZIP.${FILENAME} If defined, don't gzip ${FILENAME} | | 30 | # MDSET_NOGZIP.${FILENAME} If defined, don't gzip ${FILENAME} |
31 | # | | 31 | # |
32 | # MDSET_NOIMAGE.${FILENAME} If defined, don't add ${IMAGE} to | | 32 | # MDSET_NOIMAGE.${FILENAME} If defined, don't add ${IMAGE} to |
33 | # ${FILENAME} | | 33 | # ${FILENAME} |
34 | # | | 34 | # |
35 | # MDSET_NOSTRIP If defined, don't strip any kernels. | | 35 | # MDSET_NOSTRIP If defined, don't strip any kernels. |
36 | # | | 36 | # |
37 | # MDSET_NOSTRIP.${FILENAME} If defined, don't strip ${FILENAME} | | 37 | # MDSET_NOSTRIP.${FILENAME} If defined, don't strip ${FILENAME} |
38 | # | | 38 | # |
39 | # MDSET_NOSYMBOLS If defined, don't generate *.symbols.gz | | 39 | # MDSET_NOSYMBOLS If defined, don't generate *.symbols.gz |
40 | # | | 40 | # |
41 | # MDSET_NOSYMBOLS.${FILENAME} If defined, don't generate | | 41 | # MDSET_NOSYMBOLS.${FILENAME} If defined, don't generate |
42 | # ${FILENAME}.symbols.gz | | 42 | # ${FILENAME}.symbols.gz |
43 | # | | 43 | # |
44 | # MDSET_POST For each kernel, | | 44 | # MDSET_POST For each kernel, |
45 | # execute this after ${NM} / ${STRIP}. | | 45 | # execute this after ${NM} / ${STRIP}. |
46 | # Kernel is available as "${.TARGET}" | | 46 | # Kernel is available as "${.TARGET}" |
47 | # | | 47 | # |
48 | # MDSET_POST.${FILENAME} For each kernel named ${FILENAME}, | | 48 | # MDSET_POST.${FILENAME} For each kernel named ${FILENAME}, |
49 | # execute this after ${NM} / ${STRIP}. | | 49 | # execute this after ${NM} / ${STRIP}. |
50 | # Kernel is available as "${.TARGET}" | | 50 | # Kernel is available as "${.TARGET}" |
51 | # | | 51 | # |
52 | # MDSET_SUFFIXES.${FILENAME} List of extra install kernel suffixes | | 52 | # MDSET_SUFFIXES.${FILENAME} List of extra install kernel suffixes |
53 | # and build commands to create from | | 53 | # and build commands to create from |
54 | # ${FILENAME} after its created by | | 54 | # ${FILENAME} after its created by |
55 | # ${TOOL_MDSETIMAGE} ; ${NM} ; ${STRIP}: | | 55 | # ${TOOL_MDSETIMAGE} ; ${NM} ; ${STRIP}: |
56 | # SUFFIX COMMANDVAR | | 56 | # SUFFIX COMMANDVAR |
57 | # "${.TARGET}" is "${FILENAME}.${SUFFIX}" | | 57 | # "${.TARGET}" is "${FILENAME}.${SUFFIX}" |
58 | # COMMANDVAR is the name of the variable | | 58 | # COMMANDVAR is the name of the variable |
59 | # containing the command to build | | 59 | # containing the command to build |
60 | # ${.TARGET}. | | 60 | # ${.TARGET}. |
61 | # | | 61 | # |
62 | # Variables modified by this: | | 62 | # Variables modified by this: |
63 | # KERNELS List of kernel .gz files to build | | 63 | # KERNELS List of kernel .gz files to build |
64 | # KERNELSYMS List of kernel .symbol.gz files to build | | 64 | # KERNELSYMS List of kernel .symbol.gz files to build |
65 | # | | 65 | # |
66 | | | 66 | |
67 | .if !defined(_MAKEFILE_MDSET_) | | 67 | .if !defined(_MAKEFILE_MDSET_) |
68 | _MAKEFILE_MDSET_=1 | | 68 | _MAKEFILE_MDSET_=1 |
69 | | | 69 | |
70 | .include <bsd.kernobj.mk> | | 70 | .include <bsd.kernobj.mk> |
71 | | | 71 | |
72 | # The default is to build for all MDSETTARGETS | | 72 | # The default is to build for all MDSETTARGETS |
73 | ALL_KERNELS?= + | | 73 | ALL_KERNELS?= + |
74 | | | 74 | |
75 | .for _K _I _F in ${MDSETTARGETS} # { | | 75 | .for _K _I _F in ${MDSETTARGETS} # { |
76 | .for currentsel in ${ALL_KERNELS} # { | | 76 | .for currentsel in ${ALL_KERNELS} # { |
77 | .if ${currentsel} == "+" || ${_K} == ${currentsel} | | 77 | .if ${currentsel} == "+" || ${_K} == ${currentsel} |
78 | | | 78 | |
79 | _KERNEL:=${_K} # (work around obscure issue in make(1)) | | 79 | _KERNEL:=${_K} # (work around obscure issue in make(1)) |
80 | .if (${_KERNEL:M*/*} != "") | | 80 | .if (${_KERNEL:M*/*} != "") |
81 | _KERNNAME.${_K}.${_F}:= ${_K} | | 81 | _KERNNAME.${_K}.${_F}:= ${_K} |
82 | .else | | 82 | .else |
83 | _KERNNAME.${_K}.${_F}:= ${KERNOBJDIR}/${_K}/netbsd | | 83 | _KERNNAME.${_K}.${_F}:= ${KERNOBJDIR}/${_K}/netbsd |
84 | .endif | | 84 | .endif |
85 | | | 85 | |
86 | _FILENAME:=${_F} # (work around obscure issue in make(1)) | | 86 | _FILENAME:=${_F} # (work around obscure issue in make(1)) |
87 | .if ${_FILENAME} == "-" | | 87 | .if ${_FILENAME} == "-" |
88 | _KERNEL.${_K}.${_F}:= netbsd-${_K} | | 88 | _KERNEL.${_K}.${_F}:= netbsd-${_K} |
89 | _FILENAME:= ${_KERNEL.${_K}.${_F}} | | 89 | _FILENAME:= ${_KERNEL.${_K}.${_F}} |
90 | .else | | 90 | .else |
91 | _KERNEL.${_K}.${_F}:= ${_F} | | 91 | _KERNEL.${_K}.${_F}:= ${_F} |
92 | .endif | | 92 | .endif |
93 | | | 93 | |
94 | .for _S _C in ${MDSET_SUFFIXES.${_F}} # { | | 94 | .for _S _C in ${MDSET_SUFFIXES.${_F}} # { |
95 | CLEANFILES+= ${_KERNEL.${_K}.${_F}}.${_S} | | 95 | CLEANFILES+= ${_KERNEL.${_K}.${_F}}.${_S} |
96 | | | 96 | |
97 | ${_KERNEL.${_K}.${_F}}.${_S}: ${_KERNEL.${_K}.${_F}} ${MDSET_.${_K}.${_F}.${_S}.deps} | | 97 | ${_KERNEL.${_K}.${_F}}.${_S}: ${_KERNEL.${_K}.${_F}} ${MDSET_.${_K}.${_F}.${_S}.deps} |
98 | .if defined(${_C}) | | 98 | .if defined(${_C}) |
99 | ${${_C}} | | 99 | ${${_C}} |
100 | .else | | 100 | .else |
101 | @echo "No such variable \"${_C}\"" | | 101 | @echo "No such variable \"${_C}\"" |
102 | false | | 102 | false |
103 | .endif | | 103 | .endif |
104 | | | 104 | |
105 | .if defined(MDSET_NOGZIP.${_FILENAME}) || defined(MDSET_NOGZIP) | | 105 | .if defined(MDSET_NOGZIP.${_FILENAME}) || defined(MDSET_NOGZIP) |
106 | KERNELS+= ${_KERNEL.${_K}.${_F}}.${_S} | | 106 | KERNELS+= ${_KERNEL.${_K}.${_F}}.${_S} |
107 | .else # { | | 107 | .else # { |
108 | KERNELS+= ${_KERNEL.${_K}.${_F}}.${_S}.gz | | 108 | KERNELS+= ${_KERNEL.${_K}.${_F}}.${_S}.gz |
109 | | | 109 | |
110 | ${_KERNEL.${_K}.${_F}}.${_S}.gz: ${_KERNEL.${_K}.${_F}}.${_S} | | 110 | ${_KERNEL.${_K}.${_F}}.${_S}.gz: ${_KERNEL.${_K}.${_F}}.${_S} |
111 | ${_MKTARGET_CREATE} | | 111 | ${_MKTARGET_CREATE} |
112 | -rm -f ${.TARGET} | | 112 | -rm -f ${.TARGET} |
113 | ${TOOL_GZIP_N} -9c ${.ALLSRC} > ${.TARGET} | | 113 | ${TOOL_GZIP_N} -9c ${.ALLSRC} > ${.TARGET} |
114 | .endif # } | | 114 | .endif # } |
115 | | | 115 | |
116 | .endfor # } | | 116 | .endfor # } |
117 | | | 117 | |
118 | .if !defined(MDSET_NOSYMBOLS.${_FILENAME}) && !defined(MDSET_NOSYMBOLS) | | 118 | .if !defined(MDSET_NOSYMBOLS.${_FILENAME}) && !defined(MDSET_NOSYMBOLS) |
119 | KERNELSYMS+= ${_KERNEL.${_K}.${_F}}.symbols.gz | | 119 | KERNELSYMS+= ${_KERNEL.${_K}.${_F}}.symbols.gz |
120 | .endif | | 120 | .endif |
121 | | | 121 | |
122 | .if defined(MDSET_POST.${_FILENAME}) | | 122 | .if defined(MDSET_POST.${_FILENAME}) |
123 | _POST.${_KERNEL.${_K}.${_F}}:= ${MDSET_POST.${_FILENAME}} | | 123 | _POST.${_KERNEL.${_K}.${_F}}:= ${MDSET_POST.${_FILENAME}} |
124 | .elif defined(MDSET_POST) | | 124 | .elif defined(MDSET_POST) |
125 | _POST.${_KERNEL.${_K}.${_F}}:= ${MDSET_POST} | | 125 | _POST.${_KERNEL.${_K}.${_F}}:= ${MDSET_POST} |
126 | .endif | | 126 | .endif |
127 | | | 127 | |
128 | CLEANFILES+= ${_KERNEL.${_K}.${_F}} ${_KERNEL.${_K}.${_F}}.tmp | | 128 | CLEANFILES+= ${_KERNEL.${_K}.${_F}} ${_KERNEL.${_K}.${_F}}.tmp |
129 | | | 129 | |
130 | .if defined(MDSET_NOIMAGE.${_FILENAME}) | | 130 | .if defined(MDSET_NOIMAGE.${_FILENAME}) |
131 | ${_I}= | | 131 | ${_I}= |
132 | .endif | | 132 | .endif |
133 | | | 133 | |
134 | # Darwin requires a special hack - this is documented in | | 134 | # Darwin requires a special hack - this is documented in |
135 | # doc/HACKS, and just works around the problems described more | | 135 | # doc/HACKS, and just works around the problems described more |
136 | # fully in http://mail-index.netbsd.org/current-users/2008/06/27/msg003242.html | | 136 | # fully in http://mail-index.netbsd.org/current-users/2008/06/27/msg003242.html |
137 | OPSYS!= uname -s | | 137 | OPSYS!= uname -s |
138 | .if ${OPSYS} == "Darwin" | | 138 | .if ${OPSYS} == "Darwin" |
139 | MDSETIMAGEFLAGS= | | 139 | MDSETIMAGEFLAGS= |
140 | .else | | 140 | .else |
141 | MDSETIMAGEFLAGS=-v | | 141 | MDSETIMAGEFLAGS=-v |
142 | .endif | | 142 | .endif |
143 | | | 143 | |
144 | ${_KERNEL.${_K}.${_F}}: .NOTMAIN ${_KERNNAME.${_K}.${_F}} ${_I} | | 144 | ${_KERNEL.${_K}.${_F}}: .NOTMAIN ${_KERNNAME.${_K}.${_F}} ${_I} |
145 | ${_MKTARGET_CREATE} "(from: ${.ALLSRC})" | | 145 | ${_MKTARGET_CREATE} "(from: ${.ALLSRC})" |
146 | @rm -f ${.TARGET} ${.TARGET}.tmp ${.TARGET}.symbols.gz | | 146 | @rm -f ${.TARGET} ${.TARGET}.tmp ${.TARGET}.symbols.gz |
147 | @cp ${_KERNNAME.${_K}.${_F}} ${.TARGET}.tmp | | 147 | @cp ${_KERNNAME.${_K}.${_F}} ${.TARGET}.tmp |
148 | .if !defined(MDSET_NOIMAGE.${_FILENAME}) | | 148 | .if !defined(MDSET_NOIMAGE.${_FILENAME}) |
149 | ${TOOL_MDSETIMAGE} ${MDSETIMAGEFLAGS} ${.TARGET}.tmp ${_I} | | 149 | ${TOOL_MDSETIMAGE} ${MDSETIMAGEFLAGS} ${.TARGET}.tmp ${_I} |
150 | .endif | | 150 | .endif |
151 | .if !defined(MDSET_NOSYMBOLS.${_FILENAME}) && !defined(MDSET_NOSYMBOLS) | | 151 | .if !defined(MDSET_NOSYMBOLS.${_FILENAME}) && !defined(MDSET_NOSYMBOLS) |
152 | ${NM} ${.TARGET}.tmp | ${TOOL_GZIP_N} -9 > ${.TARGET}.symbols.gz | | 152 | ${NM} ${.TARGET}.tmp | LC_ALL=C sort | ${TOOL_GZIP_N} -9 > ${.TARGET}.symbols.gz |
153 | .endif | | 153 | .endif |
154 | .if !defined(MDSET_NOSTRIP.${_FILENAME}) && !defined(MDSET_NOSTRIP) | | 154 | .if !defined(MDSET_NOSTRIP.${_FILENAME}) && !defined(MDSET_NOSTRIP) |
155 | ${STRIP} -R .eh_frame -R .eh_frame_hdr -R .comment -R .ident ${MDSET_STRIPSECTIONS} ${.TARGET}.tmp | | 155 | ${STRIP} -R .eh_frame -R .eh_frame_hdr -R .comment -R .ident ${MDSET_STRIPSECTIONS} ${.TARGET}.tmp |
156 | .endif | | 156 | .endif |
157 | @mv ${.TARGET}.tmp ${.TARGET} | | 157 | @mv ${.TARGET}.tmp ${.TARGET} |
158 | .if defined(MDSET_POST.${_FILENAME}) || defined(MDSET_POST) | | 158 | .if defined(MDSET_POST.${_FILENAME}) || defined(MDSET_POST) |
159 | ${_POST.${.TARGET}} | | 159 | ${_POST.${.TARGET}} |
160 | .endif | | 160 | .endif |
161 | | | 161 | |
162 | .if defined(MDSET_NOGZIP.${_FILENAME}) || defined(MDSET_NOGZIP) | | 162 | .if defined(MDSET_NOGZIP.${_FILENAME}) || defined(MDSET_NOGZIP) |
163 | KERNELS+= ${_KERNEL.${_K}.${_F}} | | 163 | KERNELS+= ${_KERNEL.${_K}.${_F}} |
164 | .else # { | | 164 | .else # { |
165 | KERNELS+= ${_KERNEL.${_K}.${_F}}.gz | | 165 | KERNELS+= ${_KERNEL.${_K}.${_F}}.gz |
166 | | | 166 | |
167 | ${_KERNEL.${_K}.${_F}}.gz: ${_KERNEL.${_K}.${_F}} | | 167 | ${_KERNEL.${_K}.${_F}}.gz: ${_KERNEL.${_K}.${_F}} |
168 | ${_MKTARGET_CREATE} | | 168 | ${_MKTARGET_CREATE} |
169 | -rm -f ${.TARGET} | | 169 | -rm -f ${.TARGET} |
170 | ${TOOL_GZIP_N} -9c ${.ALLSRC} > ${.TARGET} | | 170 | ${TOOL_GZIP_N} -9c ${.ALLSRC} > ${.TARGET} |
171 | .endif # } | | 171 | .endif # } |
172 | | | 172 | |
173 | .endif | | 173 | .endif |
174 | .endfor # } | | 174 | .endfor # } |
175 | .endfor # } | | 175 | .endfor # } |
176 | | | 176 | |
177 | CLEANFILES+= ${KERNELS} ${KERNELSYMS} | | 177 | CLEANFILES+= ${KERNELS} ${KERNELSYMS} |
178 | | | 178 | |
179 | realall: ${KERNELS} | | 179 | realall: ${KERNELS} |
180 | | | 180 | |
181 | .if defined(MDSET_RELEASEDIR) | | 181 | .if defined(MDSET_RELEASEDIR) |
182 | release:: check_RELEASEDIR .WAIT ${KERNELS} | | 182 | release:: check_RELEASEDIR .WAIT ${KERNELS} |
183 | test -z "${KERNELS}" || \ | | 183 | test -z "${KERNELS}" || \ |
184 | ${RELEASE_INSTALL} ${KERNELS} ${KERNELSYMS} \ | | 184 | ${RELEASE_INSTALL} ${KERNELS} ${KERNELSYMS} \ |
185 | ${RELEASEDIR}/${RELEASEMACHINEDIR}/${MDSET_RELEASEDIR} | | 185 | ${RELEASEDIR}/${RELEASEMACHINEDIR}/${MDSET_RELEASEDIR} |
186 | .endif | | 186 | .endif |
187 | | | 187 | |
188 | | | 188 | |
189 | .endif # _MAKEFILE_MDSET_ | | 189 | .endif # _MAKEFILE_MDSET_ |