Tue Aug 25 02:57:32 2015 UTC ()
Redo Rev. 1.188:
o Explicitly add dependency of `<kernel>' on `<kernel>.ldscript', instead of
  relying on ${SYSTEM_DEP}, which is evaluated much earlier than
  `sys/conf/Makefile.kern.inc' is included, to avoid evaluation ordering
  problems.
o Print a message when creating a `<kernel>.ldscript'.
o Trim empty lines in `<kernel>.ldscript'.


(uebayasi)
diff -r1.189 -r1.190 src/sys/conf/Makefile.kern.inc

cvs diff -r1.189 -r1.190 src/sys/conf/Makefile.kern.inc (expand / switch to unified diff)

--- src/sys/conf/Makefile.kern.inc 2015/08/24 18:02:55 1.189
+++ src/sys/conf/Makefile.kern.inc 2015/08/25 02:57:32 1.190
@@ -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)
227SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS} ${SYSLIBCOMPAT} ${LIBKERN} 227SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS} ${SYSLIBCOMPAT} ${LIBKERN}
228.else 228.else
229SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS:O} ${SYSLIBCOMPAT} ${LIBKERN} 229SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS:O} ${SYSLIBCOMPAT} ${LIBKERN}
230.endif 230.endif
231SYSTEM_DEP+= Makefile ${SYSTEM_OBJ} .gdbinit 231SYSTEM_DEP+= Makefile ${SYSTEM_OBJ} .gdbinit
232.if defined(KERNLDSCRIPT) 
233.if exists(${KERNLDSCRIPT}) 
234SYSTEM_DEP+= -T ${KERNLDSCRIPT} 
235.else 
236SYSTEM_DEP+= ${.TARGET}.ldscript 
237.endif 
238.endif 
239.if defined(CTFMERGE) 232.if defined(CTFMERGE)
240SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o 233SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
241.else 234.else
242SYSTEM_CTFMERGE= ${_MKSHECHO} 235SYSTEM_CTFMERGE= ${_MKSHECHO}
243.endif 236.endif
244SYSTEM_LD_HEAD?=@rm -f $@ 237SYSTEM_LD_HEAD?=@rm -f $@
245SYSTEM_LD?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \ 238SYSTEM_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}
259EXTRA_CLEAN+= ${k}.ldscript 252EXTRA_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}) 
264LINKSCRIPT= -T ${KERNLDSCRIPT} 
265.else 
266LINKSCRIPT= -T ${.TARGET}.ldscript 258LINKSCRIPT= -T ${.TARGET}.ldscript
267.endif 259.endif
268.endif 
269 260
270TEXTADDR?= ${LOADADDRESS} # backwards compatibility 261TEXTADDR?= ${LOADADDRESS} # backwards compatibility
271LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/} 262LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/}
272LINKDATA?= ${DATAADDR:C/.+/-Tdata &/} 263LINKDATA?= ${DATAADDR:C/.+/-Tdata &/}
273ENTRYPOINT?= start 264ENTRYPOINT?= start
274LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/} 265LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/}
275LINKFLAGS?= ${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \ 266LINKFLAGS?= ${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \
276 ${EXTRA_LINKFLAGS} 267 ${EXTRA_LINKFLAGS}
277 268
278LINKFLAGS_DEBUG?= -X 269LINKFLAGS_DEBUG?= -X
279 270
280SYSTEM_LD_TAIL?=@${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c; \ 271SYSTEM_LD_TAIL?=@${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c; \
281 ${SIZE} $@; chmod 755 $@; \ 272 ${SIZE} $@; chmod 755 $@; \