Note: If you want to use this article to write a simple make statement, but you do not have the knowledge base, please go back quickly. Click here and go to the PDF to explain it in detail, half an hour is enough for you to write one.
maketree:maketree.o stackstdio.o treestdio.ogcc -g maketree.o stackstdio.o treestdio.o -o maketreemaketree.o:maketree.c tree.h stackarray.hgcc -c maketree.cstackstdio.o:stackstdio.c stackarray.hgcc -c stackstdio.ctreestdio.o:treestdio.c tree.h stackarray.hgcc -c treestdio.c#This is a makefile ,my first makefile
Basic Unit is rule
Rule: Create one or more target files
Follow the compilation to generate the files or modules on which the target file depends
Command Used to generate or update the target file
Format:
Target file list delimiter dependent file list [; command]
[Command]
[Command]
Note: The command is a line marked with a tab key starting with. If not, it is the command of the previous rule.
# Annotation
\ Input for Branch
Simple run mode of make
First, find the makefile or makefile (you can specify make-F othername)
Open according to rules
1. the target file does not exist and the dependent file does not exist. Execute the next rule.
2. the target file does not exist. The dependent file exists. The target file is generated.
3. the target file exists, the dependent file exists, and the generation time is compared.
If (time of the target file <dependent file) is regenerated
Else skip
4. trace back to the First Command (why, similar to recursive nature, but what determines the end at the beginning
Explanation: the final target rule puts the final target file to be generated in the first target file of the first rule.
)
Hide rules
Example: module. O: headl. h
Make will automatically expand:
Module. O: modele. c headl. h
Gcc-C modele. C-o modele. o
Simple use of make