Use the MAKEFILE file string handler function SUBST

Source: Internet
Author: User

Sometimes some string variables need to be processed temporarily in the makefile file. It is quite useful to know some string processing functions of the makefile file.

This article only describes how to use the subst function.

If you want to know how to use other functions, you can refer to the http://blog.csdn.net/yrj/article/details/4046853

 

Prototype

$ (Subst ;,;,;)
Name: String replacement function-subst.
Function: Replace the; string in the string ;.
Return: The function returns the replaced string.

 

Example

The CONF value of the variable is [MacRelease, MacDebug]. Remove Mac now.

Code: $ {substr Mac, $ {CONF }}

Result: Release or Debug

Notes

1. except the first space, the parameters of substr cannot contain spaces. Otherwise, spaces are used as character characters. for example, echo "cp/usr/lib/1.txt/local/$ {subst Mac, $ {CONF}". The parameter here is a space. If it is:

Cp/usr/lib/1.txt/local/Debug/

2. Double quotation marks are not required for parameters. Otherwise, double quotation marks are considered as the content of parameters.

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.