From owner-svn-src-head@FreeBSD.ORG Mon Sep 29 15:05:24 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 69457957; Mon, 29 Sep 2014 15:05:24 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3B60B856; Mon, 29 Sep 2014 15:05:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8TF5OUi066887; Mon, 29 Sep 2014 15:05:24 GMT (envelope-from will@FreeBSD.org) Received: (from will@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8TF5Nhh066884; Mon, 29 Sep 2014 15:05:23 GMT (envelope-from will@FreeBSD.org) Message-Id: <201409291505.s8TF5Nhh066884@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: will set sender to will@FreeBSD.org using -f From: Will Andrews Date: Mon, 29 Sep 2014 15:05:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272282 - head/share/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Sep 2014 15:05:24 -0000 Author: will Date: Mon Sep 29 15:05:23 2014 New Revision: 272282 URL: http://svnweb.freebsd.org/changeset/base/272282 Log: 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 Modified: head/share/mk/bsd.port.mk head/share/mk/bsd.port.subdir.mk Modified: head/share/mk/bsd.port.mk ============================================================================== --- head/share/mk/bsd.port.mk Mon Sep 29 10:36:14 2014 (r272281) +++ head/share/mk/bsd.port.mk Mon Sep 29 15:05:23 2014 (r272282) @@ -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 Modified: head/share/mk/bsd.port.subdir.mk ============================================================================== --- head/share/mk/bsd.port.subdir.mk Mon Sep 29 10:36:14 2014 (r272281) +++ head/share/mk/bsd.port.subdir.mk Mon Sep 29 15:05:23 2014 (r272282) @@ -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}"