Writing

Using Makefiles for CI/CD

Makefiles aren't just for C — they're a portable, lightweight way to standardize build and deploy commands across any CI/CD pipeline.

What is a Makefile?

Makefiles were originally designed to decide which parts of a large C or C++ program need to be recompiled. But they are far more general than that — any language with a build step can benefit from a Makefile. Java has Ant, Maven, and Gradle. Go, Rust, and TypeScript have their own build tools. Makefiles sit above all of these as a portable, standardized command runner.

Installation on Windows

Using Chocolatey:

choco install make

Creating and using a Makefile

Create a file named Makefile in your project root. Inside, declare targets — each target is like a stage or task that Make will execute.

one:
	touch demo1.txt

two:
	touch demo2.txt

all: one two
  • make one — runs the one target only
  • make two — runs the two target only
  • make one two — runs both sequentially
  • make all — runs both via the all target dependency

Targets can depend on other targets, making it easy to compose complex build workflows from simple primitives.

Using Makefiles in CI/CD

Makefiles integrate naturally with GitHub Actions and other CI systems. Instead of repeating shell commands across pipeline steps, you define them once in a Makefile and call make <target> from your pipeline. This keeps your pipeline config thin and your build logic portable — runnable locally and in CI with the same command.

References