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