[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
String substitutions in macros
------------------------------
MAKE lets you temporarily substitute characters in a previously
defined macro. For example, if you defined a macro called SOURCE as
"SOURCE = f1.cpp f2.cpp f3.cpp", you could substitute the characters
.OBJ for the characters .CPP by using "$(SOURCE:.CPP=.OBJ)". The
substitution doesn't redefine the macro.
Rules for macro substitution:
o Syntax: $(MacroName:original_text=new_text)
o No whitespace before or after the colon.
o Characters in "original_text" must exactly match the characters in the
macro definition; this text is case-sensitive.
MAKE now lets you use macros within substitution macros. For example:
MYEXT=.C
SOURCE=f1.cpp f2.cpp f3.cpp
$(SOURCE:.cpp=$(MYEXT)) #Changes f1.cpp to f1.C, etc.
Online resources provided by: http://www.ClipX.Net --- NG 2 HTML conversion by Dave Pearson