Re: [SOLVED] [HELP] PHONY pattern rule makes the file w/ the same name

Bahman Movaqar <[email protected]>
Newsgroups gmane.comp.gnu.make.general
Message-ID <[email protected]>
On Thu, 2023-10-05 at 13:11 +0200, Renaud Pacalet wrote:
> Could be related to 
> https://www.gnu.org/software/make/manual/make.html#Remaking-Makefiles:
> 
> > after reading in all makefiles make will consider each as a goal
> > target, in the order in which they were processed, and attempt to
> > update it

That's it!  Right there is the missing piece in my understanding!
I had no idea Make actually tries to make make files.

> So, in your case, make tries to update the 2 included makefiles 
> (mk/scenario1.mk and mk/scenario2.mk). As you provide pattern rules for
> that, make will build:
> 
> 1. foo1-by-scenario1 because mk/scenario1.mk depends on it
> 2. mk/scenario1.mk
> 3. foo2 because mk/scenario2.mk depends on it
> 4. mk/scenario2.mk
> 5. scenario1.first-scenario
> 6. sep
> 7. scenario2.second-scenario
> 
> The out is thus normal.

Absolutely right.  Now it all makes sense.

As suggested in the manual, I changed the `include's to mark the included
files as phony targets and got the behaviour I was expecting.


—————————————————————————————————————————————————————————————————

include mk/scenario1.mk
include mk/scenario2.mk

.PHONY : mk/scenario1.mk
.PHONY : mk/scenario2.mk

—————————————————————————————————————————————————————————————————

Thank you!

-- 
Bahman

Join the chatter on Matrix:
         🗣️ https://matrix.to/#/#.mk:matrix.org
      
Subscribe to the Lemmy community:
         🐭 https://lemmy.ml/c/makefile
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.