The following patch changes the semantics of LIB_DEPENDS/WANTLIB, hopefully
to make things simpler for ports maintenance.

Historically, all libs were registered in LIB_DEPENDS. In order to handle
updates, packages had to register all needed libraries.

The current mechanism is that a package contains
@depend
lines that state which packages it's directly dependent upon.

and totally separate @wantlib lines, that state which shared libraries it
may need.

The way dependency resolution works is as follows: pkg_add resolves direct
@depend lines, possibly installing other packages on the way.

Then it verifies @wantlib lines: those must be reachable through the full
dependency tree (namely, direct dependencies, but also packages that are
dependencies of those dependencies and so on...)

In the ports tree, we've added WANTLIB to take care of those indirect libs.

So what's LIB_DEPENDS ?
Well, it's a RUN_DEPENDS, but kind of...
Specifically, we still have architectures (vax) that don't have any shared
libraries. So a LIB_DEPENDS will be checked to actually provide shared
libraries, when it is included in a package...

For instance,  a package that marks 
LIB_DEPENDS = jpeg.>=62.::graphics/jpeg
will have

@depend graphics/jpeg:jpeg-*:jpeg-7
@wantlib jpeg.63.0

on most architectures, and nothing on vax.

On the other hand, gettext is usually marked as a RUN_DEPENDS and a 
BUILD_DEPENDDS, because the intl library is not the whole story, and packages 
do need some runtime files from gettext...

so all architectures will have:
@depend devel/gettext:gettext->=0.10.38:gettext-0.17p0

and most architectures (except vax) will also have:
@wantlib intl.4.0


The following patch *extends* the algorithm used for solving LIB_DEPENDS.
Instead of generating a @depend line  when the libspecs at the front of
LIB_DEPENDS match existing libraries, it extends the check to *all* libspecs
in LIB_DEPENDS and WANTLIB.

(Of course, all WANTLIB must be satisfied for the package to build)

The current LIB_DEPENDS with libspecs upfront will still work, but
this should allow us to separate WANTLIB entirely from LIB_DEPENDS.

Specifically, check-lib-depends should be able to spew WANTLIB lines
that look much more automatic, and so, long term, it should be much less
tedious to update big ports having those.


LIB_DEPENDS is actually necessary because of vax: the distinction between
"maybe run_depends" and "really, I need this" is not needed if you always
have shared libs.


I'm a bit afraid that the reason for the distinction will probably trip
newcomers.


Of course, this also requires quite a few tests before it gets committed.

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 13:40:44 -0000
@@ -2844,7 +2846,6 @@ _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; \
@@ -2856,25 +2857,39 @@ _print-package-args:
                        else \
                                listlibs="$$toset ${MAKE} 
print-plist-contents|${_grab_libs_from_plist}"; \
                        fi; \
+                       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}}
+.  for _i in ${_DEPRUNLIBS}
        @d='${_i}'; listlibs='echo $$shdir/lib*'; \
        ${_syslibresolve_fragment}; \
        case "$$check" in \

Reply via email to