summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rw-r--r--share/mk/bsd.port.mk16
-rw-r--r--share/mk/bsd.port.subdir.mk16
2 files changed, 12 insertions, 20 deletions
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
OpenPOWER on IntegriCloud