#!/bin/sh # Build script for st (suckless, plain Makefile - NO configure, NOT a # template build). Deps: libX11, libXft, fontconfig, freetype. # # st's shipped config.mk hardcodes X11INC/X11LIB to /usr/X11R6 (doesn't # exist on Hammerhead) and links -lX11/-lXft directly instead of going # through pkg-config. Rewrite config.mk to resolve everything via # pkg-config against $PREFIX (falls back cleanly since x11/xft/ # fontconfig/freetype2 .pc files all live under $PREFIX/lib/pkgconfig). set -e cd "$SRCDIR" # GOTCHA: st.c's openpty() header selection is an #if/#elif chain keyed on # __linux / __OpenBSD__ / __NetBSD__ / __APPLE__ / __FreeBSD__ / # __DragonFly__ - none of which match illumos-derived GCC (which defines # __sun / __SVR4 instead), so no header gets included at all and openpty() # is an implicit (and on this GCC, fatal-by-default) declaration. openpty() # lives in libutil.h on illumos, same as the FreeBSD/DragonFly branch - # add a __sun arm alongside it. sed -i \ -e 's/#elif defined(__FreeBSD__) || defined(__DragonFly__)/#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__sun)/' \ st.c export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH" sed -i \ -e "s#^PREFIX = .*#PREFIX = $PREFIX#" \ -e '/^X11INC/d' -e '/^X11LIB/d' \ -e 's#^INCS = .*#INCS = `$(PKG_CONFIG) --cflags x11 xft fontconfig freetype2`#' \ -e '/PKG_CONFIG.*--cflags fontconfig/d' \ -e '/PKG_CONFIG.*--cflags freetype2/d' \ -e 's#^LIBS = .*#LIBS = -lm -lrt -lutil `$(PKG_CONFIG) --libs x11 xft fontconfig freetype2`#' \ -e '/PKG_CONFIG.*--libs fontconfig/d' \ -e '/PKG_CONFIG.*--libs freetype2/d' \ config.mk # Hidden POSIX prototypes (readv/writev/etc.) on illumos-derived headers - # same __EXTENSIONS__ gotcha as every other X11 port here. Add rpath too # since /usr/local/lib is not on Hammerhead's default ld.so search path. sed -i \ -e 's#^STCFLAGS = .*#STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS) -D__EXTENSIONS__#' \ -e "s#^STLDFLAGS = .*#STLDFLAGS = \$(LIBS) \$(LDFLAGS) -Wl,-R,$PREFIX/lib#" \ config.mk # st's Makefile defaults CC to `c99`, which doesn't exist on Hammerhead # (GCC 14 toolchain only) - the shipped config.mk has this commented out # expecting the user to override it, but we're non-interactive so force # it on the make command line too (belt-and-suspenders with the sed above). gmake CC=gcc PREFIX="$PREFIX" # GOTCHA: the Makefile's `install` target ends with `tic -sx st.info` to # register st's terminfo entry. That's GNU-ncurses tic syntax; Hammerhead # only ships illumos' native SVR4 /usr/bin/tic, which doesn't understand # -s/-x and errors out ("Unknown option"), taking `gmake install` down # with it even though the binary+man install (the two steps before it) # already succeeded. Do the bin/man install ourselves and treat terminfo # registration as best-effort (harmless if it's a no-op - st still runs # fine falling back to $TERM=xterm-compatible entries already present). mkdir -p "$PKGDIR$PREFIX/bin" cp -f st "$PKGDIR$PREFIX/bin/st" chmod 755 "$PKGDIR$PREFIX/bin/st" mkdir -p "$PKGDIR$PREFIX/share/man/man1" sed "s/VERSION/0.9.3/g" < st.1 > "$PKGDIR$PREFIX/share/man/man1/st.1" chmod 644 "$PKGDIR$PREFIX/share/man/man1/st.1" tic st.info 2>/dev/null || true # st - simple suckless terminal emulator for X # https://st.suckless.org/ [package] name = "st" version = "0.9.3" release = 1 description = "Simple suckless terminal emulator for X" url = "https://st.suckless.org/" license = "MIT" maintainer = "Chris Tusa " arch = "x86_64" [dependencies] runtime = ["libX11", "libXft", "fontconfig", "freetype"] build = ["libX11", "libXft", "fontconfig", "freetype"] [[source]] file = "st-0.9.3.tar.gz" urls = ["https://dl.suckless.org/st/st-0.9.3.tar.gz"] checksum = "9ed9feabcded713d4ded38c8cebf36a3b08f0042ef7934a0e2b2409da56e649b" [build] parallel = true