#983115 make -t doesn't correctly touch grouped targets that are built by a recursive make

Package:
make
Source:
make-dfsg
Description:
utility for directing compilation
Submitter:
Tim Woodall
Date:
2023-02-13 14:48:08 UTC
Severity:
normal
Tags:
#983115#5
Date:
2021-02-19 17:33:07 UTC
From:
To:
Dear Maintainer,

(N.B. I've backported make 4.3-4 to buster as I need grouped targets but
I have made no changes other than to depend on guile-2.2-dev instead of
guile-3.0-dev)


In some cases you need to run make -t multiple times to touch all the
targets of a grouped target that should all be built by a single
invocation of a recipe.


Example makefile to build debs from a dsc:

$ cat Makefile
chroot=/tmp/chroot

TARGETS=libfoo.deb foo.deb

all : $(TARGETS)

$(TARGETS) &: foo.dsc
#fakeroot fakechroot chroot $(chroot) $(MAKE) -C /build chroot-foo
        $(MAKE) chroot-foo
        cp $(chroot)/build/libfoo.deb libfoo.deb
        cp $(chroot)/build/foo.deb foo.deb

.PHONY: chroot-foo
chroot-foo:
        apt-get -y build-dep foo
        cd foo-1.1 && dpkg-buildpackage -b --no-sign


Now consider the following:
$ touch foo.dsc
$ make -t
make chroot-foo
make[1]: Entering directory '/tmp/x'
make[1]: Nothing to be done for 'chroot-foo'.
make[1]: Leaving directory '/tmp/x'
touch libfoo.deb
touch libfoo.deb
$

$ make -t
make chroot-foo
make[1]: Entering directory '/tmp/x'
make[1]: Nothing to be done for 'chroot-foo'.
make[1]: Leaving directory '/tmp/x'
touch foo.deb
touch foo.deb

I have to run make -t twice to touch both the targets. I'm not sure why
they get touched twice but that might be expected, see below, but I only
expect to have to run make -t once to touch all the targets.


Change the &: to a simple : rule and we get:
$ make -t
make chroot-foo
make[1]: Entering directory '/tmp/x'
make[1]: Nothing to be done for 'chroot-foo'.
make[1]: Leaving directory '/tmp/x'
touch libfoo.deb
touch libfoo.deb
make chroot-foo
make[1]: Entering directory '/tmp/x'
make[1]: Nothing to be done for 'chroot-foo'.
make[1]: Leaving directory '/tmp/x'
touch foo.deb
touch foo.deb

As expected the rule gets executed twice, once for each target. Each
file is still touched twice.

#983115#10
Date:
2021-02-19 18:08:44 UTC
From:
To:
Might not be related, but a trivial makefile:

foo bar &:
         echo

make -t only touches foo, not bar. Rerunning says 'foo is up to date'