From glarkin@pm.sourcehosting.net  Mon Jan 23 21:27:44 2012
Return-Path: <glarkin@pm.sourcehosting.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 7E7B510656B5
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 23 Jan 2012 21:27:37 +0000 (UTC)
	(envelope-from glarkin@pm.sourcehosting.net)
Received: from mail1.sourcehosting.net (mail1.sourcehosting.net [74.205.51.45])
	by mx1.freebsd.org (Postfix) with ESMTP id 550068FC1A
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 23 Jan 2012 21:27:37 +0000 (UTC)
Received: from [192.168.100.97] (helo=pm.sourcehosting.net)
	by mail1.sourcehosting.net with esmtp (Exim 4.73 (FreeBSD))
	(envelope-from <glarkin@pm.sourcehosting.net>)
	id 1RpR9K-000IEk-UY
	for FreeBSD-gnats-submit@freebsd.org; Mon, 23 Jan 2012 16:10:01 -0500
Received: from pm.sourcehosting.net (localhost [127.0.0.1])
	by pm.sourcehosting.net (8.14.4/8.14.4) with ESMTP id q0NJuNpp040626
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 23 Jan 2012 14:56:23 -0500 (EST)
	(envelope-from glarkin@pm.sourcehosting.net)
Received: (from glarkin@localhost)
	by pm.sourcehosting.net (8.14.4/8.14.4/Submit) id q0NJuNg8040625;
	Mon, 23 Jan 2012 14:56:23 -0500 (EST)
	(envelope-from glarkin)
Message-Id: <201201231956.q0NJuNg8040625@pm.sourcehosting.net>
Date: Mon, 23 Jan 2012 14:56:23 -0500 (EST)
From: Greg Larkin <glarkin@freebsd.org>
Reply-To: Greg Larkin <glarkin@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] Pass MAKE_ENV to recursive make invocations in Mk/bsd.port.mk
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         164423
>Category:       ports
>Synopsis:       [bsd.port.mk] [patch] Pass MAKE_ENV to recursive make invocations
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    portmgr
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 23 21:30:12 UTC 2012
>Closed-Date:    
>Last-Modified:  Fri Nov  2 15:00:00 UTC 2012
>Originator:     Greg Larkin
>Release:        FreeBSD 8.2-RELEASE-p3 amd64
>Organization:
The FreeBSD Project
>Environment:
System: FreeBSD pm.sourcehosting.net 8.2-RELEASE-p3 FreeBSD 8.2-RELEASE-p3 #0: Tue Sep 27 18:45:57 UTC 2011 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64


	
>Description:
bsd.port.mk contains several targets that recursively invoke make. If
the top-level make was invoked with a user-specified MAKE_ENV, it is not
passed to the recursive invocations.

>How-To-Repeat:
In order to configure a port and store the options file
in a non-standard location, the config target can be invoked like so:

    cd /usr/ports/devel/git && \
        make PORT_DBDIR=/tmp config

The options file /tmp/git/options will be created in this example.  If
the port is configured recursively, both of the following commands place
the options files in the standard /var/db/ports location:

    cd /usr/ports/devel/git && \
        make PORT_DBDIR=/tmp config-recursive

    cd /usr/ports/devel/git && \
        make MAKE_ENV+="PORT_DBDIR=/tmp" config-recursive

>Fix:

The attached patch invokes recursive make processes with the environment
specified by the top-level MAKE_ENV variable.

--- bsd.port.mk.recursive-make-env.diff begins here ---
--- bsd.port.mk.orig	2012-01-16 17:34:21.000000000 -0500
+++ bsd.port.mk	2012-01-23 14:50:27.000000000 -0500
@@ -4329,18 +4329,18 @@
 .if ${UID} != 0 && defined(_${target:U}_SUSEQ) && !defined(INSTALL_AS_USER)
 .if defined(USE_SUBMAKE)
 ${${target:U}_COOKIE}: ${_${target:U}_DEP}
-	@cd ${.CURDIR} && ${MAKE} ${_${target:U}_SEQ}
+	@cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} ${_${target:U}_SEQ}
 .else
 ${${target:U}_COOKIE}: ${_${target:U}_DEP} ${_${target:U}_SEQ}
 .endif
 	@${ECHO_MSG} "===>  Switching to root credentials for '${target}' target"
 	@cd ${.CURDIR} && \
-		${SU_CMD} "${MAKE} ${_${target:U}_SUSEQ}"
+		${SU_CMD} "${SETENV} ${MAKE_ENV} ${MAKE} ${_${target:U}_SUSEQ}"
 	@${ECHO_MSG} "===>  Returning to user credentials"
 	@${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
 .elif defined(USE_SUBMAKE)
 ${${target:U}_COOKIE}: ${_${target:U}_DEP}
-	@cd ${.CURDIR} && \
+	@cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} \
 		${MAKE} ${_${target:U}_SEQ} ${_${target:U}_SUSEQ}
 	@${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
 .else
@@ -4353,7 +4353,7 @@
 	@if [ -e ${.TARGET} ]; then \
 		${DO_NADA}; \
 	else \
-		cd ${.CURDIR} && ${MAKE} ${.TARGET}; \
+		cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} ${.TARGET}; \
 	fi
 .endif
 
@@ -5263,14 +5263,14 @@
 fetch-recursive:
 	@${ECHO_MSG} "===> Fetching all distfiles for ${PKGNAME} and dependencies"
 	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
-		(cd $$dir; ${MAKE} fetch); \
+		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} fetch); \
 	done
 .endif
 
 .if !target(fetch-recursive-list)
 fetch-recursive-list:
 	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
-		(cd $$dir; ${MAKE} fetch-list); \
+		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} fetch-list); \
 	done
 .endif
 
@@ -5333,7 +5333,7 @@
 checksum-recursive:
 	@${ECHO_MSG} "===> Fetching and checking checksums for ${PKGNAME} and dependencies"
 	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
-		(cd $$dir; ${MAKE} checksum); \
+		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} checksum); \
 	done
 .endif
 
@@ -5458,7 +5458,7 @@
 
 package-recursive: package
 	@for dir in $$(${ALL-DEPENDS-LIST}); do \
-		(cd $$dir; ${MAKE} package-noinstall); \
+		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} package-noinstall); \
 	done
 
 # Show missing dependencies
@@ -6008,7 +6008,7 @@
 config-recursive:
 	@${ECHO_MSG} "===> Setting user-specified options for ${PKGNAME} and dependencies";
 	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
-		(cd $$dir; ${MAKE} config-conditional); \
+		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} config-conditional); \
 	done
 .endif
 
@@ -6037,10 +6037,10 @@
 		shift 3; \
 	done; \
 	if [ "$${OPTIONS_INVALID}" = "yes" ]; then \
-		cd ${.CURDIR} && ${MAKE} config; \
+		cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} config; \
 	fi;
 .else
-	cd ${.CURDIR} && ${MAKE} config;
+	cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} config;
 .endif
 .endif
 .endif
@@ -6077,7 +6077,7 @@
 showconfig-recursive:
 	@${ECHO_MSG} "===> The following configuration options are available for ${PKGNAME} and dependencies";
 	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
-		(cd $$dir; ${MAKE} showconfig); \
+		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} showconfig); \
 	done
 .endif
 
@@ -6104,7 +6104,7 @@
 rmconfig-recursive:
 	@${ECHO_MSG} "===> Removing user-specified options for ${PKGNAME} and dependencies";
 	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
-		(cd $$dir; ${MAKE} rmconfig); \
+		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} rmconfig); \
 	done
 .endif
 
--- bsd.port.mk.recursive-make-env.diff ends here ---

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->portmgr 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Mon Jan 23 21:30:37 UTC 2012 
Responsible-Changed-Why:  
bsd.port.mk is portmgr territory (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=164423 

From: Greg Larkin <glarkin@FreeBSD.org>
To: bug-followup@FreeBSD.org, glarkin@freebsd.org
Cc:  
Subject: Re: ports/164423: [bsd.port.mk] [patch] Pass MAKE_ENV to recursive
 make invocations
Date: Fri, 02 Nov 2012 10:58:06 -0400

 This is a multi-part message in MIME format.
 --------------010407030404010802090309
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit
 
 
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 I have attached an updated version of the patch that applies to the
 current version of Mk/bsd.port.mk, as of Nov 2nd, 2012.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (Darwin)
 Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
 
 iEYEARECAAYFAlCT330ACgkQ0sRouByUApD4+QCgoq7+dI8xApA7+XNX4CtTvShw
 CUwAoId/TtwsD7xNh/LpOb+vLGo6bP1N
 =w4Qr
 -----END PGP SIGNATURE-----
 
 
 --------------010407030404010802090309
 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0";
  name="bsd.port.mk.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="bsd.port.mk.diff"
 
 *** bsd.port.mk.orig	Fri Nov  2 10:40:33 2012
 --- bsd.port.mk	Fri Nov  2 10:43:31 2012
 ***************
 *** 4355,4361 ****
   ${target}: ${${target:U}_COOKIE}
   .elif !target(${target})
   ${target}: config-conditional
 ! 	@cd ${.CURDIR} && ${MAKE} CONFIG_DONE_${UNIQUENAME:U}=1 ${${target:U}_COOKIE}
   .elif target(${target}) && defined(IGNORE)
   .endif
   
 --- 4355,4361 ----
   ${target}: ${${target:U}_COOKIE}
   .elif !target(${target})
   ${target}: config-conditional
 ! 	@cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} CONFIG_DONE_${UNIQUENAME:U}=1 ${${target:U}_COOKIE}
   .elif target(${target}) && defined(IGNORE)
   .endif
   
 ***************
 *** 4364,4382 ****
   .if ${UID} != 0 && defined(_${target:U}_SUSEQ) && !defined(INSTALL_AS_USER)
   .if defined(USE_SUBMAKE)
   ${${target:U}_COOKIE}: ${_${target:U}_DEP}
 ! 	@cd ${.CURDIR} && ${MAKE} ${_${target:U}_SEQ}
   .else
   ${${target:U}_COOKIE}: ${_${target:U}_DEP} ${_${target:U}_SEQ}
   .endif
   	@${ECHO_MSG} "===>  Switching to root credentials for '${target}' target"
   	@cd ${.CURDIR} && \
 ! 		${SU_CMD} "${MAKE} ${_${target:U}_SUSEQ}"
   	@${ECHO_MSG} "===>  Returning to user credentials"
   	@${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
   .elif defined(USE_SUBMAKE)
   ${${target:U}_COOKIE}: ${_${target:U}_DEP}
   	@cd ${.CURDIR} && \
 ! 		${MAKE} ${_${target:U}_SEQ} ${_${target:U}_SUSEQ}
   	@${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
   .else
   ${${target:U}_COOKIE}: ${_${target:U}_DEP} ${_${target:U}_SEQ} ${_${target:U}_SUSEQ}
 --- 4364,4382 ----
   .if ${UID} != 0 && defined(_${target:U}_SUSEQ) && !defined(INSTALL_AS_USER)
   .if defined(USE_SUBMAKE)
   ${${target:U}_COOKIE}: ${_${target:U}_DEP}
 ! 	@cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} ${_${target:U}_SEQ}
   .else
   ${${target:U}_COOKIE}: ${_${target:U}_DEP} ${_${target:U}_SEQ}
   .endif
   	@${ECHO_MSG} "===>  Switching to root credentials for '${target}' target"
   	@cd ${.CURDIR} && \
 ! 		${SU_CMD} "${SETENV} ${MAKE_ENV} ${MAKE} ${_${target:U}_SUSEQ}"
   	@${ECHO_MSG} "===>  Returning to user credentials"
   	@${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
   .elif defined(USE_SUBMAKE)
   ${${target:U}_COOKIE}: ${_${target:U}_DEP}
   	@cd ${.CURDIR} && \
 ! 		${SETENV} ${MAKE_ENV} ${MAKE} ${_${target:U}_SEQ} ${_${target:U}_SUSEQ}
   	@${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
   .else
   ${${target:U}_COOKIE}: ${_${target:U}_DEP} ${_${target:U}_SEQ} ${_${target:U}_SUSEQ}
 ***************
 *** 4388,4394 ****
   	@if [ -e ${.TARGET} ]; then \
   		${DO_NADA}; \
   	else \
 ! 		cd ${.CURDIR} && ${MAKE} ${.TARGET}; \
   	fi
   .endif
   
 --- 4388,4394 ----
   	@if [ -e ${.TARGET} ]; then \
   		${DO_NADA}; \
   	else \
 ! 		cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} ${.TARGET}; \
   	fi
   .endif
   
 ***************
 *** 5308,5321 ****
   fetch-recursive:
   	@${ECHO_MSG} "===> Fetching all distfiles for ${PKGNAME} and dependencies"
   	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${MAKE} fetch); \
   	done
   .endif
   
   .if !target(fetch-recursive-list)
   fetch-recursive-list:
   	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${MAKE} fetch-list); \
   	done
   .endif
   
 --- 5308,5321 ----
   fetch-recursive:
   	@${ECHO_MSG} "===> Fetching all distfiles for ${PKGNAME} and dependencies"
   	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} fetch); \
   	done
   .endif
   
   .if !target(fetch-recursive-list)
   fetch-recursive-list:
   	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} fetch-list); \
   	done
   .endif
   
 ***************
 *** 5341,5351 ****
   			else	\
   				continue;	\
   			fi;;	\
 ! 		*) if [ -d ${PKG_DBDIR}/$$(cd $$dir; ${MAKE} -V PKGNAME) ]; then \
   				continue;	\
   			fi;;	\
   		esac;	\
 ! 		echo cd $$dir; cd $$dir; ${MAKE} $$targ; \
   	done
   
   .if !target(fetch-required)
 --- 5341,5351 ----
   			else	\
   				continue;	\
   			fi;;	\
 ! 		*) if [ -d ${PKG_DBDIR}/$$(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} -V PKGNAME) ]; then \
   				continue;	\
   			fi;;	\
   		esac;	\
 ! 		echo cd $$dir; cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} $$targ; \
   	done
   
   .if !target(fetch-required)
 ***************
 *** 5378,5384 ****
   checksum-recursive:
   	@${ECHO_MSG} "===> Fetching and checking checksums for ${PKGNAME} and dependencies"
   	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${MAKE} checksum); \
   	done
   .endif
   
 --- 5378,5384 ----
   checksum-recursive:
   	@${ECHO_MSG} "===> Fetching and checking checksums for ${PKGNAME} and dependencies"
   	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} checksum); \
   	done
   .endif
   
 ***************
 *** 5442,5448 ****
   			case $$checked in	\
   			$$dir|$$dir\ *|*\ $$dir|*\ $$dir\ *) continue;;	\
   			esac;	\
 ! 			childout=$$(cd $$dir; ${MAKE} CHILD_DEPENDS=yes PARENT_CHECKED="$$checked" package-depends-list); \
   			set -- $$childout; \
   			childdir=""; \
   			while [ $$\# != 0 ]; do \
 --- 5442,5448 ----
   			case $$checked in	\
   			$$dir|$$dir\ *|*\ $$dir|*\ $$dir\ *) continue;;	\
   			esac;	\
 ! 			childout=$$(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} CHILD_DEPENDS=yes PARENT_CHECKED="$$checked" package-depends-list); \
   			set -- $$childout; \
   			childdir=""; \
   			while [ $$\# != 0 ]; do \
 ***************
 *** 5503,5509 ****
   
   package-recursive: package
   	@for dir in $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${MAKE} package-noinstall); \
   	done
   
   # Show missing dependencies
 --- 5503,5509 ----
   
   package-recursive: package
   	@for dir in $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} package-noinstall); \
   	done
   
   # Show missing dependencies
 ***************
 *** 6154,6160 ****
   config-recursive:
   	@${ECHO_MSG} "===> Setting user-specified options for ${PKGNAME} and dependencies";
   	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${MAKE} config-conditional); \
   	done
   .endif # config-recursive
   
 --- 6154,6160 ----
   config-recursive:
   	@${ECHO_MSG} "===> Setting user-specified options for ${PKGNAME} and dependencies";
   	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} config-conditional); \
   	done
   .endif # config-recursive
   
 ***************
 *** 6162,6168 ****
   config-conditional: pre-config
   .if defined(COMPLETE_OPTIONS_LIST) && !defined(NO_DIALOG)
   .  if !defined(_FILE_COMPLETE_OPTIONS_LIST) || ${COMPLETE_OPTIONS_LIST:O} != ${_FILE_COMPLETE_OPTIONS_LIST:O}
 ! 	@cd ${.CURDIR} && ${MAKE} do-config;
   .  endif
   .endif
   .endif # config-conditional
 --- 6162,6168 ----
   config-conditional: pre-config
   .if defined(COMPLETE_OPTIONS_LIST) && !defined(NO_DIALOG)
   .  if !defined(_FILE_COMPLETE_OPTIONS_LIST) || ${COMPLETE_OPTIONS_LIST:O} != ${_FILE_COMPLETE_OPTIONS_LIST:O}
 ! 	@cd ${.CURDIR} && ${SETENV} ${MAKE_ENV} ${MAKE} do-config;
   .  endif
   .endif
   .endif # config-conditional
 ***************
 *** 6226,6232 ****
   showconfig-recursive:
   	@${ECHO_MSG} "===> The following configuration options are available for ${PKGNAME} and dependencies";
   	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${MAKE} showconfig); \
   	done
   .endif # showconfig-recursive
   
 --- 6226,6232 ----
   showconfig-recursive:
   	@${ECHO_MSG} "===> The following configuration options are available for ${PKGNAME} and dependencies";
   	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} showconfig); \
   	done
   .endif # showconfig-recursive
   
 ***************
 *** 6253,6259 ****
   rmconfig-recursive:
   	@${ECHO_MSG} "===> Removing user-specified options for ${PKGNAME} and dependencies";
   	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${MAKE} rmconfig); \
   	done
   .endif # rmconfig-recursive
   
 --- 6253,6259 ----
   rmconfig-recursive:
   	@${ECHO_MSG} "===> Removing user-specified options for ${PKGNAME} and dependencies";
   	@for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
 ! 		(cd $$dir; ${SETENV} ${MAKE_ENV} ${MAKE} rmconfig); \
   	done
   .endif # rmconfig-recursive
   
 
 --------------010407030404010802090309
 Content-Type: application/octet-stream; x-mac-type="0"; x-mac-creator="0";
  name="bsd.port.mk.diff.sig"
 Content-Transfer-Encoding: base64
 Content-Disposition: attachment;
  filename="bsd.port.mk.diff.sig"
 
 iEYEABECAAYFAlCT330ACgkQ0sRouByUApCyOgCdHPyNKUzBD54wiWSf+8PMwj/P/9MAn181
 NVve73JDQp533JgCdwBEYhhH
 --------------010407030404010802090309--
>Unformatted:
