Makefile style guide¶
Makefile is a text file that defines targets and rules which are executed by Make utility. This document describes conventions for writing the Makefiles.
The recommended name for make files is Makefile [f2]. Misc make files with common targets or variables should have extension .mk. This helps text redactors to identify that this is a makefile and enable syntax highlighting.
Target names should use lower case letters. Words are separated with a hyphen ‘-‘. E.g.:
Variables which are not special to make or inherited from the environment should be in lowercase. Words should be separated with underscore symbol ‘_’. E.g.:
src_dir = $(CURDIR)/src build_dir = $(CURDIR)/build
Phony target declarations should follow appropriate target declarations rather than be defined in one place [f1]. This way it’s easier to maintain targets.
all: build test .PHONY: all
.PHONY: all build test all: build test