#!/bin/sh

progname=${0#./}
system=`(uname -s) 2>/dev/null`

gettextize_file=".gettextize"
gettextize_exec="./${gettextize_file}"
libtoolv=
 libtoolf=
automakev=
 aclocalo=
autoconfv=

case ${system} in
  FreeBSD)
    libtoolv=
     libtoolf='/usr/local/share/aclocal/libtool.m4'
    automakev=14
     aclocalo='-I m4'
    autoconfv=213
    ;;
  Solaris)
    gettextize_exec='gettextize'
    ;;
esac

echo "${progname}: gettextize..."
case ${system} in
  *)
    i="`which gettextize`"
    test -f $i && test -x $i && \
      sed -e "/read dummy/D" $i > ${gettextize_file} && \
      chmod 755 ${gettextize_file}
    ;;
  Solaris)
    ;;
esac
${gettextize_exec} --force --intl --no-changelog
rm -f ${gettextize_file}
if [ -f Makefile.am~ ]; then
  mv --force Makefile.am~ Makefile.am
fi
if [ -f configure.in~ ]; then
  mv --force configure.in~ configure.in
fi

echo "${progname}: libtoolize..."
if [ -f acinclude.m4 ]; then
  mv -f acinclude.m4 acinclude.m4.original
  cp -f acinclude.m4.original acinclude.m4
fi
libtoolize${libtoolv} --force && test ${libtoolf} && test -f ${libtoolf} \
    && cat ${libtoolf} >> acinclude.m4

echo "${progname}: aclocal..."
aclocal${automakev} ${aclocalo}
if [ -f acinclude.m4.original ]; then
  mv -f acinclude.m4.original acinclude.m4
else
  rm -f acinclude.m4
fi

echo "${progname}: autoheader..."
autoheader${autoconfv}

echo "${progname}: automake..."
automake${automakev} --add-missing

echo "${progname}: autoconf..."
autoconf${autoconfv}
