Makefile.kern.inc revision 1.155 1 # $NetBSD: Makefile.kern.inc,v 1.155 2012/03/25 06:55:20 joerg 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 _MKMSG_CREATE?= :
41 _MKTARGET_COMPILE?= :
42 _MKTARGET_CREATE?= :
43
44 ##
45 ## (1) port independent source tree identification
46 ##
47 # source tree is located via $S relative to the compilation directory
48 .ifndef S
49 S!= cd ../../../..; pwd
50 .endif
51
52 ##
53 ## (2) compile settings
54 ##
55 ## CPPFLAGS, CFLAGS, and AFLAGS must be set in the port's Makefile
56 ##
57 INCLUDES?= -I. ${EXTRA_INCLUDES} -I${S}/../common/include -I$S/arch \
58 -I$S -nostdinc
59 CPPFLAGS+= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT
60 CPPFLAGS+= -std=gnu99
61 DEFCOPTS?= -O2
62 COPTS?= ${DEFCOPTS}
63 DBG= # might contain unwanted -Ofoo
64 DEFWARNINGS?= yes
65 .if (${DEFWARNINGS} == "yes")
66 CWARNFLAGS+= -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith
67 CWARNFLAGS+= -Wmissing-prototypes -Wstrict-prototypes
68 CWARNFLAGS+= -Wold-style-definition
69 CWARNFLAGS+= -Wswitch -Wshadow
70 CWARNFLAGS+= -Wcast-qual -Wwrite-strings
71 CWARNFLAGS+= -Wno-unreachable-code
72 . if defined(HAVE_GCC) || defined(HAVE_PCC)
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 . endif
82 # Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3,
83 # but our sources aren't up for it yet.
84 CWARNFLAGS+= -Wno-sign-compare
85 .endif
86
87 CWARNFLAGS.clang+= -Wno-unknown-pragmas -Wno-conversion \
88 -Wno-self-assign
89
90 CWARNFLAGS.ah_regdomain.c= ${${ACTIVE_CC} == "clang":? \
91 -Wno-shift-count-negative -Wno-shift-count-overflow:}
92
93 CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss
94 CFLAGS+= ${DEBUG} ${COPTS}
95 AFLAGS+= -D_LOCORE -Wa,--fatal-warnings
96
97 # XXX
98 .if defined(HAVE_GCC)
99 CFLAGS+= -fno-strict-aliasing
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=
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 $S/conf/osrelease.sh
342 ${_MKMSG_CREATE} vers.c
343 ${HOST_SH} $S/conf/newvers.sh ${_NVFLAGS}
344 ${_MKTARGET_COMPILE}
345 ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
346 .endif
347
348 .if defined(MEMORY_DISK_IMAGE)
349 md_root_image.h: ${MEMORY_DISK_IMAGE}
350 ${_MKTARGET_CREATE}
351 ${TOOL_HEXDUMP} -v -e '"\t" 8/1 "0x%02x, " "\n"' ${.ALLSRC} > ${.TARGET}
352
353 # XXX This is only needed when building md_root.o
354 CPPFLAGS+= -DMEMORY_DISK_IMAGE
355 md_root.o: md_root_image.h
356 .endif
357
358 # depend on MEMORY_DISK_IMAGE configuration
359 md_root.o: Makefile
360
361 # depend on root or device configuration
362 autoconf.o conf.o: Makefile
363
364 # depend on network or filesystem configuration
365 uipc_proto.o vfs_conf.o: Makefile
366
367 # depend on maxusers and CPU configuration
368 assym.h machdep.o: Makefile
369
370 ##
371 ## (7) misc targets: install, clean(dir), depend(all), lint, links, tags,
372 ## cscope, mkid
373 ##
374 ## Any ports that have other stuff to be cleaned up should fill in
375 ## EXTRA_CLEAN. Some ports may want different settings for
376 ## KERNLINTFLAGS, MKDEP_CFLAGS, or MKDEP_AFLAGS.
377 ##
378 .if !target(__CLEANKERNEL)
379 __CLEANKERNEL: .USE
380 ${_MKMSG} "${.TARGET}ing the kernel objects"
381 rm -f ${KERNELS} eddep tags *.[io] *.ln [a-z]*.s vers.c \
382 [Ee]rrs linterrs makelinks assym.h.tmp assym.h \
383 ${EXTRA_KERNELS} ${EXTRA_CLEAN}
384 .endif
385
386 .if !target(kernelnames)
387 kernelnames:
388 @echo "${KERNELS} ${EXTRA_KERNELS}"
389 .endif
390
391 .if !target(__CLEANDEPEND)
392 __CLEANDEPEND: .USE
393 echo .depend ${DEPS} | xargs rm -f --
394 .endif
395
396 # do not !target these, the kern and compat Makefiles augment them
397 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
398 clean: __CLEANKERNEL
399 depend: .depend
400 dependall: depend .WAIT all
401
402 .if !target(.depend)
403 MKDEP_AFLAGS?= ${AFLAGS}
404 MKDEP_CFLAGS?= ${CFLAGS}
405 SSRCS=${MD_SFILES} ${SFILES}
406 CSRCS=${MD_CFILES} ${MI_CFILES} ${CFILES}
407 SRCS=${SSRCS} ${CSRCS}
408 DEPS= ${SRCS:T:O:u:R:S/$/.d/g}
409
410 .for _s in ${SSRCS}
411 .if !target(${_s:T:R}.d)
412 ${_s:T:R}.d: ${_s} assym.h
413 ${_MKTARGET_CREATE}
414 ${MKDEP} -f ${.TARGET} -- ${MKDEP_AFLAGS} \
415 ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
416 .endif
417 .endfor
418 .for _s in ${CSRCS}
419 .if !target(${_s:T:R}.d)
420 ${_s:T:R}.d: ${_s}
421 ${_MKTARGET_CREATE}
422 ${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \
423 ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
424 .endif
425 .endfor
426
427 assym.d: assym.h
428 ${_MKTARGET_CREATE}
429 cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} | \
430 ${GENASSYM} -- ${MKDEP} -f assym.dep -- \
431 ${CFLAGS:N-Wa,*} ${CPPFLAGS}
432 ${TOOL_SED} -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >${.TARGET}
433 rm -f assym.dep
434
435 DEPS+= assym.d
436
437 .depend: ${DEPS}
438 ${_MKTARGET_CREATE}
439 echo "${.ALLSRC}" | ${MKDEP} -D
440 .endif
441
442 .if !target(lint)
443 ALLSFILES?= ${MD_SFILES} ${SFILES}
444 LINTSTUBS?= ${ALLSFILES:T:R:C/^.*$/LintStub_&.c/g}
445 KERNLINTFLAGS?= -bcehnxzFS
446 NORMAL_LN?= ${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i $<
447
448 _lsrc=${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES}
449 LOBJS?= ${_lsrc:T:S/.c$/.ln/g} ${LIBKERNLN} ${SYSLIBCOMPATLN}
450
451 .for _sfile in ${ALLSFILES}
452 LintStub_${_sfile:T:R}.c: ${_sfile} assym.h
453 ${_MKTARGET_COMPILE}
454 ${CC} -E -C ${AFLAGS} ${CPPFLAGS} ${_sfile} | \
455 ${TOOL_AWK} -f $S/kern/genlintstub.awk >${.TARGET}
456 .endfor
457
458 .for _cfile in ${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES}
459 ${_cfile:T:R}.ln: ${_cfile}
460 ${_MKTARGET_COMPILE}
461 ${NORMAL_LN}
462 .endfor
463
464 lint: ${LOBJS}
465 ${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} ${LOBJS}
466 .endif
467
468 # Attempt to do a syntax-only compile of the entire kernel as one entity.
469 # Alas, bugs in the GCC C frontend prevent this from completely effective
470 # but information can be gleaned from the output.
471 syntax-only: ${CFILES} ${MD_CFILES}
472 ${CC} -fsyntax-only -combine ${CFLAGS} ${CPPFLAGS} \
473 ${CFILES} ${MD_CFILES}
474
475 # List of kernel images that will be installed into the root file system.
476 # Some platforms may need to install more than one (e.g. a netbsd.aout file
477 # to be loaded directly by the firmware), so this can be overriden by them.
478 KERNIMAGES?= netbsd
479
480 .if !target(install)
481 # The install target can be redefined by putting a
482 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
483 MACHINE_NAME!= uname -n
484 install: install-kernel-${MACHINE_NAME}
485 .if !target(install-kernel-${MACHINE_NAME})
486 install-kernel-${MACHINE_NAME}:
487 .for _K in ${KERNIMAGES}
488 rm -f ${DESTDIR}/o${_K}
489 ln ${DESTDIR}/${_K} ${DESTDIR}/o${_K}
490 cp ${_K} ${DESTDIR}/n${_K}
491 mv ${DESTDIR}/n${_K} ${DESTDIR}/${_K}
492 .endfor
493 .endif
494 .endif
495
496 .if !target(tags)
497 tags:
498 @echo "see $S/kern/Makefile for tags"
499 .endif
500
501 EXTRA_CLEAN+= cscope.out cscope.tmp
502 .if !target(cscope.out)
503 cscope.out: Makefile depend
504 ${_MKTARGET_CREATE}
505 @${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/kern/.depend \
506 | tr -s ' ' '\n' \
507 | ${TOOL_SED} ';s|^../../||;' \
508 > cscope.tmp
509 @${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/compat/.depend \
510 | tr -s ' ' '\n' \
511 | ${TOOL_SED} 's|^../../||;' \
512 >> cscope.tmp
513 @echo ${SRCS} | cat - cscope.tmp | tr -s ' ' '\n' | sort -u | \
514 ${CSCOPE} -k -i - -b `echo ${INCLUDES} | ${TOOL_SED} s/-nostdinc//`
515 # cscope doesn't write cscope.out if it's uptodate, so ensure
516 # make doesn't keep calling cscope when not needed.
517 @rm -f cscope.tmp; touch cscope.out
518 .endif
519
520 .if !target(cscope)
521 cscope: cscope.out
522 @${CSCOPE} -d
523 .endif
524
525 EXTRA_CLEAN+= ID
526 .if !target(mkid)
527 .PHONY: mkid
528 mkid: ID
529
530 ID: Makefile depend
531 ${_MKTARGET_CREATE}
532 @${MKID} \
533 `${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' \
534 lib/kern/.depend lib/compat/.depend \
535 | tr ' ' '\n' \
536 | ${TOOL_SED} "s|^../../||" \
537 | sort -u` \
538 `${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' \
539 .depend \
540 | tr ' ' '\n' \
541 | sort -u`
542
543 .endif
544
545 .include "${S}/gdbscripts/Makefile.inc"
546
547 EXTRA_CLEAN+= .gdbinit
548 .gdbinit: Makefile ${S}/gdbscripts/Makefile.inc
549 ${_MKTARGET_CREATE}
550 rm -f .gdbinit
551 .for __gdbinit in ${SYS_GDBINIT}
552 echo "source ${S}/gdbscripts/${__gdbinit}" >> .gdbinit
553 .endfor
554 .if defined(GDBINIT) && !empty(GDBINIT)
555 .for __gdbinit in ${GDBINIT}
556 echo "source ${__gdbinit}" >> .gdbinit
557 .endfor
558 .endif
559
560 # The following files use alloca(3) or variable array allocations.
561 # Their full name is noted as documentation.
562 VARSTACK=kern/uipc_socket.c miscfs/genfs/genfs_vnops.c \
563 nfs/nfs_bio.c uvm/uvm_bio.c \
564 uvm/uvm_pager.c dev/ic/aic7xxx.c dev/ic/aic79xx.c arch/xen/i386/gdt.c \
565 dev/ofw/ofw_subr.c
566
567 .if defined(HAVE_GCC) || defined(HAVE_PCC)
568 .for __varstack in ${VARSTACK}
569 COPTS.${__varstack:T} += -Wno-stack-protector
570 .endfor
571 .endif
572
573 AFLAGS+= ${AOPTS.${.IMPSRC:T}}
574 CFLAGS+= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}}
575 CPPFLAGS+= ${CPPFLAGS.${.IMPSRC:T}}
576 CWARNFLAGS+= ${CWARNFLAGS.${.IMPSRC:T}}
577
578 .include <bsd.files.mk>
579 .include <bsd.clang-analyze.mk>
580
581 ##
582 ## the end
583 ##
584