#!/bin/sh
clear
ulimit -c unlimited
rm -f core
clear
if false ; then
   M32=-m32
   export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig
fi
if which gcc-10 >/dev/null ; then
   export CC=gcc-10
fi
export CFLAGS="-Wextra -Wint-conversion -Wpedantic -Wall -O2 -g $M32 -Werror"
export LDFLAGS="$M32"

if [ x$1 = xc ] ; then
   rm -f Makefile
   shift
   if [ x$1 != x ] ; then
      if [ "$1" -eq "$1" ] ; then
	 export CC=gcc-$1
	 shift
      fi
   fi
fi

#export CC=g++-10
#export CFLAGS="-Wextra                  -Wpedantic -Wall -O2 -g $M32 -Werror"

if [ ! -e Makefile ] ; then
   ./configure --prefix=/tmp/xp && make clean
fi
rm -rf /tmp/xp
make -j install  || exit 1

#export EF_ALIGNMENT=32
#export EF_ALLOW_MALLOC_0=1
#export LD_PRELOAD=libefence.so.0.0
#export G_SLICE=always-malloc
#gdb /tmp/bin/xpenguins
#exit
/tmp/xp/bin/xpenguins --g-fatal-warnings "$@"
