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=/tmp/acups.$$
|
---|
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; 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; 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; 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 | exit 0
|
---|
65 | fi
|
---|
66 |
|
---|
67 | : ${SIMPLE_BACKUP_SUFFIX='~'}
|
---|
68 |
|
---|
69 | tmpout=acupo.$$
|
---|
70 | trap 'rm -f $sedtmp $tmpout; exit 1' 1 2 15
|
---|
71 | case $# in
|
---|
72 | 0) infile=configure.in; out="> $tmpout"
|
---|
73 | # Make sure $infile can be read, and $tmpout has the same permissions.
|
---|
74 | cp $infile $tmpout || exit
|
---|
75 |
|
---|
76 | # Make sure $infile can be written.
|
---|
77 | if test ! -w $infile; then
|
---|
78 | rm -f $tmpout
|
---|
79 | echo "$0: $infile: cannot write" >&2
|
---|
80 | exit 1
|
---|
81 | fi
|
---|
82 | ;;
|
---|
83 | 1) infile="$1"; out= ;;
|
---|
84 | *) echo "$usage" >&2; exit 1 ;;
|
---|
85 | esac
|
---|
86 |
|
---|
87 | # Turn the m4 macro file into a sed script.
|
---|
88 | # For each old macro name, make one substitution command to replace it
|
---|
89 | # at the end of a line, and one when followed by ( or whitespace.
|
---|
90 | # That is easier than splitting the macros up into those that take
|
---|
91 | # arguments and those that don't.
|
---|
92 | sed -n -e '
|
---|
93 | /^AC_DEFUN(/ {
|
---|
94 | s//s%/
|
---|
95 | s/, *\[indir(\[/$%/
|
---|
96 | s/\].*/%/
|
---|
97 | p
|
---|
98 | s/\$//
|
---|
99 | s/%/^/
|
---|
100 | s/%/\\([( ]\\)^/
|
---|
101 | s/%/\\1^/
|
---|
102 | s/\^/%/g
|
---|
103 | p
|
---|
104 | }' ${AC_MACRODIR}/acoldnames.m4 > $sedtmp
|
---|
105 | eval sed -f $sedtmp $infile $out
|
---|
106 |
|
---|
107 | case $# in
|
---|
108 | 0) mv configure.in configure.in${SIMPLE_BACKUP_SUFFIX} &&
|
---|
109 | mv $tmpout configure.in ;;
|
---|
110 | esac
|
---|
111 |
|
---|
112 | rm -f $sedtmp $tmpout
|
---|
113 | exit 0
|
---|