Oh I missed the Cc to ports.
Well, I got a more sturdy patch for check-lib-depends (to be 
tested/documented).  The gist is to be able to generically be able to add
some lib variables into WANTLIB and have check-lib-depends recognize them.

Basically, this would need some support in bsd.port.mk as a list of variables
(WANTLIB_VARS) and this would arbitrarily be able to replace a specific set
of libraries back into the corresponding variable.


One cool thing in the current patch is that those sets may even overlap, as
it first recognizes all sets, THEN replaces them.

e.g.,

-SLIBCXX='c++ c++abi pthread'

for instance.

Index: check-lib-depends
===================================================================
RCS file: /cvs/ports/infrastructure/bin/check-lib-depends,v
retrieving revision 1.37
diff -u -p -r1.37 check-lib-depends
--- check-lib-depends   11 Feb 2017 12:52:58 -0000      1.37
+++ check-lib-depends   8 Apr 2017 12:12:49 -0000
@@ -201,7 +201,10 @@ sub handle_options
        my $state = shift;
 
        $state->{opt}{i} = 0;
-       $state->SUPER::handle_options('oid:D:fB:qs:O:',
+       $state->{opt}{S} = sub {
+               $state->{subst}->parse_option(shift);
+       };
+       $state->SUPER::handle_options('oid:D:fB:qS:s:O:',
                '[-fiomqx] [-B destdir] [-d pkgrepo] [-O dest] [-s source]');
 
        $state->{destdir} = $state->opt('B');
@@ -453,10 +456,41 @@ sub report_lib_issue
        return OpenBSD::Issue::NotReachable->new($lib,, $binary, @r);
 }
 
+sub has_all_libs
+{
+       my ($self, $libs, $list) = @_;
+       for my $l (@$list) {
+               if (!defined $libs->{$l}) {
+                       return 0;
+               }
+       }
+       return 1;
+}
+
+sub backsubst
+{
+       my ($self, $h, $state) = @_;
+       my $doit = {};
+       # try backsubsting each list
+       while (my ($k, $v) = each %{$state->{subst}->hash}) {
+               my @l = split(/\s+/, $v);
+               if ($self->has_all_libs($h, \@l)) {
+                       $doit->{$k} = \@l;
+               }
+       }
+       while (my ($k, $list) = each %$doit) {
+               for my $l (@$list) {
+                       delete $h->{$l};
+               }
+               $h->{'${'.$k.'}'} = 1;
+       }
+}
+
 sub print_list
 {
        my ($self, $state, $head, $h) = @_;
 
+       $self->backsubst($h, $state);
        my $line = "";
        for my $k (sort keys %$h) {
                if (length $line > 50) {

Reply via email to