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

195.1. libgd-2.3.3

GD graphics library — draws lines, shapes, text and images into PNG, JPEG, GIF, WebP, TIFF, HEIF, AVIF and BMP

Version 2.3.3, release 1
Shelf image-libs — Raster image formats, codecs, metadata, processing, barcodes, and terminal image output
Phase 42_graphics (Graphics Stack), 65 of 189 in build order
Licence GD
Homepage https://libgd.github.io/
Build time 0.6 SBU
Installed size 746.7 KiB in 29 files
Recipe ports/core/image-libs/libgd/kpkgbuild

About

GD is a C library for drawing images in code: lines, shapes, fills, text through FreeType, scaling and filters, read from and written to PNG, JPEG, GIF, WebP, TIFF, HEIF, AVIF and BMP. In KDOS, gnuplot’s PNG, GIF and JPEG terminals, graphviz’s GD renderer, libsixel, libgphoto2, ptouch-print and TeX Live build on it.

Sources

Dependencies

Depends on: pkgconf, perl, zlib, libpng, libjpeg-turbo, libwebp, libtiff, libheif, libavif, freetype2, fontconfig, libraqm, libimagequant.

Required by (6): gnuplot, graphviz, libgphoto2, libsixel, ptouch-print, texlive.

Optional, off in KDOS

These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.

Patches

build.sh applies these; kpkg applies nothing by itself.

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/42_graphics/phase.env && kpkg install libgd'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/image-libs/libgd.

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/image-libs/libgd
echo '3fe822ece20796060af63b7c60acb151e5844204d289da0ce08f8fdf131e5a61  libgd-2.3.3.tar.xz' | sha256sum -c -
echo '0dc217c7f78ed3347857c4f35bbadf14d4ff38efc80bc2b8d02910f4e0db8d65  heif-stride.patch' | 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/libgd
SRC=$SRC_ROOT/libgd-2.3.3
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libgd-2.3.3.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:

patch -p1 -i $PORT_SRC/heif-stride.patch

./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib \
	--disable-static \
	--disable-rpath \
	--disable-werror \
	--enable-gd-formats \
	--without-x \
	--with-zlib \
	--with-png \
	--with-jpeg \
	--with-webp \
	--with-tiff \
	--with-heif \
	--with-freetype \
	--with-fontconfig \
	--with-raqm \
	--with-liq \
	--without-xpm \
	--with-avif \
	ax_cv_c_openmp=unknown
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/libgd, 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 libgd-2.3.3-1.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/libgd, and runs the triggers its paths call for.

Contents

Installed programs: annotate, bdftogd, gd2copypal, gd2togif, gd2topng, gdcmpgif, gdparttopng, gdtopng, giftogd2, pngtogd, pngtogd2, webpng.

Installed libraries: libgd.so.

Installed directories: /usr/share/licenses/libgd.

Short descriptions

gdlib.pc GD graphics library