If I have the following rule
myfile.ext:
...
# `extname $@` or something
How can I reference the extension (ext
in this case) from the rule body?
The $(suffix)
function does what you want.
$(suffix names…)
Extracts the suffix of each file name in names. If the file name contains a period, the suffix is everything starting with the last period. Otherwise, the suffix is the empty string. This frequently means that the result will be empty when names is not, and if names contains multiple file names, the result may contain fewer file names.
For example,
$(suffix src/foo.c src-1.0/bar.c hacks)
produces the result ‘.c .c’.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With