*** empty log message ***
[autoconf.git] / autoreconf.in
blob4b83f80425c3467aff60832fe3f65163445713d3
1 #!/bin/sh
2 # autoreconf - remake all Autoconf configure scripts in a directory tree
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)
8 # any later version.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
19 usage="\
20 Usage: autoreconf [-f] [-h] [--help] [-m dir] [--macrodir=dir]
21 [-l dir] [--localdir=dir] [--force] [--verbose] [--version]"
23 localdir=
24 verbose=no
25 show_version=no
26 force=no
28 test -z "$AC_MACRODIR" && AC_MACRODIR=@datadir@
30 while test $# -gt 0; do
31 case "$1" in
32 -h | --help | --h*)
33 echo "$usage"; exit 0 ;;
34 --localdir=* | --l*=* )
35 localdir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
36 shift ;;
37 -l | --localdir | --l*)
38 shift
39 test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
40 localdir="${1}"
41 shift ;;
42 --macrodir=* | --m*=* )
43 AC_MACRODIR="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
44 shift ;;
45 -m | --macrodir | --m*)
46 shift
47 test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
48 AC_MACRODIR="$1"
49 shift ;;
50 --verbose | --verb*)
51 verbose=yes; shift ;;
52 -f | --force)
53 force=yes; shift ;;
54 --version | --vers*)
55 show_version=yes; shift ;;
56 --) # Stop option processing.
57 shift; break ;;
58 -*) echo "$usage" 1>&2; exit 1 ;;
59 *) break ;;
60 esac
61 done
63 if test $show_version = yes; then
64 version=`sed -n 's/define.AC_ACVERSION.[ ]*\([0-9.]*\).*/\1/p' \
65 $AC_MACRODIR/acgeneral.m4`
66 echo "Autoconf version $version"
67 exit 0
70 if test $# -ne 0; then
71 echo "$usage" 1>&2; exit 1
74 top_autoconf=`echo $0|sed s%autoreconf%autoconf%`
75 top_autoheader=`echo $0|sed s%autoreconf%autoheader%`
77 # The xargs grep filters out Cygnus configure.in files.
78 find . -name configure.in -print |
79 xargs grep -l AC_OUTPUT |
80 sed 's%/configure\.in$%%; s%^./%%' |
81 while read dir; do
83 cd $dir || continue
85 case "$dir" in
86 .) dots= ;;
87 *) # A "../" for each directory in /$dir.
88 dots=`echo /$dir|sed 's%/[^/]*%../%g'` ;;
89 esac
91 case "$0" in
92 /*) autoconf=$top_autoconf; autoheader=$top_autoheader ;;
93 */*) autoconf=$dots$top_autoconf; autoheader=$dots$top_autoheader ;;
94 *) autoconf=$top_autoconf; autoheader=$top_autoheader ;;
95 esac
97 case "$AC_MACRODIR" in
98 /*) macrodir_opt="--macrodir=$AC_MACRODIR" ;;
99 *) macrodir_opt="--macrodir=$dots$AC_MACRODIR" ;;
100 esac
102 case "$localdir" in
103 "") localdir_opt=
104 aclocal=aclocal.m4 ;;
105 /*) localdir_opt="--localdir=$localdir"
106 aclocal=$localdir/aclocal.m4 ;;
107 *) localdir_opt="--localdir=$dots$localdir"
108 aclocal=$dots$localdir/aclocal.m4 ;;
109 esac
111 test ! -f $aclocal && aclocal=
113 if test $force = no && test -f configure &&
114 ls -lt configure configure.in $aclocal | sed 1q |
115 grep 'configure$' > /dev/null
116 then
118 else
119 test $verbose = yes && echo running autoconf in $dir
120 $autoconf $macrodir_opt $localdir_opt
123 if grep AC_CONFIG_HEADER configure.in >/dev/null; then
124 template=`sed -n '/AC_CONFIG_HEADER/{
125 s%[^#]*AC_CONFIG_HEADER(\([^)]*\).*%\1%
126 t here
127 : here
128 s%.*:%%
129 t colon
130 s%$%.in%
131 : colon
134 }' configure.in`
135 if test ! -f $template || grep autoheader $template >/dev/null; then
136 if test $force = no && test -f $template &&
137 ls -lt $template configure.in $aclocal | sed 1q |
138 grep "$template$" > /dev/null
139 then
141 else
142 test $verbose = yes && echo running autoheader in $dir
143 $autoheader $macrodir_opt $localdir_opt
148 done