Index: sys/conf/kern.pre.mk =================================================================== --- sys/conf/kern.pre.mk +++ sys/conf/kern.pre.mk @@ -208,6 +208,7 @@ # Calculate path for .m files early, if needed. .if !defined(_MPATH) __MPATH!=find ${S:tA}/ -name \*_if.m +_MFILES=${__MPATH:T:O} _MPATH=${__MPATH:H:O:u} .endif @@ -227,7 +228,7 @@ .if defined(DEBUG) MKMODULESENV+= DEBUG_FLAGS="${DEBUG}" .endif -MKMODULESENV+= _MPATH="${_MPATH}" +MKMODULESENV+= _MPATH="${_MPATH}" _MFILES="${_MFILES}" # Architecture and output format arguments for objdump to convert image to # object file Index: sys/conf/kmod.mk =================================================================== --- sys/conf/kmod.mk +++ sys/conf/kmod.mk @@ -372,12 +372,16 @@ # Build _if.[ch] from _if.m, and clean them when we're done. .if !defined(_MPATH) __MPATH!=find ${SYSDIR:tA}/ -name \*_if.m +_MFILES=${__MPATH:T:O} _MPATH=${__MPATH:H:O:u} .endif .PATH.m: ${_MPATH} .for _i in ${SRCS:M*_if.[ch]} -#removes too much, comment out until it's more constrained. -#CLEANFILES+= ${_i} +_MATCH=M${_i:R:S/$/.m/} +_MATCHES=${_MFILES:${_MATCH}} +.if !empty(_MATCHES) +CLEANFILES+= ${_i} +.endif .endfor # _i .m.c: ${SYSDIR}/tools/makeobjops.awk ${AWK} -f ${SYSDIR}/tools/makeobjops.awk ${.IMPSRC} -c