« Back to Glossary Index

A makefile automation blueprint for building and managing projects. Makefiles are scripts used to automate tasks, mainly building (compiling) software.

  • They define rules: “If file X changes, run command Y.”
  • Run by a tool called make (standard on Linux/macOS; installable on Windows).
  • Commonly used for setting up virtual environments, compiling code, running tests, building Docker containers, etc

Makefiles (Makefile) come from the C/C++ world, but developers sometimes use them in Python, the are good for:

  • Multi-step processes
  • Rebuilding only what changed
  • Keeping command sequences organized

Makefiles do not have an extension and contain the Makefile syntax.

Example Makefile

install:
	pip install -r requirements.txt

run:
	python app.py

test:
	pytest tests/

To run: make install

Installation Make:

  • On Linux and Mac: it’s usually already installed.
  • On Windows: you need to install make separately (e.g., via GnuWin, Chocolatey, or by using WSL).

CommandWhat it doesExample
makeRuns the first target in the Makefile (default target).make
make <target>Runs a specific named target.make install
make -nDry run: shows what would happen without actually executing.make -n install
make -BForces rebuild, ignoring timestamps.make -B install
make -j <n>Run n jobs in parallel (speeds up building).make -j4
make cleanRuns a clean target to remove build files (if you define it).make clean
make helpIf you add a help target in your Makefile, this prints instructions.make help
make --always-makeSame as -B: always re-run all targets.make --always-make
« Back to Glossary Index