DragonFly bugs List (threaded) for 2009-02
DragonFly BSD
DragonFly bugs List (threaded) for 2009-02
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

[PATCH] Add two variables to adjust where to install kernel and modules.


From: YONETANI Tomokazu <y0netan1@xxxxxxxxxxxxxxxx>
Date: Sun, 8 Feb 2009 04:20:29 +0900

DESTLABEL	common suffix added to kernel and modules directory.  for
		example, `make DESTLABEL=test installkernel' installs them
		as /boot/kernel.test and /boot/modules.test, respectively.

DESTKERNDIR	where to install kernel and modules, /boot by default.

Add /sys/conf/kern.path.mk to define default paths for kernel and modules.
Also move KMOD* definitions to /sys/conf/kmod.mk where it really belongs.

Submitted-by: Stefan Johannesdal <stefan.johannesdal@gmail.com>
with a slight modification by me.
---
 share/mk/bsd.kmod.mk   |    1 +
 share/mk/bsd.own.mk    |   15 ---------------
 sys/conf/kern.paths.mk |   15 +++++++++++++++
 sys/conf/kern.post.mk  |   39 +++++++++++++++++++--------------------
 sys/conf/kern.pre.mk   |    1 -
 sys/conf/kmod.mk       |   12 ++++++++++--
 6 files changed, 45 insertions(+), 38 deletions(-)
 create mode 100644 sys/conf/kern.paths.mk

diff --git a/share/mk/bsd.kmod.mk b/share/mk/bsd.kmod.mk
index 61bddd6..c3a1b2c 100644
--- a/share/mk/bsd.kmod.mk
+++ b/share/mk/bsd.kmod.mk
@@ -12,5 +12,6 @@ SYSDIR=	${_dir}
 .endif
 
 .include "${SYSDIR}/conf/kmod.mk"
+.include "${SYSDIR}/conf/kern.paths.mk"
 
 .include <bsd.sys.mk>
diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk
index e09ffe6..42ca5ad 100644
--- a/share/mk/bsd.own.mk
+++ b/share/mk/bsd.own.mk
@@ -84,16 +84,6 @@
 # LIBMODE	Library mode. [${NOBINMODE}]
 #
 #
-# KMODDIR	Base path for loadable kernel modules
-#		(see kld(4)). [/boot/modules]
-#
-# KMODOWN	KLD owner. [${BINOWN}]
-#
-# KMODGRP	KLD group. [${BINGRP}]
-#
-# KMODMODE	KLD mode. [${BINMODE}]
-#
-#
 # SHAREDIR	Base path for architecture-independent ascii
 #		text files. [/usr/share]
 #
@@ -151,11 +141,6 @@ BINGRP?=	wheel
 BINMODE?=	555
 NOBINMODE?=	444
 
-KMODDIR?=	/boot/modules
-KMODOWN?=	${BINOWN}
-KMODGRP?=	${BINGRP}
-KMODMODE?=	${BINMODE}
-
 LIBDIR?=	/usr/lib
 GCCLIBDIR?=	${LIBDIR}/${CCVER}
 LIBCOMPATDIR?=	/usr/lib/compat
diff --git a/sys/conf/kern.paths.mk b/sys/conf/kern.paths.mk
new file mode 100644
index 0000000..93c3fd0
--- /dev/null
+++ b/sys/conf/kern.paths.mk
@@ -0,0 +1,15 @@
+# Set up the default install paths for kernel/modules
+#
+# DESTLABEL		add suffix to kernel and modules directory [not set]
+# DESTKERNDIR		where kernel and modules are to be installed [/boot]
+# DESTKERNNAME		name of installed kernel [${KERNEL}]
+# DESTMODULESNAME	name of modules directory [modules]
+#
+.if defined(DESTLABEL)
+DESTKERNNAME?=		${KERNEL}.${DESTLABEL}
+DESTMODULESNAME?=	modules.${DESTLABEL}
+.else
+DESTKERNNAME?=		${KERNEL}
+DESTMODULESNAME?=	modules
+.endif
+DESTKERNDIR?=		/boot
diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk
index 3074760..de0dc8e 100644
--- a/sys/conf/kern.post.mk
+++ b/sys/conf/kern.post.mk
@@ -9,6 +9,7 @@ all: ${KERNEL}.stripped
 
 _MACHINE_FWD=	${.OBJDIR}
 .include "$S/conf/kern.fwd.mk"
+.include "$S/conf/kern.paths.mk"
 
 depend kernel-depend modules-depend: ${FORWARD_HEADERS_COOKIE}
 
@@ -111,43 +112,41 @@ kernel-install: kernel-installable
 		echo "You must build a kernel first." ; \
 		exit 1 ; \
 	fi
-.  if exists(${DESTDIR}/boot/${DESTKERNNAME})
+.  if exists(${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME})
 .ifndef NOFSCHG
-	-chflags noschg ${DESTDIR}/boot/${DESTKERNNAME}
+	-chflags noschg ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
 .endif
 .    ifdef NO_KERNEL_OLD_STRIP
-	cp -p ${DESTDIR}/boot/${DESTKERNNAME} ${DESTDIR}/boot/${DESTKERNNAME}.old
+	cp -p ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}.old
 .    else
-	${OBJCOPY} --strip-debug ${DESTDIR}/boot/${DESTKERNNAME} ${DESTDIR}/boot/${DESTKERNNAME}.old
+	${OBJCOPY} --strip-debug ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}.old
 .    endif
 .  endif
+	mkdir -p ${DESTDIR}${DESTKERNDIR}
 .ifdef NOFSCHG
 	${INSTALL} -m 555 -o root -g wheel \
-		${SELECTEDKERNEL} ${DESTDIR}/boot/${DESTKERNNAME}
+		${SELECTEDKERNEL} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
 .else
 	${INSTALL} -m 555 -o root -g wheel -fschg \
-		${SELECTEDKERNEL} ${DESTDIR}/boot/${DESTKERNNAME}
+		${SELECTEDKERNEL} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
 .endif
 
 kernel-reinstall: kernel-installable
+	mkdir -p ${DESTDIR}${DESTKERNDIR}
 .ifdef NOFSCHG
 	${INSTALL} -m 555 -o root -g wheel \
-		${SELECTEDKERNEL} ${DESTDIR}/boot/${DESTKERNNAME}
+		${SELECTEDKERNEL} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
 .else
 	${INSTALL} -m 555 -o root -g wheel -fschg \
-		${SELECTEDKERNEL} ${DESTDIR}/boot/${DESTKERNNAME}
+		${SELECTEDKERNEL} ${DESTDIR}${DESTKERNDIR}/${DESTKERNNAME}
 .endif
 
-# Require DESTDIR to be manually specified when installing a
-# virtual kernel.
-#
 kernel-installable:
 .if ${P} == vkernel
 .if !defined(DESTDIR)
 	@echo "When installing a virtual kernel, DESTDIR must be manually specified"
 	@exit 1
 .endif
-.endif
 	@if [ -f ${DESTDIR}/${DESTKERNNAME} ]; then \
 		echo "You need to make buildworld, installworld, and upgrade"; \
 		echo "before you can install a new kernel, because the"; \
@@ -199,28 +198,28 @@ modules-tags:
 modules-install:
 .if !defined(NO_MODULES_OLD)
 .  ifdef NO_KERNEL_OLD_STRIP
-	set -- ${DESTDIR}/boot/modules/*; \
+	set -- ${DESTDIR}${DESTKERNDIR}/${DESTMODULESNAME}/*; \
 	if [ -f "$$1" ]; then \
-		mkdir -p ${DESTDIR}/boot/modules.old; \
+		mkdir -p ${DESTDIR}${DESTKERNDIR}/${DESTMODULESNAME}.old; \
 		for file; do \
-		cp -p $$file ${DESTDIR}/boot/modules.old; \
+		cp -p $$file ${DESTDIR}${DESTKERNDIR}/${DESTMODULESNAME}.old; \
 		done; \
 	fi
 .  else
-	set -- ${DESTDIR}/boot/modules/*; \
+	set -- ${DESTDIR}${DESTKERNDIR}/${DESTMODULESNAME}/*; \
 	if [ -f "$$1" ]; then \
-		mkdir -p ${DESTDIR}/boot/modules.old; \
+		mkdir -p ${DESTDIR}${DESTKERNDIR}/${DESTMODULESNAME}.old; \
 		for file; do \
-		${OBJCOPY} --strip-debug $$file ${DESTDIR}/boot/modules.old/$${file##*/}; \
+		${OBJCOPY} --strip-debug $$file ${DESTDIR}${DESTKERNDIR}/${DESTMODULESNAME}.old/$${file##*/}; \
 		done; \
 	fi
 .  endif
 .endif
-	mkdir -p ${DESTDIR}/boot/modules # Ensure that the modules directory exists!
+	mkdir -p ${DESTDIR}${DESTKERNDIR}/${DESTMODULESNAME} # Ensure that the modules directory exists!
 	cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
 
 modules-reinstall:
-	mkdir -p ${DESTDIR}/boot/modules # Ensure that the modules directory exists!
+	mkdir -p ${DESTDIR}/${DESTKERNDIR}/${DESTMODULESNAME} # Ensure that the modules directory exists!
 	cd $S ; env ${MKMODULESENV} ${MAKE} -f Makefile.modules install
 
 config.o:
diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index 34527fa..7aff388 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -106,7 +106,6 @@ SELECTEDKERNEL= ${KERNEL}.debug
 FULLKERNEL=	${KERNEL}.nodebug
 SELECTEDKERNEL= ${KERNEL}.stripped
 .endif
-DESTKERNNAME?=	${KERNEL}
 
 
 MKMODULESENV=	MAKEOBJDIRPREFIX=${.OBJDIR} BUILDING_WITH_KERNEL=${.OBJDIR}
diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk
index 395597b..cd6bf2b 100644
--- a/sys/conf/kmod.mk
+++ b/sys/conf/kmod.mk
@@ -12,7 +12,8 @@
 #
 # KMOD          The name of the kernel module to build.
 #
-# KMODDIR	Base path for kernel modules (see kld(4)). [/modules]
+# KMODDIR	Base path for kernel modules (see kld(4)).
+#		[${DESTKERNDIR}/${DESTMODULESNAME}]
 #
 # KMODOWN	KLD owner. [${BINOWN}]
 #
@@ -33,7 +34,9 @@
 #
 # KMODDEPS	List of modules which this one is dependant on
 #
-# DESTDIR	Change the tree where the module gets installed. [not set]
+# DESTKERNDIR	Change the tree where the kernel and the modules get
+#		installed. [/boot]  ${DESTDIR} changes the root of the tree
+#		pointed to by ${DESTKERNDIR}.
 #
 # MFILES	Optionally a list of interfaces used by the module.
 #		This file contains a default list of interfaces.
@@ -62,6 +65,11 @@ OBJCOPY?=	objcopy
 KMODLOAD?=	/sbin/kldload
 KMODUNLOAD?=	/sbin/kldunload
 
+KMODDIR?=	${DESTKERNDIR}/${DESTMODULESNAME}
+KMODOWN?=	${BINOWN}
+KMODGRP?=	${BINGRP}
+KMODMODE?=	${BINMODE}
+
 .include <bsd.init.mk>
 
 .SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
-- 
1.6.0.6


--gBBFr7Ir9EOA20Yy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="0002-Set-the-default-DESTDIR-to-var-vkernel-when-the-pla.patch"




[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]