The make program is intended to automate the mundane aspects of transforming source code into an executable. You can specify the relationships between the elements of your program, and it knows exactly what steps need to be redone to produce the desired program.

The specification file, or makefile, describes the relationship between the source, intermediate, and executable program files so that make can perform the minimum amount of work necessary to update the executable.

source

A simple makefile example

#include <stdio.h>

int main() {
  printf("Hello world");
  return 0;
}
hello: hello.c
    gcc hello.c -o hello
$ make

A generic makefile example

target: prereq1 prereq2
    commands

Why use a makefile?

[…] nowadays every project I create has a Makefile to bind together all task involved on that project. From bootstrapping the dev environment, running checks/test, starting a devserver, building releases and container images. Makefiles are just such a nice place to put scripts for these common tasks compared to normal shell scripts.

example makefile

The Language Agnostic, All-Purpose, Incredible, Makefile