#!/bin/sh
# Copyright (C) 2003-2016 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# This script populates the build infrastructure in the source tree
# checked-out from VCS.
#
# This script requires:
#   - Autoconf
#   - Automake
#

# Nuisances.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH

# Generate configure script in each subdirectories.
dir0=`pwd`

echo "$0: generating configure in gettext-runtime/libasprintf..."
cd gettext-runtime/libasprintf
aclocal -I ../../m4 -I ../m4 -I gnulib-m4 -I ../gnulib-m4 \
  && autoconf \
  && autoheader \
  && automake --add-missing --copy \
  || exit $?
  rm -rf autom4te.cache
cd "$dir0"

echo "$0: generating configure in gettext-runtime..."
cd gettext-runtime
aclocal -I m4 -I ../m4 -I gnulib-m4 \
  && autoconf \
  && autoheader \
  && automake --add-missing --copy \
  || exit $?
  rm -rf autom4te.cache
cd "$dir0"

echo "$0: generating configure in gettext-tools/examples..."
cd gettext-tools/examples
aclocal -I ../../gettext-runtime/m4 -I ../../m4 \
  && autoconf \
  && automake --add-missing --copy \
  || exit $?
  rm -rf autom4te.cache
cd "$dir0"

echo "$0: generating configure in gettext-tools..."
cd gettext-tools
aclocal -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4 -I ../gettext-runtime/gnulib-m4 \
  && autoconf \
  && autoheader \
  && automake --add-missing --copy \
  || exit $?
  rm -rf autom4te.cache
cd "$dir0"

aclocal -I m4 && autoconf && automake --add-missing --copy || exit $?
rm -rf autom4te.cache

echo "$0: done.  Now you can run './configure'."
