bsd.subdir.mk: Recursing on dependent targets

From: Bryan Drewery <bdrewery_at_FreeBSD.org>
Date: Wed, 11 Nov 2015 09:37:08 -0800
The current behavior of bsd.subdir.mk has a very surprising behavior
that I think is wrong and think that changing it will have no real impact.

Consider:

SUBDIR_TARGETS= all foo

all: foo

If you call 'make foo' it will recurse 'foo' on all sub-directories as
expected.

If you call 'make all' it will recurse 'foo' in all sub-directories and
then recurse 'all' in all sub-directories which then again calls 'foo'
in sub-directories! So technically 'foo' is called 3 times in some
directories do to 'all' implicitly calling it as well.

Here's a contrived example with 'all' and 'buildconfig' which is prone
to this problem now.

~/svn/base/usr.bin/bsdiff # make all|grep buildconfig|grep bsdiff/subdir
===> bsdiff/subdir (buildconfig)
buildconfig=/root/svn/base/usr.bin/bsdiff/bsdiff/subdir
===> bsdiff/subdir (buildconfig)
buildconfig=/root/svn/base/usr.bin/bsdiff/bsdiff/subdir
buildconfig=/root/svn/base/usr.bin/bsdiff/bsdiff/subdir

Full:
~/svn/base/usr.bin/bsdiff # make all
===> bsdiff (buildconfig)
===> bsdiff/subdir (buildconfig)
buildconfig=/root/svn/base/usr.bin/bsdiff/bsdiff/subdir
buildconfig=/root/svn/base/usr.bin/bsdiff/bsdiff
===> bspatch (buildconfig)
buildconfig=/root/svn/base/usr.bin/bsdiff/bspatch
buildconfig=/root/svn/base/usr.bin/bsdiff
===> bsdiff (all)
===> bsdiff/subdir (buildconfig)
buildconfig=/root/svn/base/usr.bin/bsdiff/bsdiff/subdir
buildconfig=/root/svn/base/usr.bin/bsdiff/bsdiff
===> bsdiff/subdir (all)
buildconfig=/root/svn/base/usr.bin/bsdiff/bsdiff/subdir
===> bspatch (all)
buildconfig=/root/svn/base/usr.bin/bsdiff/bspatch



With the change I would like to make, to only recurse on *called*
targets, the result is:

~/svn/base/usr.bin/bsdiff # make all|grep buildconfig|grep bsdiff/subdir
buildconfig=/root/svn/base/usr.bin/bsdiff/bsdiff/subdir

~/svn/base/usr.bin/bsdiff # make all
buildconfig=/root/svn/base/usr.bin/bsdiff
===> bsdiff (all)
buildconfig=/root/svn/base/usr.bin/bsdiff/bsdiff
===> bsdiff/subdir (all)
buildconfig=/root/svn/base/usr.bin/bsdiff/bsdiff/subdir
===> bspatch (all)
buildconfig=/root/svn/base/usr.bin/bsdiff/bspatch



The potential problem I see with this is if someone has some top-level
target like 'buildit' that is not in SUBDIR_TARGETS but it depends on
targets which are in SUBDIR_TARGETS, such as 'all'. This would now no
longer recurse on those.  I think this would be worth an UPDATING entry
that 'buildit' needs to be added into SUBDIR_TARGETS or called
explicitly with ${MAKE}, but I also want to be sure I'm not missing
something here about this being 'expected behavior'. From my own
experience I don't expect this to be an actual problem.


-- 
Regards,
Bryan Drewery


Received on Wed Nov 11 2015 - 16:37:12 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:00 UTC