1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/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
|