Home | History | Annotate | Line # | Download | only in conf
Makefile.kern.inc revision 1.222
      1 #	$NetBSD: Makefile.kern.inc,v 1.222 2015/09/02 14:17:03 uebayasi 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} -D_KERNEL -D_KERNEL_OPT
     66 CPPFLAGS+=	-std=gnu99
     67 DEFCOPTS?=	-O2
     68 COPTS?=		${DEFCOPTS}
     69 DBG=		# might contain unwanted -Ofoo
     70 CWARNFLAGS+=	-Wall -Wno-main -Wno-format-zero-length -Wpointer-arith
     71 CWARNFLAGS+=	-Wmissing-prototypes -Wstrict-prototypes
     72 CWARNFLAGS+=	-Wold-style-definition
     73 CWARNFLAGS+=	-Wswitch -Wshadow
     74 CWARNFLAGS+=	-Wcast-qual -Wwrite-strings
     75 CWARNFLAGS+=	-Wno-unreachable-code
     76 #CWARNFLAGS+=	-Wc++-compat -Wno-error=c++-compat
     77 CWARNFLAGS+=	-Wno-pointer-sign -Wno-attributes
     78 .  if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" || \
     79 	${MACHINE_ARCH} == "sparc64" || ${MACHINE} == "prep"
     80 CWARNFLAGS+=	-Wextra -Wno-unused-parameter
     81 .  endif
     82 .  if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64"
     83 CWARNFLAGS+=	-Wold-style-definition
     84 .  endif
     85 # Add -Wno-sign-compare.  -Wsign-compare is included in -Wall as of GCC 3.3,
     86 # but our sources aren't up for it yet.
     87 CWARNFLAGS+=	-Wno-sign-compare
     88 
     89 CWARNFLAGS.clang+=	-Wno-unknown-pragmas -Wno-conversion \
     90 			-Wno-self-assign
     91 
     92 CWARNFLAGS.ah_regdomain.c= ${${ACTIVE_CC} == "clang":? \
     93     -Wno-shift-count-negative -Wno-shift-count-overflow:}
     94 
     95 CWARNFLAGS.ioconf.c= ${${ACTIVE_CC} == "clang":? -Wno-unused-const-variable :}
     96 
     97 CFLAGS+=	-ffreestanding -fno-zero-initialized-in-bss
     98 CFLAGS+=	${DEBUG} ${COPTS}
     99 AFLAGS+=	-D_LOCORE -Wa,--fatal-warnings
    100 
    101 # XXX
    102 .if defined(HAVE_GCC) || defined(HAVE_LLVM)
    103 CFLAGS+=	-fno-strict-aliasing
    104 CFLAGS+=	-fno-common
    105 .endif
    106 
    107 .if ${USE_SSP:Uno} == "yes"
    108 COPTS.kern_ssp.c+=	-fno-stack-protector -D__SSP__
    109 .endif
    110 
    111 # for multi-cpu machines, cpu_hatch() straddles the init of
    112 # __stack_chk_guard, so ensure stack protection is disabled
    113 .if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64"
    114 COPTS.cpu.c+=		-fno-stack-protector
    115 .endif
    116 
    117 # Use the per-source COPTS variables to add -g to just those
    118 # files that match the shell patterns given in ${DEBUGLIST}
    119 #
    120 .for i in ${DEBUGLIST}
    121 . for j in ${CFILES:T:M$i.c}
    122 COPTS.${j}+=-g
    123 . endfor
    124 .endfor
    125 
    126 # Always compile debugsyms.c with debug information.
    127 # This allows gdb to use type informations.
    128 #
    129 COPTS.debugsyms.c+=	-g
    130 
    131 # Add CTF sections for DTrace
    132 .if defined(CTFCONVERT)
    133 COMPILE_CTFCONVERT=	${_MKSHECHO}\
    134 			${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \
    135 			${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
    136 .else
    137 COMPILE_CTFCONVERT=	${_MKSHNOECHO}
    138 .endif
    139 
    140 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
    141 # NOPROF and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
    142 NORMAL_C?=	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}" && \
    143 		${_MKSHECHO}\
    144 		${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< -o $@ && \
    145 		${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< -o $@ && \
    146 		${COMPILE_CTFCONVERT}
    147 NOPROF_C?=	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}" && \
    148 		${_MKSHECHO}\
    149 		${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ && \
    150 		${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< -o $@ && \
    151 		${COMPILE_CTFCONVERT}
    152 NORMAL_S?=	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}" && \
    153 		${_MKSHECHO}\
    154 		${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $< -o $@ && \
    155 		${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $< -o $@
    156 
    157 # link rules:
    158 LINK_O?=	@${_MKSHMSG} "   link  ${.CURDIR:T}/${.TARGET}" && \
    159 		${_MKSHECHO}\
    160 		${LD} -r ${LINKFORMAT} -Map=${.TARGET}.map -o ${.TARGET} ${.ALLSRC} && \
    161 		${LD} -r ${LINKFORMAT} -Map=${.TARGET}.map -o ${.TARGET} ${.ALLSRC}
    162 
    163 ##
    164 ## (3) libkern and compat
    165 ##
    166 ## Set KERN_AS in the port Makefile to "obj" or "library".  The
    167 ## default is "library", as documented in $S/lib/libkern/Makefile.inc.
    168 ##
    169 
    170 ### find out what to use for libkern
    171 .include "$S/lib/libkern/Makefile.inc"
    172 .ifndef PROF
    173 LIBKERN?=	${KERNLIB}
    174 .else
    175 LIBKERN?=	${KERNLIB_PROF}
    176 .endif
    177 
    178 LIBKERNLN?=	${KERNLIBLN}
    179 
    180 ### find out what to use for libcompat
    181 .include "$S/compat/common/Makefile.inc"
    182 .ifndef PROF
    183 SYSLIBCOMPAT?=	${COMPATLIB}
    184 .else
    185 SYSLIBCOMPAT?=	${COMPATLIB_PROF}
    186 .endif
    187 
    188 SYSLIBCOMPATLN?=	${COMPATLIBLN}
    189 
    190 ##
    191 ## (4) local objects, compile rules, and dependencies
    192 ##
    193 ## Each port should have a corresponding section with settings for
    194 ## MD_CFILES, MD_SFILES, and MD_OBJS, along with build rules for same.
    195 ##
    196 
    197 MI_CFILES=	param.c
    198 .if !defined(___USE_SUFFIX_RULES___)
    199 MI_CFILES+=	devsw.c ioconf.c
    200 .endif
    201 
    202 # the need for a MI_SFILES variable is dubitable at best
    203 MI_OBJS=${MI_CFILES:S/.c/.o/}
    204 
    205 param.c: $S/conf/param.c
    206 	${_MKTARGET_CREATE}
    207 	rm -f param.c
    208 	cp $S/conf/param.c .
    209 
    210 ##
    211 ## (5) link settings
    212 ##
    213 ## TEXTADDR (or LOADADDRESS), LINKFORMAT, LINKSCRIPT, and any EXTRA_LINKFLAGS
    214 ## must be set in the port's Makefile.  The port specific definitions for
    215 ## LINKFLAGS_NORMAL and LINKFLAGS_DEBUG will added to the LINKFLAGS
    216 ## depending on the value of DEBUG.
    217 ##
    218 # load lines for config "xxx" will be emitted as:
    219 # xxx: ${SYSTEM_DEP} swapxxxx.o vers.o build_kernel
    220 
    221 .if !empty(OBJS:Mnetbsd.ko)
    222 SYSTEM_OBJ?=	${MD_OBJS} ${MI_OBJS} ${OBJS} ${SYSLIBCOMPAT} ${LIBKERN}
    223 .else
    224 SYSTEM_OBJ?=	${MD_OBJS} ${MI_OBJS} ${OBJS:O} ${SYSLIBCOMPAT} ${LIBKERN}
    225 .endif
    226 SYSTEM_DEP+=	Makefile ${SYSTEM_OBJ} .gdbinit
    227 .if defined(CTFMERGE)
    228 SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
    229 .else
    230 SYSTEM_CTFMERGE= ${_MKSHECHO}
    231 .endif
    232 SYSTEM_LD_HEAD?=@rm -f $@
    233 SYSTEM_LD?=	@do_system_ld() { \
    234 		target=$$1; shift; \
    235 		${_MKSHMSG} "   link  ${.CURDIR:T}/${.TARGET}"; \
    236 		${_MKSHECHO}\
    237 		${LD} -Map $${target}.map --cref ${LINKFLAGS} -o $${target} '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o swap$${target}.o $$@; \
    238 		${LD} -Map $${target}.map --cref ${LINKFLAGS} -o $${target} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o swap$${target}.o $$@; \
    239 		}; \
    240 		do_system_ld
    241 
    242 # Give MD generated ldscript dependency on ${SYSTEM_OBJ}
    243 .if defined(KERNLDSCRIPT)
    244 .if target(${KERNLDSCRIPT})
    245 ${KERNLDSCRIPT}: ${SYSTEM_OBJ}
    246 .endif
    247 .endif
    248 
    249 .if defined(KERNLDSCRIPT)
    250 .for k in ${KERNELS}
    251 EXTRA_CLEAN+=	${k}.ldscript
    252 ${k}: ${k}.ldscript
    253 ${k}.ldscript: ${KERNLDSCRIPT} assym.h
    254 	${_MKTARGET_CREATE}
    255 	${CPP} -I. ${KERNLDSCRIPT} | grep -v '^#' | grep -v '^$$' >$@
    256 .endfor
    257 LINKSCRIPT=	-T ${.TARGET}.ldscript
    258 .endif
    259 
    260 TEXTADDR?=	${LOADADDRESS}			# backwards compatibility
    261 LINKTEXT?=	${TEXTADDR:C/.+/-Ttext &/}
    262 LINKDATA?=	${DATAADDR:C/.+/-Tdata &/}
    263 ENTRYPOINT?=	start
    264 LINKENTRY?=	${ENTRYPOINT:C/.+/-e &/}
    265 LINKFLAGS?=	${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \
    266 		${EXTRA_LINKFLAGS}
    267 
    268 LINKFLAGS_DEBUG?=	-X
    269 
    270 SYSTEM_LD_TAIL?=@${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c; \
    271 		${SIZE} $@; chmod 755 $@; \
    272 		${SYSTEM_CTFMERGE}
    273 SYSTEM_LD_TAIL_DEBUG?=; \
    274 		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
    275 		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
    276 		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
    277 LINKFLAGS_NORMAL?=	-S
    278 STRIPFLAGS?=	-g
    279 
    280 DEBUG?=
    281 .if !empty(DEBUG:M-g*)
    282 SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG}
    283 LINKFLAGS+=	${LINKFLAGS_DEBUG}
    284 EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gdb@}
    285 CTFFLAGS+=	-g
    286 TARGETSFX=	.gdb
    287 .elifndef PROF
    288 LINKFLAGS+=	${LINKFLAGS_NORMAL}
    289 .endif
    290 
    291 SYSTEM_LD_HEAD+=${SYSTEM_LD_HEAD_EXTRA}
    292 SYSTEM_LD_TAIL_STAGE1=	${SYSTEM_LD_TAIL}
    293 SYSTEM_LD_TAIL_STAGE2=	${SYSTEM_LD_TAIL}
    294 .if defined(COPY_SYMTAB)
    295 SYSTEM_LD_TAIL_STAGE2+=	; echo ${DBSYM} $@; ${DBSYM} $@
    296 .if !empty(DEBUG:M-g)
    297 SYSTEM_LD_TAIL_STAGE2+=	; echo ${DBSYM} $@.gdb; ${DBSYM} $@.gdb
    298 .endif
    299 .endif
    300 SYSTEM_LD_TAIL_STAGE2+=	${SYSTEM_LD_TAIL_EXTRA}
    301 
    302 ##
    303 ## (6) port independent targets and dependencies: assym.h, vers.o
    304 ##
    305 
    306 .if !defined(___USE_SUFFIX_RULES___)
    307 OBJS=	${CFILES:T:R:C|$|.o|:N*swapnetbsd*} \
    308 	${SFILES:T:R:C|$|.o|} \
    309 	${OFILES}
    310 _CFILES=${CFILES:M/*} ${CFILES:N*swapnetbsd*:N/*:C|^|$S/|}
    311 _SFILES=${SFILES:M/*} ${SFILES:N/*:C|^|$S/|}
    312 .else
    313 OBJS=	${CFILES:R:C|$|.o|:N*swapnetbsd*} \
    314 	${SFILES:R:C|$|.o|} \
    315 	${OFILES}
    316 _CFILES=${CFILES:N*swapnetbsd*}
    317 _SFILES=${SFILES}
    318 .endif # ___USE_SUFFIX_RULES___
    319 
    320 .if !defined(___USE_SUFFIX_RULES___)
    321 .for _s in ${_CFILES}
    322 .if !commands(${_s:T:R}.o)
    323 ${_s:T:R}.o: ${_s}
    324 	${NORMAL_C}
    325 .endif
    326 .endfor
    327 
    328 .for _s in ${_SFILES}
    329 .if !commands(${_s:T:R}.o)
    330 ${_s:T:R}.o: ${_s}
    331 	${NORMAL_S}
    332 .endif
    333 .endfor
    334 .endif # !___USE_SUFFIX_RULES___
    335 
    336 assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS} $S/conf/genassym.cf
    337 	${_MKTARGET_CREATE}
    338 	cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} $S/conf/genassym.cf | \
    339 	    ${GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
    340 	    ${GENASSYM_CPPFLAGS} > assym.h.tmp && \
    341 	mv -f assym.h.tmp assym.h
    342 ${MD_SFILES:C/\.[Ss]/.o/} ${SFILES:C/\.[Ss]/.o/}: assym.h
    343 
    344 MKREPRO?=no
    345 
    346 .if ${MKREPRO} == "yes"
    347 _NVFLAGS=${NVFLAGS} -r
    348 .else
    349 _NVFLAGS=${NVFLAGS}
    350 .endif
    351 
    352 .if !target(vers.o)
    353 newvers: vers.o
    354 vers.o: ${SYSTEM_OBJ} Makefile $S/conf/newvers.sh \
    355 		$S/conf/osrelease.sh ${_NETBSD_VERSION_DEPENDS}
    356 	${_MKMSG_CREATE} vers.c
    357 	${HOST_SH} $S/conf/newvers.sh ${_NVFLAGS}
    358 	${_MKTARGET_COMPILE}
    359 	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
    360 	${COMPILE_CTFCONVERT}
    361 .endif
    362 
    363 ##
    364 ## (7) misc targets: install, clean(dir), depend(all), lint, links, tags,
    365 ##                   cscope, mkid
    366 ##
    367 ## Any ports that have other stuff to be cleaned up should fill in
    368 ## EXTRA_CLEAN.  Some ports may want different settings for
    369 ## KERNLINTFLAGS, MKDEP_CFLAGS, or MKDEP_AFLAGS.
    370 ##
    371 
    372 ##
    373 ## clean
    374 ##
    375 
    376 .if !target(__CLEANKERNEL)
    377 __CLEANKERNEL: .USE
    378 	${_MKMSG} "${.TARGET}ing the kernel objects"
    379 	rm -f ${KERNELS} *.map eddep tags *.[io] *.ko *.ln [a-z]*.s vers.c \
    380 	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h \
    381 	    ${EXTRA_KERNELS} ${EXTRA_CLEAN}
    382 .endif
    383 
    384 .if !target(kernelnames)
    385 kernelnames:
    386 	@echo "${KERNELS} ${EXTRA_KERNELS}"
    387 .endif
    388 
    389 .if !target(__CLEANDEPEND)
    390 __CLEANDEPEND: .USE
    391 	echo .depend ${DEPS} | xargs rm -f --
    392 .endif
    393 
    394 # do not !target these, the kern and compat Makefiles augment them
    395 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
    396 clean: __CLEANKERNEL
    397 depend: .depend
    398 dependall: depend .WAIT all
    399 
    400 ##
    401 ## depend
    402 ##
    403 
    404 .if !target(.depend)
    405 MKDEP_AFLAGS?=	${AFLAGS}
    406 MKDEP_CFLAGS?=	${CFLAGS}
    407 SSRCS=${MD_SFILES} ${_SFILES}
    408 CSRCS=${MD_CFILES} ${MI_CFILES} ${_CFILES}
    409 SRCS=${SSRCS} ${CSRCS}
    410 .if !defined(___USE_SUFFIX_RULES___)
    411 DEPS=	${SRCS:T:u:R:S/$/.d/g}
    412 .else
    413 DEPS=	${SRCS:u:R:S/$/.d/g}
    414 .endif
    415 
    416 .if !defined(___USE_SUFFIX_RULES___)
    417 .for _s in ${SSRCS}
    418 .if !target(${_s:T:R}.d)
    419 ${_s:T:R}.d: ${_s} assym.h
    420 	${_MKTARGET_CREATE}
    421 	${MKDEP} -f ${.TARGET}.tmp -- ${MKDEP_AFLAGS} \
    422 	    ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
    423 	mv -f ${.TARGET}.tmp ${.TARGET}
    424 .endif
    425 .endfor
    426 
    427 .for _s in ${CSRCS}
    428 .if !target(${_s:T:R}.d)
    429 ${_s:T:R}.d: ${_s}
    430 	${_MKTARGET_CREATE}
    431 	${MKDEP} -f ${.TARGET}.tmp -- ${MKDEP_CFLAGS} \
    432 	    ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
    433 	mv -f ${.TARGET}.tmp ${.TARGET}
    434 .endif
    435 .endfor
    436 .endif # !___USE_SUFFIX_RULES___
    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 ##
    454 ## install
    455 ##
    456 
    457 # List of kernel images that will be installed into the root file system.
    458 # Some platforms may need to install more than one (e.g. a netbsd.aout file
    459 # to be loaded directly by the firmware), so this can be overriden by them.
    460 KERNIMAGES?=	netbsd
    461 
    462 .if !target(install)
    463 # The install target can be redefined by putting a
    464 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
    465 MACHINE_NAME!=  uname -n
    466 install: install-kernel-${MACHINE_NAME}
    467 .if !target(install-kernel-${MACHINE_NAME})
    468 install-kernel-${MACHINE_NAME}:
    469 .for _K in ${KERNIMAGES}
    470 	rm -f ${DESTDIR}/o${_K}
    471 	ln ${DESTDIR}/${_K} ${DESTDIR}/o${_K}
    472 	cp ${_K} ${DESTDIR}/n${_K}
    473 	mv ${DESTDIR}/n${_K} ${DESTDIR}/${_K}
    474 .endfor
    475 .endif
    476 .endif
    477 
    478 .include "${S}/conf/splash.mk"
    479 .include "${S}/conf/mdroot.mk"
    480 .include "${S}/conf/lint.mk"
    481 .include "${S}/conf/cscope.mk"
    482 .include "${S}/conf/gdbinit.mk"
    483 
    484 ##
    485 ## the kernel
    486 ##
    487 
    488 # The following files use alloca(3) or variable array allocations.
    489 # Their full name is noted as documentation.
    490 VARSTACK=kern/uipc_socket.c miscfs/genfs/genfs_vnops.c \
    491     nfs/nfs_bio.c uvm/uvm_bio.c \
    492     uvm/uvm_pager.c dev/ic/aic7xxx.c dev/ic/aic79xx.c arch/xen/i386/gdt.c \
    493     dev/ofw/ofw_subr.c
    494 
    495 .for __varstack in ${VARSTACK}
    496 COPTS.${__varstack:T} += -Wno-stack-protector
    497 .endfor
    498 
    499 AFLAGS+=	${AOPTS.${.IMPSRC:T}}
    500 CFLAGS+=	${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}}
    501 CPPFLAGS+=	${CPPFLAGS.${.IMPSRC:T}}
    502 CWARNFLAGS+=	${CWARNFLAGS.${.IMPSRC:T}}
    503 
    504 .if !defined(COPY_SYMTAB)
    505 build_kernel: .USE
    506 	${SYSTEM_LD_HEAD}
    507 	${SYSTEM_LD} ${.TARGET}
    508 	${SYSTEM_LD_TAIL_STAGE2}
    509 .else
    510 .for k in ${KERNELS}
    511 ${k}: $S/kern/kern_ksyms_buf.c
    512 .endfor
    513 build_kernel: .USE
    514 	${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
    515 	    -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf.o
    516 	${SYSTEM_LD_HEAD}
    517 	${SYSTEM_LD} ${.TARGET} kern_ksyms_buf.o
    518 	${SYSTEM_LD_TAIL_STAGE1}
    519 	${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
    520 	    -DSYMTAB_SPACE=$$(${DBSYM} -P ${.TARGET}${TARGETSFX}) \
    521 	    -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf_real.o
    522 	${SYSTEM_LD_HEAD}
    523 	${SYSTEM_LD} ${.TARGET} kern_ksyms_buf_real.o
    524 	${SYSTEM_LD_TAIL_STAGE2}
    525 .endif
    526 
    527 .include <bsd.files.mk>
    528 .include <bsd.clang-analyze.mk>
    529 
    530 ##
    531 ## suffix rules
    532 ##
    533 
    534 .if defined(___USE_SUFFIX_RULES___)
    535 .SUFFIXES: .genassym .assym.h
    536 .genassym.assym.h:
    537 	${_MKTARGET_CREATE}
    538 	${GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
    539 	    ${GENASSYM_CPPFLAGS} < $< > $@
    540 	mv -f $@.tmp $@
    541 
    542 .SUFFIXES: .s .d
    543 .s.d:
    544 	${_MKTARGET_CREATE}
    545 	${MKDEP} -f $@.tmp -- ${MKDEP_AFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $<
    546 	mv -f $@.tmp $@
    547 
    548 .SUFFIXES: .S .d
    549 .S.d:
    550 	${_MKTARGET_CREATE}
    551 	${MKDEP} -f $@.tmp -- ${MKDEP_AFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $<
    552 	mv -f $@.tmp $@
    553 
    554 .SUFFIXES: .c .d
    555 .c.d:
    556 	${_MKTARGET_CREATE}
    557 	${MKDEP} -f $@.tmp -- ${MKDEP_CFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $<
    558 	mv -f $@.tmp $@
    559 
    560 .SUFFIXES: .c .o
    561 .c.o:
    562 	${NORMAL_C}
    563 
    564 .SUFFIXES: .s .o
    565 .s.o:
    566 	${NORMAL_S}
    567 
    568 .SUFFIXES: .S .o
    569 .S.o:
    570 	${NORMAL_S}
    571 .endif # ___USE_SUFFIX_RULES___
    572 
    573 ##
    574 ## the end
    575 ##
    576