Define command package

Source: Internet
Author: User

Define command package

If the makefile contains some identical command sequences, we can define a variable for these identical command sequences. The syntax for defining this command sequence starts with "Define" and ends with "endef", for example:

Define run-YACC

YACC $ (firstword $ ^)

Mv y. Tab. C $ @

Endef

Here, "Run-YACC" is the name of the command package. It should not be the same as the variable name in makefile. The two lines in "Define" and "endef" are command sequences. The first command in this command package is to run YACCProgramBecause the YACC program always generates a file named "Y. Tab. c", the command on the second line is to change the file name. Let's take a look at this command package in an example.

Foo. C: Foo. Y

$ (Run-YACC)

We can see that to use this command package, we are just like using variables. In the use of this command package, "$ ^" in the Command package "Run-YACC" is "foo. Y ","$ @" Is "Foo. C "(for this special variable starting with" $ ", we will introduce it later). When executing the command package, make will execute each command in the Command package independently.

Original

Http://wiki.ubuntu.org.cn/index.php? Title = % E8 % B7 % 9f % E6 % 88% 91% E4 % B8 % 80% E8 % B5 % B7 % E5 % 86% 99 makefile: % E4 % B9 % a6 % E5 % 86% 99% E5 % 91% BD % E4 % BB % A4 & variant = ZH-HANT

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.