Hi,
I am trying to write one makefile with phony target "clean" ...it is working fine when there is no file exist by name "clean", while it create a new file "clean" , PHONY clean is not working.
.
PHONY : clean
clean:
rm -f hello.txt bye.txt
@echo "Files are deleted"
when i run this clean like
$make clean
`clean' is up to date.
(is is showing this message when a file by name clean exist in my local dir)
Can you please advise me ??
Thanks
Amit
Obviously you have the right idea that you want to create a phony target, since any file 'clean' would show as up to date since it has no dependancies.
Your code does not work however because the built-in name for phony targets is actually .PHONY not PHONY. I tested the following to work on a Debian system using GNU make:
.PHONY: clean
clean:
rm -f hello.txt bye.txt
@echo "Files are deleted"
I'd also note that not all versions of make support phony targets. GNU make definitely does though.
Yes, i also came to know that .PHONY target is dependent on make version on OS type, so some times it may show such type of behaviour.
thanks for your help
Amit