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