3 # autoreconf - remake all Autoconf configure scripts in a directory tree
4 # Copyright 1994, 1999, 2000 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 me=`echo "$0" | sed -e 's,.*[\\/],,'`
24 Usage: $0 [OPTION] ... [TEMPLATE-FILE]
26 Run \`autoconf' (and \`autoheader', \`aclocal' and \`automake', where
27 appropriate) repeatedly to remake the Autoconf \`configure' scripts
28 and configuration header templates in the directory tree rooted at the
29 current directory. By default, it only remakes those files that are
30 older than their predecessors. If you install a new version of
31 Autoconf, running \`autoreconf' remakes all of the files by giving it
32 the \`--force' option.
35 -h, --help print this help, then exit
36 -V, --version print version number, then exit
37 -v, --verbose verbosely report processing
38 -d, --debug don't remove temporary files
39 -f, --force consider every files are obsolete
40 -i, --install copy missing auxiliary files
41 -s, --symlink instead of copying, install symbolic links
43 The option \`--install' is similar to the option \`--add-missing' in
47 -A, --autoconf-dir=ACDIR Autoconf's macro files location (rarely needed)
48 -l, --localdir=DIR location of \`aclocal.m4' and \`acconfig.h'
49 -M, --m4dir=M4DIR this package's Autoconf extensions
51 Unless specified, heuristics try to compute \`M4DIR' from the \`Makefile.am',
52 or defaults to \`m4' if it exists.
54 The following options are passed to \`automake':
55 --cygnus assume program is part of Cygnus-style tree
56 --foreign set strictness to foreign
57 --gnits set strictness to gnits
58 --gnu set strictness to gnu
59 --include-deps include generated dependencies in Makefile.in
61 The environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, and ACLOCAL
64 Report bugs to <bug-autoconf@gnu.org>."
67 autoreconf (@PACKAGE_NAME@) @VERSION@
68 Written by David J. MacKenzie.
70 Copyright 1994, 1999, 2000 Free Software Foundation, Inc.
71 This is free software; see the source for copying conditions. There is NO
72 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
75 Try \`$me --help' for more information."
78 echo \"$me: option \\\`\$1' requires an argument\" >&2
83 # Only set these to C if already set. These must not be set unconditionally
84 # because not all systems understand e.g. LANG=C (notably SCO).
85 # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
86 # Non-C LC_CTYPE values break the ctype check.
87 if test "${LANG+set}" = set; then LANG=C; export LANG; fi
88 if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
89 if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
90 if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
93 : ${autoconf_dir=${AC_MACRODIR=@datadir@}}
95 dir=`echo "$0" | sed -e 's,[^\\/]*$,,'`
97 # --install -- as --add-missing in other tools.
100 # m4dir -- local Autoconf extensions. Typically `m4'.
103 # symlink -- when --install, use symlinks instead.
107 # Looking for autoconf.
108 # We test "$dir/autoconf" in case we are in the build tree, in which case
109 # the names are not transformed yet.
110 for autoconf in "$AUTOCONF" \
111 "$dir/@autoconf-name@" \
113 "@bindir@/@autoconf-name@"; do
114 test -f "$autoconf" && break
117 # Looking for autoheader.
118 for autoheader in "$AUTOHEADER" \
119 "$dir/@autoheader-name@" \
121 "@bindir@/@autoheader-name@"; do
122 test -f "$autoheader" && break
124 # Looking for automake.
125 : ${automake=${AUTOMAKE=automake}}
126 # Looking for aclocal.
127 : ${aclocal=${ACLOCAL=aclocal}}
129 # Parse command line.
130 while test $# -gt 0; do
131 optarg=`expr "x$1" : 'x--[^=]*=\(.*\)' \| \
135 echo "$version" ; exit 0 ;;
137 echo "$usage"; exit 0 ;;
145 --localdir=* | -l?* )
149 test $# = 1 && eval "$exit_missing_arg"
154 --autoconf-dir=* | -A?* )
157 --autoconf-dir | -A )
158 test $# = 1 && eval "$exit_missing_arg"
162 --macrodir=* | -m?* )
163 echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
167 echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
168 test $# = 1 && eval "$exit_missing_arg"
177 test $# = 1 && eval "$exit_missing_arg"
190 # Options of Automake.
191 --cygnus | --foreign | --gnits | --gnu | --include-deps | -i )
192 automake="$automake $1"; shift ;;
194 -- ) # Stop option processing.
198 echo "$me: invalid option $1"
206 # Find the input file.
207 if test $# -ne 0; then
209 echo "$me: invalid number of arguments"
214 # If verbose, say what you are going to use.
215 if test $verbose = echo; then
216 $autoconf --version |
217 sed "s,.*)\(.*\)$,$me: using autoconf\1: $autoconf,;1q" >&2
218 $autoheader --version |
219 sed "s,.*)\(.*\)$,$me: using autoheader\1: $autoheader,;1q" >&2
220 $automake --version |
221 sed "s,.*)\(.*\)$,$me: using automake\1: $automake,;1q" >&2
223 sed "s,.*)\(.*\)$,$me: using aclocal\1: $aclocal,;1q" >&2
226 # Dispatch autoreconf's option to the tools.
228 autoconf="$autoconf -l $localdir"
229 autoheader="$autoheader -l $localdir"
231 $force || automake="$automake --no-force"
233 autoconf="$autoconf `$verbose --verbose`"
234 autoheader="$autoheader `$verbose --verbose`"
235 automake="$automake `$verbose --verbose`"
236 aclocal="$aclocal `$verbose --verbose`"
240 autoconf="$autoconf --debug"
241 autoheader="$autoheader --debug"
245 # --install and --symlink
247 automake="$automake --add-missing `$symlink || echo --copy`"
250 # Trap on 0 to stop playing with `rm'.
253 trap 'status=$?; rm -rf $tmp && exit $status' 0
254 trap '(exit 1); exit 1' 1 2 13 15
257 # Create a (secure) tmp directory for tmp files.
260 tmp=`(umask 077 && mktemp -d -q "$TMPDIR/arXXXXXX") 2>/dev/null` &&
261 test -n "$tmp" && test -d "$tmp"
265 (umask 077 && mkdir $tmp)
268 echo "$me: cannot create a temporary directory in $TMPDIR" >&2
272 # When debugging, it is convenient that all the related temporary
273 # files be at the same place.
277 # alflags.sed -- Fetch the aclocal flags.
278 cat >$tmp/alflags.sed <<EOF
280 /^ACLOCAL_[A-Z_]*FLAGS/{
288 # Exit 0 if the first argument is not the most recent of all or is missing.
289 cat >$tmp/update.sh <<\EOF
290 test -f "$1" || { :; exit; }
291 test x`ls -1dt "$@" 2>/dev/null | sed 1q` != x"$1"
293 update="@SHELL@ $tmp/update.sh"
296 # ----------------------- #
297 # Real work starts here. #
298 # ----------------------- #
300 # Make a list of directories to process.
301 # The xargs grep filters out Cygnus configure.in files.
302 find . '(' -name configure.ac -o -name configure.in ')' -print |
303 xargs grep -l AC_INIT |
304 sed 's,/configure\.ac$,,;s,/configure\.in$,,;s,^./,,' |
310 # ----------------- #
312 # ----------------- #
314 # uses_aclocal -- is this package using aclocal?
316 grep 'generated .* by aclocal' $localdir/aclocal.m4 >/dev/null 2>&1 &&
318 test -f "$localdir/aclocal.m4" ||
322 $update $localdir/aclocal.m4 $localdir/acinclude.m4; } then
323 # If there are flags for aclocal in Makefile.am, use them.
324 aclocal_flags=`sed -f $tmp/alflags.sed Makefile.am 2>/dev/null`
326 # If m4dir no specified and these flags do not specify the
327 # location of the local Autoconf extensions, default to `m4'.
328 case $m4dir,$aclocal_flags in
329 ,*"-I "* ) ;; # Not overriden and specified.
330 ,*) # Not specified at all.
331 test -d "m4" && aclocal_flags="$aclocal_flags -I m4";;
332 * ) # Specified by the user.
333 aclocal_flags="$aclocal_flags -I $m4dir";;
336 $verbose $me: running $aclocal $aclocal_flags --output=$localdir/aclocal.m4 in $dir >&2
337 $aclocal $aclocal_flags --output=$localdir/aclocal.m4
341 # ------------------ #
342 # Running automake. #
343 # ------------------ #
345 # Assumes that there is a Makefile.am in the topmost directory.
347 test -f "Makefile.am" &&
349 # We should always run automake, and let it decide whether it shall
350 # update the file or not. In fact, the effect of `$force' is already
351 # included in `$automake' via `--no-force'.
352 if $uses_automake; then
353 $verbose $me: running $automake in $dir >&2
358 # ------------------ #
359 # Running autoconf. #
360 # ------------------ #
363 $update configure configure.ac $localdir/aclocal.m4 ||
364 $update configure configure.in $localdir/aclocal.m4; then
365 $verbose $me: running $autoconf in $dir >&2
370 # -------------------- #
371 # Running autoheader. #
372 # -------------------- #
374 # templates -- arguments of AC_CONFIG_HEADERS.
375 $verbose $me: running $autoconf -t 'AC_CONFIG_HEADERS:$1' >&2
376 templates=`$autoconf -t 'AC_CONFIG_HEADERS:$1'`
377 if test -n "$templates"; then
378 tcount=`set -- $templates; echo $#`
379 template=`set -- $templates; echo $1 | sed '
386 template_dir=`echo $template | sed -e 's,[\\/]*[^\\/]*$,,;s,^$,.,'`
387 stamp_num=`test "$tcount" -gt 1 && echo "$tcount"`
388 stamp=$template_dir/stamp-h$stamp_num.in
389 # If config.hin exists, don't override it unless it was really
390 # created by autoheader (users are allowed to write them by hand!).
391 uses_autoheader=false
392 grep autoheader "$template" >/dev/null 2>&1 &&
394 test -f "$template" ||
396 if $uses_autoheader &&
399 configure.ac $localdir/aclocal.m4 $localdir/acconfig.h ||
401 configure.in $localdir/aclocal.m4 $localdir/acconfig.h ||
403 configure.ac $localdir/aclocal.m4 $localdir/acconfig.h ||
405 configure.in $localdir/aclocal.m4 $localdir/acconfig.h; } then
406 $verbose $me: running $autoheader in $dir >&2
408 $verbose "touching $stamp" >&2 &&