[Go] call Shell in makefile

Source: Internet
Author: User

1, in Makefile can only invoke shell script in target, other places can not be output. For example, the following code does not have any output:

Var= "Hello" echo "$ (VAR)" All:   ...  ..

The above code will not output at any time, not within target, if the above code is changed to the following:

Var= "Hello" all:    echo "$ (VAR)"      .....

The above code will execute the echo command when make all.

The final printing result is:

echo "" Hello ""

"Hello"

2. Execute the shell command in makefile, one line to create a process to execute.  This is also why many makefile have many lines at the end of the "; \ "To ensure that the code is one line instead of multiple lines, so that the makefile can be executed in a process, for example:

SUBDIR=SRC Exampleall:    @ in$ (subdir);     do        echo "building";       Done

As you can see, each line in the For loop is "; \ "End of.

3. All words that begin with $ in makefile will be interpreted as variables in the makefile. If you need to invoke a variable in the shell (or an anchor in a regular expression), you need to add two $ sign ($$). Examples are as follows:

Path= "/data/" all: variable in    echo ${path}/*makefile, that is, "/data"/    echo $ $PATH/*shell variables * /

The first ${path} in the example refers to a variable in the makefile, not the PATH environment variable in the shell, which refers to the PATH environment variable in the shell.

The above three points is makefile call Shell should pay attention to the place, write makefile must pay attention to.

[Go] call Shell 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.