# m4

> traditional UNIX macro processor

**Wikidata**: [Q292068](https://www.wikidata.org/wiki/Q292068)  
**Wikipedia**: [English](https://en.wikipedia.org/wiki/M4_(computer_language))  
**Source**: https://4ort.xyz/entity/m4

## Summary
m4 is a traditional UNIX macro processor originally designed by Brian Kernighan in 1977. It functions as a general-purpose tool for processing macros and is included as a standard utility in the UNIX operating system.

## Key Facts
- **Inception:** 1977
- **Designer:** Brian Kernighan (Canadian computer scientist and co-inventor of Unix)
- **Instance of:** Standard UNIX utility, General-purpose macro processor, Programming language
- **Aliases:** UNIX m4
- **Standardization:** Documented in The Open Group Base Specifications, Issue 7
- **Command Line Options:** Supports `-s`, `-D`, and `-U` flags
- **Environment Variables:** Reads `LANG`, `LC_ALL`, `LC_CTYPE`, `LC_MESSAGES`, and `NLSPATH`
- **Wikipedia Title:** M4 (computer language)

## FAQs

### Q: Who created m4?
A: m4 was designed by Brian Kernighan, a Canadian computer scientist notable for co-inventing the Unix operating system.

### Q: What is m4 used for?
A: m4 is a general-purpose macro processor used as a standard UNIX utility. It acts as a programming language for communicating instructions to a machine, primarily to expand macros in text processing.

### Q: Where is m4 officially documented?
A: The utility is officially described at the Open Group website within "The Open Group Base Specifications, Issue 7."

## Why It Matters
m4 holds significant historical and technical importance in the field of computer science as one of the foundational tools of the UNIX operating system. Developed in 1977 by Brian Kernighan, it exemplifies the UNIX philosophy of creating single-purpose, powerful tools that can be combined with others. Unlike simple text replacement utilities, m4 is a full programming language and general-purpose macro processor, allowing for complex text manipulation and configuration management. Its endurance is evidenced by its inclusion in modern POSIX standards (The Open Group Base Specifications), ensuring that it remains a relevant tool for software portability and build systems decades after its inception.

## Notable For
- **UNIX Heritage:** Created in 1977 by Brian Kernighan, a pioneer of the Unix ecosystem.
- **POSIX Standardization:** Officially recognized as a standard UNIX utility by The Open Group.
- **Dual Classification:** Functions distinctly as both a macro processor and a programming language.
- **Extensibility:** Supports environment variables and command-line definitions (e.g., `-D`, `-U`) for flexible operation.

## Body

### History and Development
m4 was developed in 1977 by Brian Kernighan, a prominent computer scientist known for his work on Unix. Kernighan, who holds citizenship in Canada and the United States, is credited as a co-inventor of the Unix operating system. The creation of m4 addressed the need for a general-purpose macro processor within the Unix environment.

### Classification and Definition
While often categorized simply as a utility, m4 is formally classified as:
- A **standard UNIX utility or command**
- A **general-purpose macro processor**
- A **programming language** designed for communicating instructions to a machine

It is distinct from the entity identified simply as "M4" and is specifically referred to as "UNIX m4" in some contexts.

### Technical Specifications
According to The Open Group Base Specifications, Issue 7, m4 interacts with the system environment through specific variables and command-line options.

**Command Line Options:**
- `s`
- `D`
- `U`

**Environment Variables:**
The processor reads the following environment variables to determine its behavior and localization:
- `LANG`
- `LC_ALL`
- `LC_CTYPE`
- `LC_MESSAGES`
- `NLSPATH`

## References

1. Freebase Data Dumps. 2013
2. [The Open Group](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/m4.html)