home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / bin / autoupdate < prev    next >
Text File  |  1994-12-22  |  3KB  |  113 lines

  1. #!/bin/sh
  2. # autoupdate - modernize a configure.in
  3. # Copyright (C) 1994 Free Software Foundation, Inc.
  4.  
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2, or (at your option)
  8. # any later version.
  9.  
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14.  
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. # If given no args, update `configure.in';
  20. # With one arg, write on the standard output from the given template file.
  21. #
  22. # Written by David MacKenzie <djm@gnu.ai.mit.edu>
  23.  
  24. usage="\
  25. Usage: autoupdate [-h] [--help] [-m dir] [--macrodir=dir] 
  26.        [--version] [template-file]" 
  27.  
  28. sedtmp=/tmp/acups.$$
  29. # For debugging.
  30. #sedtmp=/tmp/acups
  31. show_version=no
  32. test -z "${AC_MACRODIR}" && AC_MACRODIR=/gnu/lib/autoconf
  33.  
  34. while test $# -gt 0 ; do
  35.    case "${1}" in 
  36.       -h | --help | --h* )
  37.          echo "${usage}" 1>&2; exit 0 ;;
  38.       --macrodir=* | --m*=* )
  39.          AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
  40.          shift ;;
  41.       -m | --macrodir | --m* ) 
  42.          shift
  43.          test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
  44.          AC_MACRODIR="${1}"
  45.          shift ;;
  46.       --version | --versio | --versi | --vers)
  47.         show_version=yes; shift ;;
  48.       -- )     # Stop option processing
  49.         shift; break ;;
  50.       - )    # Use stdin as input.
  51.         break ;;
  52.       -* )
  53.         echo "${usage}" 1>&2; exit 1 ;;
  54.       * )
  55.         break ;;
  56.    esac
  57. done
  58.  
  59. if test $show_version = yes; then
  60.   version=`sed -n 's/define.AC_ACVERSION.[     ]*\([0-9.]*\).*/\1/p' \
  61.     $AC_MACRODIR/acgeneral.m4`
  62.   echo "Autoconf version $version"
  63.   exit 0
  64. fi
  65.  
  66. : ${SIMPLE_BACKUP_SUFFIX='~'}
  67.  
  68. tmpout=acupo.$$
  69. trap 'rm -f $sedtmp $tmpout; exit 1' 1 2 15
  70. case $# in
  71.   0) infile=configure.in; out="> $tmpout"
  72.      # Make sure $infile can be read, and $tmpout has the same permissions.
  73.      cp $infile $tmpout || exit
  74.  
  75.      # Make sure $infile can be written.
  76.      if test ! -w $infile; then
  77.        rm -f $tmpout
  78.        echo "$0: $infile: cannot write" >&2
  79.        exit 1
  80.      fi
  81.      ;;
  82.   1) infile="$1"; out= ;;
  83.   *) echo "$usage" >&2; exit 1 ;;
  84. esac
  85.  
  86. # Turn the m4 macro file into a sed script.
  87. # For each old macro name, make one substitution command to replace it
  88. # at the end of a line, and one when followed by ( or whitespace.
  89. # That is easier than splitting the macros up into those that take
  90. # arguments and those that don't.
  91. sed -n -e '
  92. /^AC_DEFUN(/ {
  93.   s//s%/
  94.   s/, *\[indir(\[/$%/
  95.   s/\].*/%/
  96.   p
  97.   s/\$//
  98.   s/%/^/
  99.   s/%/\\([(     ]\\)^/
  100.   s/%/\\1^/
  101.   s/\^/%/g
  102.   p
  103. }' ${AC_MACRODIR}/acoldnames.m4 > $sedtmp
  104. eval sed -f $sedtmp $infile $out
  105.  
  106. case $# in
  107.   0) mv configure.in configure.in${SIMPLE_BACKUP_SUFFIX} &&
  108.      mv $tmpout configure.in ;;
  109. esac
  110.  
  111. rm -f $sedtmp $tmpout
  112. exit 0
  113.