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:
Warner Losh 2019-11-21 15:59:33 +00:00
parent 6e02be63f4
commit 3cc5d6a470
5 changed files with 20 additions and 55 deletions

View File

@ -1,22 +1,6 @@
# $FreeBSD$ # $FreeBSD$
# Search for kernel source tree in standard places. .include <bsd.sysdir.mk>
.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 "${SYSDIR}/conf/dtb.mk" .include "${SYSDIR}/conf/dtb.mk"
.include <bsd.sys.mk> .include <bsd.sys.mk>

View File

@ -1,20 +1,4 @@
# $FreeBSD$ # $FreeBSD$
# Search for kernel source tree in standard places. .include <bsd.sysdir.mk>
.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 "${SYSDIR}/conf/kmod.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) .if defined(S)
SYSDIR= ${S} SYSDIR= ${S}
.else .else
# Search for kernel source tree in standard places. .include <bsd.sysdir.mk>
.for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys
.if exists(${_dir}/kern/)
SYSDIR= ${_dir:tA}
.endif
.endfor
.endif # defined(S) .endif # defined(S)
.endif # defined(SYSDIR) .endif # defined(SYSDIR)

View File

@ -79,21 +79,7 @@ OBJCOPY?= objcopy
.include "kern.opts.mk" .include "kern.opts.mk"
.include <bsd.compiler.mk> .include <bsd.compiler.mk>
.include "config.mk" .include "config.mk"
.include <bsd.sysdir.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
.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S .m .SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S .m