clarifications about “10.8 Implicit Rule Search Al gorithm.”

Dmitry <[email protected]> Sat, 18 Oct 2025 09:47:32 +0300
Newsgroups gmane.comp.gnu.make.general
Message-ID <CAJViqFnEQ41RboZ_A69i4VNvtejs=KuTHDSBHNb8o4W=Z-0tkQ@mail.gmail.com>
Hello,
I need some clarifications about =E2=80=9C10.8 Implicit Rule Search Algorit=
hm.=E2=80=9D
If I have the following makefile:

```
foo.o:

%.o: aaa
        @echo $@ 1111

%aa :
        @echo $@ 2222
```
and run "make -Rr -d -f makefile", I see two identical lines: "Trying
pattern rule with stem 'foo'."

```
........
Updating goal targets....
Considering target file 'foo.o'.
 File 'foo.o' does not exist.
 Looking for an implicit rule for 'foo.o'.
 Trying pattern rule with stem 'foo'.
 Trying rule prerequisite 'aaa'.
 Trying pattern rule with stem 'foo'.
 Trying rule prerequisite 'aaa'.
 Looking for a rule with intermediate file 'aaa'.
........
```

Point=E2=80=AF5.3 of the search algorithm states:
Test whether all the prerequisites exist or ought to exist. (If a file
name is mentioned in the makefile as a target or as an explicit
prerequisite of target T, then we say it ought to exist.)
In my makefile aaa is neither a target nor a prerequisite, so I change it t=
o:


```
foo.o:

%.o: aaa
        @echo $@ 1111

%aa :
        @echo $@ 2222

bbb : aaa
        @echo $@ 3333
```
Now aaa is a prerequisite for the (dangling) target=E2=80=AFbbb, and the
message =E2=80=9CTrying pattern rule with stem 'foo'.=E2=80=9D appears only=
 once:

```
........
Updating goal targets....
Considering target file 'foo.o'.
 File 'foo.o' does not exist.
 Looking for an implicit rule for 'foo.o'.
 Trying pattern rule with stem 'foo'.
 Trying rule prerequisite 'aaa'.
 Found an implicit rule for 'foo.o'.
  Considering target file 'aaa'.
........
```

At first glance, everything seems OK. But I don=E2=80=99t understand what
=E2=80=9Ctarget=E2=80=AFT=E2=80=9D refers to in=E2=80=AFpoint=E2=80=AF5.3, =
since in=E2=80=AFpoint=E2=80=AF7 we have:
If a filename is mentioned as a target or as an explicit prerequisite
of any target, then it ought to exist.

So, bbb: aaa should be relevant to=E2=80=AFpoint=E2=80=AF7, not=E2=80=AF5.3=
. Why then did the
second =E2=80=9CTrying pattern rule with stem=E2=80=AF'foo'.=E2=80=9D line =
disappear?

                                                           Respect.
--
  Dmitry