svn commit: r339901 - head/sys/conf

John Baldwin jhb at FreeBSD.org
Tue Oct 30 00:23:39 UTC 2018


Author: jhb
Date: Tue Oct 30 00:23:37 2018
New Revision: 339901
URL: https://svnweb.freebsd.org/changeset/base/339901

Log:
  Permit local kernel modules to be built as part of a kernel build.
  
  Add support for "local" modules.  By default, these modules are
  located in LOCALBASE/sys/modules (where LOCALBASE defaults to
  /usr/local).  Individual modules can be built along with a kernel by
  defining LOCAL_MODULES to the list of modules.  Each is assumed to be
  a subdirectory containing a valid Makefile.  If LOCAL_MODULES is not
  specified, all of the modules present in LOCALBASE/sys/modules are
  built and installed along with the kernel.
  
  This means that a port that installs a kernel module can choose to
  install its source along with a suitable Makefile to
  /usr/local/sys/modules/<foo>.  Future kernel builds will then include
  that kernel module using the kernel configuration's opt_*.h headers
  and install it into /boot/kernel along with other kernel-specific
  modules.
  
  This is not trying to solve the issue of folks running GENERIC release
  kernels, but is instead aimed at folks who build their own kernels.
  For those folks this ensures that kernel modules from ports will
  always be using the right KBI, etc.  This includes folks running any
  KBI-breaking kernel configs (such as PAE).
  
  There are still some kinks to be worked out with cross-building (we
  probably shouldn't include local modules in cross-built kernels by
  default), but this is a sufficient starting point.
  
  Reviewed by:	imp
  MFC after:	3 months
  Relnotes:	yes
  Differential Revision:	https://reviews.freebsd.org/D16966

Modified:
  head/sys/conf/kern.post.mk

Modified: head/sys/conf/kern.post.mk
==============================================================================
--- head/sys/conf/kern.post.mk	Tue Oct 30 00:22:14 2018	(r339900)
+++ head/sys/conf/kern.post.mk	Tue Oct 30 00:23:37 2018	(r339901)
@@ -35,24 +35,41 @@ KERN_DEBUGDIR?=	${DEBUGDIR}
 
 .MAIN: all
 
+.if !defined(NO_MODULES)
+# Default prefix used for modules installed from ports
+LOCALBASE?=	/usr/local
+
+LOCAL_MODULES_DIR?= ${LOCALBASE}/sys/modules
+
+# Default to installing all modules installed by ports unless overridden
+# by the user.
+.if !defined(LOCAL_MODULES)
+LOCAL_MODULES!= ls ${LOCAL_MODULES_DIR}
+.endif
+.endif
+
 .for target in all clean cleandepend cleandir clobber depend install \
     ${_obj} reinstall tags
 ${target}: kernel-${target}
-.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
+.if !defined(NO_MODULES)
 ${target}: modules-${target}
 modules-${target}:
+.if !defined(MODULES_WITH_WORLD) && exists($S/modules)
 	cd $S/modules; ${MKMODULESENV} ${MAKE} \
 	    ${target:S/^reinstall$/install/:S/^clobber$/cleandir/}
 .endif
+.for module in ${LOCAL_MODULES}
+	cd ${LOCAL_MODULES_DIR}/${module}; ${MKMODULESENV} ${MAKE} \
+	    ${target:S/^reinstall$/install/:S/^clobber$/cleandir/}
 .endfor
+.endif
+.endfor
 
 # Handle ports (as defined by the user) that build kernel modules
 .if !defined(NO_MODULES) && defined(PORTS_MODULES)
 #
 # The ports tree needs some environment variables defined to match the new kernel
 #
-# Ports search for some dependencies in PATH, so add the location of the installed files
-LOCALBASE?=	/usr/local
 # SRC_BASE is how the ports tree refers to the location of the base source files
 .if !defined(SRC_BASE)
 SRC_BASE=	${SYSDIR:H:tA}
@@ -64,6 +81,9 @@ OSRELDATE!=	awk '/^\#define[[:space:]]*__FreeBSD_versi
 		    ${MAKEOBJDIRPREFIX}${SRC_BASE}/include/osreldate.h
 .endif
 # Keep the related ports builds in the obj directory so that they are only rebuilt once per kernel build
+#
+# Ports search for some dependencies in PATH, so add the location of the
+# installed files
 WRKDIRPREFIX?=	${.OBJDIR}
 PORTSMODULESENV=\
 	env \
@@ -110,7 +130,7 @@ kernel-clobber:
 
 kernel-obj:
 
-.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
+.if !defined(NO_MODULES)
 modules: modules-all
 
 .if !defined(NO_MODULES_OBJ)


More information about the svn-src-head mailing list