Changeset View
Changeset View
Standalone View
Standalone View
Mk/Uses/kmod.mk
# Handles common items for kernel module ports. | # Handles common items for kernel module ports. | ||||
# | # | ||||
# Feature: kmod | # Feature: kmod | ||||
# Usage: USES=kmod | # Usage: USES=kmod | ||||
# Valid ARGS: (none) debug | # Valid ARGS: (none) debug | ||||
# | # | ||||
# MAINTAINER: rene@FreeBSD.org | # MAINTAINER: rene@FreeBSD.org | ||||
.if !defined(_INCLUDE_USES_KMOD_MK) | .if !defined(_INCLUDE_USES_KMOD_MK) | ||||
_INCLUDE_USES_KMOD_MK= yes | _INCLUDE_USES_KMOD_MK= yes | ||||
_USES_POST+= kmod | _USES_POST+= kmod | ||||
.if empty(kmod_ARGS) | . if empty(kmod_ARGS) | ||||
_DEBUG_KMOD= | _DEBUG_KMOD= | ||||
.elif ${kmod_ARGS} == "debug" | . elif ${kmod_ARGS} == "debug" | ||||
_DEBUG_KMOD= yes | _DEBUG_KMOD= yes | ||||
.else | . else | ||||
IGNORE= USES=kmod takes either no arguments or 'debug' | IGNORE= USES=kmod takes either no arguments or 'debug' | ||||
.endif | . endif | ||||
.if !exists(${SRC_BASE}/sys/Makefile) && target(build) | . if !exists(${SRC_BASE}/sys/Makefile) && target(build) | ||||
IGNORE= requires kernel source files in SRC_BASE=${SRC_BASE} | IGNORE= requires kernel source files in SRC_BASE=${SRC_BASE} | ||||
.endif | . endif | ||||
CATEGORIES+= kld | CATEGORIES+= kld | ||||
SSP_UNSAFE= kernel module supports SSP natively | SSP_UNSAFE= kernel module supports SSP natively | ||||
KMODDIR?= /boot/modules | KMODDIR?= /boot/modules | ||||
.if ${KMODDIR} == /boot/kernel | . if ${KMODDIR} == /boot/kernel | ||||
KMODDIR= /boot/modules | KMODDIR= /boot/modules | ||||
.endif | . endif | ||||
_DEBUG_KMOD_SH= \ | _DEBUG_KMOD_SH= \ | ||||
${ECHO_CMD} -n "\"@dir /%%KERN_DEBUGDIR%%/%%KMODDIR%%\"" ; \ | ${ECHO_CMD} -n "\"@dir /%%KERN_DEBUGDIR%%/%%KMODDIR%%\"" ; \ | ||||
skd=`${ECHO_CMD} ${KMODDIR} | ${SED} "s,/, ,g"` ; \ | skd=`${ECHO_CMD} ${KMODDIR} | ${SED} "s,/, ,g"` ; \ | ||||
l=`${ECHO_CMD} $$skd | wc -w` ; \ | l=`${ECHO_CMD} $$skd | wc -w` ; \ | ||||
while [ $$l -gt 0 ] ; do \ | while [ $$l -gt 0 ] ; do \ | ||||
c=0 ; \ | c=0 ; \ | ||||
r="" ; \ | r="" ; \ | ||||
for p in $$skd ; do \ | for p in $$skd ; do \ | ||||
c=$$(($$c+1)) ; \ | c=$$(($$c+1)) ; \ | ||||
if [ $$c -eq $$l ] ; then \ | if [ $$c -eq $$l ] ; then \ | ||||
break ; \ | break ; \ | ||||
fi ; \ | fi ; \ | ||||
r="$$r/$$p" ; \ | r="$$r/$$p" ; \ | ||||
done ; \ | done ; \ | ||||
${ECHO_CMD} -n " \"@dir /%%KERN_DEBUGDIR%%$$r\"" ; \ | ${ECHO_CMD} -n " \"@dir /%%KERN_DEBUGDIR%%$$r\"" ; \ | ||||
l=$$(($$l-1)) ; \ | l=$$(($$l-1)) ; \ | ||||
done | done | ||||
PLIST_SUB+= KMODDIR="${KMODDIR:C,^/,,}" | PLIST_SUB+= KMODDIR="${KMODDIR:C,^/,,}" | ||||
MAKE_ENV+= KMODDIR="${KMODDIR}" SYSDIR="${SRC_BASE}/sys" NO_XREF=yes | MAKE_ENV+= KMODDIR="${KMODDIR}" SYSDIR="${SRC_BASE}/sys" NO_XREF=yes | ||||
PLIST_FILES+= "@kld ${KMODDIR}" | PLIST_FILES+= "@kld ${KMODDIR}" | ||||
STRIP_CMD+= --strip-debug # do not strip kernel symbols | STRIP_CMD+= --strip-debug # do not strip kernel symbols | ||||
.if !empty(_DEBUG_KMOD) | . if !empty(_DEBUG_KMOD) | ||||
KERN_DEBUGDIR?= ${DEBUGDIR} | KERN_DEBUGDIR?= ${DEBUGDIR} | ||||
PLIST_SUB+= KERN_DEBUGDIR="${KERN_DEBUGDIR:C,^/,,}" | PLIST_SUB+= KERN_DEBUGDIR="${KERN_DEBUGDIR:C,^/,,}" | ||||
MAKE_ENV+= KERN_DEBUGDIR="${KERN_DEBUGDIR}" | MAKE_ENV+= KERN_DEBUGDIR="${KERN_DEBUGDIR}" | ||||
_KMOD_DIRS!= ${_DEBUG_KMOD_SH} | _KMOD_DIRS!= ${_DEBUG_KMOD_SH} | ||||
PLIST_FILES+= ${_KMOD_DIRS} | PLIST_FILES+= ${_KMOD_DIRS} | ||||
.endif | . endif | ||||
.endif | .endif | ||||
.if defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_KMOD_POST_MK) | .if defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_KMOD_POST_MK) | ||||
_INCLUDE_USES_KMOD_POST_MK= yes | _INCLUDE_USES_KMOD_POST_MK= yes | ||||
_USES_install+= 290:${STAGEDIR}${KMODDIR} | _USES_install+= 290:${STAGEDIR}${KMODDIR} | ||||
${STAGEDIR}${KMODDIR}: | ${STAGEDIR}${KMODDIR}: | ||||
@${MKDIR} ${.TARGET} | @${MKDIR} ${.TARGET} | ||||
.if !empty(_DEBUG_KMOD) | . if !empty(_DEBUG_KMOD) | ||||
_USES_install+= 291:${STAGEDIR}${KERN_DEBUGDIR}${KMODDIR} | _USES_install+= 291:${STAGEDIR}${KERN_DEBUGDIR}${KMODDIR} | ||||
${STAGEDIR}${KERN_DEBUGDIR}${KMODDIR}: | ${STAGEDIR}${KERN_DEBUGDIR}${KMODDIR}: | ||||
@${MKDIR} ${.TARGET} | @${MKDIR} ${.TARGET} | ||||
.endif | . endif | ||||
.endif | .endif |