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