Introduce bsd.sysdir.mk to consolidate looking for the kernel.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D22144
This commit is contained in:
imp 2019-11-21 15:59:33 +00:00
parent 56980699b8
commit 1b08dd8f6e
5 changed files with 20 additions and 55 deletions

View File

@ -1,22 +1,6 @@
# $FreeBSD$
# Search for kernel source tree in standard places.
.if empty(KERNBUILDDIR)
.if !defined(SYSDIR)
.for _dir in ${SRCTOP:D${SRCTOP}/sys} \
${.CURDIR}/../.. ${.CURDIR}/../../.. ${.CURDIR}/../../../.. \
${.CURDIR}/../../../../.. /sys /usr/src/sys
.if !defined(SYSDIR) && exists(${_dir}/kern/) && exists(${_dir}/conf/kmod.mk)
SYSDIR= ${_dir}
.endif
.endfor
.endif
.if !defined(SYSDIR) || !exists(${SYSDIR}/kern/) || \
!exists(${SYSDIR}/conf/kmod.mk)
.error Unable to locate the kernel source tree. Set SYSDIR to override.
.endif
.endif
.include <bsd.sysdir.mk>
.include "${SYSDIR}/conf/dtb.mk"
.include <bsd.sys.mk>

View File

@ -1,20 +1,4 @@
# $FreeBSD$
# Search for kernel source tree in standard places.
.if empty(KERNBUILDDIR)
.if !defined(SYSDIR)
.for _dir in ${SRCTOP:D${SRCTOP}/sys} \
${.CURDIR}/../.. ${.CURDIR}/../../.. ${.CURDIR}/../../../.. \
${.CURDIR}/../../../../.. /sys /usr/src/sys
.if !defined(SYSDIR) && exists(${_dir}/kern/) && exists(${_dir}/conf/kmod.mk)
SYSDIR= ${_dir:tA}
.endif
.endfor
.endif
.if !defined(SYSDIR) || !exists(${SYSDIR}/kern/) || \
!exists(${SYSDIR}/conf/kmod.mk)
.error Unable to locate the kernel source tree. Set SYSDIR to override.
.endif
.endif
.include <bsd.sysdir.mk>
.include "${SYSDIR}/conf/kmod.mk"

16
share/mk/bsd.sysdir.mk Normal file
View File

@ -0,0 +1,16 @@
# $FreeBSD$
# Search for kernel source tree in standard places.
.if !defined(SYSDIR)
.for _dir in ${SRCTOP:D${SRCTOP}/sys} \
${.CURDIR}/../.. ${.CURDIR}/../../.. ${.CURDIR}/../../../.. \
${.CURDIR}/../../../../.. /sys /usr/src/sys
.if !defined(SYSDIR) && exists(${_dir}/kern/) && exists(${_dir}/conf/kmod.mk)
SYSDIR= ${_dir:tA}
.endif
.endfor
.endif
.if !defined(SYSDIR) || !exists(${SYSDIR}/kern/) || \
!exists(${SYSDIR}/conf/kmod.mk)
.error Unable to locate the kernel source tree. Set SYSDIR to override.
.endif

View File

@ -11,12 +11,7 @@ DTC?= dtc
.if defined(S)
SYSDIR= ${S}
.else
# Search for kernel source tree in standard places.
.for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys
.if exists(${_dir}/kern/)
SYSDIR= ${_dir:tA}
.endif
.endfor
.include <bsd.sysdir.mk>
.endif # defined(S)
.endif # defined(SYSDIR)

View File

@ -79,21 +79,7 @@ OBJCOPY?= objcopy
.include "kern.opts.mk"
.include <bsd.compiler.mk>
.include "config.mk"
# Search for kernel source tree in standard places.
.if empty(KERNBUILDDIR)
.if !defined(SYSDIR)
.for _dir in ${SRCTOP:D${SRCTOP}/sys} \
${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys
.if !defined(SYSDIR) && exists(${_dir}/kern/)
SYSDIR= ${_dir:tA}
.endif
.endfor
.endif
.if !defined(SYSDIR) || !exists(${SYSDIR}/kern/)
.error "can't find kernel source tree"
.endif
.endif
.include <bsd.sysdir.mk>
.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S .m