Makefile pseudo-target query

search for makefile pseudo-targets, and see an article, article link
if the author talks about pseudo-targets, it should be written like this:
.PHONY: clean
clean:
but in this example. PHONY: all is written after all. In this example, it is okay for us not to declare all as a pseudo-target? For example, I, make, default to make all, and then prog1 prog2 prog3 their respective dependencies to execute. So why declare all as PHONY, and whether there is a relationship before and after all:prog1 prog2 prog3?

is there any example to familiarize yourself with and use the usage of make?

-sharpsample Makefile 
all : prog1 prog2 prog3 
.PHONY : all 
prog1 : prog1.o utils.o 
cc -o prog1 prog1.o utils.o 
prog2 : prog2.o 
cc -o prog2 prog2.o 
prog3 : prog3.o sort.o utils.o 
cc -o prog3 prog3.o sort.o utils.o 
Mar.24,2021

the article states the reasons for using .PHONY . See this

.
avoid name conflicts between the command-only target defined in our Makefile (the purpose of which is to execute a series of commands without creating this target) and the actual files in the working directory

in fact, if there is no file with the same name as your target in the project working directory, it is also OK not to use .PHONY to specify a pseudo target, which is used to avoid conflicts with files with the same name. For example, in all , as long as the file all is not included in the project's working directory, there is no problem whether it can be added to .PHONY .

Menu