#! /bin/sh
#
# Copyright (C) 1995-1998, 2000-2002 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 2, 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

# This file is meant for authors or maintainers which want to
# internationalize their package with the help of GNU gettext.  For
# further information how to use it consult the GNU gettext manual.

echo=echo
progname=$0
force=0
intldir=
configstatus=0
origdir=`pwd`
usage="\
Usage: gettextize [OPTION]... [package-dir]
      --help           print this help and exit
      --version        print version information and exit
  -c, --copy           copy files instead of making symlinks
  -f, --force          force writing of new files even if old exist
      --intl           install libintl in a subdirectory
      --no-changelog   don't update or create ChangeLog files
Report bugs to <bug-gnu-gettext@gnu.org>."
package=gettext
version=0.11.2
try_ln_s=:
do_changelog=:

while test $# -gt 0; do
  case "$1" in
    -c | --copy | --cop | --co | --c )
      shift
      try_ln_s=false ;;
    -f | --force | --forc | --for | --fo | --f )
      shift
      force=1 ;;
    -r | --run | --ru | --r )
      shift
      configstatus=1 ;;
    --help | --hel | --he | --h )
      $echo "$usage"; exit 0 ;;
    --intl | --int | --in | --i )
      shift
      intldir=yes ;;
    --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
      shift
      do_changelog=false ;;
    --version | --versio | --versi | --vers | --ver | --ve | --v )
      echo "$progname (GNU $package) $version"
      $echo "Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
      $echo "Written by" "Ulrich Drepper"
      exit 0 ;;
    -- )	# Stop option prcessing
      shift; break ;;
    -* )
      $echo "gettextize: unknown option $1"
      $echo "Try \`gettextize --help' for more information."; exit 1 ;;
    * )
      break ;;
  esac
done

if test $# -gt 1; then
  $echo "$usage"
  exit 1
fi

# Fill in the command line options value.
if test $# -eq 1; then
  srcdir=$1
  if cd $srcdir; then
    srcdir=`pwd`
  else
    $echo "gettextize: *** Cannot change directory to '$srcdir'."
    $echo "gettextize: *** Stop."
    exit 1
  fi
else
  srcdir=$origdir
fi

# The current directory is now $srcdir.

# Directory where the sources are stored.
prefix=/usr
gettext_dir=${prefix}/share/gettext

modified_ChangeLog=
added_directories=
removed_directory=
added_extradist=
added_acoutput=
removed_acoutput=" intl/intlh.inst"
please=

test -f configure.in || test -f configure.ac || {
  $echo "gettextize: *** Missing configure.in or configure.ac, please cd to your package first."
  $echo "gettextize: *** Stop."
  exit 1
}
configure_in=NONE
if test -f configure.in; then
  configure_in=configure.in
else
  if test -f configure.ac; then
    configure_in=configure.ac
  fi
fi

if test -d intl && test $force -eq 0; then
  $echo "gettextize: *** intl/ subdirectory exists: use option -f if you really want to delete it."
  $echo "gettextize: *** Stop."
  exit 1
fi

if test -f po/Makefile.in.in && test $force -eq 0; then
  $echo "gettextize: *** po/Makefile.in.in exists: use option -f if you really want to delete it."
  $echo "gettextize: *** Stop."
  exit 1
fi

if test -f ABOUT-NLS && test $force -eq 0; then
  $echo "gettextize: *** ABOUT-NLS exists: use option -f if you really want to delete it."
  $echo "gettextize: *** Stop."
  exit 1
fi

if test ! -f intl/Makefile.in && test -n "$intldir"; then
  added_acoutput="$added_acoutput intl/Makefile"
fi
if test -f intl/Makefile.in && test -z "$intldir"; then
  removed_acoutput="$removed_acoutput intl/Makefile"
fi
if test -d intl; then
  # Remove everything inside intl except for RCS and CVS subdirs and invisible
  # files.
  $echo "Wiping out intl/ subdirectory"
  (cd intl &&
   for f in *; do
     if test CVS != "$f" && test RCS != "$f"; then
       rm -rf "$f"
     fi
   done)
  if test -z "$intldir"; then
    removed_directory=intl
  fi
else
  if test -n "$intldir"; then
    $echo "Creating intl/ subdirectory"
    mkdir intl || {
      $echo "gettextize: *** failed to create intl/ subdirectory"
      $echo "gettextize: *** Stop."
      exit 1;
    }
    added_directories="$added_directories intl"
  fi
fi

test -d po || {
  $echo "Creating po/ subdirectory"
  mkdir po || {
    $echo "gettextize: *** failed to create po/ subdirectory"
    $echo "gettextize: *** Stop."
    exit 1
  }
}

# For simplicity we changed to the gettext source directory.
cd $gettext_dir || {
  $echo "gettextize: *** gettext source directory '${gettext_dir}' doesn't exist"
  $echo "gettextize: *** Stop."
  exit 1
}

DATE=`date +%Y-%m-%d`

# Now copy all files.  Take care for the destination directories.
for file in *; do
  case $file in
    ABOUT-NLS)
      rm -f $srcdir/$file
      ($try_ln_s && ln -s $gettext_dir/$file $srcdir/$file && $echo "Symlinking file $file") 2>/dev/null ||
      { $echo "Copying file $file"; cp $file $srcdir/$file; }
      ;;
    config.rpath)
      auxdir=`cat $srcdir/$configure_in | grep '^AC_CONFIG_AUX_DIR' | sed -n -e 's/AC_CONFIG_AUX_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q`
      if test -n "$auxdir"; then
        auxdir="$auxdir/"
      fi
      if test -f $srcdir/$auxdir$file; then
        :
      else
        added_extradist="$added_extradist $auxdir$file"
      fi
      rm -f $srcdir/$auxdir$file
      ($try_ln_s && ln -s $gettext_dir/$file $srcdir/$auxdir$file && $echo "Symlinking file $auxdir$file") 2>/dev/null ||
      { $echo "Copying file $auxdir$file"; cp $file $srcdir/$auxdir$file; }
      ;;
  esac
done

# Copy files to intl/ subdirectory.
if test -n "$intldir"; then
  cd intl
  for file in *; do
    if test $file != COPYING.LIB-2.0 && test $file != COPYING.LIB-2.1; then
      rm -f $srcdir/intl/$file
      if test $file != plural.c; then
        ($try_ln_s && ln -s $gettext_dir/intl/$file $srcdir/intl/$file && $echo "Symlinking file intl/$file") 2>/dev/null ||
        { $echo "Copying file intl/$file"; cp $file $srcdir/intl/$file; }
      else
        # plural.c is a generated file; it must be copied and touched.
        $echo "Copying file intl/$file"; cp $file $srcdir/intl/$file
        (sleep 2; touch $srcdir/intl/$file) &
       fi
    fi
  done
  cd ..
else
  echo "Not copying intl/ directory."
  please="$please
Please use AM_GNU_GETTEXT([external]) in order to cause autoconfiguration
to look for an external libintl.
"
fi

# Copy files to po/ subdirectory.
cd po
modified_poChangeLog=
for file in Makefile.in.in; do
  same=no
  if test -f $srcdir/po/$file; then
    if cmp -s $file $srcdir/po/$file; then
      same=yes
    fi
  else
    added_acoutput="$added_acoutput po/Makefile.in"
  fi
  if $do_changelog && test $same = no; then
    if test -z "$modified_poChangeLog"; then
      echo "$DATE  gettextize  <bug-gnu-gettext@gnu.org>" > $srcdir/po/ChangeLog.tmp
      echo >> $srcdir/po/ChangeLog.tmp
      modified_poChangeLog=yes
    fi
    if test -f $srcdir/po/$file; then
      echo "	* $file: Upgrade to gettext-${version}." >> $srcdir/po/ChangeLog.tmp
    else
      echo "	* $file: New file, from gettext-${version}." >> $srcdir/po/ChangeLog.tmp
    fi
  fi
  if test -f $srcdir/po/$file; then
    rm -f $srcdir/po/$file~
    cp -p $srcdir/po/$file $srcdir/po/$file~
  fi
  rm -f $srcdir/po/$file
  ($try_ln_s && ln -s $gettext_dir/po/$file $srcdir/po/$file && $echo "Symlinking file po/$file") 2>/dev/null ||
  { $echo "Copying file po/$file"; cp $file $srcdir/po/$file; }
done
for file in *; do
  case $file in
    Makefile.in.in)
      # Already handled above.
      ;;
    Makevars)
      rm -f $srcdir/po/$file.template
      ($try_ln_s && ln -s $gettext_dir/po/$file $srcdir/po/$file.template && $echo "Symlinking file po/$file.template") 2>/dev/null ||
      { $echo "Copying file po/$file.template"; cp $file $srcdir/po/$file.template; }
      if test -f $srcdir/po/$file; then
        please="$please
Please update po/$file so that it defines all the variables mentioned
in po/$file.template.
You can then remove po/$file.template.
"
      else
        please="$please
Please create po/$file from the template in po/$file.template.
You can then remove po/$file.template.
"
      fi
      ;;
    *)
      same=no
      if test -f $srcdir/po/$file; then
        if cmp -s $file $srcdir/po/$file; then
          same=yes
        fi
      fi
      if $do_changelog && test $same = no; then
        if test -z "$modified_poChangeLog"; then
          echo "$DATE  gettextize  <bug-gnu-gettext@gnu.org>" > $srcdir/po/ChangeLog.tmp
          echo >> $srcdir/po/ChangeLog.tmp
          modified_poChangeLog=yes
        fi
        if test -f $srcdir/po/$file; then
          echo "	* $file: Upgrade to gettext-${version}." >> $srcdir/po/ChangeLog.tmp
        else
          echo "	* $file: New file, from gettext-${version}." >> $srcdir/po/ChangeLog.tmp
        fi
      fi
      if test -f $srcdir/po/$file; then
        rm -f $srcdir/po/$file~
        cp -p $srcdir/po/$file $srcdir/po/$file~
      fi
      rm -f $srcdir/po/$file
      ($try_ln_s && ln -s $gettext_dir/po/$file $srcdir/po/$file && $echo "Symlinking file po/$file") 2>/dev/null ||
      { $echo "Copying file po/$file"; cp $file $srcdir/po/$file; }
      ;;
  esac
done
if test -f $srcdir/po/cat-id-tbl.c; then
  $echo "Removing po/cat-id-tbl.c"
  rm -f $srcdir/po/cat-id-tbl.c
  if $do_changelog; then
    if test -z "$modified_poChangeLog"; then
      echo "$DATE  gettextize  <bug-gnu-gettext@gnu.org>" > $srcdir/po/ChangeLog.tmp
      echo >> $srcdir/po/ChangeLog.tmp
      modified_poChangeLog=yes
    fi
    $echo "	* cat-id-tbl.c: Remove file." >> $srcdir/po/ChangeLog.tmp
  fi
fi
if test -f $srcdir/po/stamp-cat-id; then
  $echo "Removing po/stamp-cat-id"
  rm -f $srcdir/po/stamp-cat-id
  if $do_changelog; then
    if test -z "$modified_poChangeLog"; then
      echo "$DATE  gettextize  <bug-gnu-gettext@gnu.org>" > $srcdir/po/ChangeLog.tmp
      echo >> $srcdir/po/ChangeLog.tmp
      modified_poChangeLog=yes
    fi
    $echo "	* stamp-cat-id: Remove file." >> $srcdir/po/ChangeLog.tmp
  fi
fi
if $do_changelog && test -n "$modified_poChangeLog"; then
  $echo >> $srcdir/po/ChangeLog.tmp
  if test -f $srcdir/po/ChangeLog; then
    $echo "Adding an entry to po/ChangeLog (backup is in po/ChangeLog~)"
    cat $srcdir/po/ChangeLog >> $srcdir/po/ChangeLog.tmp
    cp -p $srcdir/po/ChangeLog $srcdir/po/ChangeLog~
  else
    $echo "Creating po/ChangeLog"
  fi
  cp $srcdir/po/ChangeLog.tmp $srcdir/po/ChangeLog
  rm -f $srcdir/po/ChangeLog.tmp
fi

m4filelist='  codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 lcmessage.m4
  lib-ld.m4 lib-link.m4 lib-prefix.m4 progtest.m4'
# We cannot omit codeset.m4, glibc21.m4, isc-posix.m4, lcmessage.m4 if
# test -z "$intldir", otherwise "aclocal -I m4" might give an error.
# (aclocal doesn't know which macros are really needed, it looks which macros
# are potentially needed.)

# All sorts of bugs could occur if the configure file was remade with the wrong
# version of gettext.m4 et al. (because then the configure and the po/Makefile.in.in
# don't fit together). It is therefore important that the package carries the
# right versions of gettext.m4 et al. with it.
if test -f $srcdir/Makefile.am; then
  # A package using automake.
  # Extract the macro directory name from Makefile.am.
  aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ 	]*=' $srcdir/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ 	]*=\(.*\)$/\1/'`
  m4dir=m4
  m4dir_is_next=
  for arg in $aclocal_amflags; do
    if test -n "$m4dir_is_next"; then
      m4dir="$arg"
      break
    else
      if test "X$arg" = "X-I"; then
        m4dir_is_next=yes
      else
        m4dir_is_next=
      fi
    fi
  done
  # Update the *.m4 files and the corresponding Makefile.am.
  modified_m4ChangeLog=
  added_m4files=
  if test -d "$srcdir/$m4dir"; then
    :
  else
    $echo "Creating directory $m4dir"
    mkdir "$srcdir/$m4dir"
    added_directories="$added_directories $m4dir"
  fi
  for file in $m4filelist; do
    same=no
    if test -f "$srcdir/$m4dir/$file"; then
      if cmp -s ${prefix}/share/aclocal/$file $srcdir/$m4dir/$file; then
        same=yes
      fi
    else
      added_m4files="$added_m4files $file"
    fi
    if $do_changelog && test $same = no; then
      if test -z "$modified_m4ChangeLog"; then
        echo "$DATE  gettextize  <bug-gnu-gettext@gnu.org>" > $srcdir/$m4dir/ChangeLog.tmp
        echo >> $srcdir/$m4dir/ChangeLog.tmp
        modified_m4ChangeLog=yes
      fi
      if test -f "$srcdir/$m4dir/$file"; then
        echo "	* $file: Upgrade to gettext-${version}." >> $srcdir/$m4dir/ChangeLog.tmp
      else
        echo "	* $file: New file, from gettext-${version}." >> $srcdir/$m4dir/ChangeLog.tmp
      fi
    fi
    if test -f "$srcdir/$m4dir/$file"; then
      rm -f $srcdir/$m4dir/$file~
      cp -p $srcdir/$m4dir/$file $srcdir/$m4dir/$file~
    fi
    rm -f $srcdir/$m4dir/$file
    ($try_ln_s && ln -s ${prefix}/share/aclocal/$file $srcdir/$m4dir/$file && $echo "Symlinking file $m4dir/$file") 2>/dev/null ||
    { $echo "Copying file $m4dir/$file"; cp ${prefix}/share/aclocal/$file $srcdir/$m4dir/$file; }
  done
  if test -n "$added_m4files"; then
    if test -f $srcdir/$m4dir/Makefile.am; then
      $echo "Updating EXTRA_DIST in $m4dir/Makefile.am (backup is in $m4dir/Makefile.am~)"
      rm -f $srcdir/$m4dir/Makefile.am~
      cp -p $srcdir/$m4dir/Makefile.am $srcdir/$m4dir/Makefile.am~
      rm -f $srcdir/$m4dir/Makefile.am
      if grep '^EXTRA_DIST[ 	]*=' $srcdir/$m4dir/Makefile.am~ > /dev/null; then
        sed -e "s%^\(EXTRA_DIST[ 	]*=\)%\\1$added_m4files %" < $srcdir/$m4dir/Makefile.am~ > $srcdir/$m4dir/Makefile.am
        $do_changelog && echo "	* Makefile.am (EXTRA_DIST): Add the new files." >> $srcdir/$m4dir/ChangeLog.tmp
      else
        (cat $srcdir/$m4dir/Makefile.am~; echo; echo "EXTRA_DIST =$added_m4files") > $srcdir/$m4dir/Makefile.am
        $do_changelog && echo "	* Makefile.am (EXTRA_DIST): New variable." >> $srcdir/$m4dir/ChangeLog.tmp
      fi
    else
      $echo "Creating $m4dir/Makefile.am"
      echo "EXTRA_DIST =$added_m4files" > $srcdir/$m4dir/Makefile.am
      $do_changelog && echo "	* Makefile.am: New file." >> $srcdir/$m4dir/ChangeLog.tmp
      added_acoutput="$added_acoutput $m4dir/Makefile"
    fi
  fi
  if $do_changelog && test -n "$modified_m4ChangeLog"; then
    echo >> $srcdir/$m4dir/ChangeLog.tmp
    if test -f $srcdir/$m4dir/ChangeLog; then
      $echo "Adding an entry to $m4dir/ChangeLog (backup is in $m4dir/ChangeLog~)"
      cat $srcdir/$m4dir/ChangeLog >> $srcdir/$m4dir/ChangeLog.tmp
      cp -p $srcdir/$m4dir/ChangeLog $srcdir/$m4dir/ChangeLog~
    else
      $echo "Creating $m4dir/ChangeLog"
    fi
    cp $srcdir/$m4dir/ChangeLog.tmp $srcdir/$m4dir/ChangeLog
    rm -f $srcdir/$m4dir/ChangeLog.tmp
  fi
  # Also create $m4dir/Makefile.in from $m4dir/Makefile.am, because automake
  # doesn't do it by itself.
  case "$added_acoutput" in
    *" $m4dir/Makefile")
      (cd $srcdir && automake $m4dir/Makefile) 2>/dev/null ||
      please="$please
Please run 'automake $m4dir/Makefile' to create $m4dir/Makefile.in
"
      ;;
  esac
  # Update the top-level Makefile.am.
  if test -n "$added_directories" || test -n "$removed_directory" || test -z "$m4dir_is_next" || test -n "$added_extradist"; then
    if $do_changelog; then
      echo "$DATE  gettextize  <bug-gnu-gettext@gnu.org>" > $srcdir/ChangeLog.tmp
      echo >> $srcdir/ChangeLog.tmp
      modified_ChangeLog=yes
    fi
    $echo "Updating Makefile.am (backup is in Makefile.am~)"
    rm -f $srcdir/Makefile.am~
    cp -p $srcdir/Makefile.am $srcdir/Makefile.am~
    rm -f $srcdir/Makefile.am
    first="* Makefile.am "
    if test -n "$added_directories"; then
      if grep '^SUBDIRS[ 	]*=' $srcdir/Makefile.am~ > /dev/null; then
        sed -e "s%^\(SUBDIRS[ 	]*=\)%\\1$added_directories %" < $srcdir/Makefile.am~ > $srcdir/Makefile.am~1
        $do_changelog && echo "	$first(SUBDIRS): Add "`echo $added_directories | sed -e 's/ /, /g'`'.' >> $srcdir/ChangeLog.tmp
      else
        (cat $srcdir/Makefile.am~; echo; echo "SUBDIRS =$added_directories") > $srcdir/Makefile.am~1
        $do_changelog && echo "	$first(SUBDIRS): New variable." >> $srcdir/ChangeLog.tmp
      fi
      first=
    else
      cp $srcdir/Makefile.am~ $srcdir/Makefile.am~1
    fi
    if test -n "$removed_directory"; then
      sed -e '/^SUBDIRS[ 	]*=/ {
          :a
          s%\([ 	]\)'"$removed_directory"'[ 	]%\1%
          s%[ 	]'"$removed_directory"'$%%
          tb
          :b
          s%\\$%\\%
          tc
          bd
          :c
          n
          ba
        :d
      }' < $srcdir/Makefile.am~1 > $srcdir/Makefile.am~2
      if cmp -s $srcdir/Makefile.am~1 $srcdir/Makefile.am~2; then
        :
      else
        $do_changelog && echo "	$first(SUBDIRS): Remove $removed_directory." >> $srcdir/ChangeLog.tmp
      fi
      first=
    else
      cp $srcdir/Makefile.am~1 $srcdir/Makefile.am~2
    fi
    if test -z "$m4dir_is_next"; then
      if grep '^ACLOCAL_AMFLAGS[ 	]*=' $srcdir/Makefile.am~ > /dev/null; then
        sed -e "s%^\(ACLOCAL_AMFLAGS[ 	]*=\)%\\1 -I $m4dir %" < $srcdir/Makefile.am~2 > $srcdir/Makefile.am~3
        $do_changelog && echo "	$first(ACLOCAL_AMFLAGS): Add -I $m4dir." >> $srcdir/ChangeLog.tmp
      else
        (cat $srcdir/Makefile.am~2; echo; echo "ACLOCAL_AMFLAGS = -I $m4dir") > $srcdir/Makefile.am~3
        $do_changelog && echo "	$first(ACLOCAL_AMFLAGS): New variable." >> $srcdir/ChangeLog.tmp
      fi
      # Also update Makefile.in and, if existent, Makefile. Otherwise they
      # would take into account the new flags only after a few rounds of
      # "./configure", "make", "touch configure.in", "make distclean".
      for file in $srcdir/Makefile.in $srcdir/Makefile; do
        if test -f $file; then
          rm -f $file~
          cp -p $file $file~
          rm -f $file
          sed -e "s%(ACLOCAL)%(ACLOCAL) -I $m4dir%" < $file~ > $file
        fi
      done
      first=
    else
      cp $srcdir/Makefile.am~2 $srcdir/Makefile.am~3
    fi
    if test -n "$added_extradist"; then
      if grep '^EXTRA_DIST[ 	]*=' $srcdir/Makefile.am~ > /dev/null; then
        sed -e "s%^\(EXTRA_DIST[ 	]*=\)%\\1$added_extradist %" < $srcdir/Makefile.am~3 > $srcdir/Makefile.am
        $do_changelog && echo "	$first(EXTRA_DIST): Add$added_extradist." >> $srcdir/ChangeLog.tmp
      else
        (cat $srcdir/Makefile.am~3; echo; echo "EXTRA_DIST =$added_extradist") > $srcdir/Makefile.am
        $do_changelog && echo "	$first(EXTRA_DIST): New variable." >> $srcdir/ChangeLog.tmp
      fi
      first=
    else
      cp $srcdir/Makefile.am~3 $srcdir/Makefile.am
    fi
    rm -f $srcdir/Makefile.am~1 $srcdir/Makefile.am~2 $srcdir/Makefile.am~3
  fi
  please="$please
Please run 'aclocal -I $m4dir' to regenerate the aclocal.m4 file.
You need aclocal from GNU automake 1.5 (or newer) to do this.
Then run 'autoconf' to regenerate the configure file.
"
else
  please="$please
Please add the files
$m4filelist
from the ${prefix}/share/aclocal directory to your aclocal.m4 file.
"
fi
modified_configure_in=
if test -n "$added_acoutput"; then
  if grep '^AC_CONFIG_FILES(' $srcdir/$configure_in > /dev/null; then
    $echo "Updating $configure_in (backup is in $configure_in~)"
    rm -f $srcdir/$configure_in~
    cp -p $srcdir/$configure_in $srcdir/$configure_in~
    rm -f $srcdir/$configure_in
    sed -e "s%^\\(AC_CONFIG_FILES([^])\\,]*\\)%\\1$added_acoutput %" < $srcdir/$configure_in~ > $srcdir/$configure_in
    if $do_changelog; then
      if test -z "$modified_ChangeLog"; then
        echo "$DATE  gettextize  <bug-gnu-gettext@gnu.org>" > $srcdir/ChangeLog.tmp
        echo >> $srcdir/ChangeLog.tmp
        modified_ChangeLog=yes
      fi
      echo "	* $configure_in (AC_CONFIG_FILES): Add "`echo $added_acoutput | sed -e 's/ /, /g'`'.' >> $srcdir/ChangeLog.tmp
    fi
    modified_configure_in=yes
  else
    if grep '^AC_OUTPUT(' $srcdir/$configure_in > /dev/null; then
      $echo "Updating $configure_in (backup is in $configure_in~)"
      rm -f $srcdir/$configure_in~
      cp -p $srcdir/$configure_in $srcdir/$configure_in~
      rm -f $srcdir/$configure_in
      sed -e "s%^\\(AC_OUTPUT([^])\\,]*\\)%\\1$added_acoutput %" < $srcdir/$configure_in~ > $srcdir/$configure_in
      if $do_changelog; then
        if test -z "$modified_ChangeLog"; then
          echo "$DATE  gettextize  <bug-gnu-gettext@gnu.org>" > $srcdir/ChangeLog.tmp
          echo >> $srcdir/ChangeLog.tmp
          modified_ChangeLog=yes
        fi
        echo "	* $configure_in (AC_OUTPUT): Add "`echo $added_acoutput | sed -e 's/ /, /g'`'.' >> $srcdir/ChangeLog.tmp
      fi
      modified_configure_in=yes
    else
      please="$please
Please add$added_acoutput to the AC_OUTPUT or AC_CONFIG_FILES invocation in the $configure_in file.
"
    fi
  fi
fi
if test -n "$removed_acoutput"; then
  for file in $removed_acoutput; do
    tag=
    sedprog='{
      s%\([[ 	]\)'"$file"'[ 	]%\1%
      s%\([[ 	]\)'"$file"'\([]),]\)%\1\2%
      s%[[ 	]'"$file"'$%%
        :a
        tb
        :b
        s%\\$%\\%
        tc
        bd
        :c
        n
        s%\([ 	]\)'"$file"'[ 	]%\1%
        s%\([ 	]\)'"$file"'\([]),]\)%\1\2%
        s%[ 	]'"$file"'$%%
        ba
      :d
    }'
    sed -e '/^AC_CONFIG_FILES(/'"$sedprog" < $srcdir/$configure_in > $srcdir/$configure_in.tmp
    if cmp -s $srcdir/$configure_in $srcdir/$configure_in.tmp; then
      sed -e '/^AC_OUTPUT(/'"$sedprog" < $srcdir/$configure_in > $srcdir/$configure_in.tmp
      if cmp -s $srcdir/$configure_in $srcdir/$configure_in.tmp; then
        :
      else
        tag=AC_OUTPUT
      fi
    else
      tag=AC_CONFIG_FILES
    fi
    if test -n "$tag"; then
      if test -z "$modified_configure_in"; then
        $echo "Updating $configure_in (backup is in $configure_in~)"
        rm -f $srcdir/$configure_in~
        cp -p $srcdir/$configure_in $srcdir/$configure_in~
      fi
      rm -f $srcdir/$configure_in
      cp $srcdir/$configure_in.tmp $srcdir/$configure_in
      if $do_changelog; then
        if test -z "$modified_ChangeLog"; then
          echo "$DATE  gettextize  <bug-gnu-gettext@gnu.org>" > $srcdir/ChangeLog.tmp
          echo >> $srcdir/ChangeLog.tmp
          modified_ChangeLog=yes
        fi
        if test -z "$modified_configure_in"; then
          echo "	* $configure_in ($tag): Remove $file." >> $srcdir/ChangeLog.tmp
        else
          echo "	($tag): Remove $file." >> $srcdir/ChangeLog.tmp
        fi
      fi
      modified_configure_in=yes
    else
      if test "$file" != intl/intlh.inst; then
        please="$please
Please remove $file from the AC_OUTPUT or AC_CONFIG_FILES invocation
in the $configure_in file.
"
      fi
    fi
    rm -f $srcdir/$configure_in.tmp
  done
fi
sed -e 's%sed -e "/POTFILES =/r po/POTFILES" po/Makefile\.in > po/Makefile *;* *%%' < $srcdir/$configure_in > $srcdir/$configure_in.tmp
if cmp -s $srcdir/$configure_in $srcdir/$configure_in.tmp; then
  :
else
  if test -z "$modified_configure_in"; then
    $echo "Updating $configure_in (backup is in $configure_in~)"
    rm -f $srcdir/$configure_in~
    cp -p $srcdir/$configure_in $srcdir/$configure_in~
  fi
  rm -f $srcdir/$configure_in
  cp $srcdir/$configure_in.tmp $srcdir/$configure_in
  if $do_changelog; then
    if test -z "$modified_ChangeLog"; then
      echo "$DATE  gettextize  <bug-gnu-gettext@gnu.org>" > $srcdir/ChangeLog.tmp
      echo >> $srcdir/ChangeLog.tmp
      modified_ChangeLog=yes
    fi
    if test -z "$modified_configure_in"; then
      echo "	* $configure_in (AC_OUTPUT): Remove command that created po/Makefile." >> $srcdir/ChangeLog.tmp
    else
      echo "	(AC_OUTPUT): Remove command that created po/Makefile." >> $srcdir/ChangeLog.tmp
    fi
  fi
  modified_configure_in=yes
fi
rm -f $srcdir/$configure_in.tmp
sed -e '/^\(dnl \|\)AC_LINK_FILES(\$nls_cv_header_libgt, \$nls_cv_header_intl)$/d' < $srcdir/$configure_in > $srcdir/$configure_in.tmp
if cmp -s $srcdir/$configure_in $srcdir/$configure_in.tmp; then
  :
else
  if test -z "$modified_configure_in"; then
    $echo "Updating $configure_in (backup is in $configure_in~)"
    rm -f $srcdir/$configure_in~
    cp -p $srcdir/$configure_in $srcdir/$configure_in~
  fi
  rm -f $srcdir/$configure_in
  cp $srcdir/$configure_in.tmp $srcdir/$configure_in
  if $do_changelog; then
    if test -z "$modified_ChangeLog"; then
      echo "$DATE  gettextize  <bug-gnu-gettext@gnu.org>" > $srcdir/ChangeLog.tmp
      echo >> $srcdir/ChangeLog.tmp
      modified_ChangeLog=yes
    fi
    if test -z "$modified_configure_in"; then
      echo "	* $configure_in (AC_LINK_FILES): Remove invocation." >> $srcdir/ChangeLog.tmp
    else
      echo "	(AC_LINK_FILES): Remove invocation." >> $srcdir/ChangeLog.tmp
    fi
  fi
  modified_configure_in=yes
fi
rm -f $srcdir/$configure_in.tmp
if $do_changelog && test -n "$modified_ChangeLog"; then
  echo >> $srcdir/ChangeLog.tmp
  if test -f $srcdir/ChangeLog; then
    $echo "Adding an entry to ChangeLog (backup is in ChangeLog~)"
    cat $srcdir/ChangeLog >> $srcdir/ChangeLog.tmp
    cp -p $srcdir/ChangeLog $srcdir/ChangeLog~
  else
    $echo "Creating ChangeLog"
  fi
  cp $srcdir/ChangeLog.tmp $srcdir/ChangeLog
  rm -f $srcdir/ChangeLog.tmp
fi

# Recommend replacement for deprecated Makefile variables.
use_libtool=`cat $srcdir/$configure_in | grep '^A[CM]_PROG_LIBTOOL'`
for file in `(cd $srcdir; find . -name Makefile.am -print; find . -name Makefile.in -print) | sed -e 's,^\./,,'`; do
  if test -f "$srcdir/$file"; then
    if test `echo "$file" | sed -e 's,^.*/,,'` = Makefile.in && grep automake "$srcdir/$file" >/dev/null 2>&1; then
      continue;
    fi
    # INTLLIBS is deprecated because it doesn't distinguish the two
    # cases: with libtool, without libtool.
    if grep '@''INTLLIBS''@' "$srcdir/$file" >/dev/null 2>&1; then
      if test -n "$use_libtool"; then
        please="$please
Please change $file to use @""LTLIBINTL""@ or @""LIBINTL""@ instead of
@""INTLLIBS""@. Which one, depends whether it is used with libtool or not.
@""INTLLIBS""@ will go away.
"
      else
        please="$please
Please change $file to use @""LIBINTL""@ instead of @""INTLLIBS""@.
@""INTLLIBS""@ will go away.
"
      fi
    fi
    # DATADIRNAME is deprecated because we install only .gmo files nowadays,
    # which can be stored in the platform independent $prefix/share hierarchy.
    if grep '@''DATADIRNAME''@' "$srcdir/$file" >/dev/null 2>&1; then
      please="$please
Please change $file to use the constant string \"share\" instead of
@""DATADIRNAME""@. @""DATADIRNAME""@ will go away.
"
    fi
    # INSTOBJEXT is deprecated because we install only .gmo files nowadays,
    # no catgets .cat catalogs.
    if grep '@''INSTOBJEXT''@' "$srcdir/$file" >/dev/null 2>&1; then
      please="$please
Please change $file to use the constant string \".mo\" instead of
@""INSTOBJEXT""@. @""INSTOBJEXT""@ will go away.
"
    fi
    # GENCAT is deprecated because we install no catgets catalogs anymore.
    if grep '@''GENCAT''@' "$srcdir/$file" >/dev/null 2>&1; then
      please="$please
Please change $file to use the constant string \"gencat\" instead of
@""GENCAT""@. @""GENCAT""@ will go away. Maybe you don't even need it any more?
"
    fi
    # POSUB is deprecated because it causes "./configure --disable-nls", "make",
    # "make dist" to create a buggy tarfile.
    if grep '@''POSUB''@' "$srcdir/$file" >/dev/null 2>&1; then
      please="$please
Please change $file to use the constant string \"po\" instead of
@""POSUB""@. @""POSUB""@ will go away.
"
    fi
  fi
done

# Recommend replacement for deprecated configure variables.
if grep '\$nls_cv_header_' $srcdir/$configure_in >/dev/null 2>&1; then
  please="$please
Please stop using \$nls_cv_header_intl or \$nls_cv_header_libgt in the
$configure_in file. Both will go away. Use <libintl.h> or \"gettext.h\" instead.
"
fi

echo "$please"
echo "You will also need config.guess and config.sub, which you can get from"
echo "ftp://ftp.gnu.org/pub/gnu/config/."
echo
echo "You might also want to copy the convenience header file gettext.h"
echo "from the $gettext_dir directory into your package."
echo "It is a wrapper around <libintl.h> that implements the configure --disable-nls"
echo "option."
echo

exit 0
