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