From nobody@FreeBSD.org  Tue Apr 23 03:04:05 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id DDFE326B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 23 Apr 2013 03:04:05 +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 CED301502
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 23 Apr 2013 03:04:05 +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 r3N345xx069734
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 23 Apr 2013 03:04:05 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r3N345YL069733;
	Tue, 23 Apr 2013 03:04:05 GMT
	(envelope-from nobody)
Message-Id: <201304230304.r3N345YL069733@red.freebsd.org>
Date: Tue, 23 Apr 2013 03:04:05 GMT
From: Garrett Cooper <yaneurabeya@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PATCH] simplify _libraries by filtering out <lib>__L targets with associated commands
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         178068
>Category:       conf
>Synopsis:       [build] [patch] simplify _libraries by filtering out <lib>__L targets with associated commands
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 23 03:10:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Sun May 04 03:43:19 UTC 2014
>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:
In the event that someone wishes to hook in a separate library today (say ${LOCAL_LIB_DIRS}), they have to go about some degree of magic in order to filter out their manually created target.

libpam already skates by this requirement by being filtered out, so the best way to handle this is to check for a target being already defined beforehand with a series of commands associated with it, and instead of automatically generating said commands, just skip it because it's assumed that the user knows what they're doing and wish to bypass the autogeneration logic.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

From eb5946a80a4e6103a7236b23e65cbebd85c82e5c Mon Sep 17 00:00:00 2001
From: Garrett Cooper <yanegomi@gmail.com>
Date: Mon, 22 Apr 2013 18:15:55 -0700
Subject: [PATCH 2/3] Instead of specially filtering out lib/pam, use the
 commands macro to determine whether or not a rule should be generated.

Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
---
 Makefile.inc1 | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 27e0d1b..5175b5e 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -1528,18 +1528,6 @@ ${_lib}__PL: .PHONY
 .endif
 .endfor
 
-.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
-${_lib}__L: .PHONY
-.if exists(${.CURDIR}/${_lib})
-	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
-		cd ${.CURDIR}/${_lib}; \
-		${MAKE} DIRPRFX=${_lib}/ obj; \
-		${MAKE} DIRPRFX=${_lib}/ depend; \
-		${MAKE} DIRPRFX=${_lib}/ all; \
-		${MAKE} DIRPRFX=${_lib}/ install
-.endif
-.endfor
-
 # libpam is special: we need to build static PAM modules before
 # static PAM library, and dynamic PAM library before dynamic PAM
 # modules.
@@ -1551,6 +1539,20 @@ lib/libpam__L: .PHONY
 		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET all; \
 		${MAKE} DIRPRFX=lib/libpam/ -D_NO_LIBPAM_SO_YET install
 
+.for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
+.if !commands(${_lib}__L)
+${_lib}__L: .PHONY
+.if exists(${.CURDIR}/${_lib})
+	${_+_}@${ECHODIR} "===> ${_lib} (obj,depend,all,install)"; \
+		cd ${.CURDIR}/${_lib}; \
+		${MAKE} DIRPRFX=${_lib}/ obj; \
+		${MAKE} DIRPRFX=${_lib}/ depend; \
+		${MAKE} DIRPRFX=${_lib}/ all; \
+		${MAKE} DIRPRFX=${_lib}/ install
+.endif
+.endif
+.endfor
+
 _prereq_libs: ${_prereq_libs:S/$/__PL/}
 _startup_libs: ${_startup_libs:S/$/__L/}
 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
-- 
1.8.2



>Release-Note:
>Audit-Trail:

From: Garrett Cooper <yaneurabeya@gmail.com>
To: bug-followup@FreeBSD.org, yaneurabeya@gmail.com
Cc: sjg@freebsd.org
Subject: Re: conf/178068: [PATCH] simplify _libraries by filtering out
 &lt;lib&gt;__L targets with associated commands
Date: Mon, 22 Apr 2013 21:27:55 -0700

     The one thing that I accidentally overlooked with this patch is
 that it only works with bmake as make. Probably one of the things that
 can be added to a list of improvements once bmake is the default
 make...
 Thanks!
 -Garrett
>Unformatted:
