m4

macro processor

TLDR

Process file
$ m4 [input.m4]
Output to file
$ m4 [input.m4] > [output.txt]
Define macro
$ m4 -D [NAME=value] [input.m4]
Include directory
$ m4 -I [/path/to/includes] [input.m4]
Prefix builtins
$ m4 -P [input.m4]
Debug output
$ m4 -d [input.m4]

SYNOPSIS

m4 [options] [files]

DESCRIPTION

m4 is a macro processor. It expands macros in text files to generate output.The tool is used to preprocess configuration files and source code. It's part of autoconf.

PARAMETERS

FILES

Input files to process.
-D NAME=VALUE
Define macro.
-U NAME
Undefine macro.
-I DIR
Add include path.
-P
Prefix builtins with m4_.
-d
Enable debug output.
--help
Display help information.

INSTALL

sudo apt install m4
sudo dnf install m4
sudo pacman -S m4
sudo apk add m4
sudo zypper install m4
brew install m4
nix profile install nixpkgs#m4

CAVEATS

POSIX standard. Quoting rules can be tricky. Used by autoconf extensively.

HISTORY

m4 was developed at Bell Labs in the 1970s. The GNU version extends the original POSIX specification.

SEE ALSO

autoconf(1), make(1)