xref: /netbsd-src/share/mk/bsd.kernobj.mk (revision 220b5c059a84c51ea44107ea8951a57ffaecdc8c)
1#	$NetBSD: bsd.kernobj.mk,v 1.7 2001/11/27 05:39:03 jmc Exp $
2
3# KERNSRCDIR	Is the location of the top of the kernel src.
4# 		It defaults to ${BSDSRCDIR}/sys, but the top-level
5# 		Makefile.inc sets it to ${ABSTOP}/sys (ABSTOP is the
6# 		absolute path to the directory where the top-level
7# 		Makefile.inc was found.
8#
9# KERNARCHDIR	Is the location of the machine dependent kernel
10# 		sources.  It defaults to arch/${MACHINE}
11#
12# KERNCONFDIR	Is where the configuration files for kernels are
13# 		found; default is ${KERNSRCDIR}/${KERNARCHDIR}/conf.
14#
15# KERNOBJDIR	Is the kernel build directory.  The kernel GENERIC for
16# 		instance will be compiled in ${KERNOBJDIR}/GENERIC.
17# 		The default value is
18# 		${KERNSRCDIR}/${KERNARCHDIR}/compile
19#
20#		If MAKEOBJDIRPREFIX or _SRC_TOP_OBJ is set than the value will
21#		be either
22#
23#		${MAKEOBJDIRPREFIX}${KERNSRCDIR}/${KERNARCHDIR}/compile
24#
25#		or
26#
27#		${_SRC_TOP_OBJ_}/sys/${KERNARCHDIR}/compile
28#
29#		with MAKEOBJDIRPREFIX taking priority over _SRC_TOP_OBJ_
30#
31
32.include <bsd.own.mk>
33
34KERNSRCDIR?=	${BSDSRCDIR}/sys
35# just incase ${MACHINE} is not always correct
36KERNARCHDIR?=	arch/${MACHINE}
37
38#
39# XXX It's ugly but it does what we need here. If making objects use the above
40# rules for trying to figure out a KERNOBJDIR.
41#
42# When coming back through here in rules (such as building kernels for
43# a release), check which vars we're using and which directory base has been
44# made in the previous obj stage to figure out which one to expose.
45#
46# All cases will fall through to the ${KERNSRCDIR}/${KERNARCHDIR}/compile case
47# if nothing ends up setting this.
48.if make(obj) || \
49    (defined(MAKEOBJDIRPREFIX) && exists(${MAKEOBJDIRPREFIX}${KERNSRCDIR}/${KERNARCHDIR}/compile)) || \
50    (defined(_SRC_TOP_OBJ_) && exists(${_SRC_TOP_OBJ_}/sys/${KERNARCHDIR}/compile))
51.if defined (MAKEOBJDIRPREFIX)
52KERNOBJDIR?=    ${MAKEOBJDIRPREFIX}${KERNSRCDIR}/${KERNARCHDIR}/compile
53.else
54.if defined(_SRC_TOP_OBJ_) && ${_SRC_TOP_OBJ_} != ""
55KERNOBJDIR?=	${_SRC_TOP_OBJ_}/sys/${KERNARCHDIR}/compile
56.endif
57.endif
58.endif
59
60KERNOBJDIR?=	${KERNSRCDIR}/${KERNARCHDIR}/compile
61
62KERNCONFDIR?=	${KERNSRCDIR}/${KERNARCHDIR}/conf
63