summaryrefslogtreecommitdiffstats
path: root/share/mk/bsd.kmod.mk
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2000-04-08 17:20:00 +0000
committerimp <imp@FreeBSD.org>2000-04-08 17:20:00 +0000
commit028e27dc430473934d800059eca2ffdb952a1970 (patch)
tree19b8e47fbd912e7815164c9a3c1e36ecb5414252 /share/mk/bsd.kmod.mk
parent57d5ddf5b7f9c6064bac8660db373fdec6af77b1 (diff)
downloadFreeBSD-src-028e27dc430473934d800059eca2ffdb952a1970.zip
FreeBSD-src-028e27dc430473934d800059eca2ffdb952a1970.tar.gz
Add support for compiling kernel modules outside of the tree. If you
do not have the kernel you wish to compile against in either /usr/src/sys or /sys, then you will need to set SYSDIR to point to the sys directory of the source tree that contians the source. Also, minor tweaks to the load/unload targets from Bruce. I've had this through several make worlds, as well as using it on a daily basis for the past couple of weeks to build modules needed for testing at Timing Solutions. Reviewed and revised by: bde Work sponsored by: Timing Solutions
Diffstat (limited to 'share/mk/bsd.kmod.mk')
-rw-r--r--share/mk/bsd.kmod.mk49
1 files changed, 19 insertions, 30 deletions
diff --git a/share/mk/bsd.kmod.mk b/share/mk/bsd.kmod.mk
index 6d7921b..11269c8 100644
--- a/share/mk/bsd.kmod.mk
+++ b/share/mk/bsd.kmod.mk
@@ -11,8 +11,6 @@
#
# DISTRIBUTION Name of distribution. [bin]
#
-# KERN Main Kernel source directory. [${.CURDIR}/../../sys/kern]
-#
# KMOD The name of the kernel module to build.
#
# KMODDIR Base path for kernel modules (see kld(4)). [/modules]
@@ -174,26 +172,23 @@ all: objwarn ${PROG} all-man _SUBDIR
beforedepend ${OBJS}: ${_ILINKS}
-# The search for the link targets works best if we are in a normal src
-# tree, and not too deeply below src/sys/modules. If we are near "/", then
-# we may find /sys - this is harmless. Other abnormal "sys" directories
-# found in the search are likely to cause problems. If nothing is found,
-# then the links default to /usr/include and /usr/include/machine.
+# Search for kernel source tree in standard places.
+.for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys
+.if !defined(SYSDIR) && exists(${_dir}/kern/)
+SYSDIR= ${_dir}
+.endif
+.endfor
+.if !defined(SYSDIR) || !exists(${SYSDIR}/kern/)
+.error "can't find kernel source tree"
+.endif
+
${_ILINKS}:
- @set +x; for up in ../.. ../../.. ; do \
- case ${.TARGET} in \
- machine) \
- testpath=${.CURDIR}/$$up/${MACHINE_ARCH}/include ; \
- path=${.CURDIR}/$$up/${MACHINE_ARCH}/include ; \
- defaultpath=/usr/include/machine ;; \
- @) \
- testpath=${.CURDIR}/$$up/sys ; \
- path=${.CURDIR}/$$up ; \
- defaultpath=/usr/include ;; \
- esac ; \
- if [ -d $$testpath ] ; then break ; fi ; \
- path=$$defaultpath ; \
- done ; \
+ @case ${.TARGET} in \
+ machine) \
+ path=${SYSDIR}/${MACHINE_ARCH}/include ;; \
+ @) \
+ path=${SYSDIR} ;; \
+ esac ; \
path=`(cd $$path && /bin/pwd)` ; \
${ECHO} ${.TARGET} "->" $$path ; \
ln -s $$path ${.TARGET}
@@ -257,19 +252,13 @@ distribute: _SUBDIR
.endif
.if !target(load)
-load: ${PROG} install
- ${KMODLOAD} ${KMOD}
+load: ${PROG}
+ ${KMODLOAD} -v ./${KMOD}
.endif
.if !target(unload)
unload:
- ${KMODUNLOAD} ${KMOD}
-.endif
-
-.if exists(${.CURDIR}/../../kern)
-KERN= ${.CURDIR}/../../kern
-.else
-KERN= ${.CURDIR}/../../sys/kern
+ ${KMODUNLOAD} -v ${KMOD}
.endif
.for _src in ${SRCS:Mopt_*.h}
OpenPOWER on IntegriCloud