| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: Makefile.kern.inc,v 1.189 2015/08/24 18:02:55 christos Exp $ | | 1 | # $NetBSD: Makefile.kern.inc,v 1.190 2015/08/25 02:57:32 uebayasi Exp $ |
2 | # | | 2 | # |
3 | # This file contains common `MI' targets and definitions and it is included | | 3 | # This file contains common `MI' targets and definitions and it is included |
4 | # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}. | | 4 | # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}. |
5 | # | | 5 | # |
6 | # Each target in this file should be protected with `if !target(target)' | | 6 | # Each target in this file should be protected with `if !target(target)' |
7 | # or `if !commands(target)' and each variable should only be conditionally | | 7 | # or `if !commands(target)' and each variable should only be conditionally |
8 | # assigned `VAR ?= VALUE', so that everything can be overriden. | | 8 | # assigned `VAR ?= VALUE', so that everything can be overriden. |
9 | # | | 9 | # |
10 | # DEBUG is set to -g if debugging. | | 10 | # DEBUG is set to -g if debugging. |
11 | # PROF is set to -pg if profiling. | | 11 | # PROF is set to -pg if profiling. |
12 | # | | 12 | # |
13 | # To specify debugging, add the config line: makeoptions DEBUG="-g" | | 13 | # To specify debugging, add the config line: makeoptions DEBUG="-g" |
14 | # A better way is to specify -g only for a few files. | | 14 | # A better way is to specify -g only for a few files. |
| @@ -219,63 +219,54 @@ ${_cfile:T:R}.o: ${_cfile} | | | @@ -219,63 +219,54 @@ ${_cfile:T:R}.o: ${_cfile} |
219 | ## must be set in the port's Makefile. The port specific definitions for | | 219 | ## must be set in the port's Makefile. The port specific definitions for |
220 | ## LINKFLAGS_NORMAL and LINKFLAGS_DEBUG will added to the LINKFLAGS | | 220 | ## LINKFLAGS_NORMAL and LINKFLAGS_DEBUG will added to the LINKFLAGS |
221 | ## depending on the value of DEBUG. | | 221 | ## depending on the value of DEBUG. |
222 | ## | | 222 | ## |
223 | # load lines for config "xxx" will be emitted as: | | 223 | # load lines for config "xxx" will be emitted as: |
224 | # xxx: ${SYSTEM_DEP} swapxxxx.o vers.o build_kernel | | 224 | # xxx: ${SYSTEM_DEP} swapxxxx.o vers.o build_kernel |
225 | | | 225 | |
226 | .if !empty(OBJS:Mnetbsd.ko) | | 226 | .if !empty(OBJS:Mnetbsd.ko) |
227 | SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS} ${SYSLIBCOMPAT} ${LIBKERN} | | 227 | SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS} ${SYSLIBCOMPAT} ${LIBKERN} |
228 | .else | | 228 | .else |
229 | SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS:O} ${SYSLIBCOMPAT} ${LIBKERN} | | 229 | SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS:O} ${SYSLIBCOMPAT} ${LIBKERN} |
230 | .endif | | 230 | .endif |
231 | SYSTEM_DEP+= Makefile ${SYSTEM_OBJ} .gdbinit | | 231 | SYSTEM_DEP+= Makefile ${SYSTEM_OBJ} .gdbinit |
232 | .if defined(KERNLDSCRIPT) | | | |
233 | .if exists(${KERNLDSCRIPT}) | | | |
234 | SYSTEM_DEP+= -T ${KERNLDSCRIPT} | | | |
235 | .else | | | |
236 | SYSTEM_DEP+= ${.TARGET}.ldscript | | | |
237 | .endif | | | |
238 | .endif | | | |
239 | .if defined(CTFMERGE) | | 232 | .if defined(CTFMERGE) |
240 | SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o | | 233 | SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o |
241 | .else | | 234 | .else |
242 | SYSTEM_CTFMERGE= ${_MKSHECHO} | | 235 | SYSTEM_CTFMERGE= ${_MKSHECHO} |
243 | .endif | | 236 | .endif |
244 | SYSTEM_LD_HEAD?=@rm -f $@ | | 237 | SYSTEM_LD_HEAD?=@rm -f $@ |
245 | SYSTEM_LD?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \ | | 238 | SYSTEM_LD?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \ |
246 | ${_MKSHECHO}\ | | 239 | ${_MKSHECHO}\ |
247 | ${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o; \ | | 240 | ${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o; \ |
248 | ${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o | | 241 | ${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o |
249 | | | 242 | |
250 | # Give MD generated ldscript dependency on ${SYSTEM_OBJ} | | 243 | # Give MD generated ldscript dependency on ${SYSTEM_OBJ} |
251 | .if defined(KERNLDSCRIPT) | | 244 | .if defined(KERNLDSCRIPT) |
252 | .if target(${KERNLDSCRIPT}) | | 245 | .if target(${KERNLDSCRIPT}) |
253 | ${KERNLDSCRIPT}: ${SYSTEM_OBJ} | | 246 | ${KERNLDSCRIPT}: ${SYSTEM_OBJ} |
254 | .endif | | 247 | .endif |
255 | .endif | | 248 | .endif |
256 | | | 249 | |
257 | .if defined(KERNLDSCRIPT) | | 250 | .if defined(KERNLDSCRIPT) |
258 | .for k in ${KERNELS} | | 251 | .for k in ${KERNELS} |
259 | EXTRA_CLEAN+= ${k}.ldscript | | 252 | EXTRA_CLEAN+= ${k}.ldscript |
| | | 253 | ${k}: ${k}.ldscript |
260 | ${k}.ldscript: ${KERNLDSCRIPT} | | 254 | ${k}.ldscript: ${KERNLDSCRIPT} |
261 | ${CPP} ${KERNLDSCRIPT} | grep -v '^#' >$@ | | 255 | ${_MKTARGET_CREATE} |
| | | 256 | ${CPP} ${KERNLDSCRIPT} | grep -v '^#' | grep -v '^$$' >$@ |
262 | .endfor | | 257 | .endfor |
263 | .if exists(${KERNLDSCRIPT}) | | | |
264 | LINKSCRIPT= -T ${KERNLDSCRIPT} | | | |
265 | .else | | | |
266 | LINKSCRIPT= -T ${.TARGET}.ldscript | | 258 | LINKSCRIPT= -T ${.TARGET}.ldscript |
267 | .endif | | 259 | .endif |
268 | .endif | | | |
269 | | | 260 | |
270 | TEXTADDR?= ${LOADADDRESS} # backwards compatibility | | 261 | TEXTADDR?= ${LOADADDRESS} # backwards compatibility |
271 | LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/} | | 262 | LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/} |
272 | LINKDATA?= ${DATAADDR:C/.+/-Tdata &/} | | 263 | LINKDATA?= ${DATAADDR:C/.+/-Tdata &/} |
273 | ENTRYPOINT?= start | | 264 | ENTRYPOINT?= start |
274 | LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/} | | 265 | LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/} |
275 | LINKFLAGS?= ${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \ | | 266 | LINKFLAGS?= ${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \ |
276 | ${EXTRA_LINKFLAGS} | | 267 | ${EXTRA_LINKFLAGS} |
277 | | | 268 | |
278 | LINKFLAGS_DEBUG?= -X | | 269 | LINKFLAGS_DEBUG?= -X |
279 | | | 270 | |
280 | SYSTEM_LD_TAIL?=@${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c; \ | | 271 | SYSTEM_LD_TAIL?=@${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c; \ |
281 | ${SIZE} $@; chmod 755 $@; \ | | 272 | ${SIZE} $@; chmod 755 $@; \ |