|
| 1 | +#!/usr/bin/env bash |
| 2 | +# M8.3: cross-compile the LXDE data layer (libfm-extra -> menu-cache -> libfm-gtk3) to |
| 3 | +# wasm32-wasip1-threads, from UNMODIFIED upstream. Dep order is circular-ish: menu-cache needs |
| 4 | +# libfm-extra, full libfm needs menu-cache. All wasi gaps fixed in the platform/toolchain layer |
| 5 | +# (constraint #5): see toolchain/openbox-compat.c (getpwuid/exec*/ns_get*), compat-include/grp.h, |
| 6 | +# wasi-compat.c (weak strsignal), libhostcompat.a. |
| 7 | +# |
| 8 | +# Host build-tool shims (intltool is unavailable; only needed for translations, which we --disable-nls): |
| 9 | +# toolchain/host-bin/{intltool-update,intltoolize,intltool-merge,intltool-extract} + a stub |
| 10 | +# perl5/XML/Parser.pm. The real gettext tools need libxml2.so.2 on LD_LIBRARY_PATH. |
| 11 | +set -uo pipefail |
| 12 | +cd "$(dirname "$0")/.." |
| 13 | +EXP="$(pwd)"; REPO="$(cd ../.. && pwd)" |
| 14 | +export SECURE_EXEC_WASM_THREADS=1 |
| 15 | +source "$EXP/toolchain/cross-env.sh" |
| 16 | +TP="$EXP/third_party" |
| 17 | +export PATH="$EXP/toolchain/host-bin:/home/linuxbrew/.linuxbrew/bin:$PATH" |
| 18 | +export PERL5LIB="$EXP/toolchain/host-bin/perl5:${PERL5LIB:-}" |
| 19 | +# the host gettext tools (xgettext/msgfmt) need libxml2.so.2; point at the nix copy if present |
| 20 | +XML2=$(find /nix/store -maxdepth 2 -name "libxml2.so.2" 2>/dev/null | head -1) |
| 21 | +[ -n "$XML2" ] && export LD_LIBRARY_PATH="$(dirname "$XML2"):${LD_LIBRARY_PATH:-}" |
| 22 | +newest_config_sub() { echo "$TP/libX11-threads/config.sub"; } |
| 23 | +LDADD_HOST="-lhostcompat -Wl,--allow-undefined" |
| 24 | + |
| 25 | +# 0. libhostcompat.a must exist (build-openbox.sh makes it; rebuild here too in case) |
| 26 | +"$CC" $CFLAGS -c "$EXP/toolchain/openbox-compat.c" -o "$EXP/toolchain/openbox-compat.o" 2>/dev/null |
| 27 | +"$AR" rcs "$PREFIX/lib/libhostcompat.a" "$EXP"/toolchain/threads-libs/{host_socket,host_pipe_dup,override_fcntl}.o \ |
| 28 | + "$EXP/toolchain/wasi-compat-threads.o" "$EXP/toolchain/openbox-compat.o" |
| 29 | + |
| 30 | +cfg() { # cfg <dir> <extra configure args...> |
| 31 | + local d="$1"; shift |
| 32 | + cp "$(newest_config_sub)" "$(dirname "$(newest_config_sub)")/config.guess" "$TP/$d/" 2>/dev/null |
| 33 | + ( cd "$TP/$d" && export LDFLAGS="$LDFLAGS $LDADD_HOST" && make distclean >/dev/null 2>&1 |
| 34 | + ./configure $CROSS_CONFIGURE_ARGS --disable-maintainer-mode --disable-nls --disable-gtk-doc "$@" \ |
| 35 | + > "/tmp/conf-$d.log" 2>&1 && touch aclocal.m4 configure config.h.in Makefile.in */Makefile.in 2>/dev/null ) |
| 36 | +} |
| 37 | + |
| 38 | +# 1. libfm-extra (the non-GTK utility lib; menu-cache requires it) |
| 39 | +if [ ! -f "$PREFIX/lib/libfm-extra.a" ]; then |
| 40 | + cd "$TP"; [ -d libfm ] || { mkdir -p libfm && tar xf libfm.tar -C libfm --strip-components=1; } |
| 41 | + [ -d libfm-threads ] || cp -r libfm libfm-threads |
| 42 | + cfg libfm-threads --with-extra-only |
| 43 | + ( cd "$TP/libfm-threads" && export LDFLAGS="$LDFLAGS $LDADD_HOST" && make -j4 && make install ) >/tmp/make-libfmextra.log 2>&1 \ |
| 44 | + && echo " OK libfm-extra" || { echo " FAIL libfm-extra"; exit 1; } |
| 45 | +fi |
| 46 | + |
| 47 | +# 2. menu-cache (library only; menu-cache-gen needs fork/exec at runtime, not built) |
| 48 | +if [ ! -f "$PREFIX/lib/libmenu-cache.a" ]; then |
| 49 | + cd "$TP"; [ -d menu-cache ] || { mkdir -p menu-cache && tar xf menu-cache.tar -C menu-cache --strip-components=1; } |
| 50 | + [ -d menu-cache-threads ] || cp -r menu-cache menu-cache-threads |
| 51 | + cfg menu-cache-threads |
| 52 | + ( cd "$TP/menu-cache-threads" && export LDFLAGS="$LDFLAGS $LDADD_HOST" \ |
| 53 | + && make -C libmenu-cache -j4 && make -C libmenu-cache install \ |
| 54 | + && cp libmenu-cache.pc "$PREFIX/lib/pkgconfig/" 2>/dev/null ) >/tmp/make-menucache.log 2>&1 \ |
| 55 | + && echo " OK menu-cache (lib)" || { echo " FAIL menu-cache"; exit 1; } |
| 56 | +fi |
| 57 | + |
| 58 | +# 3. full libfm (gtk3). --disable-old-actions skips the Vala 'custom actions' (no valac here). |
| 59 | +cd "$TP/libfm-threads"; cfg libfm-threads --with-gtk=3 --disable-old-actions |
| 60 | +( cd "$TP/libfm-threads" && export LDFLAGS="$LDFLAGS $LDADD_HOST" && make -j4 && make install ) >/tmp/make-libfm.log 2>&1 \ |
| 61 | + && echo "OK: libfm built — $(ls $PREFIX/lib/libfm*.a | xargs -n1 basename | tr '\n' ' ')" \ |
| 62 | + || { echo "FAIL libfm"; tail -12 /tmp/make-libfm.log; exit 1; } |
0 commit comments