On Mon, 2023-01-16 at 22:14 +0900, KO Myung-Hun wrote: > > But this does not seem like an easy thing to accomplish, at all. > > What if there is a "%.exe" pattern rule, not an explicit rule for > > "foo.exe"? > > I think, it's possible to do so by finding a target as GNU Make finds > dependencies.
GNU Make doesn't try to resolve all the targets including all implicit targets first, then after they're all done try to build them. Instead, it tries to build every target as it is needed. So if you try to build "foo.exe" first and it finds an implicit target "%.exe" then you try to build "foo" second, it will see that the target "foo.exe" already exists. But if you try to build "foo" first before "foo.exe", then there will be no target "foo.exe" yet because you haven't tried to build it, and it won't be found. Note here the "foo.exe" has to be intermediate of course, otherwise it will be known to make even using an implicit rule.