m
#define m4: \
I-------------------------------\
I-------------------------------\
I /$$ /$$ /$$ /$$ \
I | $$$ /$$$| $$ | $$ \
I | $$$$ /$$$$| $$ | $$ \
I | $$ $$/$$ $$| $$$$$$$$ \
I | $$ $$$| $$|_____ $$ \
I | $$\ $ | $$ | $$ \
I | $$ \/ | $$ | $$ \
I |__/ |__/ |__/ \
I-------------------------------\
I-------------------------------I
• macro based text generation language
• part of standard *nix distributions
info m4
Macro:
<name> : simple macro
<name>(<arg>+) : function like macro, can arbitrary use all arguments passed in
{
define(macro, my_text)dnl
define(macro2, `my_text is $1')dnl
macro
macro2(lovely)
$ m4 example.m4
my_text
my_text is lovely
}
Expansion:
• text is subject to macro expansion given its recognized as a macro
Quoting:
``<literal>''
• quoted text expand to itself without quotes
• literals start with a back tick ('`') and end with a apostrophe ('\'')
Variables:
$1 $2 $3 $4 $5 $6 $7 $8 $9
• recognized inside the deplaration of function like macros
• expand to arguments
Builtin_Macros:
dnl<comment> : "Delete New Line"; deletes everything to the right of the macro on the same line, including the '\n';
used for truncating whitespace in the output and or for commenting
include(<file>) : expands to the contents of <file>
define(<name>, <value>) : creates a new macro named <name> expanding to <value>