|
root / base / motif / build.sh
build.sh Bash 68 lines 3.2 KB
 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
66
67
#!/bin/sh
# Build script for motif / OpenMotif 2.3.8 (autotools, Template A).
# Older codebase - config.sub/libtool/__EXTENSIONS__ gotchas expected.
# CORRECTION (2026-07-23): motif's own configure.ac only references its
# in-tree bitmaps/Makefile, but lib/Xm/I18List.c has a *hardcoded*
# `#include <X11/bitmaps/gray>` - a real X.Org bitmap from the standalone
# xbitmaps package, NOT one of motif's own bitmaps/. Needs base/xbitmaps
# built+installed to $PREFIX/include first (see zports base/xbitmaps).
set -e

# Resolve the port dir (holds patches/) BEFORE cd'ing into the extracted source.
PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

cd "$SRCDIR"

# MANDATORY libtool fix - see Template A (confirmed 4 kopensolaris hits
# in this configure).
if [ -f configure ]; then
    sed -i -E 's/(kopensolaris\*-gnu)([^)]*\))/\1 | hammerhead*\2/' configure
fi

# GOTCHA: lib/Xm/Xmfuncs.h #defines bcopy/bzero/bcmp as function-like
# macros (for pre-ANSI systems) BEFORE illumos's X11/Xos.h later does its
# own (normally-safe, guarded) `#include <strings.h>`. Since strings.h
# hasn't been seen yet at that point, its `extern int bcmp(const void *,
# ...)` etc. prototypes get macro-substituted into invalid syntax
# ("expected declaration specifiers ... before '(' token"). Fixed by
# patching Xmfuncs.h to pull in <strings.h> itself before defining the
# macros, so strings.h's own include guard makes Xos.h's later include a
# no-op. See patches/0001-xmfuncs-strings-h-macro-mangling.patch.
for p in "$PORTDIR"/patches/*.patch; do
    [ -f "$p" ] || continue
    echo "==> Applying patch: $(basename "$p")"
    patch -p1 < "$p"
done

# GOTCHA: ResEncod.c casts its iconv() 2nd arg to (char **) - matching
# illumos's non-POSIX-conformant iconv(3C) prototype, which /usr/include/
# iconv.h only exposes when _XPG6 is defined (otherwise it exposes the
# `const char **` prototype instead, and the explicit (char **) cast in the
# old motif source becomes an incompatible-pointer-type error under GCC 14's
# now-stricter default). Define _XPG6 to select the signature the existing
# cast already expects, rather than patching upstream source.
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"
export CFLAGS="${CFLAGS} -I$PREFIX/include -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -D_XPG6 -fpermissive -fcommon"
export LDFLAGS="${LDFLAGS} -L$PREFIX/lib -R$PREFIX/lib"

# GOTCHA: ac_find_xft.m4's Xrender probe does
# `XRENDER_LIBS="-L$x_libraries -lXft -lXrender"` unconditionally once
# $have_x=yes, with NO fallback if $x_libraries came back empty (which it
# does here since AC_PATH_XTRA never needed to search - X11 is already on
# the default $PREFIX/lib path) - producing a malformed literal "-L -lXft"
# that trips libtool ("require no space between '-L' and '-lXft'").
# Force --x-libraries/--x-includes explicitly so $x_libraries is non-empty.
./configure \
    --prefix="$PREFIX" \
    --build="$BUILD_TRIPLE" \
    --host="$BUILD_TRIPLE" \
    --sysconfdir="$SYSCONFDIR" \
    --disable-static \
    --enable-xft \
    --disable-printing \
    --x-includes="$PREFIX/include" \
    --x-libraries="$PREFIX/lib"

gmake -j${JOBS:-1}
gmake install DESTDIR="$PKGDIR"