visit
Let's say we have a target called clear-cache
, which removes the cache of an application
clear-cache:
rm -rf cache/*
The cache removal cli command will run fine most of the time, but let's check what happens if we add a file with the same name as the target at the same level as the Makefile
This default behavior is not what we expect in this case and we want to override it. This is when the .PHONY directive comes to the rescue.
.PHONY: clear-cache
clear-cache:
rm -rf cache/*
clear-cache:
rm -rf cache/*
clear-build:
rm -rf build/*
.PHONY: clear-cache clear-build
References: