Makefile.kern.inc revision 1.193 1 # $NetBSD: Makefile.kern.inc,v 1.193 2015/08/26 03:00:52 uebayasi Exp $
2 #
3 # This file contains common `MI' targets and definitions and it is included
4 # at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
5 #
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
8 # assigned `VAR ?= VALUE', so that everything can be overriden.
9 #
10 # DEBUG is set to -g if debugging.
11 # PROF is set to -pg if profiling.
12 #
13 # To specify debugging, add the config line: makeoptions DEBUG="-g"
14 # A better way is to specify -g only for a few files.
15 #
16 # makeoptions DEBUGLIST="uvm* trap if_*"
17 #
18 # all ports are expected to include bsd.own.mk for toolchain settings
19
20 # Default DEBUG to -g if kernel debug info is requested by MKKDEBUG=yes
21 .if defined(MKKDEBUG) && ${MKKDEBUG} == "yes"
22 DEBUG?=-g
23 .endif
24
25 ##
26 ## (0) toolchain settings for things that aren't part of the standard
27 ## toolchain
28 ##
29 HOST_SH?= sh
30 DBSYM?= dbsym
31 MKDEP?= mkdep
32 STRIP?= strip
33 OBJCOPY?= objcopy
34 OBJDUMP?= objdump
35 CSCOPE?= cscope
36 MKID?= mkid
37 UUDECODE?= ${TOOL_UUDECODE:Uuudecode}
38 HEXDUMP?= ${TOOL_HEXDUMP:Uhexdump}
39 GENASSYM?= ${TOOL_GENASSYM:Ugenassym}
40 .MAKEOVERRIDES+=USETOOLS # make sure proper value is propagated
41
42 _MKMSG?= @\#
43 _MKSHMSG?= echo
44 _MKSHECHO?= echo
45 _MKSHNOECHO= :
46 _MKMSG_CREATE?= :
47 _MKTARGET_COMPILE?= :
48 _MKTARGET_CREATE?= :
49
50 ##
51 ## (1) port independent source tree identification
52 ##
53 # source tree is located via $S relative to the compilation directory
54 .ifndef S
55 S!= cd ../../../..; pwd
56 .endif
57
58 ##
59 ## (2) compile settings
60 ##
61 ## CPPFLAGS, CFLAGS, and AFLAGS must be set in the port's Makefile
62 ##
63 INCLUDES?= -I. ${EXTRA_INCLUDES} -I${S}/../common/include -I$S/arch \
64 -I$S -nostdinc
65 CPPFLAGS+= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT
66 CPPFLAGS+= -std=gnu99
67 DEFCOPTS?= -O2
68 COPTS?= ${DEFCOPTS}
69 DBG= # might contain unwanted -Ofoo
70 DEFWARNINGS?= yes
71 .if (${DEFWARNINGS} == "yes")
72 CWARNFLAGS+= -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith
73 CWARNFLAGS+= -Wmissing-prototypes -Wstrict-prototypes
74 CWARNFLAGS+= -Wold-style-definition
75 CWARNFLAGS+= -Wswitch -Wshadow
76 CWARNFLAGS+= -Wcast-qual -Wwrite-strings
77 CWARNFLAGS+= -Wno-unreachable-code
78 #CWARNFLAGS+= -Wc++-compat -Wno-error=c++-compat
79 CWARNFLAGS+= -Wno-pointer-sign -Wno-attributes
80 . if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" || \
81 ${MACHINE_ARCH} == "sparc64" || ${MACHINE} == "prep"
82 CWARNFLAGS+= -Wextra -Wno-unused-parameter
83 . endif
84 . if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64"
85 CWARNFLAGS+= -Wold-style-definition
86 . endif
87 # Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3,
88 # but our sources aren't up for it yet.
89 CWARNFLAGS+= -Wno-sign-compare
90 .endif
91
92 CWARNFLAGS.clang+= -Wno-unknown-pragmas -Wno-conversion \
93 -Wno-self-assign
94
95 CWARNFLAGS.ah_regdomain.c= ${${ACTIVE_CC} == "clang":? \
96 -Wno-shift-count-negative -Wno-shift-count-overflow:}
97
98 CWARNFLAGS.ioconf.c= ${${ACTIVE_CC} == "clang":? -Wno-unused-const-variable :}
99
100 CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss
101 CFLAGS+= ${DEBUG} ${COPTS}
102 AFLAGS+= -D_LOCORE -Wa,--fatal-warnings
103
104 # XXX
105 .if defined(HAVE_GCC) || defined(HAVE_LLVM)
106 CFLAGS+= -fno-strict-aliasing
107 CFLAGS+= -fno-common
108 .endif
109
110 .if ${USE_SSP:Uno} == "yes"
111 COPTS.kern_ssp.c+= -fno-stack-protector -D__SSP__
112 .endif
113
114 # for multi-cpu machines, cpu_hatch() straddles the init of
115 # __stack_chk_guard, so ensure stack protection is disabled
116 .if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64"
117 COPTS.cpu.c+= -fno-stack-protector
118 .endif
119
120 # Use the per-source COPTS variables to add -g to just those
121 # files that match the shell patterns given in ${DEBUGLIST}
122 #
123 .for i in ${DEBUGLIST}
124 . for j in ${CFILES:T:M$i.c}
125 COPTS.${j}+=-g
126 . endfor
127 .endfor
128
129 # Always compile debugsyms.c with debug information.
130 # This allows gdb to use type informations.
131 #
132 COPTS.debugsyms.c+= -g
133
134 # Add CTF sections for DTrace
135 .if defined(CTFCONVERT)
136 COMPILE_CTFCONVERT= ${_MKSHECHO}\
137 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \
138 ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
139 .else
140 COMPILE_CTFCONVERT= ${_MKSHNOECHO}
141 .endif
142
143 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
144 # NOPROF and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
145 NORMAL_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \
146 ${_MKSHECHO}\
147 ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< && \
148 ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< && \
149 ${COMPILE_CTFCONVERT}
150 NOPROF_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \
151 ${_MKSHECHO}\
152 ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< && \
153 ${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< && \
154 ${COMPILE_CTFCONVERT}
155 NORMAL_S?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \
156 ${_MKSHECHO}\
157 ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $< && \
158 ${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $<
159
160 # link rules:
161 LINK_O?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}" && \
162 ${_MKSHECHO}\
163 ${LD} -r ${LINKFORMAT} -Map=${.TARGET}.map -o ${.TARGET} ${.ALLSRC} && \
164 ${LD} -r ${LINKFORMAT} -Map=${.TARGET}.map -o ${.TARGET} ${.ALLSRC}
165
166 ##
167 ## (3) libkern and compat
168 ##
169 ## Set KERN_AS in the port Makefile to "obj" or "library". The
170 ## default is "library", as documented in $S/lib/libkern/Makefile.inc.
171 ##
172
173 ### find out what to use for libkern
174 .include "$S/lib/libkern/Makefile.inc"
175 .ifndef PROF
176 LIBKERN?= ${KERNLIB}
177 .else
178 LIBKERN?= ${KERNLIB_PROF}
179 .endif
180
181 LIBKERNLN?= ${KERNLIBLN}
182
183 ### find out what to use for libcompat
184 .include "$S/compat/common/Makefile.inc"
185 .ifndef PROF
186 SYSLIBCOMPAT?= ${COMPATLIB}
187 .else
188 SYSLIBCOMPAT?= ${COMPATLIB_PROF}
189 .endif
190
191 SYSLIBCOMPATLN?= ${COMPATLIBLN}
192
193 ##
194 ## (4) local objects, compile rules, and dependencies
195 ##
196 ## Each port should have a corresponding section with settings for
197 ## MD_CFILES, MD_SFILES, and MD_OBJS, along with build rules for same.
198 ##
199 MI_CFILES=devsw.c ioconf.c param.c
200 # the need for a MI_SFILES variable is dubitable at best
201 MI_OBJS=${MI_CFILES:S/.c/.o/}
202
203 param.c: $S/conf/param.c
204 ${_MKTARGET_CREATE}
205 rm -f param.c
206 cp $S/conf/param.c .
207
208 param.o: Makefile
209
210 .for _cfile in ${MI_CFILES}
211 ${_cfile:T:R}.o: ${_cfile}
212 ${NORMAL_C}
213 .endfor
214
215 ##
216 ## (5) link settings
217 ##
218 ## TEXTADDR (or LOADADDRESS), LINKFORMAT, LINKSCRIPT, and any EXTRA_LINKFLAGS
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
221 ## depending on the value of DEBUG.
222 ##
223 # load lines for config "xxx" will be emitted as:
224 # xxx: ${SYSTEM_DEP} swapxxxx.o vers.o build_kernel
225
226 .if !empty(OBJS:Mnetbsd.ko)
227 SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS} ${SYSLIBCOMPAT} ${LIBKERN}
228 .else
229 SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS:O} ${SYSLIBCOMPAT} ${LIBKERN}
230 .endif
231 SYSTEM_DEP+= Makefile ${SYSTEM_OBJ} .gdbinit
232 .if defined(CTFMERGE)
233 SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
234 .else
235 SYSTEM_CTFMERGE= ${_MKSHECHO}
236 .endif
237 SYSTEM_LD_HEAD?=@rm -f $@
238 SYSTEM_LD?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \
239 ${_MKSHECHO}\
240 ${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
242
243 # Give MD generated ldscript dependency on ${SYSTEM_OBJ}
244 .if defined(KERNLDSCRIPT)
245 .if target(${KERNLDSCRIPT})
246 ${KERNLDSCRIPT}: ${SYSTEM_OBJ}
247 .endif
248 .endif
249
250 .if defined(KERNLDSCRIPT)
251 .for k in ${KERNELS}
252 EXTRA_CLEAN+= ${k}.ldscript
253 ${k}: ${k}.ldscript
254 ${k}.ldscript: ${KERNLDSCRIPT} assym.h
255 ${_MKTARGET_CREATE}
256 ${CPP} -I. ${KERNLDSCRIPT} | grep -v '^#' | grep -v '^$$' >$@
257 .endfor
258 LINKSCRIPT= -T ${.TARGET}.ldscript
259 .endif
260
261 TEXTADDR?= ${LOADADDRESS} # backwards compatibility
262 LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/}
263 LINKDATA?= ${DATAADDR:C/.+/-Tdata &/}
264 ENTRYPOINT?= start
265 LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/}
266 LINKFLAGS?= ${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \
267 ${EXTRA_LINKFLAGS}
268
269 LINKFLAGS_DEBUG?= -X
270
271 SYSTEM_LD_TAIL?=@${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c; \
272 ${SIZE} $@; chmod 755 $@; \
273 ${SYSTEM_CTFMERGE}
274 SYSTEM_LD_TAIL_DEBUG?=; \
275 echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
276 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
277 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
278 LINKFLAGS_NORMAL?= -S
279 STRIPFLAGS?= -g
280
281 DEBUG?=
282 .if !empty(DEBUG:M-g*)
283 SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG}
284 LINKFLAGS+= ${LINKFLAGS_DEBUG}
285 EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gdb@}
286 CTFFLAGS+= -g
287 TARGETSFX= .gdb
288 .elifndef PROF
289 LINKFLAGS+= ${LINKFLAGS_NORMAL}
290 .endif
291
292 SYSTEM_LD_HEAD+=${SYSTEM_LD_HEAD_EXTRA}
293 SYSTEM_LD_TAIL_STAGE1= ${SYSTEM_LD_TAIL}
294 SYSTEM_LD_TAIL_STAGE2= ${SYSTEM_LD_TAIL}
295 .if defined(COPY_SYMTAB)
296 SYSTEM_LD_TAIL_STAGE2+= ; echo ${DBSYM} $@; ${DBSYM} $@
297 .if !empty(DEBUG:M-g)
298 SYSTEM_LD_TAIL_STAGE2+= ; echo ${DBSYM} $@.gdb; ${DBSYM} $@.gdb
299 .endif
300 .endif
301 SYSTEM_LD_TAIL_STAGE2+= ${SYSTEM_LD_TAIL_EXTRA}
302
303 ##
304 ## (6) port independent targets and dependencies: assym.h, vers.o
305 ##
306 assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS} $S/conf/genassym.cf
307 ${_MKTARGET_CREATE}
308 cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} $S/conf/genassym.cf | \
309 ${GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
310 ${GENASSYM_CPPFLAGS} > assym.h.tmp && \
311 mv -f assym.h.tmp assym.h
312 ${MD_SFILES:C/\.[Ss]/.o/} ${SFILES:C/\.[Ss]/.o/}: assym.h
313
314 MKREPRO?=no
315
316 .if ${MKREPRO} == "yes"
317 _NVFLAGS=${NVFLAGS} -r
318 .else
319 _NVFLAGS=${NVFLAGS}
320 .endif
321
322 .if !target(vers.o)
323 newvers: vers.o
324 vers.o: ${SYSTEM_OBJ} Makefile $S/conf/newvers.sh \
325 $S/conf/osrelease.sh ${_NETBSD_VERSION_DEPENDS}
326 ${_MKMSG_CREATE} vers.c
327 ${HOST_SH} $S/conf/newvers.sh ${_NVFLAGS}
328 ${_MKTARGET_COMPILE}
329 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
330 ${COMPILE_CTFCONVERT}
331 .endif
332
333 # Option for embedding a splashscreen image.
334 .if defined(SPLASHSCREEN_IMAGE)
335 .include "${S}/dev/splash/splash.mk"
336 init_main.o: splash_image.o
337 .endif
338
339 .if defined(MEMORY_DISK_IMAGE)
340 md_root_image.h: ${MEMORY_DISK_IMAGE}
341 ${_MKTARGET_CREATE}
342 ${TOOL_HEXDUMP} -v -e '"\t" 8/1 "0x%02x, " "\n"' ${.ALLSRC} > ${.TARGET}
343
344 # XXX This is only needed when building md_root.o
345 CPPFLAGS+= -DMEMORY_DISK_IMAGE
346 md_root.o: md_root_image.h
347 .endif
348
349 # depend on MEMORY_DISK_IMAGE configuration
350 md_root.o: Makefile
351
352 # depend on root or device configuration
353 autoconf.o conf.o: Makefile
354
355 # depend on network or filesystem configuration
356 uipc_proto.o vfs_conf.o: Makefile
357
358 # depend on maxusers and CPU configuration
359 assym.h machdep.o: Makefile
360
361 ##
362 ## (7) misc targets: install, clean(dir), depend(all), lint, links, tags,
363 ## cscope, mkid
364 ##
365 ## Any ports that have other stuff to be cleaned up should fill in
366 ## EXTRA_CLEAN. Some ports may want different settings for
367 ## KERNLINTFLAGS, MKDEP_CFLAGS, or MKDEP_AFLAGS.
368 ##
369 .if !target(__CLEANKERNEL)
370 __CLEANKERNEL: .USE
371 ${_MKMSG} "${.TARGET}ing the kernel objects"
372 rm -f ${KERNELS} *.map eddep tags *.[io] *.ko *.ln [a-z]*.s vers.c \
373 [Ee]rrs linterrs makelinks assym.h.tmp assym.h \
374 ${EXTRA_KERNELS} ${EXTRA_CLEAN}
375 .endif
376
377 .if !target(kernelnames)
378 kernelnames:
379 @echo "${KERNELS} ${EXTRA_KERNELS}"
380 .endif
381
382 .if !target(__CLEANDEPEND)
383 __CLEANDEPEND: .USE
384 echo .depend ${DEPS} | xargs rm -f --
385 .endif
386
387 # do not !target these, the kern and compat Makefiles augment them
388 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
389 clean: __CLEANKERNEL
390 depend: .depend
391 dependall: depend .WAIT all
392
393 .if !target(.depend)
394 MKDEP_AFLAGS?= ${AFLAGS}
395 MKDEP_CFLAGS?= ${CFLAGS}
396 SSRCS=${MD_SFILES} ${SFILES}
397 CSRCS=${MD_CFILES} ${MI_CFILES} ${CFILES}
398 SRCS=${SSRCS} ${CSRCS}
399 DEPS= ${SRCS:T:u:R:S/$/.d/g}
400
401 .for _s in ${SSRCS}
402 .if !target(${_s:T:R}.d)
403 ${_s:T:R}.d: ${_s} assym.h
404 ${_MKTARGET_CREATE}
405 ${MKDEP} -f ${.TARGET} -- ${MKDEP_AFLAGS} \
406 ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
407 .endif
408 .endfor
409 .for _s in ${CSRCS}
410 .if !target(${_s:T:R}.d)
411 ${_s:T:R}.d: ${_s}
412 ${_MKTARGET_CREATE}
413 ${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \
414 ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
415 .endif
416 .endfor
417
418 assym.d: assym.h
419 ${_MKTARGET_CREATE}
420 cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} | \
421 ${GENASSYM} -- ${MKDEP} -f assym.dep -- \
422 ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${GENASSYM_CPPFLAGS}
423 ${TOOL_SED} -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >${.TARGET}
424 rm -f assym.dep
425
426 DEPS+= assym.d
427
428 .depend: ${DEPS}
429 ${_MKTARGET_CREATE}
430 echo "${.ALLSRC}" | ${MKDEP} -D
431 .endif
432
433 .if !target(lint)
434 ALLSFILES?= ${MD_SFILES} ${SFILES}
435 LINTSTUBS?= ${ALLSFILES:T:R:C/^.*$/LintStub_&.c/g}
436 KERNLINTFLAGS?= -bcehnxzFS
437 NORMAL_LN?= ${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i $<
438
439 _lsrc=${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES}
440 LOBJS?= ${_lsrc:T:S/.c$/.ln/g} ${LIBKERNLN} ${SYSLIBCOMPATLN}
441
442 .for _sfile in ${ALLSFILES}
443 LintStub_${_sfile:T:R}.c: ${_sfile} assym.h
444 ${_MKTARGET_COMPILE}
445 ${CC} -E -C ${AFLAGS} ${CPPFLAGS} ${_sfile} | \
446 ${TOOL_AWK} -f $S/kern/genlintstub.awk >${.TARGET}
447 .endfor
448
449 .for _cfile in ${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES}
450 ${_cfile:T:R}.ln: ${_cfile}
451 ${_MKTARGET_COMPILE}
452 ${NORMAL_LN}
453 .endfor
454
455 lint: ${LOBJS}
456 ${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} ${LOBJS}
457 .endif
458
459 # Attempt to do a syntax-only compile of the entire kernel as one entity.
460 # Alas, bugs in the GCC C frontend prevent this from completely effective
461 # but information can be gleaned from the output.
462 syntax-only: ${CFILES} ${MD_CFILES}
463 ${CC} -fsyntax-only -combine ${CFLAGS} ${CPPFLAGS} \
464 ${CFILES} ${MD_CFILES}
465
466 # List of kernel images that will be installed into the root file system.
467 # Some platforms may need to install more than one (e.g. a netbsd.aout file
468 # to be loaded directly by the firmware), so this can be overriden by them.
469 KERNIMAGES?= netbsd
470
471 .if !target(install)
472 # The install target can be redefined by putting a
473 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
474 MACHINE_NAME!= uname -n
475 install: install-kernel-${MACHINE_NAME}
476 .if !target(install-kernel-${MACHINE_NAME})
477 install-kernel-${MACHINE_NAME}:
478 .for _K in ${KERNIMAGES}
479 rm -f ${DESTDIR}/o${_K}
480 ln ${DESTDIR}/${_K} ${DESTDIR}/o${_K}
481 cp ${_K} ${DESTDIR}/n${_K}
482 mv ${DESTDIR}/n${_K} ${DESTDIR}/${_K}
483 .endfor
484 .endif
485 .endif
486
487 .if !target(tags)
488 tags:
489 @echo "see $S/kern/Makefile for tags"
490 .endif
491
492 EXTRA_CLEAN+= cscope.out cscope.tmp
493 .if !target(cscope.out)
494 cscope.out: Makefile depend
495 ${_MKTARGET_CREATE}
496 @${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/kern/.depend \
497 | tr -s ' ' '\n' \
498 | ${TOOL_SED} ';s|^../../||;' \
499 > cscope.tmp
500 @${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/compat/.depend \
501 | tr -s ' ' '\n' \
502 | ${TOOL_SED} 's|^../../||;' \
503 >> cscope.tmp
504 @echo ${SRCS} | cat - cscope.tmp | tr -s ' ' '\n' | sort -u | \
505 ${CSCOPE} -k -i - -b `echo ${INCLUDES} | ${TOOL_SED} s/-nostdinc//`
506 # cscope doesn't write cscope.out if it's uptodate, so ensure
507 # make doesn't keep calling cscope when not needed.
508 @rm -f cscope.tmp; touch cscope.out
509 .endif
510
511 .if !target(cscope)
512 cscope: cscope.out
513 @${CSCOPE} -d
514 .endif
515
516 EXTRA_CLEAN+= ID
517 .if !target(mkid)
518 .PHONY: mkid
519 mkid: ID
520
521 ID: Makefile depend
522 ${_MKTARGET_CREATE}
523 @${MKID} \
524 `${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' \
525 lib/kern/.depend lib/compat/.depend \
526 | tr ' ' '\n' \
527 | ${TOOL_SED} "s|^../../||" \
528 | sort -u` \
529 `${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' \
530 .depend \
531 | tr ' ' '\n' \
532 | sort -u`
533
534 .endif
535
536 .include "${S}/gdbscripts/Makefile.inc"
537
538 EXTRA_CLEAN+= .gdbinit
539 .gdbinit: Makefile ${S}/gdbscripts/Makefile.inc
540 ${_MKTARGET_CREATE}
541 rm -f .gdbinit
542 .for __gdbinit in ${SYS_GDBINIT}
543 echo "source ${S}/gdbscripts/${__gdbinit}" >> .gdbinit
544 .endfor
545 .if defined(GDBINIT) && !empty(GDBINIT)
546 .for __gdbinit in ${GDBINIT}
547 echo "source ${__gdbinit}" >> .gdbinit
548 .endfor
549 .endif
550
551 # The following files use alloca(3) or variable array allocations.
552 # Their full name is noted as documentation.
553 VARSTACK=kern/uipc_socket.c miscfs/genfs/genfs_vnops.c \
554 nfs/nfs_bio.c uvm/uvm_bio.c \
555 uvm/uvm_pager.c dev/ic/aic7xxx.c dev/ic/aic79xx.c arch/xen/i386/gdt.c \
556 dev/ofw/ofw_subr.c
557
558 .for __varstack in ${VARSTACK}
559 COPTS.${__varstack:T} += -Wno-stack-protector
560 .endfor
561
562 AFLAGS+= ${AOPTS.${.IMPSRC:T}}
563 CFLAGS+= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}}
564 CPPFLAGS+= ${CPPFLAGS.${.IMPSRC:T}}
565 CWARNFLAGS+= ${CWARNFLAGS.${.IMPSRC:T}}
566
567 locore.o machdep.o kern_ksyms.o: Makefile
568
569 .if defined(COPY_SYMTAB)
570 CPPFLAGS.locore.S+= -DCOPY_SYMTAB
571 CPPFLAGS.machdep.c+= -DCOPY_SYMTAB
572 CPPFLAGS.kern_ksyms.c+= -DCOPY_SYMTAB
573 CPPFLAGS.kern_ksyms_buf.c+= -DCOPY_SYMTAB
574 .endif
575
576 .if !defined(COPY_SYMTAB)
577 build_kernel: .USE
578 ${SYSTEM_LD_HEAD}
579 ${SYSTEM_LD} swap${.TARGET}.o
580 ${SYSTEM_LD_TAIL_STAGE2}
581 .else
582 build_kernel: .USE
583 ${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
584 -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf.o
585 ${SYSTEM_LD_HEAD}
586 ${SYSTEM_LD} swap${.TARGET}.o kern_ksyms_buf.o
587 ${SYSTEM_LD_TAIL_STAGE1}
588 ${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
589 -DSYMTAB_SPACE=$$(${DBSYM} -P ${.TARGET}${TARGETSFX}) \
590 -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf_real.o
591 ${SYSTEM_LD_HEAD}
592 ${SYSTEM_LD} swap${.TARGET}.o kern_ksyms_buf_real.o
593 ${SYSTEM_LD_TAIL_STAGE2}
594 .endif
595
596 .include <bsd.files.mk>
597 .include <bsd.clang-analyze.mk>
598
599 ##
600 ## the end
601 ##
602