[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

21.1 What does M4 do?

m4 is a general purpose tool suitable for all kinds of text processing applications—not unlike the C preprocessor, cpp, with which you are probably familiar. Its obvious application is as a front-end for a compiler—m4 is in many ways superior to cpp.

Briefly, m4 reads text from the input and writes processed text to the output. Symbolic macros may be defined which have replacement text. As macro invocations are encountered in the input, they are replaced (‘expanded’) with the macro’s definition. Macros may be defined with a set of parameters and the definition can specify where the actual parameters will appear in the expansion. These concepts will be elaborated on in Fundamentals of M4 processing.

M4 includes a set of pre-defined macros that make it substantially more useful. The most important ones will be discussed in Features of M4. These macros perform functions such as arithmetic, conditional expansion, string manipulation and running external shell commands.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by Ben Elliston on July 10, 2015 using texi2html 1.82.