SUBDIR and SUBDIRLIST work like FLAVOR/SUBPACKAGE, they should be passed
through the environment and NOT as variable you can't override on the command
line (see the various unset in bsd.port.subdir.mk and pkgpath.mk)


There might other consumers in the tree.  Fix will be the same...

Index: bin/portbump
===================================================================
RCS file: /cvs/ports/infrastructure/bin/portbump,v
retrieving revision 1.22
diff -u -p -r1.22 portbump
--- bin/portbump        27 Jun 2018 16:20:08 -0000      1.22
+++ bin/portbump        19 Feb 2020 15:52:58 -0000
@@ -98,6 +98,18 @@ my @_REV_NEIGHBORS_WEAK = qw(
 );
 my $_rev_neighbors_plain_all = join('|', @_REV_NEIGHBORS, 
@_REV_NEIGHBORS_WEAK);
 
+sub run_make
+{
+       my $dir = shift;
+       my $pid = open(my $pipe, "-|");
+       if ($pid == 0) {
+               $ENV{SUBDIR}=$dir;
+               exec {'make'} ('make', @_);
+               exit(1);
+       }
+       return $pipe;
+}
+
 sub new {
        my ($class, $dir, $tweak_wantlib, $lib_depends_tgt) = @_;
        die "lib depends target specified without WANTLIB tweaking"
@@ -117,8 +129,8 @@ sub new {
        # Get actual information about subpackages (including their
        # REVISIONs) and shared libraries.
        #
-       open (my $dumpvars, '-|', "make", "SUBDIR=$dir", "dump-vars") or
-               die "cannot run make dump-vars: $!";
+
+       my $dumpvars = run_make($dir, 'dump-vars');
        while (<$dumpvars>) {
                chomp;
                next unless /^[^,]*(?:,[^.-]*(-[^.]+)?)?\.([^=.]+)=(.*)$/;
@@ -154,8 +166,7 @@ sub new {
                # Get actual value of WANTLIB (not the one of WANTLIB-foo or 
WANTLIB-),
                # to be used to avoid extra WANTLIB-* lines.
                #
-               open ($dumpvars, '-|', "make", "SUBDIR=$dir", "show=WANTLIB") or
-                       die "cannot run make show=WANTLIB: $!";
+               $dumpvars = run_make($dir, 'show=WANTLIB');
                while (<$dumpvars>) {
                        chomp;
                        next if /^===>/;
@@ -201,8 +212,7 @@ sub new {
 
                $self->{wantlib_extra} = { "" => [] };
                $self->{wantlib_missing} = { "" => [] };
-               open ($dumpvars, '-|', "make", "SUBDIR=$dir", $lib_depends_tgt) 
or
-                       die "cannot run make $lib_depends_tgt: $!";
+               $dumpvars = run_make($dir, $lib_depends_tgt);
                my $subpkg;
                my %not_reachable;
                while (<$dumpvars>) {
Index: bin/portcheck
===================================================================
RCS file: /cvs/ports/infrastructure/bin/portcheck,v
retrieving revision 1.130
diff -u -p -r1.130 portcheck
--- bin/portcheck       12 Nov 2019 06:01:04 -0000      1.130
+++ bin/portcheck       19 Feb 2020 15:52:58 -0000
@@ -1481,7 +1481,7 @@ check_lib_depends() {
        # TODO cache print-plist-libs output?
        cd -- /usr/ports    # XXX "$portsdir" fails for openbsd-wip and like
        unset FLAVOR SUBPACKAGE
-       make "${make_args[@]}" SUBDIR="${pure_lib_deps[*]}" \
+       SUBDIR="${pure_lib_deps[*]}" make "${make_args[@]}" 
            print-plist-libs </dev/null 2>/dev/null |&
        while read -pr l; do
                case $l in
Index: mk/bsd.port.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
retrieving revision 1.1515
diff -u -p -r1.1515 bsd.port.mk
--- mk/bsd.port.mk      26 Jan 2020 12:51:47 -0000      1.1515
+++ mk/bsd.port.mk      19 Feb 2020 15:52:59 -0000
@@ -46,12 +46,11 @@
 #
 # tests and variable definitions come first, THEN targets
 #
-.if ${.MAKEFLAGS:MFLAVOR=*}
-ERRORS += "Fatal: Use 'env FLAVOR=${FLAVOR} ${MAKE}' instead."
-.endif
-.if ${.MAKEFLAGS:MSUBPACKAGE=*}
-ERRORS += "Fatal: Use 'env SUBPACKAGE=${SUBPACKAGE} ${MAKE}' instead."
-.endif
+.for forbidden in FLAVOR SUBPACKAGE SUBDIR SUBDIRLIST
+.  if ${.MAKEFLAGS:M${forbidden}=*}
+ERRORS += "Fatal: Use 'env ${forbidden}=${${forbidden}} ${MAKE}' instead."
+.  endif
+.endfor
 
 .for f v in bsd.port.mk _BSD_PORT_MK bsd.port.subdir.mk _BSD_PORT_SUBDIR_MK
 .  if defined($v)

Reply via email to