From 9591838e19776140c1c33e3eed83f41da431f5d3 Mon Sep 17 00:00:00 2001 From: bdrewery Date: Mon, 31 Aug 2015 20:44:52 +0000 Subject: MFC r272282,r272363,r272383: r272282: Search for the nearest PORTSDIR where Mk/bsd.ports.mk exists, from .CURDIR. This will only take effect if PORTSDIR is not set, as previously supported. r272363: Always resolve PORTSDIR to absolute paths using realpath(1). r272383: Revise r272363 by collapsing the tests into a for loop. Relnotes: yes --- share/mk/bsd.port.mk | 14 +++++++++++++- share/mk/bsd.port.subdir.mk | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'share/mk') diff --git a/share/mk/bsd.port.mk b/share/mk/bsd.port.mk index 87e4935..4f73d12 100644 --- a/share/mk/bsd.port.mk +++ b/share/mk/bsd.port.mk @@ -1,6 +1,18 @@ # $FreeBSD$ -PORTSDIR?= /usr/ports +.if !defined(PORTSDIR) +# 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. +.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 # Needed to keep bsd.own.mk from reading in /etc/src.conf diff --git a/share/mk/bsd.port.subdir.mk b/share/mk/bsd.port.subdir.mk index 5115602..8e608a1 100644 --- a/share/mk/bsd.port.subdir.mk +++ b/share/mk/bsd.port.subdir.mk @@ -1,6 +1,18 @@ # $FreeBSD$ -PORTSDIR?= /usr/ports +.if !defined(PORTSDIR) +# 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. +.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 .include "${BSDPORTSUBDIRMK}" -- cgit v1.1