Subject: absolute directories in ${SUBDIR}
To: None <tech-userlevel@netbsd.org>
From: Aidan Cully <aidan@kublai.com>
List: tech-userlevel
Date: 03/01/2000 00:36:24
Any objections to this patch to allow SUBDIR to contain absolute
directories?  An absolute path for .CURDIR breaks .PARSEDIR-
relative includes, since we'd be doing (in effect)
cd /${.CURDIR}/${.CURDIR}/${.PARSEDIR}.  I mean, .PARSEDIR
contains .CURDIR in that case, and .CURDIR is absolute.

The shell 'case' is necessary because the variable .if would work
against (${dir}) no longer exists when the .for is done, and the
.if is eval'ed.

So, any other objections? :-)
--aidan

--- bsd.subdir.mk	1999/02/11 05:01:39	1.31
+++ bsd.subdir.mk	2000/03/01 05:27:24
@@ -22,9 +22,17 @@
 .for targ in ${TARGETS}
 .PHONY: ${targ}-${dir}
 ${targ}-${dir}: .MAKE
-	@echo "${targ} ===> ${_THISDIR_}${dir}"
-	@cd ${.CURDIR}/${dir}; \
-	${MAKE} "_THISDIR_=${_THISDIR_}${dir}/" ${targ}
+	@case "${dir}" in /*) \
+		echo "${targ} ===> ${dir}"; \
+		cd ${dir}; \
+		${MAKE} "_THISDIR_=${dir}/" ${targ}; \
+		;; \
+	*) \
+		echo "${targ} ===> ${_THISDIR_}${dir}"; \
+		cd ${.CURDIR}/${dir}; \
+		${MAKE} "_THISDIR_=${_THISDIR_}${dir}/" ${targ}; \
+		;; \
+	esac
 subdir-${targ}: ${targ}-${dir}
 ${targ}: subdir-${targ}
 .endfor