Skip to content

Makefile Basics

Summary

Command line Flags

Option Description
-j [N] Allows N jobs at once; infinite jobs with no arg
-f FILE Read FILE as a makefile
-k Keep going when some targets can't be made.
-h Print help and exit
-i Adds a - to every command
-C Change to the directory before doing anything

Common Targets

Option Description
.PHONY Used to declare targets that don't represent output files, ensuring they're always executed regardless of file existence or timestamps
all Typically used to specify the default target
clean Conventionally used to define rules for cleaning up the project directory by removing generated files or artifacts

Common variables for C/C++

Variable Description
CC or CXX Variables for the C and C++ compilers
CFLAGS or CXXFLAGS For compiler flags for the C and C++

References

Tutorials

Official documentation

Books

CMake