tezvyn:

Make: The Original Task Runner

AI-drafted, machine-checkedSource: Wikipedia: Make (software)beginner

Make automates tasks by following a recipe in a `makefile`. It intelligently runs only the necessary steps by checking dependencies, saving time during builds. While common for compiling code, it can run any shell command.

WHY IT EXISTS Make was created to solve the problem of slow, repetitive, and error-prone manual software builds. Before Make, developers had to remember and manually re-run all the compiler commands to build a program. Forgetting a step or needlessly recompiling unchanged files was common. Make automates this by letting you define the build recipe once.

THE MENTAL MODEL Think of Make as a smart chef with a recipe book (the makefile). The recipe for a final dish, like an executable program, lists its components, like compiled object files. The chef checks if a component is already made and still fresh. If you change one ingredient (a source file), the chef knows to only remake the components that depend on it, not the entire dish from scratch.

HOW IT WORKS Make reads a configuration file, typically named makefile, which contains a set of rules. Each rule defines a target (a file to create), its dependencies (files it's built from), and a set of shell commands to create that target. When you run make <target>, it builds a dependency graph. It checks if the target file is older than any of its dependencies. If it is, or if the target doesn't exist, Make executes the associated commands.

WHEN TO USE IT Make is excellent for build automation where outputs depend on inputs, which is the classic case for compiling source code in languages like C and C++. Because it can execute any shell command, it's also a versatile tool for creating simple command aliases for a project, such as make test, make clean, or make deploy.

WHEN NOT TO USE IT For projects with very complex build logic or non-file-based dependencies, more modern build systems like Gradle, Bazel, or Meson may be a better fit. For extremely simple projects (e.g., a single source file), writing a makefile can be more work than just running the compiler command directly.

ONE CANONICAL EXAMPLE Building a C program. A makefile can state that the executable app depends on main.o and utils.o. In turn, main.o depends on main.c. If a developer modifies only main.c and runs make, the tool sees that main.c is newer than main.o. It recompiles main.c to create a new main.o, then re-links it with the existing utils.o to create the final app. It intelligently skips recompiling utils.c.

Read the original → en.wikipedia.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.