2008-02-23 20:43:36 +03:00
|
|
|
# $NetBSD: Makefile.kern.inc,v 1.109 2008/02/23 17:43:36 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
|
|
|
|
|
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
|
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 \
|
|
|
|
-I$S -nostdinc
|
2001-11-23 08:18:59 +03:00
|
|
|
CPPFLAGS+= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT
|
|
|
|
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")
|
2006-10-04 20:03:01 +04:00
|
|
|
. if !defined(NOGCCERROR)
|
2003-10-02 03:11:29 +04:00
|
|
|
CWARNFLAGS+= -Werror
|
2006-10-04 20:03:01 +04:00
|
|
|
. endif
|
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
|
2005-06-19 02:56:02 +04:00
|
|
|
CWARNFLAGS+= -Wswitch -Wshadow
|
2005-05-31 06:25:39 +04:00
|
|
|
CWARNFLAGS+= -Wcast-qual -Wwrite-strings
|
2002-11-25 04:37:11 +03: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
|
2006-05-11 21:21:38 +04:00
|
|
|
. if ${HAVE_GCC} > 3
|
2006-05-21 09:49:54 +04:00
|
|
|
CWARNFLAGS+= -Wno-pointer-sign -Wno-attributes
|
2006-10-30 20:56:30 +03:00
|
|
|
. if ${MACHINE} == "i386" || ${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
|
2006-05-11 21:21:38 +04:00
|
|
|
. endif
|
2001-12-08 18:01:41 +03:00
|
|
|
.endif
|
2003-11-06 11:23:22 +03:00
|
|
|
|
2006-06-03 02:16:18 +04:00
|
|
|
CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss
|
2004-04-25 08:24:06 +04:00
|
|
|
CFLAGS+= ${CPUFLAGS} ${DEBUG} ${COPTS} ${CWARNFLAGS}
|
2006-08-27 10:49:27 +04:00
|
|
|
AFLAGS+= ${CPUFLAGS} -D_LOCORE -Wa,-fatal-warnings
|
2004-04-25 08:24:06 +04:00
|
|
|
|
2006-05-11 21:21:38 +04:00
|
|
|
# XXX
|
|
|
|
.if ${HAVE_GCC} > 3
|
|
|
|
CFLAGS+= -fno-strict-aliasing
|
|
|
|
.endif
|
|
|
|
|
2007-10-09 01:25:35 +04:00
|
|
|
.if ${USE_SSP:Uno} == "yes"
|
2006-12-19 01:37:36 +03:00
|
|
|
CFLAGS+=-fstack-protector -Wstack-protector --param ssp-buffer-size=1
|
|
|
|
LDFLAGS+=-fstack-protector -Wstack-protector --param ssp-buffer-size=1
|
2006-11-11 05:12:53 +03:00
|
|
|
.endif
|
|
|
|
|
2006-09-07 22:41:28 +04:00
|
|
|
# If we want the bpendtsleep: label in kern_synch.c, we need to use
|
|
|
|
# -fno-reorder-blocks. Don't make this a config(1) defflag without
|
|
|
|
# making sure this fragment remains valid.
|
|
|
|
.if ${HAVE_GCC} > 3 && !empty(${CFLAGS:M-DKERN_SYNCH_BPENDTSLEEP_LABEL})
|
|
|
|
CFLAGS.kern_synch.c+= -fno-reorder-blocks
|
|
|
|
.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
|
|
|
|
|
2008-01-17 23:14:49 +03:00
|
|
|
# Always compile subr_debug_info.c with debug informations.
|
|
|
|
# This allows gdb to use type informations.
|
|
|
|
#
|
|
|
|
COPTS.debugsyms.c+= -g
|
|
|
|
|
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).
|
2003-12-04 05:33:41 +03:00
|
|
|
NORMAL_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}"; \
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKSHECHO}\
|
|
|
|
${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<; \
|
|
|
|
${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
|
2003-12-04 05:33:41 +03:00
|
|
|
NOPROF_C?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}"; \
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKSHECHO}\
|
|
|
|
${CC} ${CFLAGS} ${CPPFLAGS} -c $<; \
|
|
|
|
${CC} ${CFLAGS} ${CPPFLAGS} -c $<
|
2003-12-04 05:33:41 +03:00
|
|
|
NORMAL_S?= @${_MKSHMSG} "compile ${.CURDIR:T}/${.TARGET}"; \
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKSHECHO}\
|
|
|
|
${CC} ${AFLAGS} ${CPPFLAGS} -c $<; \
|
|
|
|
${CC} ${AFLAGS} ${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:
|
|
|
|
# xxx: ${SYSTEM_DEP} swapxxx.o
|
|
|
|
# ${SYSTEM_LD_HEAD}
|
|
|
|
# ${SYSTEM_LD} swapxxx.o
|
|
|
|
# ${SYSTEM_LD_TAIL}
|
2004-07-31 04:55:51 +04:00
|
|
|
SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS} ${SYSLIBCOMPAT} ${LIBKERN}
|
2006-04-19 11:06:22 +04:00
|
|
|
SYSTEM_DEP?= Makefile ${SYSTEM_OBJ:O} .gdbinit
|
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
|
2003-11-17 12:39:29 +03:00
|
|
|
SYSTEM_LD_TAIL?=@${SIZE} $@; chmod 755 $@
|
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
|
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@}
|
2001-12-10 08:24:17 +03:00
|
|
|
.elifndef PROF
|
2001-11-16 03:23:02 +03:00
|
|
|
LINKFLAGS+= ${LINKFLAGS_NORMAL}
|
|
|
|
.endif
|
|
|
|
|
2005-11-24 15:54:29 +03:00
|
|
|
SYSTEM_LD_TAIL+=; \
|
|
|
|
if grep -q '^\#define.*SYMTAB_SPACE' opt_ddbparam.h; then \
|
|
|
|
echo "${DBSYM} $@"; \
|
|
|
|
${DBSYM} $@; \
|
|
|
|
fi
|
|
|
|
|
2004-09-13 13:39:40 +04:00
|
|
|
SYSTEM_LD_HEAD+=${SYSTEM_LD_HEAD_EXTRA}
|
2001-11-28 02:28:42 +03:00
|
|
|
SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_EXTRA}
|
|
|
|
|
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} | \
|
|
|
|
${GENASSYM} -- ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
|
2001-11-28 02:28:42 +03:00
|
|
|
> 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
|
|
|
|
|
2001-12-09 19:04:03 +03:00
|
|
|
.if !target(vers.o)
|
|
|
|
newvers: vers.o
|
2002-08-11 14:47:24 +04:00
|
|
|
vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} $S/conf/newvers.sh $S/conf/osrelease.sh
|
2003-11-17 12:39:29 +03:00
|
|
|
${_MKMSG_CREATE} vers.c
|
|
|
|
${HOST_SH} $S/conf/newvers.sh
|
|
|
|
${_MKTARGET_COMPILE}
|
2001-11-16 03:23:02 +03:00
|
|
|
${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
|
|
|
|
.endif
|
|
|
|
|
2002-11-19 07:29:19 +03:00
|
|
|
.if !target(config_time.h)
|
2008-01-17 04:13:01 +03:00
|
|
|
BUILDSYMLINKS+= config_time.src config_time.h
|
2002-11-19 07:29:19 +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}
|
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}
|
2005-11-24 16:01:42 +03:00
|
|
|
.endfor
|
|
|
|
.for _s in ${CSRCS}
|
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}
|
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 -- \
|
2003-11-12 00:26:53 +03:00
|
|
|
${CFLAGS} ${CPPFLAGS}
|
2005-12-13 01:44:04 +03:00
|
|
|
sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >${.TARGET}
|
|
|
|
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} | \
|
|
|
|
awk -f $S/kern/genlintstub.awk >${.TARGET}
|
|
|
|
.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}
|
2004-12-16 03:35:48 +03:00
|
|
|
@sed 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/kern/.depend | \
|
|
|
|
tr -s ' ' '\n' | sed 's|^\([^.\\]\)|lib/kern/\1|;s|^../../||;' > \
|
|
|
|
cscope.tmp
|
|
|
|
@sed 's/[^:]*://;s/^ *//;s/ *\\ *$$//;' lib/compat/.depend | \
|
|
|
|
tr -s ' ' '\n' | sed 's|^\([^.\\]\)|lib/compat/\1|;s|^../../||;' >> \
|
|
|
|
cscope.tmp
|
|
|
|
@echo ${SRCS} | cat - cscope.tmp | tr -s ' ' '\n' | sort -u | \
|
|
|
|
${CSCOPE} -k -i - -b `echo ${INCLUDES} | 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}
|
2002-07-02 23:52:16 +04:00
|
|
|
@${MKID} `sed 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' lib/kern/.depend \
|
|
|
|
lib/compat/.depend | tr ' ' '\n' | sed "s|^../../||" | sort -u` \
|
|
|
|
`sed 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' .depend | tr ' ' '\n' \
|
|
|
|
| sort -u`
|
|
|
|
|
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.
|
|
|
|
VARSTACK=dev/cgd.c 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
|
|
|
|
2006-12-11 02:09:31 +03:00
|
|
|
. if ${HAVE_GCC} > 3
|
2006-11-11 05:12:53 +03:00
|
|
|
.for __varstack in ${VARSTACK}
|
|
|
|
COPTS.${__varstack:T} += -Wno-stack-protector
|
|
|
|
.endfor
|
2006-12-11 02:09:31 +03:00
|
|
|
.endif
|
2006-11-11 05:12:53 +03:00
|
|
|
|
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
|
|
|
|
2008-01-17 04:13:01 +03:00
|
|
|
.include <bsd.files.mk>
|
|
|
|
|
2001-11-16 03:23:02 +03:00
|
|
|
##
|
|
|
|
## the end
|
|
|
|
##
|