Macro languages were invented early in the history of computing. In the 1950s Alan Perlis suggested that the macro language be independent of the language being processed. Techniques such as conditional and recursive macros, and using macros to define other macros, were described by Doug McIlroy of Bell Labs in “Macro Instruction Extensions of Compiler Languages”, Communications of the ACM 3, 4 (1960), 214–20, https://dl.acm.org/doi/10.1145/367177.367223.
An important precursor of
m4 was GPM; see C. Strachey,
“A general purpose macrogenerator”, Computer Journal 8, 3
https://academic.oup.com/comjnl/article/8/3/225/336044. GPM is
also succinctly described in David Gries’s book Compiler
Construction for Digital Computers, Wiley (1971). Strachey was a
brilliant programmer: GPM fit into 250 machine instructions!
Inspired by GPM while visiting Strachey’s Lab in 1968, McIlroy wrote a
model preprocessor in that fit into a page of Snobol 3 code, and McIlroy
and Robert Morris developed a series of further models at Bell Labs.
Andrew D. Hall followed up with M6, a general purpose macro processor
used to port the Fortran source code of the Altran computer algebra
system; see Hall’s “The M6 Macro Processor”, Computing Science
Technical Report #2, Bell Labs (1972),
http://cm.bell-labs.com/cm/cs/cstr/2.pdf. M6’s source code
consisted of about 600 Fortran statements. Its name was the first of
The Brian Kernighan and P.J. Plauger book Software Tools,
Addison-Wesley (1976), describes and implements a Unix
macro-processor language, which inspired Dennis Ritchie to write
m3, a macro processor for the AP-3 minicomputer.
Kernighan and Ritchie then joined forces to develop the original
m4, described in “The M4 Macro Processor”, Bell Laboratories
It had only 21 builtin macros.
GPM was more pure,
m4 is meant to deal with
the true intricacies of real life: macros can be recognized without
being pre-announced, skipping whitespace or end-of-lines is easier,
more constructs are builtin instead of derived, etc.
Originally, the Kernighan and Plauger macro-processor, and then
m3, formed the engine for the Rational FORTRAN preprocessor,
that is, the
Ratfor equivalent of
was used as a front-end for
René Seindal released his implementation of
in 1990, with the aim of removing the artificial limitations in many
of the traditional
m4 implementations, such as maximum line
length, macro size, or number of macros.
The late Professor A. Dain Samples described and implemented a further
evolution in the form of
M5: “User’s Guide to the M5 Macro
Language: 2nd edition”, Electronic Announcement on comp.compilers
François Pinard took over maintenance of GNU
1992, until 1994 when he released GNU
m4 1.4, which was
the stable release for 10 years. It was at this time that GNU
Autoconf decided to require GNU
m4 as its underlying
engine, since all other implementations of
m4 had too many
More recently, in 2004, Paul Eggert released 1.4.1 and 1.4.2 which
addressed some long standing bugs in the venerable 1.4 release. Then in
2005, Gary V. Vaughan collected together the many patches to
m4 1.4 that were floating around the net and
released 1.4.3 and 1.4.4. And in 2006, Eric Blake joined the team and
prepared patches for the release of 1.4.5, with subsequent releases
through intervening years, as recent as 1.4.18 in 2016.
Meanwhile, development has continued on new features for
as dynamic module loading and additional builtins. When complete,
m4 2.0 will start a new series of releases.