diff --git a/Makefile.inc1 b/Makefile.inc1 index 625e8324587c..7d828ec9d081 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -97,11 +97,22 @@ SUBDIR+=contrib/ofed # SUBDIR+=etc -# These are last, since it is nice to at least get the base system -# rebuilt before you do them. -.for _DIR in ${LOCAL_LIB_DIRS} ${LOCAL_DIRS} +# Local directories are last, since it is nice to at least get the base +# system rebuilt before you do them. +.for _DIR in ${LOCAL_DIRS} .if exists(${.CURDIR}/${_DIR}/Makefile) -SUBDIR+= ${_DIR} +SUBDIR+= ${_DIR} +.endif +.endfor +# Add LOCAL_LIB_DIRS, but only if they will not be picked up as a SUBDIR +# of a LOCAL_DIRS directory. This allows LOCAL_DIRS=foo and +# LOCAL_LIB_DIRS=foo/lib to behave as expected. +.for _DIR in ${LOCAL_DIRS:M*/} ${LOCAL_DIRS:N*/:S|$|/|} +_REDUNDENT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*} +.endfor +.for _DIR in ${LOCAL_LIB_DIRS} +.if empty(_REDUNDENT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile) +SUBDIR+= ${_DIR} .endif .endfor .endif