Index: share/mk/kmod.opts.mk =================================================================== --- /dev/null +++ share/mk/kmod.opts.mk @@ -0,0 +1,20 @@ +# $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.opts.mk) +SYSDIR= ${_dir:tA} +.endif +.endfor +.endif +.if !defined(SYSDIR) || !exists(${SYSDIR}/kern/) || \ + !exists(${SYSDIR}/conf/kmod.opts.mk) +.error Unable to locate the kernel source tree. Set SYSDIR to override. +.endif +.endif + +.include "${SYSDIR}/conf/kmod.opts.mk" Index: sys/conf/kmod.mk =================================================================== --- sys/conf/kmod.mk +++ sys/conf/kmod.mk @@ -73,12 +73,7 @@ KMODISLOADED?= /sbin/kldstat -q -n OBJCOPY?= objcopy -.include -# Grab all the options for a kernel build. For backwards compat, we need to -# do this after bsd.own.mk. -.include "kern.opts.mk" -.include -.include "config.mk" +.include "kmod.opts.mk" # Search for kernel source tree in standard places. .if empty(KERNBUILDDIR) Index: sys/conf/kmod.opts.mk =================================================================== --- /dev/null +++ sys/conf/kmod.opts.mk @@ -0,0 +1,16 @@ +# $FreeBSD$ +# +# Handle options (KERN_OPTS) for kernel module options. This can be included earlier in a kmod Makefile +# to allow KERN_OPTS to control SRCS, etc. + +.if !target(____) +____: + +.include +# Grab all the options for a kernel build. For backwards compat, we need to +# do this after bsd.own.mk. +.include "kern.opts.mk" +.include +.include "config.mk" + +.endif # !target(____)