(Limitations of Usual Tools): "expr '' \| ''"
[autoconf/tsuna.git] / bin / autoconf.as
blob33d9404904272415bd46c4fd3e79c916d5784880
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., 59 Temple Place - Suite 330, Boston, MA
19 # 02111-1307, 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 2 ;;
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 shift
124 traces="$traces --trace='"`echo "$1" | sed "s/'/'\\\\\\\\''/g"`"'"
125 shift ;;
126 --initialization | -i )
127 autom4te_options="$autom4te_options --melt"
128 shift;;
130 --output=* | -o?* )
131 outfile=$optarg
132 shift ;;
133 --output | -o )
134 test $# = 1 && eval "$exit_missing_arg"
135 shift
136 outfile=$1
137 shift ;;
139 -- ) # Stop option processing
140 shift; break ;;
141 - ) # Use stdin as input.
142 break ;;
143 -* )
144 exec >&2
145 echo "$me: invalid option $1"
146 echo "$help"
147 exit 1 ;;
149 break ;;
150 esac
151 done
153 # Find the input file.
154 case $# in
156 if test -f configure.ac; then
157 if test -f configure.in; then
158 echo "$me: warning: both \`configure.ac' and \`configure.in' are present." >&2
159 echo "$me: warning: proceeding with \`configure.ac'." >&2
161 infile=configure.ac
162 elif test -f configure.in; then
163 infile=configure.in
164 else
165 echo "$me: no input file" >&2
166 exit 1
168 test -z "$traces" && test -z "$outfile" && outfile=configure;;
169 1) # autom4te doesn't like `-'.
170 test "x$1" != "x-" && infile=$1 ;;
171 *) exec >&2
172 echo "$me: invalid number of arguments."
173 echo "$help"
174 (exit 1); exit 1 ;;
175 esac
177 # Unless specified, the output is stdout.
178 test -z "$outfile" && outfile=-
180 # Run autom4te with expansion.
181 eval set x $autom4te_options \
182 --language=autoconf --output=\$outfile "$traces" \$infile
183 shift
184 $verbose "$me: running $*" >&2
185 exec "$AUTOM4TE" "$@"