From nobody@FreeBSD.org  Tue Apr 23 05:31:09 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	by hub.freebsd.org (Postfix) with ESMTP id 1844E213
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 23 Apr 2013 05:31:09 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id E41511872
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 23 Apr 2013 05:31:08 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r3N5V8Jl000620
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 23 Apr 2013 05:31:08 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r3N5V8nx000616;
	Tue, 23 Apr 2013 05:31:08 GMT
	(envelope-from nobody)
Message-Id: <201304230531.r3N5V8nx000616@red.freebsd.org>
Date: Tue, 23 Apr 2013 05:31:08 GMT
From: Garrett Cooper <yaneurabeya@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PATCH] [ports] look for Makefile.local in ${PORTSDIR} as well as ${.CURDIR}
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         178072
>Category:       ports
>Synopsis:       [PATCH] [bsd.port.mk] look for Makefile.local in ${PORTSDIR} as well as ${.CURDIR}
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bdrewery
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 23 05:40:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Thu Aug 29 20:45:52 CDT 2013
>Originator:     Garrett Cooper
>Release:        10-CURRENT
>Organization:
EMC Isilon
>Environment:
FreeBSD gran-tourismo.west.isilon.com 10.0-CURRENT FreeBSD 10.0-CURRENT #2 r+ba9afe9: Fri Apr 19 20:29:10 PDT 2013     gcooper@gran-tourismo.west.isilon.com:/usr/obj/usr/src/sys/GRAN-TOURISMO  amd64
>Description:
The attached patch looks for Makefile.local in PORTSDIR as well as .CURDIR, thus being a bit less braindead when it comes to looking for site-localizations when there are a large number of ports categories.

Thus one only needs to have one Makefile.local instead of n-categories worth when trying to apply non-invasive changes to a ports tree.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

Index: Mk/bsd.port.mk
===================================================================
--- Mk/bsd.port.mk	(revision 316288)
+++ Mk/bsd.port.mk	(working copy)
@@ -1260,10 +1260,12 @@
 USE_SUBMAKE=	yes
 .endif
 
-.if exists(${MASTERDIR}/Makefile.local)
-.include "${MASTERDIR}/Makefile.local"
+.for d in ${PORTSDIR} ${MASTERDIR}
+.if exists($d/Makefile.local)
+.include "$d/Makefile.local"
 USE_SUBMAKE=	yes
 .endif
+.endfor
 
 # where 'make config' records user configuration options
 PORT_DBDIR?=	/var/db/ports
Index: Mk/bsd.port.subdir.mk
===================================================================
--- Mk/bsd.port.subdir.mk	(revision 316288)
+++ Mk/bsd.port.subdir.mk	(working copy)
@@ -107,33 +107,33 @@
 .endif
 
 .if !defined(PYTHON_DEFAULT_VERSION)
-PYTHON_DEFAULT_VERSION!=	make -V PYTHON_DEFAULT_VERSION USE_PYTHON=1 -f ${PORTSDIR}/Mk/bsd.port.mk
+PYTHON_DEFAULT_VERSION!=	${MAKE} -V PYTHON_DEFAULT_VERSION USE_PYTHON=1 -f ${PORTSDIR}/Mk/bsd.port.mk
 .endif
 
 .if !defined(PYTHON_DEFAULT_PORTVERSION)
 # We are caching the PYTHON_PORTVERSION of the default python version so we can reuse it in the
 # common case.
-PYTHON_DEFAULT_PORTVERSION!=	make -V PYTHON_PORTVERSION USE_PYTHON=1 -f ${PORTSDIR}/Mk/bsd.port.mk
+PYTHON_DEFAULT_PORTVERSION!=	${MAKE} -V PYTHON_PORTVERSION USE_PYTHON=1 -f ${PORTSDIR}/Mk/bsd.port.mk
 .endif
 
 .if !defined(PYTHONBASE)
-PYTHONBASE!=			make -V PYTHONBASE USE_PYTHON=1 -f ${PORTSDIR}/Mk/bsd.port.mk
+PYTHONBASE!=			${MAKE} -V PYTHONBASE USE_PYTHON=1 -f ${PORTSDIR}/Mk/bsd.port.mk
 .endif
 
 .if !defined(_JAVA_VERSION_LIST_REGEXP)
-_JAVA_VERSION_LIST_REGEXP!=	make -V _JAVA_VERSION_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
+_JAVA_VERSION_LIST_REGEXP!=	${MAKE} -V _JAVA_VERSION_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
 .endif
 
 .if !defined(_JAVA_VENDOR_LIST_REGEXP)
-_JAVA_VENDOR_LIST_REGEXP!=	make -V _JAVA_VENDOR_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
+_JAVA_VENDOR_LIST_REGEXP!=	${MAKE} -V _JAVA_VENDOR_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
 .endif
 
 .if !defined(_JAVA_OS_LIST_REGEXP)
-_JAVA_OS_LIST_REGEXP!=		make -V _JAVA_OS_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
+_JAVA_OS_LIST_REGEXP!=		${MAKE} -V _JAVA_OS_LIST_REGEXP USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
 .endif
 
 .if !defined(_JAVA_PORTS_INSTALLED)
-_JAVA_PORTS_INSTALLED!=		make -V _JAVA_PORTS_INSTALLED USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
+_JAVA_PORTS_INSTALLED!=		${MAKE} -V _JAVA_PORTS_INSTALLED USE_JAVA=1 -f ${PORTSDIR}/Mk/bsd.port.mk
 .endif
 
 .if !defined(UID)
@@ -155,9 +155,11 @@
 INDEXFILE?=	INDEX-${OSVERSION:C/([0-9]*)[0-9]{5}/\1/}
 
 # local customization of the ports tree
-.if exists(${.CURDIR}/Makefile.local)
-.include "${.CURDIR}/Makefile.local"
+.for d in ${PORTSDIR} ${.CURDIR}
+.if exists($d/Makefile.local)
+.include "$d/Makefile.local"
 .endif
+.endfor
 
 TARGETS+=	all
 TARGETS+=	build


>Release-Note:
>Audit-Trail:

From: Garrett Cooper <yanegomi@gmail.com>
To: bug-followup@FreeBSD.org,
 yaneurabeya@gmail.com
Cc:  
Subject: Re: ports/178072: [PATCH] [ports] look for Makefile.local in ${PORTSDIR} as well as ${.CURDIR}
Date: Tue, 23 Apr 2013 15:56:54 -0700

 --Apple-Mail=_4687FAF2-9892-43F8-A067-721B6886C092
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=us-ascii
 
 	The attached patch is more correct than the previous one.
 1. It removes noise from another patch I submitted (ports/178070).
 2. It also fixes the case where double inclusion would be done =
 (${.CURDIR} =3D=3D ${PORTSDIR}). Granted, this check could probably be =
 improved, but this seems sane enough as-is.
 Thanks!
 -Garrett
 
 
 --Apple-Mail=_4687FAF2-9892-43F8-A067-721B6886C092
 Content-Disposition: attachment;
 	filename=search-for-Makefile.local-in-PORTSDIR.patch.txt
 Content-Type: text/plain;
 	x-unix-mode=0644;
 	name="search-for-Makefile.local-in-PORTSDIR.patch.txt"
 Content-Transfer-Encoding: 7bit
 
 Index: Mk/bsd.port.mk
 ===================================================================
 --- Mk/bsd.port.mk	(revision 316288)
 +++ Mk/bsd.port.mk	(working copy)
 @@ -1260,10 +1260,16 @@
  USE_SUBMAKE=	yes
  .endif
  
 -.if exists(${MASTERDIR}/Makefile.local)
 -.include "${MASTERDIR}/Makefile.local"
 +__dirs= ${.CURDIR}
 +.if ${PORTSDIR} != ${.CURDIR}
 +__dirs+= ${PORTSDIR}
 +.endif
 +.for d in ${__dirs}
 +.if exists($d/Makefile.local)
 +.include "$d/Makefile.local"
  USE_SUBMAKE=	yes
  .endif
 +.endfor
  
  # where 'make config' records user configuration options
  PORT_DBDIR?=	/var/db/ports
 Index: Mk/bsd.port.subdir.mk
 ===================================================================
 --- Mk/bsd.port.subdir.mk	(revision 316288)
 +++ Mk/bsd.port.subdir.mk	(working copy)
 @@ -155,9 +155,15 @@
  INDEXFILE?=	INDEX-${OSVERSION:C/([0-9]*)[0-9]{5}/\1/}
  
  # local customization of the ports tree
 -.if exists(${.CURDIR}/Makefile.local)
 -.include "${.CURDIR}/Makefile.local"
 +__dirs= ${.CURDIR}
 +.if ${PORTSDIR} != ${.CURDIR}
 +__dirs+= ${PORTSDIR}
  .endif
 +.for d in ${__dirs}
 +.if exists($d/Makefile.local)
 +.include "$d/Makefile.local"
 +.endif
 +.endfor
  
  TARGETS+=	all
  TARGETS+=	build
 
 --Apple-Mail=_4687FAF2-9892-43F8-A067-721B6886C092--
Responsible-Changed-From-To: freebsd-ports-bugs->portmgr 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu May 2 23:12:28 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=178072 
Responsible-Changed-From-To: portmgr->bdrewery 
Responsible-Changed-By: bdrewery 
Responsible-Changed-When: Thu Aug 29 20:45:51 CDT 2013 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=178072 
>Unformatted:
