English [en]

Associate members power up the Free Software Foundation. Help smash our goal of 700 new members or donate by December 31st!




Introduction to GNU M4

GNU M4 is an implementation of the traditional Unix macro processor. It is mostly SVR4 compatible although it has some extensions (for example, handling more than 9 positional parameters to macros). GNU M4 also has built-in functions for including files, running shell commands, doing arithmetic, etc.

GNU M4 is a macro processor in the sense that it copies its input to the output expanding macros as it goes. Macros are either builtin or user-defined and can take any number of arguments. Besides just doing macro expansion, m4 has builtin functions for including named files, running UNIX commands, doing integer arithmetic, manipulating text in various ways, recursion etc... m4 can be used either as a front-end to a compiler or as a macro processor in its own right.

One of the biggest users of GNU M4 is the GNU Autoconf project.

Downloading M4

The latest stable version is 1.4.18, and can be found on http://ftp.gnu.org/gnu/m4/ [via http] and ftp://ftp.gnu.org/gnu/m4/ [via FTP]. It can also be found on one of our FTP mirrors. The stable development branch can also be checked out from git, using either of:

git clone git://git.sv.gnu.org/m4
git clone http://git.savannah.gnu.org/r/m4.git

followed by:

git checkout -b branch-1.4 origin/branch-1.4


GNU M4 documentation can be found in several formats at http://www.gnu.org/software/m4/manual/. You may also find more information about GNU M4 by looking at your local documentation. For example, you might try looking in /usr/share/doc/m4/, or use info m4 at the shell prompt.

Mailing Lists

GNU M4 has several mailing lists: <bug-m4@gnu.org>, <m4-discuss@gnu.org>, <m4-patches@gnu.org>, and <m4-announce@gnu.org>. Archives of these lists are available; see the details of each list for a link to the archives.

You can subscribe to any GNU mailing list via the web as described below. Or you can send an empty mail with a Subject: header line of just "subscribe" to the relevant -request list. For example, to subscribe yourself to the bug-m4 list, you would send mail to <bug-m4-request@gnu.org> with no body and a Subject: header line of just "subscribe".

It has been necessary to moderate the GNU M4 mailing lists to prevent the flood of spam. Postings to the lists are held for release by the list moderator. Sometimes the moderators are unavailable for brief periods of time. Please be patient when posting. If you don't see the message in the list archive then it did not get posted.


The low-volume mailing list m4-announce contains all announcements about GNU M4. Important announcments about M4 and most other GNU Software are also made on <info-gnu@gnu.org>.

Tracking Development

The moderate-volume mailing list bug-m4 tracks all bug reports. For more information on submitting bugs, please see the section Report a Bug below.

The moderate-volume mailing list m4-patches is used to propose and track all significant patches. GNU M4 is being actively developed, and version 2.0 will have many new features, such as better input control, multiple precision arithmetic and loadable modules. More information about the future of GNU M4 is at http://savannah.gnu.org/projects/m4/. You can track development in git, using:

git clone git://git.sv.gnu.org/m4
git clone http://git.savannah.gnu.org/r/m4.git

You can also view the git tree on the web.

Alternatively, there is a read-only CVS mirror here:

cvs -d :pserver:anonymous@pserver.git.sv.gnu.org:/m4.git \
  co -d m4 HEAD

Please note that we do not suggest using test versions of GNU M4 for production use. One feature of the 2.0 release will be translations; you can track the progress of the i18n team at http://translationproject.org/domain/m4.html.

Request an Enhancement

If you would like any new feature to be included in future versions of GNU M4, please send a request to m4-discuss. This list tends to have a moderate volume of traffic.

Please remember that development of GNU M4 is a volunteer effort, and you can also contribute to its development. For information about contributing to the GNU Project, please read How to help GNU.

Report a Bug

If you think you have found a bug in GNU M4, then please send as complete a report as possible to <bug-m4@gnu.org>. This includes what platform and compiler you used to build M4, what version of M4 you are attempting to use, and transcripts of any error messages or behavior that was contrary to your expectations. Disagreements between the manual and the code are also bugs.


GNU M4 is maintained by Gary V. Vaughan <gary@gnu.org> and Eric Blake <ebb9@byu.net>.


 [FSF logo] “Our mission is to preserve, protect and promote the freedom to use, study, copy, modify, and redistribute computer software, and to defend the rights of Free Software users.”

The Free Software Foundation is the principal organizational sponsor of the GNU Operating System. Support GNU and the FSF by buying manuals and gear, joining the FSF as an associate member, or making a donation, either directly to the FSF or via Flattr.