Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Aug 2002 12:19:48 -0400 (EDT)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        arch@FreeBSD.org
Subject:   Conditionally building modules based on kernel options
Message-ID:  <Pine.NEB.3.96L.1020805121116.80930A-100000@fledge.watson.org>

next in thread | raw e-mail | index | archive | help

Currently, the MAC kernel modules are built regardless of the existence of
'options MAC' in the kernel configuration file.  Given that the MAC
modules are effectively useless without that option in the kernel since
the framework they hook into doesn't exist, it seems undesirable to build
the modules for a variety of reasons, not least space consumed and
potential user confusion.  Simon Schubert provided me with the following
patch to modify the kernel build code to build the MAC modules only if the
MAC framework is present:

http://corecode.ath.cx/~corecode/stuff/patch-condmac

(also attached below)

Ideally, I suppose the module contents would actually be a property of
conf/somethingfunky rather than a property solely of Makefiles, making it
possible in a more general way to correspond to kernel configuration
choices, but this appears to work in the mean time.  Is there a better way
I should be doing this?

Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
robert@fledge.watson.org      Network Associates Laboratories

Index: src/sys/conf/kern.pre.mk
===================================================================
RCS file: /home/ncvs/src/sys/conf/kern.pre.mk,v
retrieving revision 1.16
diff -u -r1.16 kern.pre.mk
--- src/sys/conf/kern.pre.mk	22 Jul 2002 00:15:01 -0000	1.16
+++ src/sys/conf/kern.pre.mk	2 Aug 2002 22:20:33 -0000
@@ -89,7 +89,7 @@
 # MKMODULESENV is set here so that port makefiles can augment
 # them.
 
-MKMODULESENV=	MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
+MKMODULESENV=	MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} AUTOMATIC_BUILD=yes
 .if (${KERN_IDENT} == LINT)
 MKMODULESENV+=	ALL_MODULES=LINT
 .endif
Index: src/sys/modules/Makefile
===================================================================
RCS file: /home/ncvs/src/sys/modules/Makefile,v
retrieving revision 1.248
diff -u -r1.248 Makefile
--- src/sys/modules/Makefile	1 Aug 2002 17:41:26 -0000	1.248
+++ src/sys/modules/Makefile	3 Aug 2002 13:17:25 -0000
@@ -48,13 +48,6 @@
 	libmchain \
 	lnc \
 	lpt \
-	mac_biba \
-	mac_bsdextended \
-	mac_ifoff \
-	mac_mls \
-	mac_none \
-	mac_seeotheruids \
-	mac_test \
 	md \
 	mii \
 	mlx \
@@ -117,6 +110,22 @@
 
 .if !defined(NO_IPFILTER) && ${MACHINE_ARCH} != "ia64"
 SUBDIR+=ipfilter
+.endif
+
+.if exists(${.OBJDIR}/../opt_mac.h)
+BUILD_MAC!=/usr/bin/grep -q "^\#define MAC 1$$" ${.OBJDIR}/../opt_mac.h && echo "yes" || echo "no"
+.else
+BUILD_MAC=no
+.endif
+
+.if !defined(AUTOMATIC_BUILD) || ${BUILD_MAC} == yes
+SUBDIR+=mac_biba \
+	mac_bsdextended \
+	mac_ifoff \
+	mac_mls \
+	mac_none \
+	mac_seeotheruids \
+	mac_test
 .endif
 
 #removed while KSE settles in:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.96L.1020805121116.80930A-100000>