Makefile.kern.inc revision 1.149.6.2 1 # $NetBSD: Makefile.kern.inc,v 1.149.6.2 2012/04/05 21:33:22 mrg 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 . if defined(HAVE_GCC) || defined(HAVE_PCC)
74 CWARNFLAGS+= -Wno-pointer-sign -Wno-attributes
75 . if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" || \
76 ${MACHINE_ARCH} == "sparc64" || ${MACHINE} == "prep"
77 CWARNFLAGS+= -Wextra -Wno-unused-parameter
78 . endif
79 . if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64"
80 CWARNFLAGS+= -Wold-style-definition
81 . endif
82 . endif
83 # Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3,
84 # but our sources aren't up for it yet.
85 CWARNFLAGS+= -Wno-sign-compare
86 .endif
87
88 CWARNFLAGS.clang+= -Wno-unknown-pragmas -Wno-conversion \
89 -Wno-self-assign
90
91 CWARNFLAGS.ah_regdomain.c= ${${ACTIVE_CC} == "clang":? \
92 -Wno-shift-count-negative -Wno-shift-count-overflow:}
93
94 CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss
95 CFLAGS+= ${DEBUG} ${COPTS}
96 AFLAGS+= -D_LOCORE -Wa,--fatal-warnings
97
98 # XXX
99 .if defined(HAVE_GCC)
100 CFLAGS+= -fno-strict-aliasing
101 .endif
102
103 .if ${USE_SSP:Uno} == "yes"
104 COPTS.kern_ssp.c+= -fno-stack-protector -D__SSP__
105 .endif
106
107 # for multi-cpu machines, cpu_hatch() straddles the init of
108 # __stack_chk_guard, so ensure stack protection is disabled
109 .if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64"
110 COPTS.cpu.c+= -fno-stack-protector
111 .endif
112
113 # If we want the bpendtsleep: label in kern_synch.c, we need to use
114 # -fno-reorder-blocks. Don't make this a config(1) defflag without
115 # making sure this fragment remains valid.
116 .if defined(HAVE_GCC) && !empty(${CFLAGS:M-DKERN_SYNCH_BPENDTSLEEP_LABEL})
117 COPTS.kern_synch.c+= -fno-reorder-blocks
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 ##
161 ## (3) libkern and compat
162 ##
163 ## Set KERN_AS in the port Makefile to "obj" or "library". The
164 ## default is "library", as documented in $S/lib/libkern/Makefile.inc.
165 ##
166
167 ### find out what to use for libkern
168 .include "$S/lib/libkern/Makefile.inc"
169 .ifndef PROF
170 LIBKERN?= ${KERNLIB}
171 .else
172 LIBKERN?= ${KERNLIB_PROF}
173 .endif
174
175 LIBKERNLN?= ${KERNLIBLN}
176
177 ### find out what to use for libcompat
178 .include "$S/compat/common/Makefile.inc"
179 .ifndef PROF
180 SYSLIBCOMPAT?= ${COMPATLIB}
181 .else
182 SYSLIBCOMPAT?= ${COMPATLIB_PROF}
183 .endif
184
185 SYSLIBCOMPATLN?= ${COMPATLIBLN}
186
187 ##
188 ## (4) local objects, compile rules, and dependencies
189 ##
190 ## Each port should have a corresponding section with settings for
191 ## MD_CFILES, MD_SFILES, and MD_OBJS, along with build rules for same.
192 ##
193 MI_CFILES=devsw.c ioconf.c param.c
194 # the need for a MI_SFILES variable is dubitable at best
195 MI_OBJS=${MI_CFILES:S/.c/.o/}
196
197 param.c: $S/conf/param.c
198 ${_MKTARGET_CREATE}
199 rm -f param.c
200 cp $S/conf/param.c .
201
202 param.o: Makefile
203
204 .for _cfile in ${MI_CFILES}
205 ${_cfile:T:R}.o: ${_cfile}
206 ${NORMAL_C}
207 .endfor
208
209 ##
210 ## (5) link settings
211 ##
212 ## TEXTADDR (or LOADADDRESS), LINKFORMAT, and any EXTRA_LINKFLAGS must
213 ## be set in the port's Makefile. The port specific definitions for
214 ## LINKFLAGS_NORMAL and LINKFLAGS_DEBUG will added to the LINKFLAGS
215 ## depending on the value of DEBUG.
216 ##
217 # load lines for config "xxx" will be emitted as:
218 # xxx: ${SYSTEM_DEP} swapxxx.o
219 # ${SYSTEM_LD_HEAD}
220 # ${SYSTEM_LD} swapxxx.o
221 # ${SYSTEM_LD_TAIL}
222 SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS:O} ${SYSLIBCOMPAT} ${LIBKERN}
223 SYSTEM_DEP?= Makefile ${SYSTEM_OBJ:O} .gdbinit
224 .if defined(KERNLDSCRIPT)
225 SYSTEM_DEP+= ${KERNLDSCRIPT}
226 .endif
227 .if defined(CTFMERGE)
228 SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
229 .else
230 SYSTEM_CTFMERGE= ${_MKSHECHO}
231 .endif
232 SYSTEM_LD_HEAD?=@rm -f $@
233 SYSTEM_LD?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \
234 ${_MKSHECHO}\
235 ${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o; \
236 ${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
237
238 AUTO_SYMTAB_SPACE?= yes
239
240 .if empty(AUTO_SYMTAB_SPACE:M[Yy][Ee][Ss]) || defined(_SYMTAB_SPACE_ADJUSTED)
241 SYSTEM_LD_TAIL_DBSYM?= true
242 .else
243 SYSTEM_LD_TAIL_DBSYM?= \
244 if grep '^\#define.*SYMTAB_SPACE' opt_ksyms.h > /dev/null; then \
245 _modify_opt_ksyms_h () { \
246 ${TOOL_SED} \
247 -e 's/^\(\#define.*SYMTAB_SPACE[ ]*\)[0-9]*/\1'$$1/ \
248 -e 's/\(.equiv[ ]*_KERNEL_OPT_SYMTAB_SPACE,0x\)[0-9a-f]*/\1'$$(printf %x $$1)/ \
249 opt_ksyms.h > opt_ksyms.h.ADJ && \
250 mv opt_ksyms.h.ADJ opt_ksyms.h && \
251 ${MAKE} ${MFLAGS} _SYMTAB_SPACE_ADJUSTED=1 $@; \
252 }; \
253 _adj_symtab_space () { \
254 set -- $$(${DBSYM} -p $@); \
255 echo Symtab size: $$1, space: $$2; \
256 if [ "$$1" -gt "$$2" ]; then \
257 echo Adjusting symtab space; \
258 rm -f $@; \
259 _modify_opt_ksyms_h $$1; \
260 fi; \
261 }; \
262 _adj_symtab_space; \
263 fi
264 .endif
265
266 .if defined(_SYMTAB_SPACE_ADJUSTED)
267 SYSTEM_LD_TAIL?=true
268 .else
269 SYSTEM_LD_TAIL?=@${SYSTEM_LD_TAIL_DBSYM} ; \
270 ${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/\\.*//' vers.c; \
271 ${SIZE} $@; chmod 755 $@; \
272 ${SYSTEM_CTFMERGE}
273 .endif
274
275 TEXTADDR?= ${LOADADDRESS} # backwards compatibility
276 LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/}
277 LINKDATA?= ${DATAADDR:C/.+/-Tdata &/}
278 ENTRYPOINT?= start
279 LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/}
280 LINKFLAGS?= ${LINKFORMAT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \
281 ${EXTRA_LINKFLAGS}
282
283 LINKFLAGS_DEBUG?= -X
284 SYSTEM_LD_TAIL_DEBUG?=; \
285 echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
286 echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
287 ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
288 LINKFLAGS_NORMAL?= -S
289 STRIPFLAGS?= -g
290
291 DEBUG?=
292 .if !empty(DEBUG:M-g*)
293 SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG}
294 LINKFLAGS+= ${LINKFLAGS_DEBUG}
295 EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gdb@}
296 CTFFLAGS+= -g
297 .if !defined(_SYMTAB_SPACE_ADJUSTED)
298 SYSTEM_LD_TAIL+=; \
299 if grep '^\#define.*SYMTAB_SPACE' opt_ksyms.h > /dev/null; then \
300 echo "${DBSYM} $@.gdb"; \
301 ${DBSYM} $@.gdb || (rm -f $@ ; exit 1) || exit 1; \
302 fi
303 .endif
304 .elifndef PROF
305 LINKFLAGS+= ${LINKFLAGS_NORMAL}
306 .endif
307
308 .if !defined(_SYMTAB_SPACE_ADJUSTED)
309 SYSTEM_LD_TAIL+=; \
310 if grep '^\#define.*SYMTAB_SPACE' opt_ksyms.h > /dev/null; then \
311 echo "${DBSYM} $@"; \
312 ${DBSYM} $@ || (rm -f $@ ; exit 1) || exit 1; \
313 fi
314 .endif
315
316 SYSTEM_LD_HEAD+=${SYSTEM_LD_HEAD_EXTRA}
317 SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_EXTRA}
318
319 ##
320 ## (6) port independent targets and dependencies: assym.h, vers.o
321 ##
322 .if !target(assym.h)
323 assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS}
324 ${_MKTARGET_CREATE}
325 cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} | \
326 ${GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
327 > assym.h.tmp && \
328 mv -f assym.h.tmp assym.h
329 ${MD_SFILES:C/\.[Ss]/.o/} ${SFILES:C/\.[Ss]/.o/}: assym.h
330 .endif
331
332 MKREPRO?=no
333
334 .if ${MKREPRO} == "yes"
335 _NVFLAGS=${NVFLAGS} -r
336 .else
337 _NVFLAGS=${NVFLAGS}
338 .endif
339
340 .if !target(vers.o)
341 newvers: vers.o
342 vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} $S/conf/newvers.sh $S/conf/osrelease.sh
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 .if defined(HAVE_GCC) || defined(HAVE_PCC)
569 .for __varstack in ${VARSTACK}
570 COPTS.${__varstack:T} += -Wno-stack-protector
571 .endfor
572 .endif
573
574 AFLAGS+= ${AOPTS.${.IMPSRC:T}}
575 CFLAGS+= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}}
576 CPPFLAGS+= ${CPPFLAGS.${.IMPSRC:T}}
577 CWARNFLAGS+= ${CWARNFLAGS.${.IMPSRC:T}}
578
579 .include <bsd.files.mk>
580 .include <bsd.clang-analyze.mk>
581
582 ##
583 ## the end
584 ##
585