0Pricing
C Academy · Lesson

Makefiles

Automate the build.

Why Makefiles

Typing gcc commands by hand gets unmanageable fast. make reads a Makefile describing how to build your project and runs only the commands needed.

Its killer feature: it rebuilds a file only when its inputs are newer than its output, saving huge amounts of compile time.

Rule Anatomy

A rule has three parts: a target, its prerequisites, and a recipe.

The recipe line MUST begin with a real TAB character, not spaces. This is the single most common Makefile mistake.

target: prerequisite1 prerequisite2
	<TAB>command to build target

All lessons in this course

  1. Conditional Compilation
  2. Multi-File Projects
  3. Makefiles
  4. Static and Shared Libraries
← Back to C Academy