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)
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
21 Usage: autoreconf [-f] [-h] [--help] [-m dir] [--macrodir=dir]
22 [-l dir] [--localdir=dir] [--force] [--verbose] [--version]
23 [--cygnus] [--foreign] [--gnits] [--gnu] [-i] [--include-deps]"
32 test -z "$AC_MACRODIR" && AC_MACRODIR=@datadir@
34 while test $# -gt 0; do
37 echo "$usage"; exit 0 ;;
38 --localdir=* | --l*=* )
39 localdir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
41 -l | --localdir | --l*)
43 test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
46 --macrodir=* | --m*=* )
47 AC_MACRODIR="`echo \"$1\" | sed -e 's/^[^=]*=//'`"
49 -m | --macrodir | --m*)
51 test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
59 show_version=yes; shift ;;
60 --cygnus | --foreign | --gnits | --gnu)
61 automake_mode=$1; shift ;;
63 automake_deps=$1; shift ;;
64 --) # Stop option processing.
66 -*) echo "$usage" 1>&2; exit 1 ;;
71 if test $show_version = yes; then
72 version=`sed -n 's/define.AC_ACVERSION.[ ]*\([0-9.]*\).*/\1/p' \
73 $AC_MACRODIR/acgeneral.m4`
74 echo "Autoconf version $version"
78 if test $# -ne 0; then
79 echo "$usage" 1>&2; exit 1
82 # The paths to the autoconf and autoheader scripts, at the top of the tree.
83 top_autoconf=`echo $0|sed s%autoreconf%autoconf%`
84 top_autoheader=`echo $0|sed s%autoreconf%autoheader%`
86 # Make a list of directories to process.
87 # The xargs grep filters out Cygnus configure.in files.
88 find . -name configure.in -print |
89 xargs grep -l AC_OUTPUT |
90 sed 's%/configure\.in$%%; s%^./%%' |
97 *) # A "../" for each directory in /$dir.
98 dots=`echo /$dir|sed 's%/[^/]*%../%g'` ;;
102 /*) autoconf=$top_autoconf; autoheader=$top_autoheader ;;
103 */*) autoconf=$dots$top_autoconf; autoheader=$dots$top_autoheader ;;
104 *) autoconf=$top_autoconf; autoheader=$top_autoheader ;;
107 case "$AC_MACRODIR" in
108 /*) macrodir_opt="--macrodir=$AC_MACRODIR" ;;
109 *) macrodir_opt="--macrodir=$dots$AC_MACRODIR" ;;
114 aclocal=aclocal.m4 ;;
115 /*) localdir_opt="--localdir=$localdir"
116 aclocal=$localdir/aclocal.m4 ;;
117 *) localdir_opt="--localdir=$dots$localdir"
118 aclocal=$dots$localdir/aclocal.m4 ;;
121 # Regenerate aclocal.m4 if necessary. FIXME: if aclocal searches
122 # nonstandard directories, we need to deal with that here. The
123 # easiest way is to move this info into configure.in.
125 if test -f "$aclocal" &&
126 grep 'generated automatically by aclocal' $aclocal > /dev/null
130 if test -f `echo $aclocal | sed 's,/*[^/]*$,,;s,^$,.,'`/acinclude.m4
135 if test $run_aclocal = yes
137 if test $force = no &&
138 ls -lt configure.in $aclocal \
139 `echo $aclocal | sed 's,/*[^/]*$,,;s,^$,.,'`/acinclude.m4 |
141 grep 'aclocal\.m4$' > /dev/null
145 test $verbose = yes && echo running aclocal in $dir, creating $aclocal
146 aclocal --output=$aclocal -I `echo $aclocal | sed 's,/*[^/]*$,,;s,^$,.,'`
150 # Re-run automake if required. Assumes that there is a Makefile.am
151 # in the topmost directory.
152 if test -f Makefile.am
155 test $force = no && amforce=--no-force
156 test $verbose = yes && echo running automake`test x"$amforce" = x || echo " ($amforce)"` in $dir
157 automake $amforce $automake_mode $automake_deps
160 test ! -f $aclocal && aclocal=
162 if test $force = no && test -f configure &&
163 ls -lt configure configure.in $aclocal | sed 1q |
164 grep 'configure$' > /dev/null
168 test $verbose = yes && echo running autoconf in $dir
169 $autoconf $macrodir_opt $localdir_opt
172 if grep 'A[CM]_CONFIG_HEADER' configure.in >/dev/null; then
173 templates=`sed -n '/A[CM]_CONFIG_HEADER/ {
174 s%[^#]*A[CM]_CONFIG_HEADER[ ]*(\([^)]*\).*%\1%
178 tcount=`set -- $templates; echo $#`
179 template=`set -- $templates; echo $1 | sed '
186 stamp=`echo $template | sed 's,/*[^/]*$,,;s,^$,.,'`/stamp-h`test "$tcount" -gt 1 && echo "$tcount"`.in
187 if test ! -f "$template" || grep autoheader "$template" >/dev/null; then
188 if test $force = no && test -f $template &&
189 ls -lt $template configure.in $aclocal $stamp 2>/dev/null \
190 `echo $localdir_opt | sed -e 's/--localdir=//' \
191 -e '/./ s%$%/%'`acconfig.h |
192 sed 1q | egrep "$template$|$stamp$" > /dev/null
196 test $verbose = yes && echo running autoheader in $dir
197 $autoheader $macrodir_opt $localdir_opt &&
198 { test $verbose != yes || echo touching $stamp; } &&