2 # autoreconf - remake all Autoconf configure scripts in a directory tree
3 # Copyright (C) 1994, 99, 2000 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 me=`echo "$0" | sed -e 's,.*/,,'`
23 Usage: $0 [OPTION] ... [TEMPLATE-FILE]
25 Run \`autoconf' (and \`autoheader', \`aclocal' and \`automake', where
26 appropriate) repeatedly to remake the Autoconf \`configure' scripts
27 and configuration header templates in the directory tree rooted at the
28 current directory. By default, it only remakes those files that are
29 older than their predecessors. If you install a new version of
30 Autoconf, running \`autoreconf' remakes all of the files by giving it
31 the \`--force' option.
33 -h, --help print this help, then exit
34 -V, --version print version number, then exit
35 -v, --verbose verbosely report processing
36 -m, --macrodir=DIR directory storing macro files
37 -l, --localdir=DIR directory storing \`aclocal.m4' and \`acconfig.h'
38 -f, --force consider every files are obsolete
40 The following options are passed to \`automake':
41 --cygnus assume program is part of Cygnus-style tree
42 --foreign set strictness to foreign
43 --gnits set strictness to gnits
44 --gnu set strictness to gnu
45 -i, --include-deps include generated dependencies in Makefile.in
47 Report bugs to <bug-autoconf@gnu.org>."
50 autoreconf (GNU @PACKAGE@) @VERSION@
51 Written by David J. MacKenzie.
53 Copyright (C) 1994, 99, 2000 Free Software Foundation, Inc.
54 This is free software; see the source for copying conditions. There is NO
55 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
58 Try \`$me --help' for more information."
66 test -z "$AC_MACRODIR" && AC_MACRODIR=@datadir@
68 while test $# -gt 0; do
70 --version | --vers* | -V )
71 echo "$version" ; exit 0 ;;
73 echo "$usage"; exit 0 ;;
75 --verbose | --verb* | -v )
79 --localdir=* | --l*=* )
80 localdir=`echo "$1" | sed -e 's/^[^=]*=//'`
82 --localdir | --l* | -l )
84 test $# = 0 && { echo "$help" >&2; exit 1; }
88 --macrodir=* | --m*=* )
89 AC_MACRODIR=`echo "$1" | sed -e 's/^[^=]*=//'`
91 --macrodir | --m* | -m )
93 test $# = 0 && { echo "$help" >&2; exit 1; }
99 --cygnus | --foreign | --gnits | --gnu)
100 automake_mode=$1; shift ;;
102 automake_deps=$1; shift ;;
104 -- ) # Stop option processing.
108 echo "$me: invalid option $1"
116 # Find the input file.
117 if test $# -ne 0; then
119 echo "$me: invalid number of arguments"
124 # The paths to the autoconf and autoheader scripts, at the top of the tree.
125 top_autoconf=`echo "$0" | sed s%autoreconf%autoconf%`
126 top_autoheader=`echo "$0" | sed s%autoreconf%autoheader%`
128 # Make a list of directories to process.
129 # The xargs grep filters out Cygnus configure.in files.
130 find . -name configure.in -print |
131 xargs grep -l AC_OUTPUT |
132 sed 's%/configure\.in$%%; s%^./%%' |
139 *) # A "../" for each directory in /$dir.
140 dots=`echo /$dir|sed 's%/[^/]*%../%g'` ;;
144 /*) autoconf=$top_autoconf; autoheader=$top_autoheader ;;
145 */*) autoconf=$dots$top_autoconf; autoheader=$dots$top_autoheader ;;
146 *) autoconf=$top_autoconf; autoheader=$top_autoheader ;;
149 case "$AC_MACRODIR" in
150 /*) macrodir_opt="--macrodir=$AC_MACRODIR" ;;
151 *) macrodir_opt="--macrodir=$dots$AC_MACRODIR" ;;
156 aclocal_m4=aclocal.m4 ;;
157 /*) localdir_opt="--localdir=$localdir"
158 aclocal_m4=$localdir/aclocal.m4 ;;
159 *) localdir_opt="--localdir=$dots$localdir"
160 aclocal_m4=$dots$localdir/aclocal.m4 ;;
163 # Regenerate aclocal.m4 if necessary.
165 aclocal_dir=`echo $aclocal_m4 | sed 's,/*[^/]*$,,;s,^$,.,'`
166 if test -f "$aclocal_m4" &&
167 grep 'generated automatically by aclocal' $aclocal_m4 > /dev/null
171 if test -f "$aclocal_dir/acinclude.m4"
176 if test $run_aclocal = yes
178 # If there are flags for aclocal, use them. Makefile.am and Makefile
180 aclocal_flags=`sed -ne '\
181 /^ACLOCAL_[A-Z_]*FLAGS/{
185 }' Makefile.in 2>/dev/null`
186 if test $force = no &&
187 ls -lt configure.in $aclocal_m4 $aclocal_dir/acinclude.m4 2>/dev/null|
189 grep 'aclocal\.m4$' > /dev/null
193 if test x"$aclocal_dir" != x.
195 aclocal_flags="$aclocal_flags -I $aclocal_dir"
197 $verbose "running aclocal $aclocal_flags in $dir, creating $aclocal_m4"
198 aclocal $aclocal_flags --output=$aclocal_m4
202 # Re-run automake if required. Assumes that there is a Makefile.am
203 # in the topmost directory.
204 if test -f Makefile.am
207 test $force = no && amforce=--no-force
208 $verbose running automake $amforce in $dir
209 automake $amforce $automake_mode $automake_deps
212 test ! -f $aclocal_m4 && aclocal_m4=
214 if test $force = no && test -f configure &&
215 ls -lt configure configure.in $aclocal_m4 | sed 1q |
216 grep 'configure$' > /dev/null
220 $verbose "running autoconf in $dir"
221 $autoconf $macrodir_opt $localdir_opt
224 if grep '^[ ]*A[CM]_CONFIG_HEADER' configure.in >/dev/null; then
225 templates=`sed -n '/A[CM]_CONFIG_HEADER/ {
226 s%[^#]*A[CM]_CONFIG_HEADER[ ]*(\([^)]*\).*%\1%
230 tcount=`set -- $templates; echo $#`
231 template=`set -- $templates; echo $1 | sed '
238 stamp=`echo $template | sed 's,/*[^/]*$,,;s,^$,.,'`/stamp-h`test "$tcount" -gt 1 && echo "$tcount"`.in
239 if test ! -f "$template" || grep autoheader "$template" >/dev/null; then
240 if test $force = no && test -f $template &&
241 ls -lt $template configure.in $aclocal_m4 $stamp 2>/dev/null \
242 `echo $localdir_opt | sed -e 's/--localdir=//' \
243 -e '/./ s%$%/%'`acconfig.h |
244 sed 1q | egrep "$template$|$stamp$" > /dev/null
248 $verbose "running autoheader in $dir"
249 $autoheader $macrodir_opt $localdir_opt &&
250 $verbose "touching $stamp" &&