Blame autoupdate.sh

Packit 1ca270
#! @SHELL@
Packit 1ca270
# autoupdate - modernize a configure.in
Packit 1ca270
# Copyright (C) 1994 Free Software Foundation, Inc.
Packit 1ca270
Packit 1ca270
# This program is free software; you can redistribute it and/or modify
Packit 1ca270
# it under the terms of the GNU General Public License as published by
Packit 1ca270
# the Free Software Foundation; either version 2, or (at your option)
Packit 1ca270
# any later version.
Packit 1ca270
Packit 1ca270
# This program is distributed in the hope that it will be useful,
Packit 1ca270
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 1ca270
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 1ca270
# GNU General Public License for more details.
Packit 1ca270
Packit 1ca270
# You should have received a copy of the GNU General Public License
Packit 1ca270
# along with this program; if not, write to the Free Software
Packit 1ca270
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
Packit 1ca270
# 02111-1307, USA.
Packit 1ca270
Packit 1ca270
# If given no args, update `configure.in';
Packit 1ca270
# With one arg, write on the standard output from the given template file.
Packit 1ca270
#
Packit 1ca270
# Written by David MacKenzie <djm@gnu.ai.mit.edu>
Packit 1ca270
Packit 1ca270
usage="\
Packit 1ca270
Usage: autoupdate [-h] [--help] [-m dir] [--macrodir=dir] 
Packit 1ca270
       [--version] [template-file]" 
Packit 1ca270
Packit 1ca270
sedtmp=/tmp/acups.$$
Packit 1ca270
# For debugging.
Packit 1ca270
#sedtmp=/tmp/acups
Packit 1ca270
show_version=no
Packit 1ca270
test -z "${AC_MACRODIR}" && AC_MACRODIR=@datadir@
Packit 1ca270
Packit 1ca270
while test $# -gt 0 ; do
Packit 1ca270
   case "${1}" in 
Packit 1ca270
      -h | --help | --h* )
Packit 1ca270
         echo "${usage}" 1>&2; exit 0 ;;
Packit 1ca270
      --macrodir=* | --m*=* )
Packit 1ca270
         AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
Packit 1ca270
         shift ;;
Packit 1ca270
      -m | --macrodir | --m* ) 
Packit 1ca270
         shift
Packit 1ca270
         test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
Packit 1ca270
         AC_MACRODIR="${1}"
Packit 1ca270
         shift ;;
Packit 1ca270
      --version | --versio | --versi | --vers)
Packit 1ca270
        show_version=yes; shift ;;
Packit 1ca270
      -- )     # Stop option processing
Packit 1ca270
        shift; break ;;
Packit 1ca270
      - )	# Use stdin as input.
Packit 1ca270
        break ;;
Packit 1ca270
      -* )
Packit 1ca270
        echo "${usage}" 1>&2; exit 1 ;;
Packit 1ca270
      * )
Packit 1ca270
        break ;;
Packit 1ca270
   esac
Packit 1ca270
done
Packit 1ca270
Packit 1ca270
if test $show_version = yes; then
Packit 1ca270
  version=`sed -n 's/define.AC_ACVERSION.[ 	]*\([0-9.]*\).*/\1/p' \
Packit 1ca270
    $AC_MACRODIR/acgeneral.m4`
Packit 1ca270
  echo "Autoconf version $version"
Packit 1ca270
  exit 0
Packit 1ca270
fi
Packit 1ca270
Packit 1ca270
: ${SIMPLE_BACKUP_SUFFIX='~'}
Packit 1ca270
Packit 1ca270
tmpout=acupo.$$
Packit 1ca270
trap 'rm -f $sedtmp $tmpout; exit 1' 1 2 15
Packit 1ca270
case $# in
Packit 1ca270
  0) infile=configure.in; out="> $tmpout"
Packit 1ca270
     # Make sure $infile can be read, and $tmpout has the same permissions.
Packit 1ca270
     cp $infile $tmpout || exit
Packit 1ca270
Packit 1ca270
     # Make sure $infile can be written.
Packit 1ca270
     if test ! -w $infile; then
Packit 1ca270
       rm -f $tmpout
Packit 1ca270
       echo "$0: $infile: cannot write" >&2
Packit 1ca270
       exit 1
Packit 1ca270
     fi
Packit 1ca270
     ;;
Packit 1ca270
  1) infile="$1"; out= ;;
Packit 1ca270
  *) echo "$usage" >&2; exit 1 ;;
Packit 1ca270
esac
Packit 1ca270
Packit 1ca270
# Turn the m4 macro file into a sed script.
Packit 1ca270
# For each old macro name, make one substitution command to replace it
Packit 1ca270
# at the end of a line, and one when followed by ( or whitespace.
Packit 1ca270
# That is easier than splitting the macros up into those that take
Packit 1ca270
# arguments and those that don't.
Packit 1ca270
sed -n -e '
Packit 1ca270
/^AC_DEFUN(/ {
Packit 1ca270
  s//s%/
Packit 1ca270
  s/, *\[indir(\[/$%/
Packit 1ca270
  s/\].*/%/
Packit 1ca270
  p
Packit 1ca270
  s/\$//
Packit 1ca270
  s/%/^/
Packit 1ca270
  s/%/\\([( 	]\\)^/
Packit 1ca270
  s/%/\\1^/
Packit 1ca270
  s/\^/%/g
Packit 1ca270
  p
Packit 1ca270
}' ${AC_MACRODIR}/acoldnames.m4 > $sedtmp
Packit 1ca270
eval sed -f $sedtmp $infile $out
Packit 1ca270
Packit 1ca270
case $# in
Packit 1ca270
  0) mv configure.in configure.in${SIMPLE_BACKUP_SUFFIX} &&
Packit 1ca270
     mv $tmpout configure.in ;;
Packit 1ca270
esac
Packit 1ca270
Packit 1ca270
rm -f $sedtmp $tmpout
Packit 1ca270
exit 0