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