[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]>
Hey all πŸ‘‹

To my mind, whenever a target is marked as PHONY it is supposed to simply
ignore files with the same name.  And that should be the behaviour of
PHONY pattern rules too.

With that said, I need some help understanding what happens in the
following scenario please.


β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

####################################################
# shell
####################################################

$ ls *

Makefile

mk:
echo.mk

####################################################
# ./Makefile
####################################################

include mk/echo.mk

####################################################
# ./mk/echo.mk
####################################################

.PHONY : a-target

a-target.% :
	@echo 'a-target invoked with "$(*)"'

###

.PHONY : echo.%

echo.% : a-target.invoked-by-echo
	@echo 'echo invoked with "$(*)"'

####################################################
# shell
####################################################

$ make echo.hello-there

a-target invoked with "invoked-by-echo"
echo invoked with "mk/mk"
echo invoked with "hello-there"

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

I wasn't expecting PHONY `echo.%' to be invoked for `echo.mk' which is a
file.

Am I missing something obvious in my snippet?  Have I misunderstood the
concept of PHONY?

-- 
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.