#!/usr/xpg4/bin/sh -e

patchit () {
  echo '#!/usr/xpg4/bin/sh' > $1.tmp
  tail -n +2 $1 >> $1.tmp
  mv -f $1.tmp $1
  chmod 0755 $1
}

# Solaris doesn't understand POSIX.1-2008 either.
sed -e 's/XOPEN_SOURCE=700/XOPEN_SOURCE=600/' < configure > configure.tmp
mv -f configure.tmp configure

patchit ./configure
patchit ./tools/install.sh
patchit ./tools/gen-deps.sh

echo 'SHELL := /usr/xpg4/bin/sh' > Makefile.tmp
echo >> Makefile.tmp
cat Makefile >> Makefile.tmp
mv -f Makefile.tmp Makefile
