From owner-svn-src-all@freebsd.org Tue Oct 30 00:23:38 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B838A10EE960; Tue, 30 Oct 2018 00:23:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 625298C9C1; Tue, 30 Oct 2018 00:23:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3FEC715C0D; Tue, 30 Oct 2018 00:23:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9U0Nclm048741; Tue, 30 Oct 2018 00:23:38 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9U0NcOb048740; Tue, 30 Oct 2018 00:23:38 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201810300023.w9U0NcOb048740@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Tue, 30 Oct 2018 00:23:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339901 - head/sys/conf X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/sys/conf X-SVN-Commit-Revision: 339901 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Oct 2018 00:23:39 -0000 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/. 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)