2 # autoreconf - remake all Autoconf configure scripts in a directory tree
3 # Copyright 1994, 1999, 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.
34 -h, --help print this help, then exit
35 -V, --version print version number, then exit
36 -v, --verbose verbosely report processing
37 -d, --debug don't remove temporary files
38 -f, --force consider every files are obsolete
39 -i, --install copy missing auxiliary files
40 -s, --symlink instead of copying, install symbolic links
42 The option \`--install' is similar to the option \`--add-missing' in
46 -A, --autoconf-dir=ACDIR Autoconf's macro files location (rarely needed)
47 -l, --localdir=DIR location of \`aclocal.m4' and \`acconfig.h'
48 -M, --m4dir=M4DIR this package's Autoconf extensions
50 Unless specified, heuristics try to compute \`M4DIR' from the \`Makefile.am',
51 or defaults to \`m4' if it exists.
53 The following options are passed to \`automake':
54 --cygnus assume program is part of Cygnus-style tree
55 --foreign set strictness to foreign
56 --gnits set strictness to gnits
57 --gnu set strictness to gnu
58 --include-deps include generated dependencies in Makefile.in
60 The environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, and ACLOCAL
63 Report bugs to <bug-autoconf@gnu.org>."
66 autoreconf (@PACKAGE_NAME@) @VERSION@
67 Written by David J. MacKenzie.
69 Copyright 1994, 1999, 2000 Free Software Foundation, Inc.
70 This is free software; see the source for copying conditions. There is NO
71 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
74 Try \`$me --help' for more information."
77 echo \"$me: option \\\`\$1' requires an argument\" >&2
82 # Only set these to C if already set. These must not be set unconditionally
83 # because not all systems understand e.g. LANG=C (notably SCO).
84 # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
85 # Non-C LC_CTYPE values break the ctype check.
86 if test "${LANG+set}" = set; then LANG
=C
; export LANG
; fi
87 if test "${LC_ALL+set}" = set; then LC_ALL
=C
; export LC_ALL
; fi
88 if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES
=C
; export LC_MESSAGES
; fi
89 if test "${LC_CTYPE+set}" = set; then LC_CTYPE
=C
; export LC_CTYPE
; fi
92 : ${autoconf_dir=${AC_MACRODIR=@datadir@}}
94 dir
=`echo "$0" | sed -e 's,[^\\/]*$,,'`
96 # --install -- as --add-missing in other tools.
99 # m4dir -- local Autoconf extensions. Typically `m4'.
102 # symlink -- when --install, use symlinks instead.
106 # Looking for autoconf.
107 # We test "$dir/autoconf" in case we are in the build tree, in which case
108 # the names are not transformed yet.
109 for autoconf
in "$AUTOCONF" \
110 "$dir/@autoconf-name@" \
112 "@bindir@/@autoconf-name@"; do
113 test -f "$autoconf" && break
116 # Looking for autoheader.
117 for autoheader
in "$AUTOHEADER" \
118 "$dir/@autoheader-name@" \
120 "@bindir@/@autoheader-name@"; do
121 test -f "$autoheader" && break
123 # Looking for automake.
124 : ${automake=${AUTOMAKE=automake}}
125 # Looking for aclocal.
126 : ${aclocal=${ACLOCAL=aclocal}}
128 # Parse command line.
129 while test $# -gt 0; do
130 optarg
=`expr "x$1" : 'x--[^=]*=\(.*\)' \| \
134 echo "$version" ; exit 0 ;;
136 echo "$usage"; exit 0 ;;
144 --localdir=* |
-l?
* )
148 test $# = 1 && eval "$exit_missing_arg"
153 --autoconf-dir=* |
-A?
* )
156 --autoconf-dir |
-A )
157 test $# = 1 && eval "$exit_missing_arg"
161 --macrodir=* |
-m?
* )
162 echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
166 echo "$me: warning: --macrodir is obsolete, use --autoconf-dir" >&2
167 test $# = 1 && eval "$exit_missing_arg"
176 test $# = 1 && eval "$exit_missing_arg"
189 # Options of Automake.
190 --cygnus |
--foreign |
--gnits |
--gnu |
--include-deps |
-i )
191 automake
="$automake $1"; shift ;;
193 -- ) # Stop option processing.
197 echo "$me: invalid option $1"
205 # Find the input file.
206 if test $# -ne 0; then
208 echo "$me: invalid number of arguments"
213 # If verbose, say what you are going to use.
214 if test $verbose = echo; then
215 $autoconf --version |
216 sed "s,.*)\(.*\)$,$me: using autoconf\1: $autoconf,;1q" >&2
217 $autoheader --version |
218 sed "s,.*)\(.*\)$,$me: using autoheader\1: $autoheader,;1q" >&2
219 $automake --version |
220 sed "s,.*)\(.*\)$,$me: using automake\1: $automake,;1q" >&2
222 sed "s,.*)\(.*\)$,$me: using aclocal\1: $aclocal,;1q" >&2
225 # Dispatch autoreconf's option to the tools.
227 autoconf
="$autoconf -l $localdir"
228 autoheader
="$autoheader -l $localdir"
230 $force || automake
="$automake --no-force"
232 autoconf
="$autoconf `$verbose --verbose`"
233 autoheader
="$autoheader `$verbose --verbose`"
234 automake
="$automake `$verbose --verbose`"
235 aclocal
="$aclocal `$verbose --verbose`"
239 autoconf
="$autoconf --debug"
240 autoheader
="$autoheader --debug"
244 # --install and --symlink
246 automake
="$automake --add-missing `$symlink || echo --copy`"
249 # Trap on 0 to stop playing with `rm'.
252 trap 'status=$?; rm -rf $tmp && exit $status' 0
253 trap '(exit $?); exit' 1 2 13 15
256 # Create a (secure) tmp directory for tmp files.
259 tmp
=`(umask 077 && mktemp -d -q "$TMPDIR/arXXXXXX") 2>/dev/null` &&
260 test -n "$tmp" && test -d "$tmp"
264 (umask 077 && mkdir
$tmp)
267 echo "$me: cannot create a temporary directory in $TMPDIR" >&2
271 # When debugging, it is convenient that all the related temporary
272 # files be at the same place.
276 # alflags.sed -- Fetch the aclocal flags.
277 cat >$tmp/alflags.
sed <<EOF
279 /^ACLOCAL_[A-Z_]*FLAGS/{
287 # Exit 0 if the first argument is not the most recent of all or is missing.
288 cat >$tmp/update.sh
<<\EOF
289 test -f "$1" ||
{ :; exit; }
290 test x
`ls -1dt "$@" 2>/dev/null | sed 1q` != x
"$1"
292 update
="@SHELL@ $tmp/update.sh"
295 # ----------------------- #
296 # Real work starts here. #
297 # ----------------------- #
299 # Make a list of directories to process.
300 # The xargs grep filters out Cygnus configure.in files.
301 find .
'(' -name configure.ac
-o -name configure.
in ')' -print |
302 xargs grep -l AC_INIT |
303 sed 's,/configure\.ac$,,;s,/configure\.in$,,;s,^./,,' |
309 # ----------------- #
311 # ----------------- #
313 # uses_aclocal -- is this package using aclocal?
315 grep 'generated .* by aclocal' $localdir/aclocal.
m4 >/dev
/null
2>&1 &&
317 test -f "$localdir/aclocal.m4" ||
321 $update $localdir/aclocal.
m4 $localdir/acinclude.
m4; } then
322 # If there are flags for aclocal in Makefile.am, use them.
323 aclocal_flags
=`sed -f $tmp/alflags.sed Makefile.am 2>/dev/null`
325 # If m4dir no specified and these flags do not specify the
326 # location of the local Autoconf extensions, default to `m4'.
327 case $m4dir,$aclocal_flags in
328 ,*"-I "* ) ;; # Not overriden and specified.
329 ,*) # Not specified at all.
330 test -d "m4" && aclocal_flags
="$aclocal_flags -I m4";;
331 * ) # Specified by the user.
332 aclocal_flags
="$aclocal_flags -I $m4dir";;
335 $verbose $me: running
$aclocal $aclocal_flags --output=$localdir/aclocal.
m4 in $dir >&2
336 $aclocal $aclocal_flags --output=$localdir/aclocal.
m4
340 # ------------------ #
341 # Running automake. #
342 # ------------------ #
344 # Assumes that there is a Makefile.am in the topmost directory.
346 test -f "Makefile.am" &&
348 # We should always run automake, and let it decide whether it shall
349 # update the file or not. In fact, the effect of `$force' is already
350 # included in `$automake' via `--no-force'.
351 if $uses_automake; then
352 $verbose $me: running
$automake in $dir >&2
357 # ------------------ #
358 # Running autoconf. #
359 # ------------------ #
362 $update configure configure.ac
$localdir/aclocal.
m4 ||
363 $update configure configure.
in $localdir/aclocal.
m4; then
364 $verbose $me: running
$autoconf in $dir >&2
369 # -------------------- #
370 # Running autoheader. #
371 # -------------------- #
373 # templates -- arguments of AC_CONFIG_HEADERS.
374 $verbose $me: running
$autoconf -t 'AC_CONFIG_HEADERS:$1' >&2
375 templates
=`$autoconf -t 'AC_CONFIG_HEADERS:$1'`
376 if test -n "$templates"; then
377 tcount
=`set -- $templates; echo $#`
378 template
=`set -- $templates; echo $1 | sed '
385 template_dir
=`echo $template | sed -e 's,[\\/]*[^\\/]*$,,;s,^$,.,'`
386 stamp_num
=`test "$tcount" -gt 1 && echo "$tcount"`
387 stamp
=$template_dir/stamp-h
$stamp_num.
in
388 # If config.hin exists, don't override it unless it was really
389 # created by autoheader (users are allowed to write them by hand!).
390 uses_autoheader
=false
391 grep autoheader
"$template" >/dev
/null
2>&1 &&
393 test -f "$template" ||
395 if $uses_autoheader &&
398 configure.ac
$localdir/aclocal.
m4 $localdir/acconfig.h ||
400 configure.
in $localdir/aclocal.
m4 $localdir/acconfig.h ||
402 configure.ac
$localdir/aclocal.
m4 $localdir/acconfig.h ||
404 configure.
in $localdir/aclocal.
m4 $localdir/acconfig.h
; } then
405 $verbose $me: running
$autoheader in $dir >&2
407 $verbose "touching $stamp" >&2 &&