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