2 # autoupdate - modernize a configure.in
3 # Copyright (C) 1994 Free Software Foundation, Inc.
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)
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.
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., 59 Temple Place - Suite 330, Boston, MA
20 # If given no args, update `configure.in';
21 # With one arg, write on the standard output from the given template file.
23 # Written by David MacKenzie <djm@gnu.ai.mit.edu>
26 Usage: autoupdate [-h] [--help] [-m dir] [--macrodir=dir]
27 [--version] [template-file]"
29 sedtmp=`/bin/mktemp /tmp/acups.XXXXXX`
33 test -z "${AC_MACRODIR}" && AC_MACRODIR=@datadir@
35 while test $# -gt 0 ; do
38 echo "${usage}" 1>&2; rm -f $sedtmp; exit 0 ;;
39 --macrodir=* | --m*=* )
40 AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
42 -m | --macrodir | --m* )
44 test $# -eq 0 && { echo "${usage}" 1>&2; rm -f $sedtmp; exit 1; }
47 --version | --versio | --versi | --vers)
48 show_version=yes; shift ;;
49 -- ) # Stop option processing
51 - ) # Use stdin as input.
54 echo "${usage}" 1>&2; rm -f $sedtmp; exit 1 ;;
60 if test $show_version = yes; then
61 version=`sed -n 's/define.AC_ACVERSION.[ ]*\([0-9.]*\).*/\1/p' \
62 $AC_MACRODIR/acgeneral.m4`
63 echo "Autoconf version $version"
68 : ${SIMPLE_BACKUP_SUFFIX='~'}
71 trap 'rm -f $sedtmp $tmpout; exit 1' 1 2 15
72 trap 'rm -f $sedtmp' 0
74 0) infile=configure.in; out="> $tmpout"
75 # Make sure $infile can be read, and $tmpout has the same permissions.
76 cp $infile $tmpout || exit
78 # Make sure $infile can be written.
79 if test ! -w $infile; then
81 echo "$0: $infile: cannot write" >&2
85 1) infile="$1"; out= ;;
86 *) echo "$usage" >&2; exit 1 ;;
89 # Turn the m4 macro file into a sed script.
90 # For each old macro name, make one substitution command to replace it
91 # at the end of a line, and one when followed by ( or whitespace.
92 # That is easier than splitting the macros up into those that take
93 # arguments and those that don't.
106 }' ${AC_MACRODIR}/acoldnames.m4 > $sedtmp
107 eval sed -f $sedtmp $infile $out
110 0) mv configure.in configure.in${SIMPLE_BACKUP_SUFFIX} &&
111 mv $tmpout configure.in ;;
114 rm -f $sedtmp $tmpout