diff --git a/share/mk/bsd.dtb.mk b/share/mk/bsd.dtb.mk index 718c41dab4fa..69f65015201e 100644 --- a/share/mk/bsd.dtb.mk +++ b/share/mk/bsd.dtb.mk @@ -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 .include "${SYSDIR}/conf/dtb.mk" .include diff --git a/share/mk/bsd.kmod.mk b/share/mk/bsd.kmod.mk index d790165623c3..683967749e75 100644 --- a/share/mk/bsd.kmod.mk +++ b/share/mk/bsd.kmod.mk @@ -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 .include "${SYSDIR}/conf/kmod.mk" diff --git a/share/mk/bsd.sysdir.mk b/share/mk/bsd.sysdir.mk new file mode 100644 index 000000000000..665905e1d537 --- /dev/null +++ b/share/mk/bsd.sysdir.mk @@ -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 diff --git a/sys/conf/dtb.build.mk b/sys/conf/dtb.build.mk index 140440336cad..1966bee19460 100644 --- a/sys/conf/dtb.build.mk +++ b/sys/conf/dtb.build.mk @@ -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 .endif # defined(S) .endif # defined(SYSDIR) diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index 307ae2a74d4e..73184acd5cb9 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -79,21 +79,7 @@ OBJCOPY?= objcopy .include "kern.opts.mk" .include .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 .SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S .m