# 使用 Homebrew, apk, apt, dnf, MacPorts, Nix, pacman, zypper, scoop 安装 m4

查看 m4 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:m4
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install m4
```

  证据: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install m4
```

  证据: MacPorts ports tree: devel/m4/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- apk (92%):

```sh
sudo apk add m4
```

  证据: Alpine Linux edge package indexes: m4 from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz

- Debian apt (92%):

```sh
sudo apt install m4
```

  证据: Debian stable package indexes: m4 from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz

- dnf (92%):

```sh
sudo dnf install m4
```

  证据: Fedora Rawhide package metadata: m4 from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst

- Nix (92%):

```sh
nix profile install nixpkgs#m4
```

  证据: nixpkgs package indexes: m4 from https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/top-level/all-packages.nix

- pacman (92%):

```sh
sudo pacman -S m4
```

  证据: Arch Linux sync databases: m4 from https://geo.mirror.pkgbuild.com/core/os/x86_64/core.db.tar.gz

- zypper (92%):

```sh
sudo zypper install m4
```

  证据: openSUSE Tumbleweed package metadata: m4 from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst

### Windows

- Scoop (92%):

```sh
scoop install main/m4
```

  证据: Scoop official bucket manifest trees: bucket/m4.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1

## 软件包事实

- **软件包键:** brew:m4
- **软件包管理器:** Homebrew
- **版本:** 1.4.21
- **来源摘要:** Macro processing language
- **主页:** <https://www.gnu.org/software/m4/>
- **最后更新:** 2026-07-17T16:54:41-04:00
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

- m4 (别名)

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 1.4.21
## 项目历史与用法

GNU M4 is the GNU implementation of the traditional Unix `m4` macro processor. It expands built-in and user-defined macros while copying input to output and is used both directly and as infrastructure for other build tools.

### 项目历史

The m4 lineage is older than GNU: the GNU manual traces macro-language ideas to 1950s and 1960s work by Alan Perlis, Doug McIlroy, Christopher Strachey, and Bell Labs macro processors such as GPM and M6.

Kernighan and Ritchie developed the original `m4` at Bell Labs in 1977. GNU M4 was released by Rene Seindal in 1990 to remove artificial limits in many traditional implementations, including line length, macro size, and macro-count limits.

Francois Pinard maintained GNU M4 in the early 1990s and released version 1.4 in 1994. After a long stable period, maintenance resumed with Paul Eggert, Gary V. Vaughan, Eric Blake, and later releases in the 1.4 series through 1.4.20.

### 采用历史

The GNU manual notes that `m4` is widely available on Unix systems and standardized by POSIX. Many users install GNU M4 indirectly because GNU Autoconf requires it to generate configure scripts.

The supplied package-manager facts show the package across Homebrew, Debian, Ubuntu, Fedora, Arch, Alpine, Nix, MacPorts, Scoop, and openSUSE, which matches its role as a baseline development dependency.

### 使用方式

GNU M4 can be invoked as `m4 [option...] [file...]`. It supports macro expansion, file inclusion, shell-command execution, arithmetic, text manipulation, and recursion.

In package builds, direct human-written M4 macros are less common than Autoconf usage, but maintainers still care about GNU M4 compatibility because configure-generation failures often trace back to macro behavior.

### 为什么软件包爱好者会关心

GNU M4 is one of the quiet pieces of the Autotools stack: many source packages do not need it at runtime, but build-from-VCS workflows and autoreconf pipelines often need the GNU implementation.

It matters to package maintainers because POSIX `m4`, vendor `m4`, and GNU M4 have historically differed in limits and extensions, and Autoconf intentionally standardized on GNU M4 to avoid those limitations.

### 时间线

- 1977: Original Bell Labs m4 described by Kernighan and Ritchie
- 1990: Rene Seindal released GNU M4
- 1994: GNU M4 1.4 released as a long-lived stable version
- 2004: 1.4.1 and 1.4.2 addressed long-standing bugs
- 2025: GNU M4 1.4.20 released

### Related projects

- GNU Autoconf is one of GNU M4's biggest users and requires GNU M4 as its macro engine.
- Traditional Unix m4 implementations, GPM, M6, M5, and Ratfor-related preprocessors are part of the historical macro-processor lineage.

### 来源

- <https://www.gnu.org/software/m4/>
- <https://www.gnu.org/software/m4/manual/>
- <https://www.gnu.org/software/m4/manual/html_node/History.html>
- <https://www.gnu.org/software/m4/manual/html_node/Intro.html>
- source_facts.package-manager


## 安全说明

narrow executable package without higher-risk signals.

- **Geiger 风险:** 绿色 / 低
- narrow executable package without higher-risk signals

## 其他软件包管理器记录

- Debian apt - m4 - 1.4.19-8: normalized package name match | Debian stable package indexes: m4 from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | macro processing language | https://www.gnu.org/software/m4/
- Debian apt - m4-doc - 1.4.19-8: normalized package name match | Debian stable package indexes: m4-doc from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | Documentation for GNU m4 | https://www.gnu.org/software/m4/
- Nix - m4: normalized package name match | nixpkgs package indexes: m4 from https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/top-level/all-packages.nix
- Ubuntu apt - m4 - 1.4.19-4build1: normalized package name match | Ubuntu 24.04 LTS package indexes: m4 from https://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64/Packages.gz | macro processing language | https://www.gnu.org/software/m4/
- Ubuntu apt - m4-doc - 1.4.19-4build1: normalized package name match | Ubuntu 24.04 LTS package indexes: m4-doc from https://archive.ubuntu.com/ubuntu/dists/noble/main/binary-amd64/Packages.gz | Documentation for GNU m4 | https://www.gnu.org/software/m4/
- apk - m4 - 1.4.21-r0: normalized package name match | Alpine Linux edge package indexes: m4 from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | GNU macro processor | https://www.gnu.org/software/m4
- apk - m4-doc - 1.4.21-r0: normalized package name match | Alpine Linux edge package indexes: m4-doc from https://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz | GNU macro processor (documentation) | https://www.gnu.org/software/m4
- dnf - m4 - 1.4.21-3.fc45: normalized package name match | Fedora Rawhide package metadata: m4 from https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/repodata/07190dc5ae9f35ae73866675fed6d95fe6e8d9fe22c9d7cdf85862cb2ed24a4c-primary.xml.zst | GNU macro processor | https://www.gnu.org/software/m4/
- pacman - m4 - 1.4.21-2: normalized package name match | Arch Linux sync databases: m4 from https://geo.mirror.pkgbuild.com/core/os/x86_64/core.db.tar.gz | The GNU macro processor | https://www.gnu.org/software/m4
- zypper - m4 - 1.4.21-1.4: normalized package name match | openSUSE Tumbleweed package metadata: m4 from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst | GNU m4 | https://www.gnu.org/software/m4/
- MacPorts - m4: normalized package name match | MacPorts ports tree: devel/m4/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1
- Scoop - main/m4: normalized package name match | Scoop official bucket manifest trees: bucket/m4.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1


## Combined YAML source

View the package source record on GitHub. [combined/m4.yml](https://github.com/mxcl/pkgdb/blob/main/combined/m4.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
