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