What is the `make` Command in Linux? cover image

What is the `make` Command in Linux?

Scott Keck-Warren • June 2, 2025

If you've ever worked on a project that uses a compiled language like C or C++, you've probably bumped into the make command. It's been built to be used for projects that have a complex build, test, and install process. However, even in the web development world where there tends to be little to no build and install process the make command can be a powerful tool for automating repetitive development tasks like running tests, checking code style, and building assets.

So, what exactly is make, and how can we use it effectively as PHP developers?

What is make?

At its core, make is a build automation tool. It reads instructions from a file called "Makefile" and runs the commands you and your team define there. While it originated in the C programming world to compile and link source code, at its core make can be used as a general-purpose task runner. If you write a "Makefile" with steps to run PHPUnit, lint code, or compile SCSS, make will happily do that for you.

You can think of it as a simple way to script tasks that can be executed with a single command and share those tasks across your team.

What’s a "Makefile"?

A "Makefile" is a plain text file that contains “rules.” Each rule looks like this:

target: dependencies
<tab>command-to-run
<tab>another-command-to-run

Where : * target is the name of the task/output file. * dependencies are optional and usually refer to files or other tasks. * command-to-run is what gets executed.

Please note the commands must be indented using a tab character and not spaces or you'll receive a syntax error.

A "Makefile" for a PHP project

Let’s say you’re working on a PHP project and want to automate a few common tasks including running tests and checking code style.

This "Makefile" will allow us to do just this.

pre-commit: phpcs

test:
 ./vendor/bin/phpunit

phpcs:
 ./vendor/bin/phpcs --standard=PSR12 src/

Now from your terminal, you can run make test and PHPUnit will run or make phpcs and phpcs will run. You could also run both by chaining targets make test phpcs.

Why bother with make?

Now you might be thinking to yourself that this seems like a lot of extra work for little gain but having a shared "Makefile" can provide several benefits including:


Wrapping up

Even though make is built for development in areas with complex build, test, and install processes, it’s still useful in modern PHP development. Because it’s a lightweight task runner that doesn’t require installing anything new you can easily create a shared set of common commands with your team (even if you're a team of one) and save everyone some time and wasted keystrokes.

Next time you catch yourself retyping the same command over and over, consider throwing it into a "Makefile". Your future self (and your teammates) will thank you.

This was originally published at https://phpdeveloperstv.substack.com/p/what-is-the-make-command-in-linux