Install
cpulimit builds with GNU make and any C99 compiler. It has no dependencies beyond the C library (and libkvm on FreeBSD).
Build and install
git clone https://github.com/denji/cpulimit.git
cd cpulimit
make # binary in build/cpulimit (copied to src/cpulimit)
make check # unit, CLI and integration tests
sudo make install # /usr/local/bin/cpulimit and the man pageOn FreeBSD, OpenBSD, NetBSD and illumos the GNU make is gmake (pkg install gmake, pkg_add gmake); the plain make of those systems cannot read the Makefile.
Variables
| Variable | Default | Meaning |
|---|---|---|
PREFIX | /usr/local | install prefix; BINDIR and MANDIR derive from it |
DESTDIR | empty | staging root for packagers |
CC, CFLAGS, CPPFLAGS, LDFLAGS | -O2 -g | yours are never overridden: the flags the program needs (-D_GNU_SOURCE, -Wall -Wextra) are kept apart from them |
BUILD | build | object and output directory; the build is non-recursive and rebuilds when the compiler or any flag changes |
WERROR=1 | off | turn warnings into errors (what CI uses) |
STATIC_CC | musl-gcc | compiler for make static |
make install never calls sudo itself. make uninstall removes what it installed.
Static binary
make static STATIC_CC=musl-gcc # build/static/cpulimit, no shared libraries
make static-installThe static build uses its own object directory, so it never mixes with a dynamic one.
Release binaries
Tagged releases are meant to carry static musl binaries (x86_64, aarch64, armv7, i686, ppc64le, s390x, riscv64) with a .sha256 file each. The release workflow has not produced a release yet, so look at the releases page to see whether one exists for your version before relying on it. How to check a download: Releases.
Notes for packagers
- The man page is hand written (
man/cpulimit.1) and installed bymake install;make manonly checks that it formats. make checkneeds/proc(Linux) or the platform's process interface; the integration tests start real processes.SKIP_INTEGRATION=1runs only the unit tests, andCPULIMIT_SKIP_TIMING=1skips the checks that depend on CPU accounting being accurate (emulated CPUs, busy shared builders).- The version is in three places that a test keeps equal:
src/cli/cli.c, the man page header and the top ofCHANGELOG.md.
Which systems are tested
All of Linux (glibc and musl), macOS, FreeBSD, OpenBSD and NetBSD have a process iterator; the honest version of how much each was run is on the platforms page. Short form: Linux is tested heavily, macOS and OpenBSD run the unit tests in CI, FreeBSD and the other BSDs are built and report their results to a non-gating workflow, and NetBSD and Solaris/illumos have not yet been confirmed on a real system.