2002-11-25 04:37:11 +03:00
|
|
|
# $NetBSD: Makefile.kern.inc,v 1.30 2002/11/25 01:37:11 thorpej Exp $
|
2001-11-16 03:23:02 +03:00
|
|
|
#
|
|
|
|
# This file contains common `MI' targets and definitions and it is included
|
|
|
|
# at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}. There are
|
|
|
|
# many `MI' definitions that should end up in here, but they are not yet.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# To specify debugging, add the config line: makeoptions DEBUG="-g"
|
|
|
|
# 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
|
|
|
|
##
|
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
|
2002-03-18 18:20:08 +03:00
|
|
|
.MAKEOVERRIDES+=USETOOLS # make sure proper value is propagated
|
2001-11-16 19:15:08 +03:00
|
|
|
|
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
|
|
|
|
##
|
2001-11-23 08:18:59 +03:00
|
|
|
INCLUDES?= -I. ${EXTRA_INCLUDES} -I$S/arch -I$S -nostdinc
|
|
|
|
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")
|
2002-10-05 21:17:48 +04:00
|
|
|
CWARNFLAGS+= -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith
|
2001-12-08 18:01:41 +03:00
|
|
|
CWARNFLAGS+= -Wmissing-prototypes -Wstrict-prototypes
|
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
|
2001-11-16 03:23:02 +03:00
|
|
|
# XXX Delete -Wuninitialized for now, since the compiler doesn't
|
|
|
|
# XXX always get it right. --thorpej
|
|
|
|
CWARNFLAGS+= -Wno-uninitialized
|
2001-12-08 18:01:41 +03:00
|
|
|
.endif
|
2001-12-24 01:45:07 +03:00
|
|
|
CFLAGS+= -ffreestanding ${DEBUG} ${COPTS} ${CWARNFLAGS}
|
2001-11-23 08:18:59 +03:00
|
|
|
AFLAGS+= -D_LOCORE
|
2001-11-16 03:23:02 +03:00
|
|
|
|
|
|
|
# Define a set of xxx_G variables that will add -g to just those
|
|
|
|
# files that match the shell patterns given in ${DEBUGLIST}
|
|
|
|
#
|
|
|
|
.for i in ${DEBUGLIST}
|
|
|
|
.for j in ${CFILES:T:M$i.c}
|
|
|
|
${j:R}_G?= -g
|
|
|
|
.endfor
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
# 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).
|
|
|
|
NORMAL_C?= ${CC} ${CFLAGS} ${CPPFLAGS} ${${<:T:R}_G} ${PROF} -c $<
|
|
|
|
NOPROF_C?= ${CC} ${CFLAGS} ${CPPFLAGS} ${${<:T:R}_G} -c $<
|
|
|
|
NORMAL_S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c $<
|
|
|
|
|
|
|
|
##
|
|
|
|
## (3) libkern and compat
|
|
|
|
##
|
|
|
|
## 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
|
|
|
|
LIBCOMPAT?= ${COMPATLIB}
|
|
|
|
.else
|
|
|
|
LIBCOMPAT?= ${COMPATLIB_PROF}
|
|
|
|
.endif
|
|
|
|
|
2002-11-02 10:57:05 +03:00
|
|
|
LIBCOMPATLN?= ${COMPATLIBLN}
|
|
|
|
|
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
|
|
|
|
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}
|
|
|
|
SYSTEM_OBJ?= ${MD_OBJS} ${MI_OBJS} ${OBJS} ${LIBCOMPAT} ${LIBKERN}
|
2002-09-02 03:04:47 +04:00
|
|
|
SYSTEM_DEP?= Makefile ${SYSTEM_OBJ} .gdbinit
|
2001-11-16 03:23:02 +03:00
|
|
|
SYSTEM_LD_HEAD?= @rm -f $@
|
|
|
|
SYSTEM_LD?= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
|
|
|
|
${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
|
|
|
|
SYSTEM_LD_TAIL?= @${SIZE} $@; chmod 755 $@
|
|
|
|
|
|
|
|
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?=
|
|
|
|
.if ${DEBUG} == "-g"
|
|
|
|
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
|
|
|
|
|
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)
|
2001-11-28 02:28:42 +03:00
|
|
|
assym.h: $S/kern/genassym.sh ${GENASSYM} ${GENASSYM_EXTRAS}
|
|
|
|
cat ${GENASSYM} ${GENASSYM_EXTRAS} | \
|
|
|
|
sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
|
|
|
|
> 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
|
2001-11-16 03:23:02 +03:00
|
|
|
sh $S/conf/newvers.sh
|
|
|
|
${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
|
|
|
|
.endif
|
|
|
|
|
2002-11-19 07:29:19 +03:00
|
|
|
.if !target(config_time.h)
|
|
|
|
EXTRA_CLEAN+= config_time.h
|
|
|
|
config_time.h: Makefile
|
|
|
|
cp config_time.src config_time.h
|
|
|
|
.endif
|
|
|
|
|
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
|
|
|
|
@echo "${.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
|
|
|
|
rm -f .depend
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# do not !target these, the kern and compat Makefiles augment them
|
|
|
|
cleandir distclean: __CLEANKERNEL __CLEANDEPEND
|
|
|
|
clean: __CLEANKERNEL
|
|
|
|
depend: .depend
|
|
|
|
|
|
|
|
.if !target(.depend)
|
|
|
|
SRCS?= ${MD_SFILES} ${MD_CFILES} ${MI_CFILES} ${CFILES} ${SFILES}
|
|
|
|
MKDEP_AFLAGS?= ${AFLAGS}
|
|
|
|
MKDEP_CFLAGS?= ${CFLAGS}
|
|
|
|
.depend: ${SRCS} assym.h
|
|
|
|
${MKDEP} ${MKDEP_AFLAGS} ${CPPFLAGS} ${MD_SFILES} ${SFILES}
|
|
|
|
${MKDEP} -a ${MKDEP_CFLAGS} ${CPPFLAGS} ${MD_CFILES} ${MI_CFILES} \
|
|
|
|
${CFILES}
|
2001-11-28 02:28:42 +03:00
|
|
|
cat ${GENASSYM} ${GENASSYM_EXTRAS} | \
|
|
|
|
sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} ${CPPFLAGS}
|
2001-11-16 03:23:02 +03:00
|
|
|
@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
|
|
|
|
@rm -f assym.dep
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !target(dependall)
|
|
|
|
dependall: depend all
|
|
|
|
.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}
|
|
|
|
LOBJS?= ${_lsrc:T:S/.c$/.ln/g} ${LIBKERNLN} ${LIBCOMPATLN}
|
|
|
|
|
2001-11-16 03:23:02 +03:00
|
|
|
.for _sfile in ${ALLSFILES}
|
|
|
|
LintStub_${_sfile:T:R}.c: ${_sfile} assym.h
|
|
|
|
${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}
|
|
|
|
${NORMAL_LN}
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
lint: ${LOBJS}
|
|
|
|
${LINT} ${KERNLINTFLAGS} ${CPPFLAGS:M-[IDU]*} ${LOBJS}
|
2001-11-16 03:23:02 +03:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.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}:
|
2001-12-08 18:01:41 +03:00
|
|
|
rm -f ${DESTDIR}/onetbsd
|
|
|
|
ln ${DESTDIR}/netbsd ${DESTDIR}/onetbsd
|
|
|
|
cp netbsd ${DESTDIR}/nnetbsd
|
|
|
|
mv ${DESTDIR}/nnetbsd ${DESTDIR}/netbsd
|
2001-11-16 03:23:02 +03:00
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !target(tags)
|
|
|
|
tags:
|
|
|
|
@echo "see $S/kern/Makefile for tags"
|
|
|
|
.endif
|
|
|
|
|
2002-06-18 00:31:26 +04:00
|
|
|
EXTRA_CLEAN+= cscope.out
|
|
|
|
.if !target(cscope.out)
|
2002-07-12 21:48:23 +04:00
|
|
|
cscope.out: Makefile depend
|
2002-06-18 00:31:26 +04:00
|
|
|
@echo Building cscope.out source database
|
2002-07-02 23:52:16 +04:00
|
|
|
@echo ${SRCS} `sed 's/[^:]*://;s/^ *//;s/ *\\\\ *$$//;' \
|
|
|
|
lib/kern/.depend lib/compat/.depend | tr ' ' '\n' | \
|
|
|
|
sed "s|^../../||" | 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.
|
|
|
|
@touch cscope.out
|
|
|
|
.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
|
2002-06-18 00:31:26 +04:00
|
|
|
@echo Building mkid database
|
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
|
|
|
|
@echo building GDB initialization file
|
|
|
|
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
|
|
|
|
|
2001-11-16 03:23:02 +03:00
|
|
|
##
|
|
|
|
## the end
|
|
|
|
##
|