Wildcard in makefile

Source: Internet
Author: User

Function wildcard

In the rule, the wildcard is automatically expanded. However, when defining variables and referencing functions, wildcards will become invalid. In this case, if the wildcard is required to be valid, you need to use the Function
"Wildcard", which is used: $ (wildcard pattern ...)
. In makefile, it is expanded into a list of all existing files that are separated by spaces and match this mode. If no file meets this mode, the function ignores the mode character and returns
Null. Note: In this case, the expansion of the wildcard in the rule is different from that in the previous section that matches the wildcard.
Generally, we can use "$ (wildcard
*. C) to obtain the list of all. c files in the working directory. Complex usage; you can use "$ (patsubst %. C, %. O, $ (wildcard
*. C) ", first use the" wildcard "function to obtain the. c file list in the working directory, and then replace the suffix. C of all file names in the list with. O. In this way, we can obtain
Directory. Therefore, you can use makefile of the following content in a directory to compile all. c files in the working directory and connect them to an executable file:
# Sample makefile
Objects: = $ (patsubst %. C, %. O, $ (wildcard *. c ))
Foo: $ (objects)
CC-O Foo $ (objects)

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.