resetting manifest requested domain to floor
[platform/upstream/autoconf213.git] / autoupdate.sh
1 #! @SHELL@
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., 59 Temple Place - Suite 330, Boston, MA
18 # 02111-1307, USA.
19
20 # If given no args, update `configure.in';
21 # With one arg, write on the standard output from the given template file.
22 #
23 # Written by David MacKenzie <djm@gnu.ai.mit.edu>
24
25 usage="\
26 Usage: autoupdate [-h] [--help] [-m dir] [--macrodir=dir] 
27        [--version] [template-file]" 
28
29 sedtmp=`/bin/mktemp /tmp/acups.XXXXXX`
30 # For debugging.
31 #sedtmp=/tmp/acups
32 show_version=no
33 test -z "${AC_MACRODIR}" && AC_MACRODIR=@datadir@
34
35 while test $# -gt 0 ; do
36    case "${1}" in 
37       -h | --help | --h* )
38          echo "${usage}" 1>&2; rm -f $sedtmp; exit 0 ;;
39       --macrodir=* | --m*=* )
40          AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
41          shift ;;
42       -m | --macrodir | --m* ) 
43          shift
44          test $# -eq 0 && { echo "${usage}" 1>&2; rm -f $sedtmp; exit 1; }
45          AC_MACRODIR="${1}"
46          shift ;;
47       --version | --versio | --versi | --vers)
48         show_version=yes; shift ;;
49       -- )     # Stop option processing
50         shift; break ;;
51       - )       # Use stdin as input.
52         break ;;
53       -* )
54         echo "${usage}" 1>&2; rm -f $sedtmp; exit 1 ;;
55       * )
56         break ;;
57    esac
58 done
59
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"
64   rm -f $sedtmp
65   exit 0
66 fi
67
68 : ${SIMPLE_BACKUP_SUFFIX='~'}
69
70 tmpout=acupo.$$
71 trap 'rm -f $sedtmp $tmpout; exit 1' 1 2 15
72 trap 'rm -f $sedtmp' 0
73 case $# in
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
77
78      # Make sure $infile can be written.
79      if test ! -w $infile; then
80        rm -f $tmpout
81        echo "$0: $infile: cannot write" >&2
82        exit 1
83      fi
84      ;;
85   1) infile="$1"; out= ;;
86   *) echo "$usage" >&2; exit 1 ;;
87 esac
88
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.
94 sed -n -e '
95 /^AC_DEFUN(/ {
96   s//s%/
97   s/, *\[indir(\[/$%/
98   s/\].*/%/
99   p
100   s/\$//
101   s/%/^/
102   s/%/\\([(     ]\\)^/
103   s/%/\\1^/
104   s/\^/%/g
105   p
106 }' ${AC_MACRODIR}/acoldnames.m4 > $sedtmp
107 eval sed -f $sedtmp $infile $out
108
109 case $# in
110   0) mv configure.in configure.in${SIMPLE_BACKUP_SUFFIX} &&
111      mv $tmpout configure.in ;;
112 esac
113
114 rm -f $sedtmp $tmpout
115 exit 0