Makefile and shell scripts

Source: Internet
Author: User
Tags call shell
1. in Makefile, Shell scripts can only be called in target, but cannot be output elsewhere. For example, the following code has no output: VAR = & quot; Hello & quot; echo & quot; $ VAR & quot; all: the above code is not output at any time, if the above code is not in the target, it should be changed to the following: 1. in Makefile, Shell scripts can only be called in the target, but cannot be output elsewhere. For example, the following code shows no output: VAR = "Hello" echo "$ VAR" all :..... the above code is not output at any time and is not in the target. if the above code is changed to the following: VAR = "Hello" all: echo "$ VAR "..... the above code will execute the echo command when making all. 2. execute the shell command in Makefile and create a process in one line for execution. This is why many makefiles have many rows ending with "; \" to ensure that the code is a line rather than multiple lines. in this way, Makefile can be executed in a process, for example: SUBDIR = src exampleall: @ for subdir in $ (SUBDIR); \ do \ echo "building"; \ done the above shows that each row in the for loop ends. 3. all words starting with $ in Makefile are interpreted as variables in Makefile. If you need to call the variables in the shell (or the variable $ in the regular expression), you need to add two $ symbols ($ ). Example: PATH = "/data/" all: echo $ {PATH} echo $ PATH in the example, the first $ {PATH} references variables in Makefile, instead of the PATH environment variable in shell, the latter references the PATH environment variable in Shell. The above three points should be noted when using Makefile to call shell, so be sure to write 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.