Reference: http://blog.csdn.net/haoel/article/details/2889
When the command and dependency description are in the same line, you can use semicolons to separate them.
When the command is too long, you can also use the backslash \ to separate multiple lines, and the line to be separated can have any tab at the beginning (it doesn't matter if there is a space ).
When specifying a file directory, you can use ~ To indicate the home directory of the system, because make will be executed in shell.
Special variables in the VPATH Makefile file. It specifies the directories that make can search for dependent files and target files.
If it is not defined by default, it is found in the current directory. Multiple directories are separated by colons (:).
Vpath is a command used to find matching directories. Use % to match zero or several characters in the file name
Vpath pattern directories
Vpath pattern: clears the directory in the current mode.
Vpath: clear all search directories defined by vpath
Example
Mymk = ~ /Desktop/B. mkf-include $ (mymk) edit: $ (objs) cc-o edit $ (objs) # VPATH = srcs: headersvpath %. c srcs: headersvpath %. h srcs: headers # vpath % # vpath main. o: kbd. o: command. o: display. o: insert. o: search. o: utils. o:; cc-c utils. c files. o:; cc-c-g files. c. PHONY: clean: #-rm edit $ (objs)-rm *. o edit
Pseudo-target as the first target
# Defines a pseudo-target all, which is the first target of makefie. As mentioned above, the first 1st targets are the execution targets generated by makefile, but here they are pseudo targets, so no execution files will be generated. # Directly make all or make. This will generate three execution files aa bb CCall: aa bb cc. PHONY: all AA:. o command. occ-o aa. o command. o BB: B. occ-o bb B. o CC: C. o utils. occ-o cc c. o utils. o
Pseudo-target depends on pseudo-target
# Cleanall dependency (including) cleanobj cleandiff. PHONY: cleanall cleanobj cleandiff cleanall: cleanobj cleandiff-rm aa bb cc edit cleanobj:-rm *. o cleandiff:-rm *. diff
GNU-makefle (3) rule syntax, file search, and pseudo targets