Sign in

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.

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 withTopicWhat differs
LinuxGNU m4 on Linux vs illumos m4The 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 fourinclude 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 fourtracing 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 modeSolnix -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 sizeSolnix -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 fouroption orderingOn 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, NetBSDlong optionsSolnix 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 fourGNU mode, prefix and fatal-warning flagsSolnix 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, NetBSDbuiltins without parenthesesOn 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, NetBSDlimitsSolnix 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, NetBSDfrozen state filesLinux 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

TaskSolnixLinuxFreeBSDOpenBSDNetBSD
expand the macros in a filem4 filem4 filem4 filem4 filem4 file
define a macro on the command linem4 -D name=val filem4 -D name=value filem4 -Dname=value filem4 -Dname=value filem4 -D name=value file
run with unbuffered output, ignoring interruptsm4 -e filem4 -i file———

Standards

Writing portable scripts

  • For portable scripts, use only -D, -U, -s and file operands, with -s first, then -D and -U, then the files. Do not rely on -I, -d, -t, -P, -E or 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.