Based on the docs, I can't tell the difference between the two. It seems that either of them can be used in prerequisites, targets, and variables to achieve the same result.
1 Answers
Quoting from the manual:
$%
is
The target member name, when the target is an archive member. See Archives. For example, if the target is foo.a(bar.o) then ‘$%’ is bar.o and ‘$@’ is foo.a. ‘$%’ is empty when the target is not an archive member.
$*
is
The stem with which an implicit rule matches (see How Patterns Match). If the target is dir/a.foo.b and the target pattern is a.%.b then the stem is dir/foo. The stem is useful for constructing names of related files. In a static pattern rule, the stem is part of the file name that matched the ‘%’ in the target pattern. (There's more detail in the manual.)
* when used in a target or a prerequisite list is a file glob wildcard.
% when used in targets and prerequisites is a pattern wildcard in either a static pattern rule or a normal pattern rule.
So the $*
variable has the same contents as the % matched in that rule's target and prerequisites.
The $%
variable is used when dealing with archive targets.
The * is filename globbing when used in targets and prerequisites.

- 77,877
- 8
- 106
- 148
-
So, in this case: http://stackoverflow.com/questions/2483182/recursive-wildcards-in-gnu-make the % is used in a static pattern rule in order to generate the prerequisite from the target which is invoked by `patsubst` in `$(MP3_FILES)` which can be called by `make all`, correct? – paulkon Nov 19 '13 at 01:57
-
1The patsubst transforms the flac filenames into mp3 file names. The `mp3/%.mp3: flac/%.flac` bit is a normal pattern rule (they could have used a static pattern rule if they'd wanted to) which says for any file you are asked to build which matches the `mp3/%.mp3` pattern which has a prerequisite file of `flac/%.flac` run the following rule. The inclusion of `$(MP3_FILES)` in the `all` target's prerequisite list means that `make all` will try to build all those mp3 files. – Etan Reisner Nov 19 '13 at 02:28
-
So if it was written as a static pattern rule then could the same thing be accomplished in less code? Also, how would it be written using a static pattern rule? – paulkon Nov 19 '13 at 03:09
-
1Wouldn't change much of anything in that specific case that I can tell a static pattern rule mostly just limits the pattern rule application to the listed targets. `$(MP3_FILES): mp3/%.mp3: flac/%.flac` – Etan Reisner Nov 19 '13 at 03:50