#!/bin/sh


WRAPPER_LIBDIR="${WRAPPER_LIBDIR:=-L${STAGING_DIR:-/mnt/disk/openwrt-21.02/staging_dir/target-mips64_octeonplus_64_musl}/lib/}"

WRAPPER_OPTIONS=""
WRAPPER_LIBS="-lc -lgcc_s -lssp_nonshared"

WRAPPER_INCLIB="Y"
for arg
do
	case "$arg" in
	-c|-E|-S) WRAPPER_INCLIB="N" ;;
	-static) [ "$WRAPPER_LIBS" != "-lc -lgcc_s -lssp_nonshared -lgcc_eh" ] && WRAPPER_LIBS="-lc -lgcc_s -lssp_nonshared -lgcc_eh" ;;
	esac
done
if [ "$WRAPPER_INCLIB" = "Y" ]
then
	WRAPPER_OPTIONS="$WRAPPER_OPTIONS -nodefaultlibs $WRAPPER_LIBDIR -Wl,-Bdynamic,-luClibc++,-Bstatic,-lstdc++,-Bdynamic $WRAPPER_LIBS"
fi

[ -n "$V" ] && [ $V -gt 1 ] && echo mips64-openwrt-linux-musl-g++ -fno-builtin  -DGCC_HASCLASSVISIBILITY  $WRAPPER_INCLUDEDIR "$@" $WRAPPER_OPTIONS
exec mips64-openwrt-linux-musl-g++ -fno-builtin  -DGCC_HASCLASSVISIBILITY  $WRAPPER_INCLUDEDIR "$@" $WRAPPER_OPTIONS

