What Is A Makefile?
If you’ve ever built something from source, you’ve probably seen a makefile. If you’re anything like me, you probably wonder what exactly is a makefile?
The answer is quite simple actually. It’s a todo list for the make command. The make command does what it says on the tin: it makes things. Or really it builds things. But in order to know how to build something it needs instructions, which is where the makefile comes in. make then takes those instructions and makes an executable binary for the user to use.
Here is a simple example:
say_hello:
echo "I Found This Code on the TLC Website"
If you were to put that in a directory, and then run make, you’d get
$ make
echo "I Found This Code on the TLC Website"
I Found This Code on the TLC Website
So the make file defines the say_hello function, which is then run when you make the file.
There’s obviously a lot more that goes into this, but the basics are there. The file defines the rules and instructions, make executes those and spits out a binary.
If we do the same thing but add one little change:
say_hello:
@echo "I Found This Code on the TLC Website"
You’ll get
I Found This Code on the TLC Website
Along the way, the makefile can be used to create files and directories that the binary will need to run. It will also usually include error functions for if something goes wrong.
If you’re interested in diving deep on makefiles, you can go here.

Support My Work
If you enjoy this content, consider supporting me on Patreon to help keep it going!
Become a Patron




