Home | History | Annotate | Line # | Download | only in conf
Makefile.kern.inc revision 1.298
      1 #	$NetBSD: Makefile.kern.inc,v 1.298 2023/07/26 03:39:55 rin 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 overridden.
      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 MKDEBUGKERNEL=yes
     21 .if ${MKDEBUGKERNEL:Uno} == "yes" || ${MKDEBUG:Uno} == "yes"
     22 DEBUG?=-g
     23 .else
     24 DEBUG?=
     25 .endif
     26 
     27 ##
     28 ## (0) toolchain settings for things that aren't part of the standard
     29 ## toolchain
     30 ##
     31 HOST_SH?=	sh
     32 DBSYM?=		dbsym
     33 MKDEP?=		mkdep
     34 STRIP?=		strip
     35 OBJCOPY?=	objcopy
     36 OBJDUMP?=	objdump
     37 CSCOPE?=	cscope
     38 MKID?=		mkid
     39 UUDECODE?=	${TOOL_UUDECODE:Uuudecode}
     40 HEXDUMP?=	${TOOL_HEXDUMP:Uhexdump}
     41 GENASSYM?=	${TOOL_GENASSYM:Ugenassym}
     42 .MAKEOVERRIDES+=USETOOLS	# make sure proper value is propagated
     43 
     44 _MKMSG?=		@\#
     45 _MKSHMSG?=		echo
     46 _MKSHECHO?=		echo
     47 _MKSHNOECHO=		:
     48 _MKMSG_CREATE?=		:
     49 _MKTARGET_COMPILE?=	:
     50 _MKTARGET_CREATE?=	:
     51 
     52 ##
     53 ## (1) port independent source tree identification
     54 ##
     55 # source tree is located via $S relative to the compilation directory
     56 .ifndef S
     57 S!=	cd ../../../.. && pwd
     58 .endif
     59 
     60 ##
     61 ## (2) compile settings
     62 ##
     63 ## CPPFLAGS, CFLAGS, and AFLAGS must be set in the port's Makefile
     64 ##
     65 INCLUDES?=	-I. ${EXTRA_INCLUDES} -I${S}/../common/include -I$S/arch \
     66 		-I$S -nostdinc
     67 CPPFLAGS+=	${INCLUDES} ${IDENT} -D_KERNEL -D_KERNEL_OPT
     68 .if !defined(COVERITY_TOP_CONFIG)
     69 CPPFLAGS+=	-std=gnu99
     70 .endif
     71 .if ${KERNEL_DIR:Uno} == "yes"
     72 CPPFLAGS+=	-DKERNEL_DIR
     73 .endif
     74 DEFCOPTS?=	-O2
     75 COPTS?=		${DEFCOPTS}
     76 DBG=		# might contain unwanted -Ofoo
     77 CWARNFLAGS+=	-Wall -Wno-main -Wno-format-zero-length -Wpointer-arith
     78 CWARNFLAGS+=	-Wmissing-prototypes -Wstrict-prototypes
     79 CWARNFLAGS+=	-Wold-style-definition
     80 CWARNFLAGS+=	-Wswitch -Wshadow
     81 CWARNFLAGS+=	-Wcast-qual -Wwrite-strings
     82 CWARNFLAGS+=	-Wno-unreachable-code
     83 #CWARNFLAGS+=	-Wc++-compat -Wno-error=c++-compat
     84 CWARNFLAGS+=	-Wno-pointer-sign -Wno-attributes
     85 CWARNFLAGS+=	-Wno-type-limits
     86 .  if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" || \
     87 	${MACHINE_ARCH} == "sparc64" || ${MACHINE} == "prep"
     88 CWARNFLAGS+=	-Wextra -Wno-unused-parameter
     89 .  endif
     90 .  if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64"
     91 CWARNFLAGS+=	-Wold-style-definition
     92 .  endif
     93 # Add -Wno-sign-compare.  -Wsign-compare is included in -Wall as of GCC 3.3,
     94 # but our sources aren't up for it yet.
     95 CWARNFLAGS+=	-Wno-sign-compare
     96 
     97 CWARNFLAGS.clang+=	-Wno-unknown-pragmas -Wno-conversion \
     98 			-Wno-self-assign \
     99 			-Wno-error=constant-conversion
    100 CWARNFLAGS+=		${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
    101 
    102 CWARNFLAGS.ah_regdomain.c= ${${ACTIVE_CC} == "clang":? \
    103     -Wno-shift-count-negative -Wno-shift-count-overflow:}
    104 
    105 CWARNFLAGS.ioconf.c= ${${ACTIVE_CC} == "clang":? -Wno-unused-const-variable :}
    106 
    107 CFLAGS+=	-ffreestanding -fno-zero-initialized-in-bss
    108 CFLAGS+=	${${ACTIVE_CC} == "gcc":? -fno-delete-null-pointer-checks :}
    109 CFLAGS+=	${DEBUG} ${COPTS}
    110 AFLAGS+=	-D_LOCORE -Wa,--fatal-warnings
    111 
    112 # example usage to find largest stack users in kernel compile directory:
    113 #    find . -name \*.su | xargs awk '{ printf "%6d %s\n", $2, $1 }' | sort -n
    114 .if ${MACHINE} != "vax"
    115 # GCC/vax 8.4 does not support -fstack-usage.
    116 CFLAGS+=	${${ACTIVE_CC} == "gcc":? -fstack-usage -Wstack-usage=3584 :}
    117 .endif
    118 CWARNFLAGS+=	-Walloca
    119 
    120 # XXX
    121 .if defined(HAVE_GCC) || defined(HAVE_LLVM)
    122 CFLAGS+=	-fno-strict-aliasing
    123 CFLAGS+=	-fno-common
    124 .endif
    125 
    126 # Use the per-source COPTS variables to add -g to just those
    127 # files that match the shell patterns given in ${DEBUGLIST}
    128 #
    129 .for i in ${DEBUGLIST}
    130 . for j in ${ALLFILES:M*.c:T:M$i.c}
    131 COPTS.${j}+=-g
    132 . endfor
    133 .endfor
    134 
    135 # Always compile debugsyms.c with debug information.
    136 # This allows gdb to use type informations.
    137 #
    138 COPTS.debugsyms.c+=	-g
    139 
    140 # Add CTF sections for DTrace
    141 .if defined(CTFCONVERT)
    142 COMPILE_CTFCONVERT=	${_MKSHECHO}\
    143 			${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \
    144 			${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
    145 .else
    146 COMPILE_CTFCONVERT=	${_MKSHNOECHO}
    147 .endif
    148 
    149 KCOMPILE.c=	${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
    150 KCOMPILE.s=	${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $< -o $@
    151 KLINK.o=	${LD} -r ${LINKFORMAT} -Map=${.TARGET}.map -o ${.TARGET} ${.ALLSRC}
    152 
    153 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
    154 # NOPROF and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
    155 NORMAL_C?=	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}" && \
    156 		${_MKSHECHO} ${KCOMPILE.c} ${PROF} && \
    157 		${KCOMPILE.c} ${PROF} && \
    158 		${COMPILE_CTFCONVERT}
    159 NOPROF_C?=	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}" && \
    160 		${_MKSHECHO} ${KCOMPILE.c} && \
    161 		${KCOMPILE.c} && \
    162 		${COMPILE_CTFCONVERT}
    163 NORMAL_S?=	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}" && \
    164 		${_MKSHECHO} ${KCOMPILE.s} && \
    165 		${KCOMPILE.s}
    166 
    167 # link rules:
    168 LINK_O?=	@${_MKSHMSG} "   link  ${.CURDIR:T}/${.TARGET}" && \
    169 		${_MKSHECHO} ${KLINK.o} && \
    170 		${KLINK.o}
    171 
    172 ##
    173 ## (3) libkern
    174 ##
    175 ## Set OPT_MODULAR in the port Makefile if module(7) is enabled,
    176 ## as documented in $S/lib/libkern/Makefile.inc.
    177 ##
    178 
    179 ### find out what to use for libkern
    180 .include "$S/lib/libkern/Makefile.inc"
    181 .ifndef PROF
    182 LIBKERN?=	${KERNLIB}
    183 .else
    184 LIBKERN?=	${KERNLIB_PROF}
    185 .endif
    186 
    187 LIBKERNLN?=	${KERNLIBLN}
    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 
    196 .if !defined(___USE_SUFFIX_RULES___)
    197 _MD_OBJS=	${MD_OBJS:T}
    198 .else
    199 _MD_OBJS=	${MD_OBJS}
    200 .endif
    201 
    202 ##
    203 ## (5) link settings
    204 ##
    205 ## TEXTADDR (or LOADADDRESS), LINKFORMAT, LINKSCRIPT, and any EXTRA_LINKFLAGS
    206 ## must be set in the port's Makefile.  The port specific definitions for
    207 ## LINKFLAGS_NORMAL and LINKFLAGS_DEBUG will added to the LINKFLAGS
    208 ## depending on the value of DEBUG.
    209 ##
    210 # load lines for config "xxx" will be emitted as:
    211 # xxx: ${SYSTEM_DEP} swapxxxx.o vers.o build_kernel
    212 
    213 SYSTEM_LIB=	${MD_LIBS} ${LIBKERN}
    214 SYSTEM_OBJ?=	${_MD_OBJS} ${OBJS} ${SYSTEM_LIB}
    215 SYSTEM_DEP+=	Makefile ${SYSTEM_OBJ:O}
    216 .if defined(CTFMERGE)
    217 SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
    218 .else
    219 SYSTEM_CTFMERGE= ${_MKSHECHO}
    220 .endif
    221 
    222 REMOVE_SWAP=   [@]
    223 .for k in ${KERNELS}
    224 REMOVE_SWAP:=  ${REMOVE_SWAP}:Nswap${k}.o
    225 .endfor
    226 
    227 SYSTEM_LD_HEAD?=@rm -f $@
    228 SYSTEM_LD?=	${_MKSHMSG} "   link  ${.CURDIR:T}/${.TARGET}"; \
    229 		${_MKSHECHO}\
    230 		${LD} -Map ${.TARGET}.map --cref ${LINKFLAGS} -o ${.TARGET} \
    231 		'$${SYSTEM_OBJ:${REMOVE_SWAP}}' '$${EXTRA_OBJ}' vers.o \
    232 		${OBJS:M*swap${.TARGET}.o}; \
    233 		${LD} -Map ${.TARGET}.map --cref ${LINKFLAGS} -o ${.TARGET} \
    234 		${SYSTEM_OBJ:${REMOVE_SWAP}} ${EXTRA_OBJ} vers.o \
    235 		${OBJS:M*swap${.TARGET}.o}
    236 
    237 TEXTADDR?=	${LOADADDRESS}			# backwards compatibility
    238 LINKTEXT?=	${TEXTADDR:C/.+/-Ttext &/}
    239 LINKDATA?=	${DATAADDR:C/.+/-Tdata &/}
    240 ENTRYPOINT?=	start
    241 LINKENTRY?=	${ENTRYPOINT:C/.+/-e &/}
    242 LINKFLAGS?=	${LINKFORMAT} ${LINKSCRIPT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \
    243 		${EXTRA_LINKFLAGS}
    244 
    245 LINKFLAGS_DEBUG?=	-X
    246 KERNEL_CONFIG?=	${KERNEL_BUILD:T}
    247 
    248 SYSTEM_LD_TAIL?= @${_MKSHECHO}
    249 SYSTEM_LD_TAIL+= && ${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/" "//;s/\\.*//' vers.c && \
    250 		${SIZE} $@ && ${SYSTEM_CTFMERGE} && chmod 755 $@
    251 SYSTEM_LD_TAIL+= && runit() { echo $$@; $$@; }
    252 
    253 OBJCOPY_STRIPFLAGS?= -g
    254 
    255 SYSTEM_LD_TAIL_DEBUG?=&& \
    256 	runit mv -f $@ $@.gdb && \
    257 	runit ${OBJCOPY} --only-keep-debug $@.gdb $@-${KERNEL_CONFIG}.debug && \
    258 	runit ${OBJCOPY} ${OBJCOPY_STRIPFLAGS} -p -R .gnu_debuglink \
    259 	    --add-gnu-debuglink=$@-${KERNEL_CONFIG}.debug $@.gdb $@ && \
    260 	runit chmod 755 $@ $@.gdb $@-${KERNEL_CONFIG}.debug
    261 
    262 LINKFLAGS_NORMAL?=	-S
    263 STRIPFLAGS?=	-g
    264 
    265 .if !empty(DEBUG:M-g*)
    266 SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG}
    267 LINKFLAGS+=	${LINKFLAGS_DEBUG}
    268 EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gdb@}
    269 CTFFLAGS+=	-g
    270 TARGETSFX=	.gdb
    271 .elifndef PROF
    272 LINKFLAGS+=	${LINKFLAGS_NORMAL}
    273 .endif
    274 
    275 .if ${MKDEBUG:Uno} == "yes"
    276 # XXX: KERNEL_DIR?
    277 debuginstall: install-kernel-debug
    278 .for k in ${KERNELS}
    279 install-kernel-debug: ${DESTDIR}${DEBUGDIR}/${k}-${KERNEL_CONFIG}.debug
    280 
    281 ${DESTDIR}${DEBUGDIR}/${k}-${KERNEL_CONFIG}.debug: ${k}-${KERNEL_CONFIG}.debug
    282 	${_MKTARGET_INSTALL}
    283 	${INSTALL_FILE} -o root -g bin -m 444 ${.ALLSRC} ${.TARGET}
    284 .endfor
    285 .else
    286 debuginstall:
    287 .endif
    288 
    289 SYSTEM_LD_HEAD+=	${SYSTEM_LD_HEAD_EXTRA}
    290 SYSTEM_LD_TAIL_STAGE1=	${SYSTEM_LD_TAIL}
    291 SYSTEM_LD_TAIL_STAGE2=	${SYSTEM_LD_TAIL}
    292 .if defined(COPY_SYMTAB)
    293 SYSTEM_LD_TAIL_STAGE2+=	&& runit ${DBSYM} $@
    294 .if !empty(DEBUG:M-g)
    295 SYSTEM_LD_TAIL_STAGE2+=	&& runit ${DBSYM} $@.gdb
    296 .endif
    297 .endif
    298 SYSTEM_LD_TAIL_STAGE2+=	${SYSTEM_LD_TAIL_EXTRA}
    299 
    300 ##
    301 ## (6) port independent targets and dependencies: assym.h, vers.o
    302 ##
    303 
    304 .if !defined(___USE_SUFFIX_RULES___)
    305 
    306 # Generate list of *.o files to pass to ${LD}, preserving order.
    307 #	x/y/z/a.[csS] -> a.[csS]
    308 #	a.[csS] -> a.o
    309 OBJS=	${ALLFILES:C|^.*/([^/]*\.[csS])$|\1|:C|^(.*)\.[csS]$|\1.o|}
    310 
    311 CFILES=	${ALLFILES:M*.c}
    312 SFILES=	${ALLFILES:M*.[sS]}
    313 OFILES=	${ALLFILES:M*.o}
    314 # absolute, generated (build directory), relative (under $S)
    315 _CFILES=${CFILES:M/*} ${CFILES:N/*:N*/*} ${CFILES:N/*:M*/*:C|^|$S/|}
    316 _SFILES=${SFILES:M/*} ${SFILES:N/*:N*/*} ${SFILES:N/*:M*/*:C|^|$S/|}
    317 _MD_CFILES=${MD_CFILES}
    318 _MD_SFILES=${MD_SFILES}
    319 CSRCS=	${_MD_CFILES} ${_CFILES}
    320 SSRCS=	${_MD_SFILES} ${_SFILES}
    321 SRCS=	${CSRCS} ${SSRCS}
    322 
    323 .else # ___USE_SUFFIX_RULES___
    324 OBJS=	${ALLFILES:C|\.[csS]$|.o|}
    325 SRCS=	${ALLFILES:M*.[csS]}
    326 .endif # ___USE_SUFFIX_RULES___
    327 
    328 .if !defined(___USE_SUFFIX_RULES___)
    329 .for _s in ${_CFILES}
    330 .if !commands(${_s:T:R}.o)
    331 ${_s:T:R}.o: ${_s}
    332 	${NORMAL_C}
    333 .endif
    334 .endfor
    335 
    336 .for _s in ${_SFILES}
    337 .if !commands(${_s:T:R}.o)
    338 ${_s:T:R}.o: ${_s}
    339 	${NORMAL_S}
    340 .endif
    341 .endfor
    342 .endif # !___USE_SUFFIX_RULES___
    343 
    344 .include "${S}/conf/ldscript.mk"
    345 .include "${S}/conf/assym.mk"
    346 .include "${S}/conf/newvers.mk"
    347 .include "${S}/dev/splash/splash.mk"
    348 .include "${S}/conf/mdroot.mk"
    349 .include "${S}/conf/lint.mk"
    350 .include "${S}/conf/cscope.mk"
    351 .include "${S}/conf/gdbinit.mk"
    352 .include "${S}/conf/ssp.mk"
    353 .if "${_SKIP_DTS}" != "yes"
    354 .include "${S}/conf/dts.mk"
    355 .endif
    356 .include "${S}/conf/copts.mk"
    357 
    358 ##
    359 ## (7) misc targets: install, clean(dir), depend(all), lint, links, tags,
    360 ##                   cscope, mkid
    361 ##
    362 ## Any ports that have other stuff to be cleaned up should fill in
    363 ## EXTRA_CLEAN.  Some ports may want different settings for
    364 ## KERNLINTFLAGS, MKDEP_CFLAGS, or MKDEP_AFLAGS.
    365 ##
    366 
    367 ##
    368 ## clean
    369 ##
    370 
    371 .if !target(__CLEANKERNEL)
    372 __CLEANKERNEL: .USE
    373 	${_MKMSG} "${.TARGET}ing the kernel objects"
    374 	rm -f ${KERNELS} *.map *.[io] *.ko *.ln [a-z]*.s *.su vers.c \
    375 	    eddep tags [Ee]rrs linterrs makelinks assym.h.tmp assym.h \
    376 	    ${EXTRA_KERNELS} ${EXTRA_CLEAN}
    377 .endif
    378 
    379 .if !target(kernelnames)
    380 kernelnames:
    381 	@echo "${KERNELS} ${EXTRA_KERNELS}"
    382 .endif
    383 
    384 .if !target(__CLEANDEPEND)
    385 __CLEANDEPEND: .USE
    386 	echo .depend ${DEPS} | xargs rm -f --
    387 .endif
    388 
    389 # do not !target these, the kern and compat Makefiles augment them
    390 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
    391 clean: __CLEANKERNEL
    392 depend: .depend
    393 dependall: depend .WAIT all
    394 
    395 ##
    396 ## depend
    397 ##
    398 
    399 .if !target(.depend)
    400 MKDEP_AFLAGS?=	${AFLAGS}
    401 MKDEP_CFLAGS?=	${CFLAGS}
    402 .if !defined(___USE_SUFFIX_RULES___)
    403 DEPS+=	${SRCS:T:R:S/$/.d/g}
    404 .else
    405 DEPS+=	${SRCS:R:S/$/.d/g}
    406 .endif
    407 
    408 .if !defined(___USE_SUFFIX_RULES___)
    409 .for _s in ${SSRCS}
    410 .if !commands(${_s:T:R}.d)
    411 ${_s:T:R}.d: ${_s}
    412 	${_MKTARGET_CREATE}
    413 	${MKDEP} -f ${.TARGET}.tmp -- ${MKDEP_AFLAGS} \
    414 	    ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
    415 	mv -f ${.TARGET}.tmp ${.TARGET}
    416 .endif
    417 .endfor
    418 
    419 .for _s in ${CSRCS}
    420 .if !commands(${_s:T:R}.d)
    421 ${_s:T:R}.d: ${_s}
    422 	${_MKTARGET_CREATE}
    423 	${MKDEP} -f ${.TARGET}.tmp -- ${MKDEP_CFLAGS} \
    424 	    ${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
    425 	mv -f ${.TARGET}.tmp ${.TARGET}
    426 .endif
    427 .endfor
    428 .endif # !___USE_SUFFIX_RULES___
    429 
    430 .depend: ${DEPS:O}
    431 	${_MKTARGET_CREATE}
    432 	echo "${.ALLSRC}" | ${MKDEP} -D
    433 .endif
    434 
    435 ##
    436 ## install
    437 ##
    438 
    439 # List of kernel images that will be installed into the root file system.
    440 # Some platforms may need to install more than one (e.g. a netbsd.aout file
    441 # to be loaded directly by the firmware), so this can be overridden by them.
    442 KERNIMAGES?=	netbsd
    443 
    444 .if !target(install)
    445 # The install target can be redefined by putting a
    446 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
    447 MACHINE_NAME!=  uname -n
    448 install: install-kernel-${MACHINE_NAME}
    449 .if !target(install-kernel-${MACHINE_NAME})
    450 install-kernel-${MACHINE_NAME}:
    451 .for _K in ${KERNIMAGES}
    452 .if ${KERNEL_DIR:Uno} == "yes"
    453 	rm -fr ${DESTDIR}/o${_K}
    454 	mv ${DESTDIR}/${_K} ${DESTDIR}/o${_K}
    455 	mkdir -p ${DESTDIR}/${_K}
    456 	cp ${_K} ${DESTDIR}/${_K}/kernel
    457 .else
    458 	rm -f ${DESTDIR}/o${_K}
    459 	ln ${DESTDIR}/${_K} ${DESTDIR}/o${_K}
    460 	cp ${_K} ${DESTDIR}/n${_K}
    461 	mv ${DESTDIR}/n${_K} ${DESTDIR}/${_K}
    462 .endif
    463 .endfor
    464 .endif
    465 .endif
    466 
    467 ##
    468 ## the kernel
    469 ##
    470 
    471 AFLAGS+=	${AOPTS.${.IMPSRC:T}}
    472 CFLAGS+=	${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}}
    473 CPPFLAGS+=	${CPPFLAGS.${.IMPSRC:T}}
    474 CWARNFLAGS+=	${CWARNFLAGS.${.IMPSRC:T}}
    475 
    476 .for _v in COPTS CPPFLAGS CWARNFLAGS
    477 .for _c in ${CSRCS}
    478 ${_v}.${_c:T}+=${OPT.${_c:T}:@.o.@${${_v}.${.o.}}@}
    479 .endfor
    480 .endfor
    481 
    482 .MAIN: all
    483 all: .gdbinit
    484 .for k in ${KERNELS}
    485 all: .WAIT ${k}
    486 ${k}: ${SYSTEM_DEP:O} swap${k}.o vers.o build_kernel #${MKLINT:Myes:%=lint}
    487 .endfor
    488 
    489 .if !defined(COPY_SYMTAB)
    490 build_kernel: .USE
    491 	${SYSTEM_LD_HEAD}
    492 	${SYSTEM_LD}
    493 	${SYSTEM_LD_TAIL_STAGE2}
    494 .else
    495 .for k in ${KERNELS}
    496 ${k}: $S/kern/kern_ksyms_buf.c
    497 .endfor
    498 build_kernel: .USE
    499 	${CC} ${CFLAGS} ${CPPFLAGS} \
    500 	    -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf.o
    501 	${SYSTEM_LD_HEAD}
    502 	${SYSTEM_LD} kern_ksyms_buf.o
    503 	${SYSTEM_LD_TAIL_STAGE1}
    504 	${CC} ${CFLAGS} ${CPPFLAGS} \
    505 	    -DSYMTAB_SPACE=$$(${DBSYM} -P ${.TARGET}${TARGETSFX}) \
    506 	    -c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf_real.o
    507 	${SYSTEM_LD_HEAD}
    508 	${SYSTEM_LD} kern_ksyms_buf_real.o
    509 	${SYSTEM_LD_TAIL_STAGE2}
    510 .endif
    511 
    512 .include <bsd.files.mk>
    513 .include <bsd.clang-analyze.mk>
    514 
    515 ##
    516 ## suffix rules
    517 ##
    518 
    519 .if defined(___USE_SUFFIX_RULES___)
    520 .SUFFIXES: .s .d
    521 .s.d:
    522 	${_MKTARGET_CREATE}
    523 	${MKDEP} -f $@.tmp -- ${MKDEP_AFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $<
    524 	mv -f $@.tmp $@
    525 
    526 .SUFFIXES: .S .d
    527 .S.d:
    528 	${_MKTARGET_CREATE}
    529 	${MKDEP} -f $@.tmp -- ${MKDEP_AFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $<
    530 	mv -f $@.tmp $@
    531 
    532 .SUFFIXES: .c .d
    533 .c.d:
    534 	${_MKTARGET_CREATE}
    535 	${MKDEP} -f $@.tmp -- ${MKDEP_CFLAGS} ${CPPFLAGS} ${CPPFLAGS.${<:T}} $<
    536 	mv -f $@.tmp $@
    537 
    538 .SUFFIXES: .c .o .go .po
    539 .c.o:
    540 	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}"
    541 	@${_MKSHECHO} ${KCOMPILE.c}
    542 	@${KCOMPILE.c}
    543 	@${COMPILE_CTFCONVERT}
    544 .c.go:
    545 	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}"
    546 	@${_MKSHECHO} ${KCOMPILE.c} -g
    547 	@${KCOMPILE.c} -g
    548 	@${COMPILE_CTFCONVERT}
    549 .c.po:
    550 	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}"
    551 	@${_MKSHECHO} ${KCOMPILE.c} -pg
    552 	@${KCOMPILE.c} -pg
    553 	@${COMPILE_CTFCONVERT}
    554 
    555 .SUFFIXES: .s .o .go .po
    556 .s.o:
    557 	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}"
    558 	@${_MKSHECHO} ${KCOMPILE.s}
    559 	@${KCOMPILE.s}
    560 .s.go:
    561 	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}"
    562 	@${_MKSHECHO} ${KCOMPILE.s} -g
    563 	@${KCOMPILE.s} -g
    564 .s.po:
    565 	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}"
    566 	@${_MKSHECHO} ${KCOMPILE.s} -pg
    567 	@${KCOMPILE.s} -pg
    568 
    569 .S.o:
    570 	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}"
    571 	@${_MKSHECHO} ${KCOMPILE.s}
    572 	@${KCOMPILE.s}
    573 .S.go:
    574 	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}"
    575 	@${_MKSHECHO} ${KCOMPILE.s} -g
    576 	@${KCOMPILE.s} -g
    577 .S.po:
    578 	@${_MKSHMSG} "compile  ${.CURDIR:T}/${.TARGET}"
    579 	@${_MKSHECHO} ${KCOMPILE.s} -pg
    580 	@${KCOMPILE.s} -pg
    581 .endif # ___USE_SUFFIX_RULES___
    582 
    583 ##
    584 ## the end
    585 ##
    586