Faster patch...  this removes a lot of old cruft, and yields a 
_print-package-args  that's about twice as fast, instead of potentially slower.

Specifically, always grab lib lists off the ports tree proper, evaluate them
once, and use the fact that resolve-lib has known how to handle multiple
specs for quite a long time by now.

Still, this does require tests.

Index: bsd.port.mk
===================================================================
RCS file: /home/openbsd/cvs/ports/infrastructure/mk/bsd.port.mk,v
retrieving revision 1.1007
diff -u -p -r1.1007 bsd.port.mk
--- bsd.port.mk 20 Jun 2010 07:48:20 -0000      1.1007
+++ bsd.port.mk 2 Jul 2010 14:29:34 -0000
@@ -1286,32 +1288,12 @@ _noshared =
 .endif
 
 _libresolve_fragment = \
-       case "$$d" in \
-       */*) shdir="${LOCALBASE}/$${d%/*}";; \
-       *) shdir="${LOCALBASE}/lib";; \
-       esac; \
-       check=`eval $$listlibs 2>/dev/null| \
+       check=`for _lib in $$libs; do echo $$_lib; done | \
                LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} \
                        perl ${PORTSDIR}/infrastructure/build/resolve-lib \
                                ${_noshared} $$d` \
                        || check=Failed
 
-_syslibresolve_fragment = \
-       case "$$d" in \
-       /*) \
-               shdir="$${d%/*}/";; \
-       */*) \
-               shdir="${DEPBASE}/$${d%/*}";; \
-       *) \
-               shdir="${DEPBASE}/lib"; \
-               listlibs="$$listlibs /usr/lib/lib* ${X11BASE}/lib/lib*";; \
-       esac; \
-       check=`eval $$listlibs 2>/dev/null| \
-               LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} \
-               perl ${PORTSDIR}/infrastructure/build/resolve-lib ${_noshared} 
$$d` \
-               || check=Failed
-
-
 PORT_LD_LIBRARY_PATH = ${LOCALBASE}/lib:${X11BASE}/lib:/usr
 _set_ld_library_path = :
 DEPBASE = ${LOCALBASE}
@@ -2844,48 +2826,57 @@ _print-package-args:
        @echo '${_i}'|{ \
                IFS=:; read dep pkg subdir target; \
                ${_flavor_fragment}; \
-               libspecs='';comma=''; \
                if default=`eval $$toset ${MAKE} _print-packagename`; then \
                        case "X$$pkg" in X) pkg=`echo "$$default" 
|${_version2default}`;; \
                        esac; \
-                       if ${_PKG_QUERY} "$$pkg" -q; then \
-                               listlibs='echo ${DEPDIR}$$shdir/lib*'; \
-                               case "$$dir" in ${PKGPATH}) \
-                                       listlibs="$$toset ${MAKE} 
print-plist-contents|${_grab_libs_from_plist}; $$listlibs";; \
-                               esac; \
-                       else \
-                               listlibs="$$toset ${MAKE} 
print-plist-contents|${_grab_libs_from_plist}"; \
-                       fi; \
+                       libs=`eval $$toset ${MAKE} 
print-plist-contents|${_grab_libs_from_plist}`; \
+                       needed=false; \
                        IFS=,; for d in $$dep; do \
-                               ${_libresolve_fragment}; \
-                               case "$$check" in \
+                               ${_libresolve_fragment}; \
+                               case "$$check" in \
                                *.a) continue;; \
                                Failed) \
                                        echo 1>&2 "Can't resolve libspec $$d 
(in ${SUBPACKAGE})"; \
                                        exit 1;; \
+                               *) \
+                                       needed=true;; \
+                               esac; \
+                       done; \
+                       exec 3>&2; \
+                       unset IFS; for d in ${_DEPRUNLIBS:S/>/\>/g}; do \
+                               if $$needed; then continue; fi; \
+                               exec 2>/dev/null; \
+                               ${_libresolve_fragment}; \
+                               case "$$check" in \
+                               *.a|Failed) \
+                                       continue;; \
                                *) \
-                                       echo "-W $$check";; \
+                                       needed=true;; \
                                esac; \
                        done; \
-                       echo "-P $$subdir:$$pkg:$$default"; \
+                       exec 2>&3; \
+                       if $$needed; then echo "-P $$subdir:$$pkg:$$default"; 
fi; \
                else \
                        echo 1>&2 "Problem with dependency ${_i}"; \
                        exit 1; \
                fi; \
        }
 .  endfor
-.  for _i in ${WANTLIB${SUBPACKAGE}}
-       @d='${_i}'; listlibs='echo $$shdir/lib*'; \
-       ${_syslibresolve_fragment}; \
-       case "$$check" in \
-       *.a) ;; \
-       Failed) \
-               echo 1>&2 "Can't resolve libspec $$d"; \
-               exit 1;; \
-       *) \
-               echo "-W $$check";; \
-       esac
-.   endfor
+       @listlibs="echo ${LOCALBASE}/lib/lib* /usr/lib/lib* 
${X11BASE}/lib/lib*"; \
+       for d in ${_DEPRUNLIBS:S/>/\>/g}; do \
+               case "$$d" in \
+               /*) listlibs="$$listlibs $${d%/*}/lib*";; \
+               */*) listlibs="$$listlibs ${LOCALBASE}/$${d%/*}/lib*";; \
+               esac; \
+       done; \
+       if found=`eval $$listlibs 2>/dev/null| \
+               LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} perl \
+               ${PORTSDIR}/infrastructure/build/resolve-lib ${_noshared} 
${_DEPRUNLIBS:S/>/\>/g}`; then \
+               for k in $$found; do echo "-W $$k"; done; \
+       else \
+               echo 1>&2 "Can't resolve libspec"; \
+               exit 1; \
+       fi
 .endif
 
 _list-port-libs:

Reply via email to