use shell functions to speed up autotest and produce slimmer testsuites
[autoconf.git] / bin / autoconf.as
blob17c6150d844f14a3e9ca267626d43f7a50669346
1 AS_INIT[]dnl -*- shell-script -*-
2 # autoconf -- create `configure' using m4 macros
4 # Copyright (C) 1992, 1993, 1994, 1996, 1999, 2000, 2001, 2002, 2003,
5 # 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 usage=["\
21 Usage: $0 [OPTION] ... [TEMPLATE-FILE]
23 Generate a configuration script from a TEMPLATE-FILE if given, or
24 \`configure.ac' if present, or else \`configure.in'. Output is sent
25 to the standard output if TEMPLATE-FILE is given, else into
26 \`configure'.
28 Operation modes:
29 -h, --help print this help, then exit
30 -V, --version print version number, then exit
31 -v, --verbose verbosely report processing
32 -d, --debug don't remove temporary files
33 -f, --force consider all files obsolete
34 -o, --output=FILE save output in FILE (stdout is the default)
35 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [syntax]
37 Warning categories include:
38 \`cross' cross compilation issues
39 \`obsolete' obsolete constructs
40 \`syntax' dubious syntactic constructs
41 \`all' all the warnings
42 \`no-CATEGORY' turn off the warnings on CATEGORY
43 \`none' turn off all the warnings
44 \`error' warnings are error
46 The environment variables \`M4' and \`WARNINGS' are honored.
48 Library directories:
49 -B, --prepend-include=DIR prepend directory DIR to search path
50 -I, --include=DIR append directory DIR to search path
52 Tracing:
53 -t, --trace=MACRO report the list of calls to MACRO
54 -i, --initialization also trace Autoconf's initialization process
56 In tracing mode, no configuration script is created.
58 Report bugs to <bug-autoconf@gnu.org>."]
60 version=["\
61 autoconf (@PACKAGE_NAME@) @VERSION@
62 Copyright (C) @RELEASE_YEAR@ Free Software Foundation, Inc.
63 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
64 This is free software: you are free to change and redistribute it.
65 There is NO WARRANTY, to the extent permitted by law.
67 Written by David J. MacKenzie and Akim Demaille."]
69 help="\
70 Try \`$as_me --help' for more information."
72 exit_missing_arg='
73 AS_ECHO(["$as_me: option \`$[1]'\'' requires an argument"]) >&2
74 AS_ECHO(["$help"]) >&2
75 exit 1
78 # Variables.
79 : ${AUTOM4TE='@bindir@/@autom4te-name@'}
80 autom4te_options=
81 outfile=
82 verbose=false
84 # Parse command line.
85 while test $# -gt 0 ; do
86 option=[`expr "x$1" : 'x\(--[^=]*\)' \| \
87 "x$1" : 'x\(-.\)'`]
88 optarg=[`expr "x$1" : 'x--[^=]*=\(.*\)' \| \
89 "x$1" : 'x-.\(.*\)'`]
90 case $1 in
91 --version | -V )
92 echo "$version" ; exit ;;
93 --help | -h )
94 AS_ECHO(["$usage"]); exit ;;
96 --verbose | -v )
97 verbose=:
98 autom4te_options="$autom4te_options $1"; shift ;;
100 # Arguments passed as is to autom4te.
101 --debug | -d | \
102 --force | -f | \
103 --include=* | -I?* | \
104 --prepend-include=* | -B?* | \
105 --warnings=* | -W?* )
106 autom4te_options="$autom4te_options '$1'"; shift ;;
108 # Options with separated arg passed as is to autom4te.
109 --include | -I | \
110 --prepend-include | -B | \
111 --warnings | -W )
112 test $# = 1 && eval "$exit_missing_arg"
113 autom4te_options="$autom4te_options $option '$2'"
114 shift; shift ;;
116 --trace=* | -t?* )
117 traces="$traces --trace='"`AS_ECHO(["$optarg"]) | sed "s/'/'\\\\\\\\''/g"`"'"
118 shift ;;
119 --trace | -t )
120 test $# = 1 && eval "$exit_missing_arg"
121 traces="$traces --trace='"`AS_ECHO(["$[2]"]) | sed "s/'/'\\\\\\\\''/g"`"'"
122 shift; shift ;;
123 --initialization | -i )
124 autom4te_options="$autom4te_options --melt"
125 shift;;
127 --output=* | -o?* )
128 outfile=$optarg
129 shift ;;
130 --output | -o )
131 test $# = 1 && eval "$exit_missing_arg"
132 outfile=$2
133 shift; shift ;;
135 -- ) # Stop option processing
136 shift; break ;;
137 - ) # Use stdin as input.
138 break ;;
139 -* )
140 exec >&2
141 AS_ECHO(["$as_me: invalid option $[1]"])
142 AS_ECHO(["$help"])
143 exit 1 ;;
145 break ;;
146 esac
147 done
149 # Find the input file.
150 case $# in
152 if test -f configure.ac; then
153 if test -f configure.in; then
154 AS_ECHO(["$as_me: warning: both \`configure.ac' and \`configure.in' are present."]) >&2
155 AS_ECHO(["$as_me: warning: proceeding with \`configure.ac'."]) >&2
157 infile=configure.ac
158 elif test -f configure.in; then
159 infile=configure.in
160 else
161 AS_ECHO(["$as_me: no input file"]) >&2
162 exit 1
164 test -z "$traces" && test -z "$outfile" && outfile=configure;;
166 infile=$1 ;;
167 *) exec >&2
168 AS_ECHO(["$as_me: invalid number of arguments."])
169 AS_ECHO(["$help"])
170 (exit 1); exit 1 ;;
171 esac
173 # Unless specified, the output is stdout.
174 test -z "$outfile" && outfile=-
176 # Run autom4te with expansion.
177 eval set x $autom4te_options \
178 --language=autoconf --output=\$outfile "$traces" \$infile
179 shift
180 $verbose && AS_ECHO(["$as_me: running $AUTOM4TE $*"]) >&2
181 exec "$AUTOM4TE" "$@"