Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Oct 2014 20:52:08 +0000 (UTC)
From:      Will Andrews <will@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r272383 - head/share/mk
Message-ID:  <201410012052.s91Kq8Md005971@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: will
Date: Wed Oct  1 20:52:08 2014
New Revision: 272383
URL: https://svnweb.freebsd.org/changeset/base/272383

Log:
  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)

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	Wed Oct  1 20:37:15 2014	(r272382)
+++ head/share/mk/bsd.port.mk	Wed Oct  1 20:52:08 2014	(r272383)
@@ -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

Modified: head/share/mk/bsd.port.subdir.mk
==============================================================================
--- head/share/mk/bsd.port.subdir.mk	Wed Oct  1 20:37:15 2014	(r272382)
+++ head/share/mk/bsd.port.subdir.mk	Wed Oct  1 20:52:08 2014	(r272383)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410012052.s91Kq8Md005971>