简体   繁体   中英

what does “%” mean in a Makefile?

I was going through some shell scripts, and I came across (for the first time) the use "%", some thing like:

build/audio/base/%.wav: src-audio/%.wav

I do not know what it is supposed to mean. Is it some thing like "*"?

Thanks!

That is from a makefile, not a shell script. From the documentation :

A target pattern is composed of a ' % ' between a prefix and a suffix, either or both of which may be empty. The pattern matches a file name only if the file name starts with the prefix and ends with the suffix, without overlap. The text between the prefix and the suffix is called the stem. Thus, when the pattern ' %.o ' matches the file name test.o , the stem is ' test '. The pattern rule prerequisites are turned into actual file names by substituting the stem for the character ' % '. Thus, if in the same example one of the prerequisites is written as ' %.c ', it expands to ' test.c '.

So every file that matches "build/audio/base/*.wav" has a dependency of "src-audio/*.wav" where the two parts that are represented by "*" must match.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM