From b98c483e82dda6c959e86013ad94b93b6b79ec73 Mon Sep 17 00:00:00 2001 From: will Date: Wed, 1 Oct 2014 20:52:08 +0000 Subject: Revise r272363 by collapsing the tests into a for loop. This has the side effect of ensuring that realpath is also run for the nominal case of PORTSDIR=/usr/ports (assuming .CURDIR is a ports directory that relies on /usr/ports but is not rooted in it). This ensures that any generated PORTSDIR used is always the actual location. Submitted by: jkim (different implementation) --- share/mk/bsd.port.mk | 16 ++++++---------- share/mk/bsd.port.subdir.mk | 16 ++++++---------- 2 files changed, 12 insertions(+), 20 deletions(-) (limited to 'share') diff --git a/share/mk/bsd.port.mk b/share/mk/bsd.port.mk index 0800c71..4f73d12 100644 --- a/share/mk/bsd.port.mk +++ b/share/mk/bsd.port.mk @@ -4,17 +4,13 @@ # Autodetect if the command is being run in a ports tree that's not rooted # in the default /usr/ports. The ../../.. case is in case ports ever grows # a third level. -.if exists(${.CURDIR}/Mk/bsd.port.mk) -PORTSDIR!= realpath ${.CURDIR} -.elif exists(${.CURDIR}/../Mk/bsd.port.mk) -PORTSDIR!= realpath ${.CURDIR}/.. -.elif exists(${.CURDIR}/../../Mk/bsd.port.mk) -PORTSDIR!= realpath ${.CURDIR}/../.. -.elif exists(${.CURDIR}/../../../Mk/bsd.port.mk) -PORTSDIR!= realpath ${.CURDIR}/../../.. -.else -PORTSDIR= /usr/ports +.for RELPATH in . .. ../.. ../../.. +.if !defined(_PORTSDIR) && exists(${.CURDIR}/${RELPATH}/Mk/bsd.port.mk) +_PORTSDIR= ${.CURDIR}/${RELPATH} .endif +.endfor +_PORTSDIR?= /usr/ports +PORTSDIR!= realpath ${_PORTSDIR} .endif BSDPORTMK?= ${PORTSDIR}/Mk/bsd.port.mk diff --git a/share/mk/bsd.port.subdir.mk b/share/mk/bsd.port.subdir.mk index 55a1a7e..8e608a1 100644 --- a/share/mk/bsd.port.subdir.mk +++ b/share/mk/bsd.port.subdir.mk @@ -4,17 +4,13 @@ # Autodetect if the command is being run in a ports tree that's not rooted # in the default /usr/ports. The ../../.. case is in case ports ever grows # a third level. -.if exists(${.CURDIR}/Mk/bsd.port.mk) -PORTSDIR!= realpath ${.CURDIR} -.elif exists(${.CURDIR}/../Mk/bsd.port.mk) -PORTSDIR!= realpath ${.CURDIR}/.. -.elif exists(${.CURDIR}/../../Mk/bsd.port.mk) -PORTSDIR!= realpath ${.CURDIR}/../.. -.elif exists(${.CURDIR}/../../../Mk/bsd.port.mk) -PORTSDIR!= realpath ${.CURDIR}/../../.. -.else -PORTSDIR= /usr/ports +.for RELPATH in . .. ../.. ../../.. +.if !defined(_PORTSDIR) && exists(${.CURDIR}/${RELPATH}/Mk/bsd.port.mk) +_PORTSDIR= ${.CURDIR}/${RELPATH} .endif +.endfor +_PORTSDIR?= /usr/ports +PORTSDIR!= realpath ${_PORTSDIR} .endif BSDPORTSUBDIRMK?= ${PORTSDIR}/Mk/bsd.port.subdir.mk -- cgit v1.1