m4(1) on Solnix vs Linux and the BSDs
On Solnix, m4 is the illumos m4 at /usr/bin/m4, with size options (-B, -H, -S, -T) and -e for interactive use. It documents no -I, -d, -t, -P or -E, which GNU m4 and the BSD m4 pages document, and no long options, which Linux, FreeBSD and NetBSD have.
The manual pages
- Solnix: m4(1) from
pkgs.solnix.illumos-world-man; the default on Solnix · illumos.org - Solnix: m4(1) from
pkgs.solnix.gnum4; add the package to get it - Solnix: m4(1) from
pkgs.solnix.m4; add the package to get it - Linux: m4(1) gnum4-1.4.21
- FreeBSD: m4(1) 15.1-RELEASE
- OpenBSD: m4(1) 8.0
- NetBSD: m4(1) 11.0
- Standard: POSIX.1-2024 (IEEE Std 1003.1-2024),
m4
What Solnix runs
/usr/bin/m4 is the illumos m4. /usr/xpg4/bin/m4 is also shipped, with nearly the same synopsis. Two other implementations are packaged and not on PATH by default: m4(1) from pkgs.solnix.gnum4, which is GNU M4 1.4.20, and m4(1) from pkgs.solnix.m4.
Differences
| Compared with | Topic | What differs |
|---|---|---|
| Linux | GNU m4 on Linux vs illumos m4 | The pkgs.solnix.gnum4 m4 page is GNU M4 1.4.20, with the same options as the Linux page (GNU M4 1.4.21): it is the same program. The default /usr/bin/m4 is not GNU m4, so GNU features need that package.Source: Solnix m4(1) from pkgs.solnix.gnum4; Linux m4(1); illumos m4(1) SYNOPSIS |
| all four | include path (-I) | Solnix m4 documents no -I. Linux, FreeBSD, OpenBSD and NetBSD all have -I dirname to add an include directory, and Linux also reads M4PATH.Source: illumos m4(1) SYNOPSIS, OPTIONS; Linux m4(1) -I, M4PATH; FreeBSD, OpenBSD and NetBSD m4(1) -I |
| all four | tracing and debugging (-d, -t) | Solnix m4 documents no -d or -t. Linux, FreeBSD, OpenBSD and NetBSD all have -d flags and -t macro; the BSDs send trace output to a file with -o, and Linux uses --debugfile.Source: illumos m4(1) OPTIONS; Linux m4(1) -d, -t, --debugfile; FreeBSD, OpenBSD and NetBSD m4(1) -d, -t, -o |
| all four | -e and interactive mode | Solnix -e makes m4 interactive: interrupts are ignored and output is unbuffered. Linux and NetBSD spell this -i (--interactive). The FreeBSD and OpenBSD pages document no interactive option.Source: illumos m4(1) -e; Linux m4(1) -i; NetBSD m4(1) -i; FreeBSD and OpenBSD m4(1) SYNOPSIS |
| Linux | -H hash table size | Solnix -H int sets the symbol table hash size, default 199, and says the size should be prime. Linux -H sets the same table, default 65537.Source: illumos m4(1) -H; Linux m4(1) -H, --hashsize |
| all four | option ordering | On Solnix the -B, -e, -H, -s, -S and -T flags must appear before any file names and before any -D or -U flag to take effect. The other pages do not state this rule.Source: illumos m4(1) OPTIONS ("To be effective, the above flags must appear before any file names") |
| Linux, FreeBSD, NetBSD | long options | Solnix m4 documents only single-letter options. Linux, FreeBSD and NetBSD accept long forms such as --define, --undefine, --include and --synclines, and the OpenBSD page lists none.Source: illumos m4(1) SYNOPSIS; Linux m4(1) -D, --define; FreeBSD m4(1) --define; NetBSD m4(1) --define; OpenBSD m4(1) SYNOPSIS |
| all four | GNU mode, prefix and fatal-warning flags | Solnix has no -g, -G, -P or -E. Linux, FreeBSD, OpenBSD and NetBSD document -P (prefix builtins with m4_) and -E (warnings fatal); Linux, FreeBSD and NetBSD document -g and -G, and OpenBSD -g only.Source: illumos m4(1) SYNOPSIS; Linux m4(1) -E, -G, -g, -P; FreeBSD m4(1) -E, -G, -g, -P; OpenBSD m4(1) -E, -g, -P; NetBSD m4(1) -E, -G, -g, -P |
| FreeBSD, OpenBSD, NetBSD | builtins without parentheses | On Solnix, a defined macro not followed by ( is called with no arguments. FreeBSD, OpenBSD and NetBSD say most built-ins are not recognized as special without a parenthesis, and note that many other m4 expand them anyway. Source: illumos m4(1) Macro Syntax; FreeBSD, OpenBSD and NetBSD m4(1) DESCRIPTION, STANDARDS |
| FreeBSD, OpenBSD, NetBSD | limits | Solnix documents hard limits: at most nine nested include files, ten diversions (0-9, others discarded), and quote and comment markers of up to five characters. The BSD -g mode makes the number of diversions unlimited.Source: illumos m4(1) DESCRIPTION, divert, changequote, changecom; FreeBSD m4(1) -g; OpenBSD m4(1) -g; NetBSD m4(1) -g |
| Linux, NetBSD | frozen state files | Linux and NetBSD have -F to save state and -R to reload it. The Solnix page documents no equivalent option.Source: Linux m4(1) -F, -R; NetBSD m4(1) -F, -R; illumos m4(1) OPTIONS |
Everyday tasks
| Task | Solnix | Linux | FreeBSD | OpenBSD | NetBSD |
|---|---|---|---|---|---|
| expand the macros in a file | m4 file | m4 file | m4 file | m4 file | m4 file |
| define a macro on the command line | m4 -D name=val file | m4 -D name=value file | m4 -Dname=value file | m4 -Dname=value file | m4 -D name=value file |
| run with unbuffered output, ignoring interrupts | m4 -e file | m4 -i file | — | — | — |
Standards
- POSIX: m4 is a POSIX.1-2024 utility.
- FreeBSD: The m4 utility is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification. The flags
-dEGgIPotare extensions to it. - OpenBSD: The m4 utility is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification. The flags
-dEgIPotare extensions to it. - NetBSD: The m4 utility is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification. The flags
-dgIotare extensions to it.
Writing portable scripts
- For portable scripts, use only
-D,-U,-sand file operands, with-sfirst, then-Dand-U, then the files. Do not rely on-I,-d,-t,-P,-Eor long options. - Write macro calls with explicit parentheses, such as define(), so built-ins behave the same whether or not the m4 expands them without arguments.
Every difference here is taken from the manual pages linked above: Solnix's published page, Linux (man-pages and the GNU and util-linux manuals), FreeBSD, OpenBSD and NetBSD. Each row names its source. Where a manual is silent, this page is too. Compiled 2026-10-26. Found a mistake? Mail hackers@lists.solnix.io.