Makefile overview
What is makefile. How to write a makefile.
Ref: https://opensource.com/article/18/8/what-how-makefile
What is makefile
A makefile
is a file containing a set of directives used by a make
build automation tool to generate a target/goal.
You may have used make to compile a program from source code.
How to write makefile
To summarize, below is the syntax of a typical rule:
|
|
As an example, a target might be a binary file that depends on prerequisites (source files). On the other hand, a prerequisite can also be a target that depends on other dependencies:
|
|
It is not necessary for the target and prerequisites to be a file; it could be just a name for the recipe, as in our example. We call these “phony targets.”
Example
|
|