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