diff options
author | will <will@FreeBSD.org> | 2014-09-29 15:05:23 +0000 |
---|---|---|
committer | will <will@FreeBSD.org> | 2014-09-29 15:05:23 +0000 |
commit | 57c53dc77d6c623a52956cacd08eadd4b76b2d03 (patch) | |
tree | 2b3413d19aa8b940b2aee7ef9775c3b9db2256fa | |
parent | 3e09082bfdd0ef879633abe454ba89a2f215cc36 (diff) | |
download | FreeBSD-src-57c53dc77d6c623a52956cacd08eadd4b76b2d03.zip FreeBSD-src-57c53dc77d6c623a52956cacd08eadd4b76b2d03.tar.gz |
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.
Use .if exists(), for four specific possibilities relative to .CURDIR:
., .., ../.., and ../../.. The fourth possibility is primarily in case
ports ever grows a third level. If none of these paths exist, fall back to
the old default of /usr/ports.
This removes the need to set PORTSDIR explicitly (or via wrapper script) if
one is running out of a ports tree that is not in /usr/ports, but in a
home directory.
Reviewed by: bapt, bdrewery (older version)
CR: D799
MFC after: 1 week
Sponsored by: Spectra Logic
-rw-r--r-- | share/mk/bsd.port.mk | 18 | ||||
-rw-r--r-- | share/mk/bsd.port.subdir.mk | 18 |
2 files changed, 34 insertions, 2 deletions
diff --git a/share/mk/bsd.port.mk b/share/mk/bsd.port.mk index 87e4935..ca9f857 100644 --- a/share/mk/bsd.port.mk +++ b/share/mk/bsd.port.mk @@ -1,6 +1,22 @@ # $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. +.if exists(${.CURDIR}/Mk/bsd.port.mk) +PORTSDIR= ${.CURDIR} +.elif exists(${.CURDIR}/../Mk/bsd.port.mk) +PORTSDIR= ${.CURDIR}/.. +.elif exists(${.CURDIR}/../../Mk/bsd.port.mk) +PORTSDIR= ${.CURDIR}/../.. +.elif exists(${.CURDIR}/../../../Mk/bsd.port.mk) +PORTSDIR= ${.CURDIR}/../../.. +.else +PORTSDIR= /usr/ports +.endif +.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..bdf07d5 100644 --- a/share/mk/bsd.port.subdir.mk +++ b/share/mk/bsd.port.subdir.mk @@ -1,6 +1,22 @@ # $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. +.if exists(${.CURDIR}/Mk/bsd.port.mk) +PORTSDIR= ${.CURDIR} +.elif exists(${.CURDIR}/../Mk/bsd.port.mk) +PORTSDIR= ${.CURDIR}/.. +.elif exists(${.CURDIR}/../../Mk/bsd.port.mk) +PORTSDIR= ${.CURDIR}/../.. +.elif exists(${.CURDIR}/../../../Mk/bsd.port.mk) +PORTSDIR= ${.CURDIR}/../../.. +.else +PORTSDIR= /usr/ports +.endif +.endif + BSDPORTSUBDIRMK?= ${PORTSDIR}/Mk/bsd.port.subdir.mk .include "${BSDPORTSUBDIRMK}" |