#!/bin/sh
# xld-gcc ARGS…: i686-apple-darwin8-gcc as OpenSSL's Makefile runs it to link, with the link itself run by $XLD, the
# toolchain's ld64 with patches/xtools (cross-build.sh's step_ld), which gives an i386 dylib for 10.4 a table of
# contents. gcc runs its own linker whatever -B says, so the link is the collect2 command of gcc -###, whose
# arguments go to ld as they are (after /www/tiger-sdl2's xld_link). A compile (-c) is gcc's own.
for a in "$@"; do [ "$a" = -c ] && exec i686-apple-darwin8-gcc "$@"; done
cmd=$(i686-apple-darwin8-gcc "$@" -### 2>&1 | grep '/collect2 ') || { echo "xld-gcc: no collect2 in: $*" >&2; exit 1; }
eval "set -- $cmd"
shift
exec "$XLD" "$@"
