2014-09-05 10:52:12 +04:00
|
|
|
# $NetBSD: Makefile.kern.inc,v 1.173 2014/09/05 06:52:12 matt Exp $
|
2001-11-16 03:23:02 +03:00
|
|
|
#
|
|
|
|
# This file contains common `MI' targets and definitions and it is included
|
2002-12-10 22:33:11 +03:00
|
|
|
# at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
|
2001-11-16 03:23:02 +03:00
|
|
|
#
|
|
|
|
# Each target in this file should be protected with `if !target(target)'
|
|
|
|
# or `if !commands(target)' and each variable should only be conditionally
|
|
|
|
# assigned `VAR ?= VALUE', so that everything can be overriden.
|
|
|
|
#
|
|
|
|
# DEBUG is set to -g if debugging.
|
|
|
|
# PROF is set to -pg if profiling.
|
|
|
|
#
|
2005-02-27 01:58:54 +03:00
|
|
|
# To specify debugging, add the config line: makeoptions DEBUG="-g"
|
2001-11-16 03:23:02 +03:00
|
|
|
# A better way is to specify -g only for a few files.
|
|
|
|
#
|
|
|
|
# makeoptions DEBUGLIST="uvm* trap if_*"
|
|
|
|
#
|
|
|
|
# all ports are expected to include bsd.own.mk for toolchain settings
|
|
|
|
|
2014-05-05 23:06:29 +04:00
|
|
|
# Default DEBUG to -g if kernel debug info is requested by MKKDEBUG=yes
|
|
|
|
.if defined(MKKDEBUG) && ${MKKDEBUG} == "yes"
|
|
|
|
DEBUG?=-g
|
|
|
|
.endif
|
|
|
|
|
2001-11-16 19:15:08 +03:00
|
|
|
##
|
|
|
|
## (0) toolchain settings for things that aren't part of the standard
|
|
|
|
## toolchain
|
|
|
|
##
|
2003-11-17 12:39:29 +03:00
|
|
|
HOST_SH?= sh
|
2002-05-29 20:12:54 +04:00
|
|
|
DBSYM?= dbsym
|
2001-11-16 19:15:08 +03:00
|
|
|
MKDEP?= mkdep
|
|
|
|
STRIP?= strip
|
|
|
|
OBJCOPY?= objcopy
|
|
|
|
OBJDUMP?= objdump
|
2002-06-18 00:31:26 +04:00
|
|
|
CSCOPE?= cscope
|
|
|
|
MKID?= mkid
|
2004-07-15 07:35:20 +04:00
|
|
|
UUDECODE?= ${TOOL_UUDECODE:Uuudecode}
|
2005-05-31 08:03:46 +04:00
|
|
|
HEXDUMP?= ${TOOL_HEXDUMP:Uhexdump}
|
|
|
|
GENASSYM?= ${TOOL_GENASSYM:Ugenassym}
|
2002-03-18 18:20:08 +03:00
|
|
|
.MAKEOVERRIDES+=USETOOLS # make sure proper value is propagated
|
2001-11-16 19:15:08 +03:00
|
|
|
|
2003-11-20 10:08:02 +03:00
|
|
|
_MKMSG?= @\#
|
2003-11-25 12:15:50 +03:00
|
|
|
_MKSHMSG?= echo
|
|
|
|
_MKSHECHO?= echo
|
2012-03-25 13:15:20 +04:00
|
|
|
_MKSHNOECHO= :
|
2003-11-20 10:08:02 +03:00
|
|
|
_MKMSG_CREATE?= :
|
|
|
|
_MKTARGET_COMPILE?= :
|
|
|
|
_MKTARGET_CREATE?= :
|
|
|
|
|
2001-11-16 03:23:02 +03:00
|
|
|
##
|
|
|
|
## (1) port independent source tree identification
|
|
|
|
##
|
|
|
|
# source tree is located via $S relative to the compilation directory
|
|
|
|
.ifndef S
|
|
|
|
S!= cd ../../../..; pwd
|
|
|
|
.endif
|
|
|
|
|
|
|
|
##
|
|
|
|
## (2) compile settings
|
|
|
|
##
|
|
|
|
## CPPFLAGS, CFLAGS, and AFLAGS must be set in the port's Makefile
|
|
|
|
##
|
2006-04-28 07:40:15 +04:00
|
|
|
INCLUDES?= -I. ${EXTRA_INCLUDES} -I${S}/../common/include -I$S/arch \
|
2013-10-18 12:06:06 +04:00
|
|
|
-I$S -nostdinc
|
2001-11-23 08:18:59 +03:00
|
|
|
CPPFLAGS+= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT
|
2011-01-02 22:24:47 +03:00
|
|
|
CPPFLAGS+= -std=gnu99
|
2001-11-23 08:18:59 +03:00
|
|
|
DEFCOPTS?= -O2
|
2002-10-06 04:07:17 +04:00
|
|
|
COPTS?= ${DEFCOPTS}
|
2001-12-08 18:01:41 +03:00
|
|
|
DBG= # might contain unwanted -Ofoo
|
|
|
|
DEFWARNINGS?= yes
|
|
|
|
.if (${DEFWARNINGS} == "yes")
|
2003-10-02 03:11:29 +04:00
|
|
|
CWARNFLAGS+= -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith
|
2001-12-08 18:01:41 +03:00
|
|
|
CWARNFLAGS+= -Wmissing-prototypes -Wstrict-prototypes
|
2012-02-12 20:34:06 +04:00
|
|
|
CWARNFLAGS+= -Wold-style-definition
|
2005-06-19 02:56:02 +04:00
|
|
|
CWARNFLAGS+= -Wswitch -Wshadow
|
2005-05-31 06:25:39 +04:00
|
|
|
CWARNFLAGS+= -Wcast-qual -Wwrite-strings
|
2008-06-21 05:00:43 +04:00
|
|
|
CWARNFLAGS+= -Wno-unreachable-code
|
2014-09-05 10:52:12 +04:00
|
|
|
#CWARNFLAGS+= -Wc++-compat -Wno-error=c++-compat
|
2006-05-21 09:49:54 +04:00
|
|
|
CWARNFLAGS+= -Wno-pointer-sign -Wno-attributes
|
2008-09-05 17:37:24 +04:00
|
|
|
. if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64" || \
|
|
|
|
${MACHINE_ARCH} == "sparc64" || ${MACHINE} == "prep"
|
2006-10-17 18:28:46 +04:00
|
|
|
CWARNFLAGS+= -Wextra -Wno-unused-parameter
|
2006-10-04 20:03:01 +04:00
|
|
|
. endif
|
2012-02-04 03:39:26 +04:00
|
|
|
. if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64"
|
|
|
|
CWARNFLAGS+= -Wold-style-definition
|
|
|
|
. endif
|
2011-05-23 17:55:55 +04:00
|
|
|
# Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3,
|
|
|
|
# but our sources aren't up for it yet.
|
|
|
|
CWARNFLAGS+= -Wno-sign-compare
|
2001-12-08 18:01:41 +03:00
|
|
|
.endif
|
2003-11-06 11:23:22 +03:00
|
|
|
|
2011-05-26 16:56:24 +04:00
|
|
|
CWARNFLAGS.clang+= -Wno-unknown-pragmas -Wno-conversion \
|
2011-08-09 17:02:53 +04:00
|
|
|
-Wno-self-assign
|
2011-05-26 16:56:24 +04:00
|
|
|
|
2011-12-19 18:06:16 +04:00
|
|
|
CWARNFLAGS.ah_regdomain.c= ${${ACTIVE_CC} == "clang":? \
|
|
|
|
-Wno-shift-count-negative -Wno-shift-count-overflow:}
|
|
|
|
|
2013-09-22 02:28:12 +04:00
|
|
|
CWARNFLAGS.ioconf.c= ${${ACTIVE_CC} == "clang":? -Wno-unused-const-variable :}
|
|
|
|
|
2006-06-03 02:16:18 +04:00
|
|
|
CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss
|
2008-09-05 15:03:53 +04:00
|
|
|
CFLAGS+= ${DEBUG} ${COPTS}
|
2011-05-20 01:24:55 +04:00
|
|
|
AFLAGS+= -D_LOCORE -Wa,--fatal-warnings
|
2004-04-25 08:24:06 +04:00
|
|
|
|
2006-05-11 21:21:38 +04:00
|
|
|
# XXX
|
2012-08-10 20:05:26 +04:00
|
|
|
.if defined(HAVE_GCC) || defined(HAVE_LLVM)
|
2006-05-11 21:21:38 +04:00
|
|
|
CFLAGS+= -fno-strict-aliasing
|
2012-07-27 09:40:51 +04:00
|
|
|
CFLAGS+= -fno-common
|
2006-05-11 21:21:38 +04:00
|
|
|
.endif
|
|
|
|
|
2007-10-09 01:25:35 +04:00
|
|
|
.if ${USE_SSP:Uno} == "yes"
|
2009-02-12 21:24:18 +03:00
|
|
|
COPTS.kern_ssp.c+= -fno-stack-protector -D__SSP__
|
2006-11-11 05:12:53 +03:00
|
|
|
.endif
|
|
|
|
|
2011-09-01 00:16:43 +04:00
|
|
|
# for multi-cpu machines, cpu_hatch() straddles the init of
|
|
|
|
# __stack_chk_guard, so ensure stack protection is disabled
|
|
|
|
.if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "x86_64"
|
|
|
|
COPTS.cpu.c+= -fno-stack-protector
|
|
|
|
.endif
|
|
|
|
|
2003-11-17 12:39:29 +03:00
|
|
|
# Use the per-source COPTS variables to add -g to just those
|
2001-11-16 03:23:02 +03:00
|
|
|
# files that match the shell patterns given in ${DEBUGLIST}
|
|
|
|
#
|
|
|
|
.for i in ${DEBUGLIST}
|
2006-10-04 20:03:01 +04:00
|
|
|
. for j in ${CFILES:T:M$i.c}
|
2003-11-17 12:39:29 +03:00
|
|
|
COPTS.${j}+=-g
|
2006-10-04 20:03:01 +04:00
|
|
|
. endfor
|
2001-11-16 03:23:02 +03:00
|
|
|
.endfor
|
|
|
|
|
2011-04-30 23:21:09 +04:00
|
|
|
# Always compile debugsyms.c with debug information.
|
2008-01-17 23:14:49 +03:00
|
|
|
# This allows gdb to use type informations.
|
|
|
|
#
|
|
|
|
COPTS.debugsyms.c+= -g
|
|
|
|
|
DTrace: Add an SDT (Statically Defined Tracing) provider framework, and
implement most of the proc provider. Adds proc:::create, exec,
exec_success, exec_faillure, signal_send, signal_discard, signal_handle,
lwp_create, lwp_start, lwp_exit.
2010-03-02 00:10:13 +03:00
|
|
|
# Add CTF sections for DTrace
|
|
|
|
.if defined(CTFCONVERT)
|
|
|
|
COMPILE_CTFCONVERT= ${_MKSHECHO}\
|
2010-03-06 02:06:49 +03:00
|
|
|
${CTFCONVERT} ${CTFFLAGS} ${.TARGET} && \
|
DTrace: Add an SDT (Statically Defined Tracing) provider framework, and
implement most of the proc provider. Adds proc:::create, exec,
exec_success, exec_faillure, signal_send, signal_discard, signal_handle,
lwp_create, lwp_start, lwp_exit.
2010-03-02 00:10:13 +03:00
|
|
|
${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
|
|
|
|
.else
|
2012-03-25 13:15:20 +04:00
|
|
|
COMPILE_CTFCONVERT= ${_MKSHNOECHO}
|
DTrace: Add an SDT (Statically Defined Tracing) provider framework, and
implement most of the proc provider. Adds proc:::create, exec,
exec_success, exec_faillure, signal_send, signal_discard, signal_handle,
lwp_create, lwp_start, lwp_exit.
2010-03-02 00:10:13 +03:00
|
|
|
.endif
|
|
|
|
|
2001-11-16 03:23:02 +03:00
|
|
|
# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
|
|
|
|
# NOPROF and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
|
2010-03-06 02:06:49 +03:00
|
|
|
NORMAL_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKSHECHO}\
|
2011-05-17 11:16:02 +04:00
|
|
|
${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< && \
|
|
|
|
${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< && \
|
DTrace: Add an SDT (Statically Defined Tracing) provider framework, and
implement most of the proc provider. Adds proc:::create, exec,
exec_success, exec_faillure, signal_send, signal_discard, signal_handle,
lwp_create, lwp_start, lwp_exit.
2010-03-02 00:10:13 +03:00
|
|
|
${COMPILE_CTFCONVERT}
|
2010-03-06 02:06:49 +03:00
|
|
|
NOPROF_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKSHECHO}\
|
2011-05-17 11:16:02 +04:00
|
|
|
${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< && \
|
|
|
|
${CC} ${COPTS.${<:T}} ${CFLAGS} ${CPPFLAGS} -c $< && \
|
DTrace: Add an SDT (Statically Defined Tracing) provider framework, and
implement most of the proc provider. Adds proc:::create, exec,
exec_success, exec_faillure, signal_send, signal_discard, signal_handle,
lwp_create, lwp_start, lwp_exit.
2010-03-02 00:10:13 +03:00
|
|
|
${COMPILE_CTFCONVERT}
|
2010-03-06 02:06:49 +03:00
|
|
|
NORMAL_S?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}" && \
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKSHECHO}\
|
2011-05-17 11:16:02 +04:00
|
|
|
${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $< && \
|
|
|
|
${CC} ${AFLAGS} ${AFLAGS.${<:T}} ${CPPFLAGS} -c $<
|
2001-11-16 03:23:02 +03:00
|
|
|
|
|
|
|
##
|
2005-02-27 01:58:54 +03:00
|
|
|
## (3) libkern and compat
|
2001-11-16 03:23:02 +03:00
|
|
|
##
|
|
|
|
## Set KERN_AS in the port Makefile to "obj" or "library". The
|
|
|
|
## default is "library", as documented in $S/lib/libkern/Makefile.inc.
|
|
|
|
##
|
|
|
|
|
|
|
|
### find out what to use for libkern
|
|
|
|
.include "$S/lib/libkern/Makefile.inc"
|
|
|
|
.ifndef PROF
|
|
|
|
LIBKERN?= ${KERNLIB}
|
|
|
|
.else
|
|
|
|
LIBKERN?= ${KERNLIB_PROF}
|
|
|
|
.endif
|
|
|
|
|
2002-11-02 10:57:05 +03:00
|
|
|
LIBKERNLN?= ${KERNLIBLN}
|
|
|
|
|
2001-11-16 03:23:02 +03:00
|
|
|
### find out what to use for libcompat
|
|
|
|
.include "$S/compat/common/Makefile.inc"
|
|
|
|
.ifndef PROF
|
2004-07-31 04:55:51 +04:00
|
|
|
SYSLIBCOMPAT?= ${COMPATLIB}
|
2001-11-16 03:23:02 +03:00
|
|
|
.else
|
2004-07-31 04:55:51 +04:00
|
|
|
SYSLIBCOMPAT?= ${COMPATLIB_PROF}
|
2001-11-16 03:23:02 +03:00
|
|
|
.endif
|
|
|
|
|
2004-07-31 04:55:51 +04:00
|
|
|
SYSLIBCOMPATLN?= ${COMPATLIBLN}
|
2002-11-02 10:57:05 +03:00
|
|
|
|
2001-11-16 03:23:02 +03:00
|
|
|
##
|
|
|
|
## (4) local objects, compile rules, and dependencies
|
|
|
|
##
|
|
|
|
## Each port should have a corresponding section with settings for
|
|
|
|
## MD_CFILES, MD_SFILES, and MD_OBJS, along with build rules for same.
|
|
|
|
##
|
2002-09-06 17:18:43 +04:00
|
|
|
MI_CFILES=devsw.c ioconf.c param.c
|
2001-11-16 03:23:02 +03:00
|
|
|
# the need for a MI_SFILES variable is dubitable at best
|
|
|
|
MI_OBJS=${MI_CFILES:S/.c/.o/}
|
|
|
|
|
|
|
|
param.c: $S/conf/param.c
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKTARGET_CREATE}
|
2001-11-16 03:23:02 +03:00
|
|
|
rm -f param.c
|
|
|
|
cp $S/conf/param.c .
|
|
|
|
|
|
|
|
param.o: Makefile
|
|
|
|
|
|
|
|
.for _cfile in ${MI_CFILES}
|
|
|
|
${_cfile:T:R}.o: ${_cfile}
|
|
|
|
${NORMAL_C}
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
##
|
|
|
|
## (5) link settings
|
|
|
|
##
|
|
|
|
## TEXTADDR (or LOADADDRESS), LINKFORMAT, and any EXTRA_LINKFLAGS must
|
|
|
|
## be set in the port's Makefile. The port specific definitions for
|
|
|
|
## LINKFLAGS_NORMAL and LINKFLAGS_DEBUG will added to the LINKFLAGS
|
|
|
|
## depending on the value of DEBUG.
|
|
|
|
##
|
|
|
|
# load lines for config "xxx" will be emitted as:
|
2014-08-18 01:17:43 +04:00
|
|
|
# xxx: ${SYSTEM_DEP} swapxxxx.o vers.o build_kernel
|
|
|
|
|
2008-11-13 09:48:38 +03:00
|
|
|
SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS:O} ${SYSLIBCOMPAT} ${LIBKERN}
|
2013-07-17 18:05:43 +04:00
|
|
|
SYSTEM_DEP+= Makefile ${SYSTEM_OBJ:O} .gdbinit
|
2011-01-04 04:52:30 +03:00
|
|
|
.if defined(KERNLDSCRIPT)
|
|
|
|
SYSTEM_DEP+= ${KERNLDSCRIPT}
|
|
|
|
.endif
|
DTrace: Add an SDT (Statically Defined Tracing) provider framework, and
implement most of the proc provider. Adds proc:::create, exec,
exec_success, exec_faillure, signal_send, signal_discard, signal_handle,
lwp_create, lwp_start, lwp_exit.
2010-03-02 00:10:13 +03:00
|
|
|
.if defined(CTFMERGE)
|
2014-03-10 06:04:29 +04:00
|
|
|
SYSTEM_CTFMERGE= ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
|
DTrace: Add an SDT (Statically Defined Tracing) provider framework, and
implement most of the proc provider. Adds proc:::create, exec,
exec_success, exec_faillure, signal_send, signal_discard, signal_handle,
lwp_create, lwp_start, lwp_exit.
2010-03-02 00:10:13 +03:00
|
|
|
.else
|
|
|
|
SYSTEM_CTFMERGE= ${_MKSHECHO}
|
|
|
|
.endif
|
2003-11-17 12:39:29 +03:00
|
|
|
SYSTEM_LD_HEAD?=@rm -f $@
|
2003-12-01 04:12:58 +03:00
|
|
|
SYSTEM_LD?= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKSHECHO}\
|
2006-08-25 01:23:40 +04:00
|
|
|
${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o; \
|
|
|
|
${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o
|
2012-03-19 09:38:26 +04:00
|
|
|
|
2001-11-16 03:23:02 +03:00
|
|
|
TEXTADDR?= ${LOADADDRESS} # backwards compatibility
|
2001-11-28 02:28:42 +03:00
|
|
|
LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/}
|
|
|
|
LINKDATA?= ${DATAADDR:C/.+/-Tdata &/}
|
2001-11-16 03:23:02 +03:00
|
|
|
ENTRYPOINT?= start
|
2001-11-28 06:58:25 +03:00
|
|
|
LINKENTRY?= ${ENTRYPOINT:C/.+/-e &/}
|
2001-11-16 03:23:02 +03:00
|
|
|
LINKFLAGS?= ${LINKFORMAT} ${LINKTEXT} ${LINKDATA} ${LINKENTRY} \
|
|
|
|
${EXTRA_LINKFLAGS}
|
|
|
|
|
2001-11-23 08:18:59 +03:00
|
|
|
LINKFLAGS_DEBUG?= -X
|
2013-08-09 13:08:47 +04:00
|
|
|
|
2014-08-18 01:17:43 +04:00
|
|
|
SYSTEM_LD_TAIL?=@${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/\\.*//' vers.c; \
|
2013-08-09 13:08:47 +04:00
|
|
|
${SIZE} $@; chmod 755 $@; \
|
|
|
|
${SYSTEM_CTFMERGE}
|
2001-11-16 03:23:02 +03:00
|
|
|
SYSTEM_LD_TAIL_DEBUG?=; \
|
|
|
|
echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
|
|
|
|
echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
|
|
|
|
${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
|
2001-11-23 08:18:59 +03:00
|
|
|
LINKFLAGS_NORMAL?= -S
|
2001-11-16 03:23:02 +03:00
|
|
|
STRIPFLAGS?= -g
|
|
|
|
|
|
|
|
DEBUG?=
|
2005-05-24 02:01:11 +04:00
|
|
|
.if !empty(DEBUG:M-g*)
|
2001-11-16 03:23:02 +03:00
|
|
|
SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_DEBUG}
|
|
|
|
LINKFLAGS+= ${LINKFLAGS_DEBUG}
|
2001-12-08 18:01:41 +03:00
|
|
|
EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gdb@}
|
DTrace: Add an SDT (Statically Defined Tracing) provider framework, and
implement most of the proc provider. Adds proc:::create, exec,
exec_success, exec_faillure, signal_send, signal_discard, signal_handle,
lwp_create, lwp_start, lwp_exit.
2010-03-02 00:10:13 +03:00
|
|
|
CTFFLAGS+= -g
|
2001-12-10 08:24:17 +03:00
|
|
|
.elifndef PROF
|
2001-11-16 03:23:02 +03:00
|
|
|
LINKFLAGS+= ${LINKFLAGS_NORMAL}
|
|
|
|
.endif
|
|
|
|
|
2004-09-13 13:39:40 +04:00
|
|
|
SYSTEM_LD_HEAD+=${SYSTEM_LD_HEAD_EXTRA}
|
2014-08-18 01:17:43 +04:00
|
|
|
SYSTEM_LD_TAIL_STAGE1= ${SYSTEM_LD_TAIL}
|
|
|
|
SYSTEM_LD_TAIL_STAGE2= ${SYSTEM_LD_TAIL}
|
2014-08-21 02:02:20 +04:00
|
|
|
.if defined(COPY_SYMTAB)
|
2014-08-18 01:17:43 +04:00
|
|
|
SYSTEM_LD_TAIL_STAGE2+= ; echo ${DBSYM} $@; ${DBSYM} $@
|
2013-08-09 13:08:47 +04:00
|
|
|
.endif
|
2014-08-18 01:17:43 +04:00
|
|
|
SYSTEM_LD_TAIL_STAGE2+= ${SYSTEM_LD_TAIL_EXTRA}
|
2001-11-28 02:28:42 +03:00
|
|
|
|
2001-11-16 03:23:02 +03:00
|
|
|
##
|
2001-12-09 19:04:03 +03:00
|
|
|
## (6) port independent targets and dependencies: assym.h, vers.o
|
2001-11-16 03:23:02 +03:00
|
|
|
##
|
|
|
|
.if !target(assym.h)
|
2005-05-31 08:03:46 +04:00
|
|
|
assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS}
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKTARGET_CREATE}
|
2005-05-31 08:03:46 +04:00
|
|
|
cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} | \
|
2012-03-25 10:55:19 +04:00
|
|
|
${GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \
|
2014-03-04 18:58:14 +04:00
|
|
|
${GENASSYM_CPPFLAGS} > assym.h.tmp && \
|
2001-11-16 03:23:02 +03:00
|
|
|
mv -f assym.h.tmp assym.h
|
2002-02-11 06:43:53 +03:00
|
|
|
${MD_SFILES:C/\.[Ss]/.o/} ${SFILES:C/\.[Ss]/.o/}: assym.h
|
2001-11-16 03:23:02 +03:00
|
|
|
.endif
|
|
|
|
|
2009-03-30 20:34:19 +04:00
|
|
|
MKREPRO?=no
|
|
|
|
|
|
|
|
.if ${MKREPRO} == "yes"
|
2011-08-12 02:37:57 +04:00
|
|
|
_NVFLAGS=${NVFLAGS} -r
|
2009-03-30 20:34:19 +04:00
|
|
|
.else
|
2011-08-12 02:37:57 +04:00
|
|
|
_NVFLAGS=${NVFLAGS}
|
2009-03-30 20:34:19 +04:00
|
|
|
.endif
|
|
|
|
|
2001-12-09 19:04:03 +03:00
|
|
|
.if !target(vers.o)
|
|
|
|
newvers: vers.o
|
2012-11-04 15:12:31 +04:00
|
|
|
vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} $S/conf/newvers.sh \
|
|
|
|
$S/conf/osrelease.sh ${_NETBSD_VERSION_DEPENDS}
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKMSG_CREATE} vers.c
|
2009-03-30 20:34:19 +04:00
|
|
|
${HOST_SH} $S/conf/newvers.sh ${_NVFLAGS}
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKTARGET_COMPILE}
|
2001-11-16 03:23:02 +03:00
|
|
|
${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
|
2014-03-10 06:36:50 +04:00
|
|
|
${COMPILE_CTFCONVERT}
|
2001-11-16 03:23:02 +03:00
|
|
|
.endif
|
|
|
|
|
2003-03-07 04:26:12 +03:00
|
|
|
.if defined(MEMORY_DISK_IMAGE)
|
|
|
|
md_root_image.h: ${MEMORY_DISK_IMAGE}
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKTARGET_CREATE}
|
2003-07-10 14:33:58 +04:00
|
|
|
${TOOL_HEXDUMP} -v -e '"\t" 8/1 "0x%02x, " "\n"' ${.ALLSRC} > ${.TARGET}
|
2003-03-07 04:26:12 +03:00
|
|
|
|
|
|
|
# XXX This is only needed when building md_root.o
|
|
|
|
CPPFLAGS+= -DMEMORY_DISK_IMAGE
|
|
|
|
md_root.o: md_root_image.h
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# depend on MEMORY_DISK_IMAGE configuration
|
|
|
|
md_root.o: Makefile
|
|
|
|
|
2001-11-16 03:23:02 +03:00
|
|
|
# depend on root or device configuration
|
|
|
|
autoconf.o conf.o: Makefile
|
|
|
|
|
|
|
|
# depend on network or filesystem configuration
|
|
|
|
uipc_proto.o vfs_conf.o: Makefile
|
|
|
|
|
|
|
|
# depend on maxusers and CPU configuration
|
|
|
|
assym.h machdep.o: Makefile
|
|
|
|
|
|
|
|
##
|
2002-06-18 00:31:26 +04:00
|
|
|
## (7) misc targets: install, clean(dir), depend(all), lint, links, tags,
|
|
|
|
## cscope, mkid
|
2001-11-16 03:23:02 +03:00
|
|
|
##
|
|
|
|
## Any ports that have other stuff to be cleaned up should fill in
|
|
|
|
## EXTRA_CLEAN. Some ports may want different settings for
|
|
|
|
## KERNLINTFLAGS, MKDEP_CFLAGS, or MKDEP_AFLAGS.
|
|
|
|
##
|
|
|
|
.if !target(__CLEANKERNEL)
|
|
|
|
__CLEANKERNEL: .USE
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKMSG} "${.TARGET}ing the kernel objects"
|
2002-11-02 10:57:05 +03:00
|
|
|
rm -f ${KERNELS} eddep tags *.[io] *.ln [a-z]*.s vers.c \
|
2001-11-16 03:23:02 +03:00
|
|
|
[Ee]rrs linterrs makelinks assym.h.tmp assym.h \
|
2001-12-08 18:01:41 +03:00
|
|
|
${EXTRA_KERNELS} ${EXTRA_CLEAN}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !target(kernelnames)
|
|
|
|
kernelnames:
|
|
|
|
@echo "${KERNELS} ${EXTRA_KERNELS}"
|
2001-11-16 03:23:02 +03:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !target(__CLEANDEPEND)
|
|
|
|
__CLEANDEPEND: .USE
|
2005-12-13 01:44:04 +03:00
|
|
|
echo .depend ${DEPS} | xargs rm -f --
|
2001-11-16 03:23:02 +03:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# do not !target these, the kern and compat Makefiles augment them
|
|
|
|
cleandir distclean: __CLEANKERNEL __CLEANDEPEND
|
|
|
|
clean: __CLEANKERNEL
|
|
|
|
depend: .depend
|
2006-10-26 09:10:55 +04:00
|
|
|
dependall: depend .WAIT all
|
2001-11-16 03:23:02 +03:00
|
|
|
|
|
|
|
.if !target(.depend)
|
|
|
|
MKDEP_AFLAGS?= ${AFLAGS}
|
|
|
|
MKDEP_CFLAGS?= ${CFLAGS}
|
2005-11-24 16:01:42 +03:00
|
|
|
SSRCS=${MD_SFILES} ${SFILES}
|
|
|
|
CSRCS=${MD_CFILES} ${MI_CFILES} ${CFILES}
|
|
|
|
SRCS=${SSRCS} ${CSRCS}
|
2006-04-19 11:08:17 +04:00
|
|
|
DEPS= ${SRCS:T:O:u:R:S/$/.d/g}
|
2005-11-24 16:01:42 +03:00
|
|
|
|
|
|
|
.for _s in ${SSRCS}
|
2011-08-29 03:15:53 +04:00
|
|
|
.if !target(${_s:T:R}.d)
|
2008-01-17 04:56:02 +03:00
|
|
|
${_s:T:R}.d: ${_s} assym.h
|
2005-12-13 01:44:04 +03:00
|
|
|
${_MKTARGET_CREATE}
|
|
|
|
${MKDEP} -f ${.TARGET} -- ${MKDEP_AFLAGS} \
|
|
|
|
${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
|
2011-08-29 03:15:53 +04:00
|
|
|
.endif
|
2005-11-24 16:01:42 +03:00
|
|
|
.endfor
|
|
|
|
.for _s in ${CSRCS}
|
2011-08-29 03:15:53 +04:00
|
|
|
.if !target(${_s:T:R}.d)
|
2008-01-17 04:56:02 +03:00
|
|
|
${_s:T:R}.d: ${_s}
|
2005-12-13 01:44:04 +03:00
|
|
|
${_MKTARGET_CREATE}
|
|
|
|
${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \
|
|
|
|
${CPPFLAGS} ${CPPFLAGS.${_s:T}} ${_s}
|
2011-08-29 03:15:53 +04:00
|
|
|
.endif
|
2005-11-24 16:01:42 +03:00
|
|
|
.endfor
|
|
|
|
|
2008-01-17 04:56:02 +03:00
|
|
|
assym.d: assym.h
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKTARGET_CREATE}
|
2005-05-31 08:03:46 +04:00
|
|
|
cat ${GENASSYM_CONF} ${GENASSYM_EXTRAS} | \
|
|
|
|
${GENASSYM} -- ${MKDEP} -f assym.dep -- \
|
2014-03-04 18:58:14 +04:00
|
|
|
${CFLAGS:N-Wa,*} ${CPPFLAGS} ${GENASSYM_CPPFLAGS}
|
2008-10-26 02:27:34 +04:00
|
|
|
${TOOL_SED} -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >${.TARGET}
|
2005-12-13 01:44:04 +03:00
|
|
|
rm -f assym.dep
|
|
|
|
|
2008-02-23 20:43:36 +03:00
|
|
|
DEPS+= assym.d
|
|
|
|
|
|
|
|
.depend: ${DEPS}
|
2005-12-13 01:44:04 +03:00
|
|
|
${_MKTARGET_CREATE}
|
|
|
|
echo "${.ALLSRC}" | ${MKDEP} -D
|
2001-11-16 03:23:02 +03:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !target(lint)
|
|
|
|
ALLSFILES?= ${MD_SFILES} ${SFILES}
|
|
|
|
LINTSTUBS?= ${ALLSFILES:T:R:C/^.*$/LintStub_&.c/g}
|
2002-11-02 10:57:05 +03:00
|
|
|
KERNLINTFLAGS?= -bcehnxzFS
|
|
|
|
NORMAL_LN?= ${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i $<
|
|
|
|
|
|
|
|
_lsrc=${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES}
|
2004-07-31 04:55:51 +04:00
|
|
|
LOBJS?= ${_lsrc:T:S/.c$/.ln/g} ${LIBKERNLN} ${SYSLIBCOMPATLN}
|
2002-11-02 10:57:05 +03:00
|
|
|
|
2001-11-16 03:23:02 +03:00
|
|
|
.for _sfile in ${ALLSFILES}
|
|
|
|
LintStub_${_sfile:T:R}.c: ${_sfile} assym.h
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKTARGET_COMPILE}
|
2001-11-16 03:23:02 +03:00
|
|
|
${CC} -E -C ${AFLAGS} ${CPPFLAGS} ${_sfile} | \
|
2008-10-20 02:05:19 +04:00
|
|
|
${TOOL_AWK} -f $S/kern/genlintstub.awk >${.TARGET}
|
2001-11-16 03:23:02 +03:00
|
|
|
.endfor
|
2002-11-02 10:57:05 +03:00
|
|
|
|
|
|
|
.for _cfile in ${CFILES} ${LINTSTUBS} ${MI_CFILES} ${MD_CFILES}
|
|
|
|
${_cfile:T:R}.ln: ${_cfile}
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKTARGET_COMPILE}
|
2002-11-02 10:57:05 +03:00
|
|
|
${NORMAL_LN}
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
lint: ${LOBJS}
|
|
|
|
${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} ${LOBJS}
|
2001-11-16 03:23:02 +03:00
|
|
|
.endif
|
|
|
|
|
2008-02-03 09:46:29 +03:00
|
|
|
# Attempt to do a syntax-only compile of the entire kernel as one entity.
|
|
|
|
# Alas, bugs in the GCC C frontend prevent this from completely effective
|
|
|
|
# but information can be gleaned from the output.
|
|
|
|
syntax-only: ${CFILES} ${MD_CFILES}
|
|
|
|
${CC} -fsyntax-only -combine ${CFLAGS} ${CPPFLAGS} \
|
|
|
|
${CFILES} ${MD_CFILES}
|
|
|
|
|
2007-03-12 18:09:01 +03:00
|
|
|
# List of kernel images that will be installed into the root file system.
|
|
|
|
# Some platforms may need to install more than one (e.g. a netbsd.aout file
|
|
|
|
# to be loaded directly by the firmware), so this can be overriden by them.
|
|
|
|
KERNIMAGES?= netbsd
|
|
|
|
|
2001-11-16 03:23:02 +03:00
|
|
|
.if !target(install)
|
|
|
|
# The install target can be redefined by putting a
|
|
|
|
# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
|
|
|
|
MACHINE_NAME!= uname -n
|
|
|
|
install: install-kernel-${MACHINE_NAME}
|
2002-11-04 00:12:27 +03:00
|
|
|
.if !target(install-kernel-${MACHINE_NAME})
|
2001-11-16 03:23:02 +03:00
|
|
|
install-kernel-${MACHINE_NAME}:
|
2007-03-12 18:09:01 +03:00
|
|
|
.for _K in ${KERNIMAGES}
|
|
|
|
rm -f ${DESTDIR}/o${_K}
|
|
|
|
ln ${DESTDIR}/${_K} ${DESTDIR}/o${_K}
|
|
|
|
cp ${_K} ${DESTDIR}/n${_K}
|
|
|
|
mv ${DESTDIR}/n${_K} ${DESTDIR}/${_K}
|
|
|
|
.endfor
|
2001-11-16 03:23:02 +03:00
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !target(tags)
|
|
|
|
tags:
|
|
|
|
@echo "see $S/kern/Makefile for tags"
|
|
|
|
.endif
|
|
|
|
|
2004-12-16 03:35:48 +03:00
|
|
|
EXTRA_CLEAN+= cscope.out cscope.tmp
|
2002-06-18 00:31:26 +04:00
|
|
|
.if !target(cscope.out)
|
2002-07-12 21:48:23 +04:00
|
|
|
cscope.out: Makefile depend
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKTARGET_CREATE}
|
2008-10-26 02:27:34 +04:00
|
|
|
@${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/kern/.depend \
|
|
|
|
| tr -s ' ' '\n' \
|
2009-03-20 12:13:06 +03:00
|
|
|
| ${TOOL_SED} ';s|^../../||;' \
|
2008-10-26 02:27:34 +04:00
|
|
|
> cscope.tmp
|
|
|
|
@${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/compat/.depend \
|
|
|
|
| tr -s ' ' '\n' \
|
2009-03-20 12:13:06 +03:00
|
|
|
| ${TOOL_SED} 's|^../../||;' \
|
2008-10-26 02:27:34 +04:00
|
|
|
>> cscope.tmp
|
2004-12-16 03:35:48 +03:00
|
|
|
@echo ${SRCS} | cat - cscope.tmp | tr -s ' ' '\n' | sort -u | \
|
2008-10-26 02:27:34 +04:00
|
|
|
${CSCOPE} -k -i - -b `echo ${INCLUDES} | ${TOOL_SED} s/-nostdinc//`
|
2002-06-18 00:31:26 +04:00
|
|
|
# cscope doesn't write cscope.out if it's uptodate, so ensure
|
|
|
|
# make doesn't keep calling cscope when not needed.
|
2004-12-16 03:35:48 +03:00
|
|
|
@rm -f cscope.tmp; touch cscope.out
|
2002-06-18 00:31:26 +04:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !target(cscope)
|
|
|
|
cscope: cscope.out
|
|
|
|
@${CSCOPE} -d
|
|
|
|
.endif
|
|
|
|
|
|
|
|
EXTRA_CLEAN+= ID
|
|
|
|
.if !target(mkid)
|
|
|
|
.PHONY: mkid
|
|
|
|
mkid: ID
|
|
|
|
|
2002-06-19 03:46:52 +04:00
|
|
|
ID: Makefile depend
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKTARGET_CREATE}
|
2008-10-26 02:27:34 +04:00
|
|
|
@${MKID} \
|
|
|
|
`${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' \
|
|
|
|
lib/kern/.depend lib/compat/.depend \
|
|
|
|
| tr ' ' '\n' \
|
|
|
|
| ${TOOL_SED} "s|^../../||" \
|
|
|
|
| sort -u` \
|
|
|
|
`${TOOL_SED} 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' \
|
|
|
|
.depend \
|
|
|
|
| tr ' ' '\n' \
|
|
|
|
| sort -u`
|
2002-07-02 23:52:16 +04:00
|
|
|
|
2002-06-18 00:31:26 +04:00
|
|
|
.endif
|
|
|
|
|
2002-09-02 03:04:47 +04:00
|
|
|
.include "${S}/gdbscripts/Makefile.inc"
|
|
|
|
|
|
|
|
EXTRA_CLEAN+= .gdbinit
|
|
|
|
.gdbinit: Makefile ${S}/gdbscripts/Makefile.inc
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKTARGET_CREATE}
|
2002-09-02 03:04:47 +04:00
|
|
|
rm -f .gdbinit
|
|
|
|
.for __gdbinit in ${SYS_GDBINIT}
|
|
|
|
echo "source ${S}/gdbscripts/${__gdbinit}" >> .gdbinit
|
|
|
|
.endfor
|
|
|
|
.if defined(GDBINIT) && !empty(GDBINIT)
|
|
|
|
.for __gdbinit in ${GDBINIT}
|
|
|
|
echo "source ${__gdbinit}" >> .gdbinit
|
|
|
|
.endfor
|
|
|
|
.endif
|
|
|
|
|
2007-01-27 04:37:57 +03:00
|
|
|
# The following files use alloca(3) or variable array allocations.
|
2006-11-11 05:12:53 +03:00
|
|
|
# Their full name is noted as documentation.
|
2009-11-10 23:24:50 +03:00
|
|
|
VARSTACK=kern/uipc_socket.c miscfs/genfs/genfs_vnops.c \
|
2007-09-25 19:16:05 +04:00
|
|
|
nfs/nfs_bio.c uvm/uvm_bio.c \
|
2007-11-29 04:39:27 +03:00
|
|
|
uvm/uvm_pager.c dev/ic/aic7xxx.c dev/ic/aic79xx.c arch/xen/i386/gdt.c \
|
|
|
|
dev/ofw/ofw_subr.c
|
2006-11-11 05:12:53 +03:00
|
|
|
|
|
|
|
.for __varstack in ${VARSTACK}
|
|
|
|
COPTS.${__varstack:T} += -Wno-stack-protector
|
|
|
|
.endfor
|
|
|
|
|
2006-09-11 07:12:48 +04:00
|
|
|
AFLAGS+= ${AOPTS.${.IMPSRC:T}}
|
2005-05-31 18:59:31 +04:00
|
|
|
CFLAGS+= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}}
|
|
|
|
CPPFLAGS+= ${CPPFLAGS.${.IMPSRC:T}}
|
2005-06-01 04:11:32 +04:00
|
|
|
CWARNFLAGS+= ${CWARNFLAGS.${.IMPSRC:T}}
|
2005-05-31 18:59:31 +04:00
|
|
|
|
2014-08-18 01:17:43 +04:00
|
|
|
locore.o machdep.o kern_ksyms.o: Makefile
|
|
|
|
|
2014-08-21 11:57:25 +04:00
|
|
|
.if defined(COPY_SYMTAB)
|
2014-08-18 01:17:43 +04:00
|
|
|
CPPFLAGS.locore.S+= -DCOPY_SYMTAB
|
|
|
|
CPPFLAGS.machdep.c+= -DCOPY_SYMTAB
|
|
|
|
CPPFLAGS.kern_ksyms.c+= -DCOPY_SYMTAB
|
|
|
|
CPPFLAGS.kern_ksyms_buf.c+= -DCOPY_SYMTAB
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !defined(COPY_SYMTAB)
|
|
|
|
build_kernel: .USE
|
|
|
|
${SYSTEM_LD_HEAD}
|
|
|
|
${SYSTEM_LD} swap${.TARGET}.o
|
|
|
|
${SYSTEM_LD_TAIL_STAGE2}
|
|
|
|
.else
|
|
|
|
build_kernel: .USE
|
|
|
|
${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
|
|
|
|
-c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf.o
|
|
|
|
${SYSTEM_LD_HEAD}
|
|
|
|
${SYSTEM_LD} swap${.TARGET}.o kern_ksyms_buf.o
|
|
|
|
${SYSTEM_LD_TAIL_STAGE1}
|
|
|
|
${CC} ${CFLAGS} ${CPPFLAGS} -DCOPY_SYMTAB \
|
|
|
|
-DSYMTAB_SPACE=$$(${DBSYM} -P ${.TARGET}) \
|
|
|
|
-c $S/kern/kern_ksyms_buf.c -o kern_ksyms_buf_real.o
|
|
|
|
${SYSTEM_LD_HEAD}
|
|
|
|
${SYSTEM_LD} swap${.TARGET}.o kern_ksyms_buf_real.o
|
|
|
|
${SYSTEM_LD_TAIL_STAGE2}
|
|
|
|
.endif
|
|
|
|
|
2008-01-17 04:13:01 +03:00
|
|
|
.include <bsd.files.mk>
|
2011-09-26 02:26:33 +04:00
|
|
|
.include <bsd.clang-analyze.mk>
|
2008-01-17 04:13:01 +03:00
|
|
|
|
2001-11-16 03:23:02 +03:00
|
|
|
##
|
|
|
|
## the end
|
|
|
|
##
|