Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

135.3. flac-1.5.0

Free Lossless Audio Codec library and tools

Version 1.5.0, release 2
Shelf audio-codecs — Audio codecs, containers and tagging, including the Bluetooth audio codecs
Phase 41_system (System), 20 of 1047 in build order
Licence BSD-3-Clause AND GPL-2.0-or-later
Homepage https://xiph.org/flac/
Build time 0.9 SBU
Installed size 1.8 MiB in 34 files
Recipe ports/core/audio-codecs/flac/kpkgbuild

About

FLAC is the Free Lossless Audio Codec: the libraries libFLAC and libFLAC++ and the flac and metaflac commands. Programs read and write .flac files through it, among them libsndfile, gst-plugins-good, sdl2-mixer, audacity and chromium.

It is one of the hot libraries the tree builds with -O3 and link-time optimisation (see Every port).

Why it is in KDOS

The comment above the 5 ports from libogg to lame in script/phases/41_system/packages.d/audio-codecs.txt:

ffmpeg, libsndfile and the gst plugin packages are configured against these and are only as capable as what is installed: each of those build systems answers a missing library by disabling the feature rather than failing. One encoder per format — adding a second earns nothing.

Sources

Dependencies

Depends on: libogg.

Required by (33): amiberry, ardour, audacious-plugins, audacity, audex, audiocd-kio, audiofile, chromium, cmus, endless-sky, gst-plugins-good, ironwail, k3b, kwave, libopenmpt, libsndfile, mednafen, minidlna, mkvtoolnix, mpd, musescore, openrct2, opus-tools, schismtracker, scummvm, sdl2-mixer, sdl3-mixer, sdrangel, sox, tenacity, vice, vlc, vorbis-tools.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install flac'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/audio-codecs/flac.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/audio-codecs/flac
echo 'f2c1c76592a82ffff8413ba3c4a1299b6c7ab06c734dee03fd88630485c2b920  flac-1.5.0.tar.xz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/flac
SRC=$SRC_ROOT/flac-1.5.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf flac-1.5.0.tar.xz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

lto="-flto=auto -frandom-seed=flac"
export CFLAGS="${CFLAGS/-O2/-O3} $lto" CXXFLAGS="${CXXFLAGS/-O2/-O3} $lto"
export LDFLAGS="$LDFLAGS -flto=auto"
export AR=gcc-ar NM=gcc-nm RANLIB=gcc-ranlib

./configure --prefix=/usr --libdir=/usr/lib --disable-static \
	--disable-doxygen-docs \
	--disable-examples \
	--disable-version-from-git \
	--enable-ogg
make
make DESTDIR=$PKG install

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/flac, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf flac-1.5.0-2.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/flac, and runs the triggers its paths call for.

Contents

Installed programs: flac, metaflac.

Installed libraries: libFLAC++.so, libFLAC.so.

Installed directories: /usr/include/FLAC, /usr/include/FLAC++, /usr/share/doc/flac, /usr/share/licenses/flac.

Short descriptions

flac Free Lossless Audio Codec
metaflac program to list, add, remove, or edit metadata in one or more FLAC files.
flac.pc Free Lossless Audio Codec Library
flac++.pc Free Lossless Audio Codec Library (C++ API)