Home | History | Annotate | Line # | Download | only in conf
Makefile.kern.inc revision 1.224
      1 #	$NetBSD: Makefile.kern.inc,v 1.224 2015/09/02 15:35:52 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 .if !defined(___USE_SUFFIX_RULES___)
    198 MI_CFILES=	param.c
    199 MI_CFILES+=	devsw.c ioconf.c
    200 .else
    201 MI_CFILES=	conf/param.c
    202 .endif
    203 
    204 # the need for a MI_SFILES variable is dubitable at best
    205 MI_OBJS=${MI_CFILES:S/.c/.o/}
    206 
    207 .if !defined(___USE_SUFFIX_RULES___)
    208 param.c: $S/conf/param.c
    209 	${_MKTARGET_CREATE}
    210 	rm -f param.c
    211 	cp $S/conf/param.c .
    212 .endif
    213 
    214 ##
    215 ## (5) link settings
    216 ##
    217 ## TEXTADDR (or LOADADDRESS), LINKFORMAT, LINKSCRIPT, and any EXTRA_LINKFLAGS
    218 ## must be set in the port's Makefile.  The port specific definitions for
    219 ## LINKFLAGS_NORMAL and LINKFLAGS_DEBUG will added to the LINKFLAGS
    220 ## depending on the value of DEBUG.
    221 ##
    222 # load lines for config "xxx" will be emitted as:
    223 # xxx: ${SYSTEM_DEP} swapxxxx.o vers.o build_kernel
    224 
    225 .if !empty(OBJS:Mnetbsd.ko)
    226 SYSTEM_OBJ?=	${MD_OBJS} ${MI_OBJS} ${OBJS} ${SYSLIBCOMPAT} ${LIBKERN}
    227 .else
    228 SYSTEM_OBJ?=	${MD_OBJS} ${MI_OBJS} ${OBJS:O} ${SYSLIBCOMPAT} ${LIBKERN}
    229 .endif
    230 SYSTEM_OBJ_NOSWAP=	${SYSTEM_OBJ:N*swapnetbsd*}
    231 SYSTEM_DEP+=	Makefile ${SYSTEM_OBJ} .gdbinit
    232 .if defined(CTFMERGE)
    233 SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
    234 .else
    235 SYSTEM_CTFMERGE= ${_MKSHECHO}
    236 .endif
    237 SYSTEM_LD_HEAD?=@rm -f $@
    238 SYSTEM_LD?=	${_MKSHMSG} "   link  ${.CURDIR:T}/${.TARGET}"; \
    239 		${_MKSHECHO}\
    240 		${LD} -Map ${.TARGET}.map --cref ${LINKFLAGS} -o ${.TARGET} '$${SYSTEM_OBJ_NOSWAP}' '$${EXTRA_OBJ}' vers.o '$${OBJS:M*swap${.TARGET}.o}'; \
    241 		${LD} -Map ${.TARGET}.map --cref ${LINKFLAGS} -o ${.TARGET} ${SYSTEM_OBJ_NOSWAP} ${EXTRA_OBJ} vers.o ${OBJS:M*swap${.TARGET}.o}
    242 
    243 # Give MD generated ldscript dependency on ${SYSTEM_OBJ}
    244 .if defined(KERNLDSCRIPT)
    245 .if target(${KERNLDSCRIPT})
    246 ${KERNLDSCRIPT}: ${SYSTEM_OBJ}
    247 .endif
    248 .endif
    249 
    250 .if defined(KERNLDSCRIPT)
    251 .for k in ${KERNELS}
    252 EXTRA_CLEAN+=	${k}.ldscript
    253 ${k}: ${k}.ldscript
    254 ${k}.ldscript: ${KERNLDSCRIPT} assym.h
    255 	${_MKTARGET_CREATE}
    256 	${CPP} -I. ${KERNLDSCRIPT} | grep -v '^#' | grep -v '^$$' >$@
    257 .endfor
    258 LINKSCRIPT=	-T ${.TARGET}.ldscript
    259 .endif
    260 
    261 TEXTADDR?=	${LOADADDRESS}			# backwards compatibility
    262 LINKTEXT?=	${TEXTADDR:C/.+/-Ttext &/}
    263 LINKDATA?=	${DATAADDR:C/.+/-Tdata &/}
    264 ENTRYPOINT?=	start
    265 LINKENTRY?=	${ENTRYPOINT:C/.+/-e &/}
    266 LINKFLAGS?=	${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \
    267 		${EXTRA_LINKFLAGS}
    268 
    269 LINKFLAGS_DEBUG?=	-X
    270 
    271 SYSTEM_LD_TAIL?=@${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c; \
    272 		${SIZE} $@; chmod 755 $@; \
    273 		${SYSTEM_CTFMERGE}
    274 SYSTEM_LD_TAIL_DEBUG?=; \
    275 		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
    276 		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
    277 		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
    278 LINKFLAGS_NORMAL?=	-S
    279 STRIPFLAGS?=	-g
    280 
    281 DEBUG?=
    282 .if !empty(DEBUG:M-g*)
    283 SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG}
    284 LINKFLAGS+=	${LINKFLAGS_DEBUG}
    285 EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gdb@}
    286 CTFFLAGS+=	-g
    287 TARGETSFX=	.gdb
    288 .elifndef PROF
    289 LINKFLAGS+=	${LINKFLAGS_NORMAL}
    290 .endif
    291 
    292 SYSTEM_LD_HEAD+=${SYSTEM_LD_HEAD_EXTRA}
    293 SYSTEM_LD_TAIL_STAGE1=	${SYSTEM_LD_TAIL}
    294 SYSTEM_LD_TAIL_STAGE2=	${SYSTEM_LD_TAIL}
    295 .if defined(COPY_SYMTAB)
    296 SYSTEM_LD_TAIL_STAGE2+=	; echo ${DBSYM} $@; ${DBSYM} $@
    297 .if !empty(DEBUG:M-g)
    298 SYSTEM_LD_TAIL_STAGE2+=	; echo ${DBSYM} $@.gdb; ${DBSYM} $@.gdb
    299 .endif
    300 .endif
    301 SYSTEM_LD_TAIL_STAGE2+=	${SYSTEM_LD_TAIL_EXTRA}
    302 
    303 ##
    304 ## (6) port independent targets and dependencies: assym.h, vers.o
    305 ##
    306 
    307 .if !defined(___USE_SUFFIX_RULES___)
    308 OBJS=	${CFILES:T:R:C|$|.o|} \
    309 	${SFILES:T:R:C|$|.o|} \
    310 	${OFILES}
    311 # absolute, generated (build directory), relative (under $S)
    312 _CFILES=${CFILES:M/*} ${CFILES:N/*:N*/*} ${CFILES:N/*:M*/*:C|^|$S/|}
    313 _SFILES=${SFILES:M/*} ${SFILES:N/*:N*/*} ${SFILES:N/*:M*/*:C|^|$S/|}
    314 .else
    315 OBJS=	${CFILES:R:C|$|.o|} \
    316 	${SFILES:R:C|$|.o|} \
    317 	${OFILES}
    318 _CFILES=${CFILES}
    319 _SFILES=${SFILES}
    320 .endif # ___USE_SUFFIX_RULES___
    321 
    322 .if !defined(___USE_SUFFIX_RULES___)
    323 .for _s in ${_CFILES}
    324 .if !commands(${_s:T:R}.o)
    325 ${_s:T:R}.o: ${_s}
    326 	${NORMAL_C}
    327 .endif
    328 .endfor
    329 
    330 .for _s in ${_SFILES}
    331 .if !commands(${_s:T:R}.o)
    332 ${_s:T:R}.o: ${_s}
    333 	${NORMAL_S}
    334 .endif
    335 .endfor
    336 .endif # !___USE_SUFFIX_RULES___
    337 
    338 assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS} $S/conf/genassym.cf
    339 	${_MKTARGET_CREATE}
    340 	cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} $S/conf/genassym.cf | \
    341 	    ${GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
    342 	    ${GENASSYM_CPPFLAGS} > assym.h.tmp && \
    343 	mv -f assym.h.tmp assym.h
    344 ${MD_SFILES:C/\.[Ss]/.o/} ${SFILES:C/\.[Ss]/.o/}: assym.h
    345 
    346 MKREPRO?=no
    347 
    348 .if ${MKREPRO} == "yes"
    349 _NVFLAGS=${NVFLAGS} -r
    350 .else
    351 _NVFLAGS=${NVFLAGS}
    352 .endif
    353 
    354 .if !target(vers.o)
    355 newvers: vers.o
    356 vers.o: ${SYSTEM_OBJ} Makefile $S/conf/newvers.sh \
    357 		$S/conf/osrelease.sh ${_NETBSD_VERSION_DEPENDS}
    358 	${_MKMSG_CREATE} vers.c
    359 	${HOST_SH} $S/conf/newvers.sh ${_NVFLAGS}
    360 	${_MKTARGET_COMPILE}
    361 	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
    362 	${COMPILE_CTFCONVERT}
    363 .endif
    364 
    365 ##
    366 ## (7) misc targets: install, clean(dir), depend(all), lint, links, tags,
    367 ##                   cscope, mkid
    368 ##
    369 ## Any ports that have other stuff to be cleaned up should fill in
    370 ## EXTRA_CLEAN.  Some ports may want different settings for
    371 ## KERNLINTFLAGS, MKDEP_CFLAGS, or MKDEP_AFLAGS.
    372 ##
    373 
    374 ##
    375 ## clean
    376 ##
    377 
    378 .if !target(__CLEANKERNEL)
    379 __CLEANKERNEL: .USE
    380 	${_MKMSG} "${.TARGET}ing the kernel objects"
    381 	rm -f ${KERNELS} *.map eddep tags *.[io] *.ko *.ln [a-z]*.s vers.c \
    382 	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h \
    383 	    ${EXTRA_KERNELS} ${EXTRA_CLEAN}
    384 .endif
    385 
    386 .if !target(kernelnames)
    387 kernelnames:
    388 	@echo "${KERNELS} ${EXTRA_KERNELS}"
    389 .endif
    390 
    391 .if !target(__CLEANDEPEND)
    392 __CLEANDEPEND: .USE
    393 	echo .depend ${DEPS} | xargs rm -f --
    394 .endif
    395 
    396 # do not !target these, the kern and compat Makefiles augment them
    397 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
    398 clean: __CLEANKERNEL
    399 depend: .depend
    400 dependall: depend .WAIT all
    401 
    402 ##
    403 ## depend
    404 ##
    405 
    406 .if !target(.depend)
    407 MKDEP_AFLAGS?=	${AFLAGS}
    408 MKDEP_CFLAGS?=	${CFLAGS}
    409 SSRCS=${MD_SFILES} ${_SFILES}
    410 CSRCS=${MD_CFILES} ${MI_CFILES} ${_CFILES}
    411 SRCS=${SSRCS} ${CSRCS}
    412 .if !defined(___USE_SUFFIX_RULES___)
    413 DEPS=	${SRCS:T:u:R:S/$/.d/g}
    414 .else
    415 DEPS=	${SRCS:u:R:S/$/.d/g}
    416 .endif
    417 
    418 .if !defined(___USE_SUFFIX_RULES___)
    419 .for _s in ${SSRCS}
    420 .if !target(${_s:T:R}.d)
    421 ${_s:T:R}.d: ${_s} assym.h
    422 	${_MKTARGET_CREATE}
    423 	${MKDEP} -f ${.TARGET}.tmp -- ${MKDEP_AFLAGS} \
    424 	    ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
    425 	mv -f ${.TARGET}.tmp ${.TARGET}
    426 .endif
    427 .endfor
    428 
    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}.tmp -- ${MKDEP_CFLAGS} \
    434 	    ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
    435 	mv -f ${.TARGET}.tmp ${.TARGET}
    436 .endif
    437 .endfor
    438 .endif # !___USE_SUFFIX_RULES___
    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} ${GENASSYM_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 ##
    456 ## install
    457 ##
    458 
    459 # List of kernel images that will be installed into the root file system.
    460 # Some platforms may need to install more than one (e.g. a netbsd.aout file
    461 # to be loaded directly by the firmware), so this can be overriden by them.
    462 KERNIMAGES?=	netbsd
    463 
    464 .if !target(install)
    465 # The install target can be redefined by putting a
    466 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
    467 MACHINE_NAME!=  uname -n
    468 install: install-kernel-${MACHINE_NAME}
    469 .if !target(install-kernel-${MACHINE_NAME})
    470 install-kernel-${MACHINE_NAME}:
    471 .for _K in ${KERNIMAGES}
    472 	rm -f ${DESTDIR}/o${_K}
    473 	ln ${DESTDIR}/${_K} ${DESTDIR}/o${_K}
    474 	cp ${_K} ${DESTDIR}/n${_K}
    475 	mv ${DESTDIR}/n${_K} ${DESTDIR}/${_K}
    476 .endfor
    477 .endif
    478 .endif
    479 
    480 .include "${S}/conf/splash.mk"
    481 .include "${S}/conf/mdroot.mk"
    482 .include "${S}/conf/lint.mk"
    483 .include "${S}/conf/cscope.mk"
    484 .include "${S}/conf/gdbinit.mk"
    485 
    486 ##
    487 ## the kernel
    488 ##
    489 
    490 # The following files use alloca(3) or variable array allocations.
    491 # Their full name is noted as documentation.
    492 VARSTACK=kern/uipc_socket.c miscfs/genfs/genfs_vnops.c \
    493     nfs/nfs_bio.c uvm/uvm_bio.c \
    494     uvm/uvm_pager.c dev/ic/aic7xxx.c dev/ic/aic79xx.c arch/xen/i386/gdt.c \
    495     dev/ofw/ofw_subr.c
    496 
    497 .for __varstack in ${VARSTACK}
    498 COPTS.${__varstack:T} += -Wno-stack-protector
    499 .endfor
    500 
    501 AFLAGS+=	${AOPTS.${.IMPSRC:T}}
    502 CFLAGS+=	${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}}
    503 CPPFLAGS+=	${CPPFLAGS.${.IMPSRC:T}}
    504 CWARNFLAGS+=	${CWARNFLAGS.${.IMPSRC:T}}
    505 
    506 .if !defined(COPY_SYMTAB)
    507 build_kernel: .USE
    508 	${SYSTEM_LD_HEAD}
    509 	${SYSTEM_LD}
    510 	${SYSTEM_LD_TAIL_STAGE2}
    511 .else
    512 .for k in ${KERNELS}
    513 ${k}: $S/kern/kern_ksyms_buf.c
    514 .endfor
    515 build_kernel: .USE
    516 	${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
    517 	    -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf.o
    518 	${SYSTEM_LD_HEAD}
    519 	${SYSTEM_LD} kern_ksyms_buf.o
    520 	${SYSTEM_LD_TAIL_STAGE1}
    521 	${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
    522 	    -DSYMTAB_SPACE=$$(${DBSYM} -P ${.TARGET}${TARGETSFX}) \
    523 	    -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf_real.o
    524 	${SYSTEM_LD_HEAD}
    525 	${SYSTEM_LD} kern_ksyms_buf_real.o
    526 	${SYSTEM_LD_TAIL_STAGE2}
    527 .endif
    528 
    529 .include <bsd.files.mk>
    530 .include <bsd.clang-analyze.mk>
    531 
    532 ##
    533 ## suffix rules
    534 ##
    535 
    536 .if defined(___USE_SUFFIX_RULES___)
    537 .SUFFIXES: .genassym .assym.h
    538 .genassym.assym.h:
    539 	${_MKTARGET_CREATE}
    540 	${GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
    541 	    ${GENASSYM_CPPFLAGS} < $< > $@
    542 	mv -f $@.tmp $@
    543 
    544 .SUFFIXES: .s .d
    545 .s.d:
    546 	${_MKTARGET_CREATE}
    547 	${MKDEP} -f $@.tmp -- ${MKDEP_AFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $<
    548 	mv -f $@.tmp $@
    549 
    550 .SUFFIXES: .S .d
    551 .S.d:
    552 	${_MKTARGET_CREATE}
    553 	${MKDEP} -f $@.tmp -- ${MKDEP_AFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $<
    554 	mv -f $@.tmp $@
    555 
    556 .SUFFIXES: .c .d
    557 .c.d:
    558 	${_MKTARGET_CREATE}
    559 	${MKDEP} -f $@.tmp -- ${MKDEP_CFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $<
    560 	mv -f $@.tmp $@
    561 
    562 .SUFFIXES: .c .o
    563 .c.o:
    564 	${NORMAL_C}
    565 
    566 .SUFFIXES: .s .o
    567 .s.o:
    568 	${NORMAL_S}
    569 
    570 .SUFFIXES: .S .o
    571 .S.o:
    572 	${NORMAL_S}
    573 .endif # ___USE_SUFFIX_RULES___
    574 
    575 ##
    576 ## the end
    577 ##
    578