.PHONY: something something: ifeq ($(var),foo) @echo $(var) "bar" else @echo "others" endif
$ make something var=foo foo bar $ make something others
ifeq ($(shell uname),Darwin) UPDATE_COMMAND = brew update else UPDATE_COMMAND = apt-get update endif
Check Whether a File or Directory Exists
ifneq ($(wildcard /usr/local/HAL-9000/bin/hal),) UP_COMMAND = /usr/local/HAL-9000/bin/hal up else UP_COMMAND = docker-compose up endif up: $(UP_COMMAND) install: pip install -r requirements_dev.txt
Call Another Target in the Same Makefile
coverage depends on
.PHONY: clean clean: find . -regex "\(.*__pycache__.*\|*.py[co]\)" -delete .PHONY: coverage coverage: clean docker exec -i -t streetvoice_django_1 python -m coverage run manage.py test --failfast docker exec -i -t streetvoice_django_1 python -m coverage html -i
What does .PHONY mean?
Let's assume you have install target, which is a very common in makefiles. If you do not use .PHONY, and a file named install exists in the same directory as the Makefile, then make install will do nothing.