#!/bin/sh # Build as34 (assembler), ld34 (linker) and dis34 (disassembler) from Andrew # Morton's gsptools, patched to build on a 64-bit Linux host. # # Everything is fetched/built under tools/as34/build (override with # AS34_BUILD_DIR) so the repository tree stays clean. # # The upstream tarball is an UNCOMPRESSED tar with a .tar.gz name; that is # how the Wayback Machine archived it. set -eu here=$(cd "$(dirname "$0")" && pwd) builddir=${AS34_BUILD_DIR:-"$here/build"} tarball="$builddir/gsp.tar.gz" srcdir="$builddir/src" treesrc="$srcdir/gsp/binutils" TARBALL_SHA256=efff8e59f7e3bf0285c4bd44d63e2357d6c26a85d939d4843d6be3471af9ef46 TARBALL_URL="https://web.archive.org/web/20070206220404if_/http://www.zip.com.au/~akpm/gsp.tar.gz" mkdir -p "$builddir" if [ ! -f "$tarball" ]; then echo "fetching $tarball" curl -fL --max-time 300 -o "$tarball" "$TARBALL_URL" fi echo "$TARBALL_SHA256 $tarball" | sha256sum -c - if [ ! -d "$treesrc" ]; then mkdir -p "$srcdir" tar xf "$tarball" -C "$srcdir" fi if [ ! -f "$srcdir/.patched" ]; then patch -p1 -d "$srcdir/gsp" < "$here/as34-port.patch" touch "$srcdir/.patched" fi # -std=gnu17: C23 removed K&R definitions, which this 1998 code uses. # -fcommon: the sources rely on tentative definitions being merged. # as34 needs -DBISON to select the flex/bison input path in as.l. CC_BASE="gcc -std=gnu17 -O2 -fcommon \ -Wno-implicit-function-declaration -Wno-int-conversion \ -Wno-incompatible-pointer-types -Wno-builtin-declaration-mismatch \ -Wno-implicit-int -Wno-return-mismatch -Wno-format -Wno-unused-result" echo "building as34" make -C "$treesrc/as34" clean >/dev/null 2>&1 || true make -C "$treesrc/as34" \ CC="$CC_BASE -DBISON" \ XCFLAGS="-include $here/proto.h" echo "building ld34 and dis34" make -C "$treesrc/ld34" clean >/dev/null 2>&1 || true make -C "$treesrc/ld34" ld34 CC="$CC_BASE" make -C "$treesrc/ld34" dis34 CC="$CC_BASE" echo echo "built:" ls -l "$treesrc/as34/as34" "$treesrc/ld34/ld34" "$treesrc/ld34/dis34"