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