5 eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
8 # autoconf -- create 'configure' using m4 macros.
10 # Copyright (C) 1992-1994, 1996, 1999-2017, 2020-2024 Free Software
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <https://www.gnu.org/licenses/>.
28 use warnings FATAL => 'all';
32 my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '@pkgdatadir@';
33 unshift @INC, $pkgdatadir;
35 # Override SHELL. On DJGPP SHELL may not be set to a shell
36 # that can handle redirection and quote arguments correctly,
37 # e.g.: COMMAND.COM. For DJGPP always use the shell that configure
39 $ENV{'SHELL'} = '@SHELL@' if ($^O eq 'dos');
42 use Autom4te::ChannelDefs;
43 use Autom4te::Channels qw(msg);
44 use Autom4te::General;
47 my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@';
48 my $trailer_m4 = $ENV{'trailer_m4'} || '@pkgdatadir@/autoconf/trailer.m4';
52 $help = "Usage: $0 [OPTION]... [TEMPLATE-FILE]
54 Generate a configuration script from a TEMPLATE-FILE if given, or
55 'configure.ac' if present, or else 'configure.in'. Output is sent
56 to the standard output if TEMPLATE-FILE is given, else into
60 -h, --help print this help, then exit
61 -V, --version print version number, then exit
62 -v, --verbose verbosely report processing
63 -d, --debug don't remove temporary files
64 -f, --force consider all files obsolete
65 -o, --output=FILE save output in FILE (stdout is the default)
66 -W, --warnings=CATEGORY report the warnings falling in CATEGORY
67 (comma-separated list accepted)
69 " . Autom4te::ChannelDefs::usage . "
72 -B, --prepend-include=DIR prepend directory DIR to search path
73 -I, --include=DIR append directory DIR to search path
76 -t, --trace=MACRO[:FORMAT] report the list of calls to MACRO
77 -i, --initialization also trace Autoconf's initialization process
79 In tracing mode, no configuration script is created. FORMAT defaults
80 to '\$f:\$l:\$n:\$%'; see 'autom4te --help' for information about FORMAT.
82 Report bugs to <bug-autoconf\@gnu.org>.
84 The full documentation for Autoconf can be read via 'info autoconf',
85 or on the Web at <https://www.gnu.org/software/autoconf/manual/>.
90 $version = "autoconf (@PACKAGE_NAME@) @VERSION@
91 Copyright (C) @RELEASE_YEAR@ Free Software Foundation, Inc.
92 License GPLv3+/Autoconf: GNU GPL version 3 or later
93 <https://gnu.org/licenses/gpl.html>, <https://gnu.org/licenses/exceptions.html>
94 This is free software: you are free to change and redistribute it.
95 There is NO WARRANTY, to the extent permitted by law.
97 Written by David J. MacKenzie and Akim Demaille.
106 my @autom4te_options;
111 # Process any command line arguments.
115 # Arguments passed as-is to autom4te.
116 'I|include=s' => sub { push @autom4te_options, '--include='.$_[1] },
117 'B|prepend-include=s' => sub { push @autom4te_options,
118 '--prepend-include='.$_[1] },
119 'W|warnings=s' => sub { push @autom4te_options,
120 '--warnings='.$_[1] },
122 # Arguments processed (somewhat) in this program.
123 'i|initialization' => sub { push @autom4te_options, '--melt' },
124 't|trace=s' => sub { push @traces, '--trace='.$_[1] },
125 'o|output=s' => \$outfile,
128 # Also pass down certain options that were processed into their own
129 # variables by Autom4te::General::getopt.
130 push @autom4te_options, '--debug' if $debug;
131 push @autom4te_options, '--force' if $force;
132 push @autom4te_options, '--verbose' if $verbose;
134 # Find the input file.
137 $outfile = 'configure' if !$outfile && !@traces;
139 if (-f 'configure.ac')
141 $infile = 'configure.ac';
142 if (-f 'configure.in')
145 q(both 'configure.ac' and 'configure.in' are present);
147 q(proceeding with 'configure.ac');
150 elsif (-f 'configure.in')
152 $infile = 'configure.in';
156 fatal 'no input file';
165 fatal "invalid number of arguments.\n"
166 . "Try '$me --help' for more information.";
169 # Unless already set, the output is stdout.
170 $outfile = '-' if !$outfile;
179 # Construct the autom4te invocation.
180 # $autom4te might contain additional command line options; word-split it
181 # exactly as the shell would.
182 my @autom4te_command = split /[ \t\n]+/, $autom4te;
183 push @autom4te_command, @autom4te_options;
184 push @autom4te_command, '--language=autoconf', "--output=$outfile", @traces;
186 # Don't read trailer.m4 if we are tracing.
187 # trailer.m4 is read _before_ $infile, despite the name,
188 # because putting it afterward screws up autom4te's location tracing.
189 push @autom4te_command, $trailer_m4 if !@traces;
190 push @autom4te_command, $infile;
194 join (" ", map { shell_quote($_) } @autom4te_command),
198 exec {$autom4te_command[0]} @autom4te_command;
200 ### Setup "GNU" style for perl-mode and cperl-mode.
202 ## perl-indent-level: 2
203 ## perl-continued-statement-offset: 2
204 ## perl-continued-brace-offset: 0
205 ## perl-brace-offset: 0
206 ## perl-brace-imaginary-offset: 0
207 ## perl-label-offset: -2
208 ## cperl-indent-level: 2
209 ## cperl-brace-offset: 0
210 ## cperl-continued-brace-offset: 0
211 ## cperl-label-offset: -2
212 ## cperl-extra-newline-before-brace: t
213 ## cperl-merge-trailing-else: nil
214 ## cperl-continued-statement-offset: 2