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