# Adding a tool here First follow the shared bar in `emu-tools/docs/adding-a-tool.md` (layout, versioning, the contract, ROMs by environment variable, a smoke test). Then, for this repository: 1. **Check the upstream's licence** at the exact commit you pin (its licence file and the headers of the files you use). Allowed: GPL-2.0-or-later, GPL-3.0, LGPL-2.1+/3.0, MPL-2.0, permissive. Stop and report if it is AGPL, non-commercial, unlicensed, or by an author who objects to AI use. If it is GPL-2.0-only, the tool goes to `emu-tools-gpl2` instead (its README). **A file with no "or later" grant, in a repository whose LICENSE is the GPL-2.0 text, is GPL-2.0-only** (Aubrey, 2026-11-24): check every file the tool compiles, links, loads into its own process, declares the API of, or patches, not only the licence file. Record it in emulator-lineage's `docs/sources.md` and in `docs/upstreams.md`. 2. **Pin and fetch.** `build.sh` fetches the upstream at its pinned commit into a git-ignored `upstream/` directory and applies `patches/*.patch` in order. Upstream code is not committed here unless it must be (then with its licence file beside it). 3. **Patches are ours, GPL.** Keep them small and named for what they expose (for example `trace-hooks.patch`). Prefer adding a documented hook to scraping debugger text. Before patching: use the upstream's own API, scripting or libretro interface if it suffices; offer generic hooks upstream where the project accepts AI-assisted contributions. A fork only when patches grow large. **A GPL-2.0-only (or AGPL) upstream's patches and fork never live here:** they go in a repository under that exact licence (`emu-tools-gpl2` for GPL-2.0-only), and the patched program speaks the contract itself, as a separate executable (see the proposal's "When an upstream must be patched"). 4. **Export documented behaviour only.** Pins named as the data sheet names them, bus cycles, documented registers, pictures, sound. Do not export internal node names or state-machine labels: an MIT consumer could not use them, and they invite copying. 5. **The README is the only text that crosses the wall.** Describe the command line and outputs in prose; no code fragments, no upstream source comments. 6. **SPDX headers:** `GPL-3.0-or-later` on our files; upstream files keep their own. 7. **Its path is fixed and documented:** `$EMU_TOOLS_GPL/tools//...`, listed in `tools/README.md`. A tool's README may offer an optional per-tool override; nothing more.