Pseudo-Targets in makefile

Source: Internet
Author: User

A pseudo-target is a goal that is always executed, and a pseudo-target does not take into account the new and old relationship between its dependent timestamp and its own timestamp, relative to the target, and thus decides whether to execute the rule. Pseudo-Target format:

. Phony:cleanclean:    -rm *.O

In makefile, the goal of clean is usually specified as a pseudo-target, which has a feature of no dependency, then every time the make is executed its rules:-rm *.O, then why to specify as a pseudo-target, Usually see the makefile is the general goal of it. Assuming that clean is not specified as a pseudo target, there are 1 files under my current folder:

A.C. My makefile:

1 All : 2     gcc a.c-o clean35clean:6     rm Clean

After you execute make, the clean executable is generated, assuming now that I want to clear the generated file, I'll execute make, and the result is prompt:

  Make: ' Clean ' is up to date.

This is because clean is treated as a common goal, according to make automatic rule deduction, it was intended to execute: GCC clean.c-o clean, the results found that no dependent clean.c, it thought clean is the latest to do nothing. If you add:

. Phony:clean

To declare as a pseudo-target, it is enforced regardless of dependencies or dependencies.

Pseudo-Targets in makefile

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.