GNU-makefle (3) rule syntax, file search, and pseudo targets

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.