| mp | index | guide | reference |
a port is one directory, category/name (networking/curl, say), holding a single pkg.conf. ports/template/pkg.conf in the ports tree is the field-by-field reference, every key with its own inline comment. this page is the walkthrough: what to actually write, in what order, for the common cases.
the smallest real port is four lines of metadata and one phase pair:
pkg_name="hello"
pkg_ver="1.0"
pkg_fetch="git:https://example.com/hello.git"
install:
make install PREFIX=$MP_PREFIX
remove:
rm -rf $MP_PREFIX/bin/hello
fetch, patch, build, and check are all optional. a port with no build: phase just skips straight to install: against whatever fetch: (or pkg_fetch=) put in place. most real ports don't write fetch/build by hand at all: they set pkg_fetch= (a one-line git or tarball source) and inherit= one of classes/autotools.mp, cmake.mp, meson.mp, configure-make.mp, plain-make.mp, or bootstrap-make.mp, which supplies a matching build: for you.
pkg_name="hello"
pkg_ver="1.0"
pkg_fetch="git:https://example.com/hello.git"
inherit="autotools"
a class's own phases run first. anything you declare yourself under the same phase name in your own pkg.conf replaces the inherited one, it does not append to it. write your own fetch:, build:, or whatever only for the part that actually needs to differ, and inherit the rest.
dependencies. pkg_deps="foo bar" covers the common "needed to build and at runtime" case. split into pkg_bdepend and pkg_rdepend only when a port genuinely needs the distinction, a codegen tool that's gone by runtime, say. a dependency can be a plain name, a version constraint (name>=1.2, name=1.2.3, name~1.2), an exact slot (name:slot), or a tag (%name, resolving to whichever provider has the lowest pkg_pref). you almost never need to list %libc, %shell, or %coreutils yourself, mp appends GLOBAL_DEPS to every port by default.
versioning. pkg_ver is whatever scheme upstream uses, or literally "git" to track head. pkg_fetch's ref template (git:https://x.git@v<ver_>) lets "mp install name=1.2.3" pin an exact version by substituting it into the fetch itself. write your own fetch: phase instead for anything a one-liner can't express, svn, auth, picking among several mirrors.
optional features. pkg_use="ssl:%openssl x11:libxcb,libx11 debug" declares three flags: ssl pulls in %openssl when enabled, x11 pulls in two plain deps, debug is a bare bit with no deps of its own (exported as use_debug=1). a user turns one on globally (USE=ssl in mp.conf) or per-package. "mp use curl" lists what curl declares and its current state; "mp use curl +ssl" toggles and persists it.
patches. drop *.patch files in patches/ next to pkg.conf and they apply automatically, sorted by filename, no patch: phase needed. patches/use-<flag>/ and patches/nouse-<flag>/ gate on a use flag by directory alone. patches/patches.conf adds per-patch conditions (IF_DEP, IF_VER, IF_USE), explicit AFTER= ordering when filename order isn't enough, and DEPS+= when a specific patch needs its own extra dependency. see patches.conf.example's closing example for a "one use flag drives a patch, a dependency, and a hook together" walkthrough.
slot, if this port needs to coexist with other builds of itself. pkg_slot="12" installs into MP_PREFIX/name-12 instead of flat, referenced as name:12. most ports never set this. pkg_slot_use goes further: list use flags there and each one's enabled state contributes to the effective slot automatically. curl built with USE=ssl and curl built without coexist as curl:ssl and curl with zero extra pkg_slot bookkeeping. a dependent port just writes pkg_deps="curl:ssl" like any other slot reference and gets that exact build's prefix wired into its own build flags automatically.
conflicts. pkg_conflicts="other-libc" (or !other-libc for a warn-only soft conflict) when two ports genuinely can't coexist, see ports/libcs/musl and glibc for the canonical case. checked both directions and matched by bare name regardless of which slot is actually installed, so you write it the way you'd expect: the plain name, no slot suffix, even if it's commonly installed slotted.
tags. pkg_tags="cc" declares this port as a provider of the %cc tag; pkg_pref="50" (lower wins) ranks it among other providers when more than one exists. only needed if this port is genuinely interchangeable with something else, most ports declare no tags at all.
testing. "mp install --dry-run yourport" resolves the whole dependency graph without installing anything. "mp verify" sanity-checks every port in the tree parses and has no dependency cycle. RUN_TESTS=yes, globally or per-package, opts a check: phase into running. see test/ in the mp repo for how this project tests its own resolution/slot/patches/hooks machinery end to end, if you're touching mp itself rather than just adding a port.