Provide O(n) replacement macros for M4 1.4.x.
[autoconf.git] / bin / autoconf.as
blob5540002662eefcef37a14671d83b3e3bdb81e223
1 AS_INIT[]dnl -*- shell-script -*-
2 m4_divert_push([HEADER-COPYRIGHT])dnl
3 # @configure_input@
4 # autoconf -- create `configure' using m4 macros
6 # Copyright (C) 1992, 1993, 1994, 1996, 1999, 2000, 2001, 2002, 2003,
7 # 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
12 # any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 # 02110-1301, USA.
24 m4_divert_pop([HEADER-COPYRIGHT])dnl back to BODY
26 usage=["\
27 Usage: $0 [OPTION] ... [TEMPLATE-FILE]
29 Generate a configuration script from a TEMPLATE-FILE if given, or
30 \`configure.ac' if present, or else \`configure.in'. Output is sent
31 to the standard output if TEMPLATE-FILE is given, else into
32 \`configure'.
34 Operation modes:
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 all files obsolete
40 -o, --output=FILE save output in FILE (stdout is the default)
41 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [syntax]
43 Warning categories include:
44 \`cross' cross compilation issues
45 \`obsolete' obsolete constructs
46 \`syntax' dubious syntactic constructs
47 \`all' all the warnings
48 \`no-CATEGORY' turn off the warnings on CATEGORY
49 \`none' turn off all the warnings
50 \`error' warnings are error
52 The environment variables \`M4' and \`WARNINGS' are honored.
54 Library directories:
55 -B, --prepend-include=DIR prepend directory DIR to search path
56 -I, --include=DIR append directory DIR to search path
58 Tracing:
59 -t, --trace=MACRO[:FORMAT] report the list of calls to MACRO
60 -i, --initialization also trace Autoconf's initialization process
62 In tracing mode, no configuration script is created. FORMAT defaults
63 to \`\$f:\$l:\$n:\$%'; see \`autom4te --help' for information about FORMAT.
65 Report bugs to <bug-autoconf@gnu.org>."]
67 version=["\
68 autoconf (@PACKAGE_NAME@) @VERSION@
69 Copyright (C) @RELEASE_YEAR@ Free Software Foundation, Inc.
70 License GPLv2+: GNU GPL version 2 or later
71 <http://gnu.org/licenses/old-licenses/gpl-2.0.html>
72 This is free software: you are free to change and redistribute it.
73 There is NO WARRANTY, to the extent permitted by law.
75 Written by David J. MacKenzie and Akim Demaille."]
77 help="\
78 Try \`$as_me --help' for more information."
80 exit_missing_arg='
81 AS_ECHO(["$as_me: option \`$[1]'\'' requires an argument"]) >&2
82 AS_ECHO(["$help"]) >&2
83 exit 1
84 ' # restore font-lock: "
86 # Variables.
87 : ${AUTOM4TE='@bindir@/@autom4te-name@'}
88 autom4te_options=
89 outfile=
90 verbose=false
92 # Parse command line.
93 while test $# -gt 0 ; do
94 option=[`expr "x$1" : 'x\(--[^=]*\)' \| \
95 "x$1" : 'x\(-.\)'`]
96 optarg=[`expr "x$1" : 'x--[^=]*=\(.*\)' \| \
97 "x$1" : 'x-.\(.*\)'`]
98 case $1 in
99 --version | -V )
100 echo "$version" ; exit ;;
101 --help | -h )
102 AS_ECHO(["$usage"]); exit ;;
104 --verbose | -v )
105 verbose=:
106 autom4te_options="$autom4te_options $1"; shift ;;
108 # Arguments passed as is to autom4te.
109 --debug | -d | \
110 --force | -f | \
111 --include=* | -I?* | \
112 --prepend-include=* | -B?* | \
113 --warnings=* | -W?* )
114 case $1 in
115 *\'*) arg=`AS_ECHO(["$1"]) | sed "s/'/'\\\\\\\\''/g"` ;;
116 *) arg=$1 ;;
117 esac
118 autom4te_options="$autom4te_options '$arg'"; shift ;;
119 # Options with separated arg passed as is to autom4te.
120 --include | -I | \
121 --prepend-include | -B | \
122 --warnings | -W )
123 test $# = 1 && eval "$exit_missing_arg"
124 case $2 in
125 *\'*) arg=`AS_ECHO(["$2"]) | sed "s/'/'\\\\\\\\''/g"` ;;
126 *) arg=$2 ;;
127 esac
128 autom4te_options="$autom4te_options $option '$arg'"
129 shift; shift ;;
131 --trace=* | -t?* )
132 traces="$traces --trace='"`AS_ECHO(["$optarg"]) | sed "s/'/'\\\\\\\\''/g"`"'"
133 shift ;;
134 --trace | -t )
135 test $# = 1 && eval "$exit_missing_arg"
136 traces="$traces --trace='"`AS_ECHO(["$[2]"]) | sed "s/'/'\\\\\\\\''/g"`"'"
137 shift; shift ;;
138 --initialization | -i )
139 autom4te_options="$autom4te_options --melt"
140 shift;;
142 --output=* | -o?* )
143 outfile=$optarg
144 shift ;;
145 --output | -o )
146 test $# = 1 && eval "$exit_missing_arg"
147 outfile=$2
148 shift; shift ;;
150 -- ) # Stop option processing
151 shift; break ;;
152 - ) # Use stdin as input.
153 break ;;
154 -* )
155 exec >&2
156 AS_ECHO(["$as_me: invalid option $[1]"])
157 AS_ECHO(["$help"])
158 exit 1 ;;
160 break ;;
161 esac
162 done
164 # Find the input file.
165 case $# in
167 if test -f configure.ac; then
168 if test -f configure.in; then
169 AS_ECHO(["$as_me: warning: both \`configure.ac' and \`configure.in' are present."]) >&2
170 AS_ECHO(["$as_me: warning: proceeding with \`configure.ac'."]) >&2
172 infile=configure.ac
173 elif test -f configure.in; then
174 infile=configure.in
175 else
176 AS_ECHO(["$as_me: no input file"]) >&2
177 exit 1
179 test -z "$traces" && test -z "$outfile" && outfile=configure;;
181 infile=$1 ;;
182 *) exec >&2
183 AS_ECHO(["$as_me: invalid number of arguments."])
184 AS_ECHO(["$help"])
185 (exit 1); exit 1 ;;
186 esac
188 # Unless specified, the output is stdout.
189 test -z "$outfile" && outfile=-
191 # Run autom4te with expansion.
192 eval set x "$autom4te_options" \
193 --language=autoconf --output=\"\$outfile\" "$traces" \"\$infile\"
194 shift
195 $verbose && AS_ECHO(["$as_me: running $AUTOM4TE $*"]) >&2
196 exec "$AUTOM4TE" "$@"