usage of $(subst) in makefile?
时间: 2024-02-18 22:59:14 浏览: 30
The `$(subst)` function in Makefile is used to replace all occurrences of a string with another string in a given variable or text. The syntax for using the `$(subst)` function is as follows:
```
$(subst from,to,text)
```
Here, `from` is the string to be replaced, `to` is the replacement string, and `text` is the variable or text in which the replacement should be made.
For example, suppose we have a variable `message` with the value `Hello, world!`. If we want to replace all occurrences of the string `world` with the string `everyone`, we can use the `$(subst)` function like so:
```
new_message = $(subst world,everyone,$(message))
```
This will replace all occurrences of the string `world` with the string `everyone` in the `message` variable, and store the result in the `new_message` variable.
So, in this example, `new_message` would have the value `Hello, everyone!`.
The `$(subst)` function can be very useful in Makefiles when we need to perform string replacements on variable values or text.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)