Don't use "shift 2".
[autoconf.git] / bin / autoconf.as
blobb9e90a8ec215d92a95dd2116751fd68d6922e0be
1 AS_INIT[]dnl -*- shell-script -*-
2 # autoconf -- create `configure' using m4 macros
3 # Copyright (C) 1992, 1993, 1994, 1996, 1999, 2000, 2001, 2002, 2003, 2004, 2005
4 # 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)
9 # any later version.
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., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
21 usage=["\
22 Usage: $0 [OPTION] ... [TEMPLATE-FILE]
24 Generate a configuration script from a TEMPLATE-FILE if given, or
25 \`configure.ac' if present, or else \`configure.in'. Output is sent
26 to the standard output if TEMPLATE-FILE is given, else into
27 \`configure'.
29 Operation modes:
30 -h, --help print this help, then exit
31 -V, --version print version number, then exit
32 -v, --verbose verbosely report processing
33 -d, --debug don't remove temporary files
34 -f, --force consider all files obsolete
35 -o, --output=FILE save output in FILE (stdout is the default)
36 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [syntax]
38 Warning categories include:
39 \`cross' cross compilation issues
40 \`obsolete' obsolete constructs
41 \`syntax' dubious syntactic constructs
42 \`all' all the warnings
43 \`no-CATEGORY' turn off the warnings on CATEGORY
44 \`none' turn off all the warnings
45 \`error' warnings are error
47 The environment variable \`WARNINGS' is honored.
49 Library directories:
50 -B, --prepend-include=DIR prepend directory DIR to search path
51 -I, --include=DIR append directory DIR to search path
53 Tracing:
54 -t, --trace=MACRO report the list of calls to MACRO
55 -i, --initialization also trace Autoconf's initialization process
57 In tracing mode, no configuration script is created.
59 Report bugs to <bug-autoconf@gnu.org>."]
61 version=["\
62 autoconf (@PACKAGE_NAME@) @VERSION@
63 Written by David J. MacKenzie and Akim Demaille.
65 Copyright (C) 2005 Free Software Foundation, Inc.
66 This is free software; see the source for copying conditions. There is NO
67 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."]
69 me=`AS_BASENAME([$0])`
71 help="\
72 Try \`$me --help' for more information."
74 exit_missing_arg="\
75 echo \"$me: option \\\`\$1' requires an argument\" >&2
76 echo \"\$help\" >&2
77 exit 1"
79 # Variables.
80 : ${AUTOM4TE='@bindir@/@autom4te-name@'}
81 autom4te_options=
82 dir=`AS_DIRNAME([$0])`
83 outfile=
84 verbose=:
86 # Parse command line.
87 while test $# -gt 0 ; do
88 option=[`expr "x$1" : 'x\(--[^=]*\)' \| \
89 "x$1" : 'x\(-.\)'`]
90 optarg=[`expr "x$1" : 'x--[^=]*=\(.*\)' \| \
91 "x$1" : 'x-.\(.*\)'`]
92 case $1 in
93 --version | -V )
94 echo "$version" ; exit ;;
95 --help | -h )
96 echo "$usage"; exit ;;
98 --verbose | -v )
99 verbose=echo
100 autom4te_options="$autom4te_options $1"; shift ;;
102 # Arguments passed as is to autom4te.
103 --debug | -d | \
104 --force | -f | \
105 --include=* | -I?* | \
106 --prepend-include=* | -B?* | \
107 --warnings=* | -W?* )
108 autom4te_options="$autom4te_options '$1'"; shift ;;
110 # Options with separated arg passed as is to autom4te.
111 --include | -I | \
112 --prepend-include | -B | \
113 --warnings | -W )
114 test $# = 1 && eval "$exit_missing_arg"
115 autom4te_options="$autom4te_options $option '$2'"
116 shift; shift ;;
118 --trace=* | -t?* )
119 traces="$traces --trace='"`echo "$optarg" | sed "s/'/'\\\\\\\\''/g"`"'"
120 shift ;;
121 --trace | -t )
122 test $# = 1 && eval "$exit_missing_arg"
123 traces="$traces --trace='"`echo "$2" | sed "s/'/'\\\\\\\\''/g"`"'"
124 shift; shift ;;
125 --initialization | -i )
126 autom4te_options="$autom4te_options --melt"
127 shift;;
129 --output=* | -o?* )
130 outfile=$optarg
131 shift ;;
132 --output | -o )
133 test $# = 1 && eval "$exit_missing_arg"
134 outfile=$2
135 shift; shift ;;
137 -- ) # Stop option processing
138 shift; break ;;
139 - ) # Use stdin as input.
140 break ;;
141 -* )
142 exec >&2
143 echo "$me: invalid option $1"
144 echo "$help"
145 exit 1 ;;
147 break ;;
148 esac
149 done
151 # Find the input file.
152 case $# in
154 if test -f configure.ac; then
155 if test -f configure.in; then
156 echo "$me: warning: both \`configure.ac' and \`configure.in' are present." >&2
157 echo "$me: warning: proceeding with \`configure.ac'." >&2
159 infile=configure.ac
160 elif test -f configure.in; then
161 infile=configure.in
162 else
163 echo "$me: no input file" >&2
164 exit 1
166 test -z "$traces" && test -z "$outfile" && outfile=configure;;
167 1) # autom4te doesn't like `-'.
168 test "x$1" != "x-" && infile=$1 ;;
169 *) exec >&2
170 echo "$me: invalid number of arguments."
171 echo "$help"
172 (exit 1); exit 1 ;;
173 esac
175 # Unless specified, the output is stdout.
176 test -z "$outfile" && outfile=-
178 # Run autom4te with expansion.
179 eval set x $autom4te_options \
180 --language=autoconf --output=\$outfile "$traces" \$infile
181 shift
182 $verbose "$me: running $*" >&2
183 exec "$AUTOM4TE" "$@"