File Coverage

blib/lib/auto/share/dist/Alien-autoconf/bin/autoheader
Criterion Covered Total %
statement 61 144 42.3
branch 2 44 4.5
condition 10 34 29.4
subroutine 15 16 93.7
pod n/a
total 88 238 36.9


line stmt bran cond sub pod time code
1             #! /usr/local/bin/perl
2             BEGIN {
3 1     1   3994 use strict;
  1         1  
  1         33  
4 1     1   3 use warnings;
  1         2  
  1         40  
5 1     1   4 use File::Spec;
  1         2  
  1         267  
6 1     1   26 my($v,$d) = File::Spec->splitpath(File::Spec->rel2abs(__FILE__));
7 1         14 my @d = File::Spec->splitdir($d);
8 1         4 pop @d for 1..2;
9 1         29 my $dist_dir = File::Spec->catpath($v,File::Spec->catdir(@d), '');
10 1   33     25 $ENV{AUTOM4TE} ||= File::Spec->catfile($dist_dir, 'bin/autom4te');
11 1   33     24 $ENV{autom4te_perllibdir} ||= File::Spec->catdir($dist_dir, 'share/autoconf');
12 1   33     9 $ENV{AC_MACRODIR} ||= File::Spec->catdir($dist_dir, 'share/autoconf');
13 1   33     14 $ENV{AUTOCONF} ||= File::Spec->catfile($dist_dir, 'bin/autoconf');
14 1   33     8 $ENV{AUTOHEADER} ||= File::Spec->catfile($dist_dir, 'bin/autoheader');
15 1 50 33     16 $ENV{AUTOM4TE_CFG} ||= File::Spec->catfile($dist_dir, 'share/autoconf/autom4te.blib.cfg')
      33        
16             if $d[-5] eq 'lib' && $d[-6] eq 'blib';
17 1   33     44 $ENV{trailer_m4} ||= File::Spec->catdir($dist_dir, 'share/autoconf/autoconf/trailer.m4');
18             }
19             # -*- Perl -*-
20             # Generated from bin/autoheader.in; do not edit by hand.
21              
22 1         143305 eval 'case $# in 0) exec /usr/local/bin/perl -S "$0";; *) exec /usr/local/bin/perl -S "$0" "$@";; esac'
23             if 0;
24              
25             # autoheader -- create 'config.h.in' from 'configure.ac'.
26              
27             # Copyright (C) 1992-1994, 1996, 1998-2017, 2020-2023 Free Software
28             # Foundation, Inc.
29              
30             # This program is free software: you can redistribute it and/or modify
31             # it under the terms of the GNU General Public License as published by
32             # the Free Software Foundation, either version 3 of the License, or
33             # (at your option) any later version.
34              
35             # This program is distributed in the hope that it will be useful,
36             # but WITHOUT ANY WARRANTY; without even the implied warranty of
37             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38             # GNU General Public License for more details.
39              
40             # You should have received a copy of the GNU General Public License
41             # along with this program. If not, see .
42              
43             # Written by Roland McGrath.
44             # Rewritten in Perl by Akim Demaille.
45              
46 1     1   14 use 5.006;
  1         4  
47 1     1   4 use strict;
  1         1  
  1         23  
48 1     1   2 use warnings FATAL => 'all';
  1         1  
  1         100  
49              
50             BEGIN
51             {
52 1   50 1   5 my $pkgdatadir = $ENV{'autom4te_perllibdir'} || '/usr/local/lib/perl5/site_perl/5.42.0/x86_64-linux/auto/share/dist/Alien-autoconf/share/autoconf';
53 1         2 unshift @INC, "$pkgdatadir";
54              
55             # Override SHELL. On DJGPP SHELL may not be set to a shell
56             # that can handle redirection and quote arguments correctly,
57             # e.g.: COMMAND.COM. For DJGPP always use the shell that configure
58             # has detected.
59 1 50       18 $ENV{'SHELL'} = '/bin/bash' if ($^O eq 'dos');
60             }
61              
62 1     1   519 use Autom4te::ChannelDefs;
  1         2  
  1         141  
63 1     1   8 use Autom4te::Channels;
  1         2  
  1         123  
64 1     1   488 use Autom4te::Configure_ac;
  1         2  
  1         74  
65 1     1   464 use Autom4te::FileUtils;
  1         2  
  1         118  
66 1     1   475 use Autom4te::General;
  1         4  
  1         242  
67 1     1   706 use Autom4te::XFile;
  1         3  
  1         78827  
68              
69             # These vars must be package globals so they can be accessed by code
70             # evaluated via 'do FILE', below.
71 1         3 our ($config_h, %symbol, %verbatim);
72              
73             # Lib files.
74 1   50     34 my $autom4te = $ENV{'AUTOM4TE'} || '/usr/local/lib/perl5/site_perl/5.42.0/x86_64-linux/auto/share/dist/Alien-autoconf/bin/autom4te';
75 1         6 my $config_h_in;
76             my @prepend_include;
77 1         0 my @include;
78 1         0 my @warnings;
79              
80             # $HELP
81             # -----
82 1         14 $help = "Usage: $0 [OPTION]... [TEMPLATE-FILE]
83              
84             Create a template file of C '\#define' statements for 'configure' to
85             use. To this end, scan TEMPLATE-FILE, or 'configure.ac' if present,
86             or else 'configure.in'.
87              
88             -h, --help print this help, then exit
89             -V, --version print version number, then exit
90             -v, --verbose verbosely report processing
91             -d, --debug don\'t remove temporary files
92             -f, --force consider all files obsolete
93             -W, --warnings=CATEGORY report the warnings falling in CATEGORY
94             (comma-separated list accepted)
95              
96             " . Autom4te::ChannelDefs::usage . "
97              
98             Library directories:
99             -B, --prepend-include=DIR prepend directory DIR to search path
100             -I, --include=DIR append directory DIR to search path
101              
102             Report bugs to .
103              
104             The full documentation for Autoconf can be read via 'info autoconf',
105             or on the Web at .
106             ";
107              
108              
109             # $VERSION
110             # --------
111 1         6 $version = "autoheader (GNU Autoconf) 2.72
112             Copyright (C) 2023 Free Software Foundation, Inc.
113             License GPLv3+/Autoconf: GNU GPL version 3 or later
114             ,
115             This is free software: you are free to change and redistribute it.
116             There is NO WARRANTY, to the extent permitted by law.
117              
118             Written by Roland McGrath and Akim Demaille.
119             ";
120              
121              
122             ## ---------- ##
123             ## Routines. ##
124             ## ---------- ##
125              
126              
127             # parse_args ()
128             # -------------
129             # Process any command line arguments.
130             sub parse_args ()
131             {
132 1     1   2 my $srcdir;
133              
134 1         7 getopt ('I|include=s' => \@include,
135             'B|prepend-include=s' => \@prepend_include,
136             'W|warnings=s' => \@warnings);
137              
138 0           parse_WARNINGS;
139 0           parse_warnings @warnings;
140              
141 0 0         if (! @ARGV)
142             {
143 0           my $configure_ac = require_configure_ac;
144 0           push @ARGV, $configure_ac;
145             }
146             }
147              
148              
149             ## -------------- ##
150             ## Main program. ##
151             ## -------------- ##
152              
153 1         9 mktmpdir ('ah');
154 1         7 parse_args;
155              
156             # Preach.
157 0         0 my $config_h_top = find_file ("config.h.top?",
158             reverse (@prepend_include), @include);
159 0         0 my $config_h_bot = find_file ("config.h.bot?",
160             reverse (@prepend_include), @include);
161 0         0 my $acconfig_h = find_file ("acconfig.h?",
162             reverse (@prepend_include), @include);
163 0 0 0     0 if ($config_h_top || $config_h_bot || $acconfig_h)
      0        
164             {
165 0         0 my $msg = << "END";
166             Using auxiliary files such as 'acconfig.h', 'config.h.bot'
167             and 'config.h.top', to define templates for 'config.h.in'
168             is deprecated and discouraged.
169              
170             Using the third argument of 'AC_DEFINE_UNQUOTED' and
171             'AC_DEFINE' allows one to define a template without
172             'acconfig.h':
173              
174             AC_DEFINE([NEED_FUNC_MAIN], 1,
175             [Define if a function 'main' is needed.])
176              
177             More sophisticated templates can also be produced, see the
178             documentation.
179             END
180 0         0 $msg =~ s/^ /WARNING: /gm;
181 0         0 msg 'obsolete', $msg;
182             }
183              
184             # Set up autoconf.
185 0         0 my $autoconf = "'$autom4te' --language=autoconf ";
186 0         0 $autoconf .= join (' --include=', '', map { shell_quote ($_) } @include);
  0         0  
187 0         0 $autoconf .= join (' --prepend-include=', '', map { shell_quote ($_) } @prepend_include);
  0         0  
188 0 0       0 $autoconf .= ' --debug' if $debug;
189 0 0       0 $autoconf .= ' --force' if $force;
190 0 0       0 $autoconf .= ' --verbose' if $verbose;
191              
192             # ----------------------- #
193             # Real work starts here. #
194             # ----------------------- #
195              
196             # Source what the traces are trying to tell us.
197 0         0 verb "$me: running $autoconf to trace from $ARGV[0]";
198 0         0 my $quoted_tmp = shell_quote ($tmp);
199             {
200             # Suppress all warnings from the subsidiary autoconf invocation.
201 0         0 local $ENV{WARNINGS} = 'none';
  0         0  
202 0         0 xsystem ("$autoconf"
203             # If you change this list, update the
204             # 'Autoheader-preselections' section of autom4te.in.
205             . ' --trace AC_CONFIG_HEADERS:\'$$config_h ||= \'"\'"\'$1\'"\'"\';\''
206             . ' --trace AH_OUTPUT:\'$$verbatim{\'"\'"\'$1\'"\'"\'} = \'"\'"\'$2\'"\'"\';\''
207             . ' --trace AC_DEFINE_TRACE_LITERAL:\'$$symbol{\'"\'"\'$1\'"\'"\'} = 1;\''
208             . " " . shell_quote ($ARGV[0]) . " >$quoted_tmp/traces.pl");
209             }
210              
211 0         0 local (%verbatim, %symbol);
212 0         0 debug "$me: 'do'ing $tmp/traces.pl:\n" . `sed 's/^/| /' $quoted_tmp/traces.pl`;
213 0         0 do "$tmp/traces.pl";
214 0 0       0 warn "couldn't parse $tmp/traces.pl: $@" if $@;
215 0 0       0 unless ($config_h)
216             {
217 0         0 error "error: AC_CONFIG_HEADERS not found in $ARGV[0]";
218 0         0 exit 1;
219             }
220              
221             # Support "outfile[:infile]", defaulting infile="outfile.in".
222             sub templates_for_header
223             {
224 0     0     my ($spec) = @_;
225 0           my ($header, @templates) = split(':', $spec);
226              
227 0 0         return @templates if @templates;
228 0           return $header . '.in';
229             }
230              
231 0         0 my @config_templates = map(templates_for_header($_), split(' ', $config_h));
232              
233             # We template only the first CONFIG_HEADER.
234 0         0 $config_h_in = shift(@config_templates);
235 0         0 $config_h =~ s/[ :].*//;
236              
237             # %SYMBOL might contain things like 'F77_FUNC(name,NAME)', but we keep
238             # only the name of the macro.
239 0         0 %symbol = map { s/\(.*//; $_ => 1 } keys %symbol;
  0         0  
  0         0  
240              
241 0         0 my $out = new Autom4te::XFile ("$tmp/config.hin", ">");
242              
243             # Don't write "do not edit" -- it will get copied into the
244             # config.h, which it's ok to edit.
245 0         0 print $out "/* $config_h_in. Generated from $ARGV[0] by autoheader. */\n";
246              
247             # Dump the top.
248 0 0       0 if ($config_h_top)
249             {
250 0         0 my $in = new Autom4te::XFile ($config_h_top, "<");
251 0         0 while ($_ = $in->getline)
252             {
253 0         0 print $out $_;
254             }
255             }
256              
257             # Dump 'acconfig.h', except for its bottom portion.
258 0 0       0 if ($acconfig_h)
259             {
260 0         0 my $in = new Autom4te::XFile ($acconfig_h, "<");
261 0         0 while ($_ = $in->getline)
262             {
263 0 0       0 last if /\@BOTTOM\@/;
264 0 0       0 next if /\@TOP\@/;
265 0         0 print $out $_;
266             }
267             }
268              
269             # Dump the templates from 'configure.ac'.
270 0         0 foreach (sort keys %verbatim)
271             {
272 0         0 print $out "\n$verbatim{$_}\n";
273             }
274              
275             # Dump bottom portion of 'acconfig.h'.
276 0 0       0 if ($acconfig_h)
277             {
278 0         0 my $in = new Autom4te::XFile ($acconfig_h, "<");
279 0         0 my $dump = 0;
280 0         0 while ($_ = $in->getline)
281             {
282 0 0       0 print $out $_ if $dump;
283 0 0       0 $dump = 1 if /\@BOTTOM\@/;
284             }
285             }
286              
287             # Dump the bottom.
288 0 0       0 if ($config_h_bot)
289             {
290 0         0 my $in = new Autom4te::XFile ($config_h_bot, "<");
291 0         0 while ($_ = $in->getline)
292             {
293 0         0 print $out $_;
294             }
295             }
296              
297 0         0 $out->close;
298              
299             # Check that all the symbols have a template.
300             {
301 0         0 foreach my $template ("$tmp/config.hin", @config_templates)
  0         0  
302             {
303 0 0       0 if (! -r $template)
304             {
305 0         0 msg 'syntax', "cannot read $template: $!";
306             }
307             else
308             {
309 0         0 my $in = new Autom4te::XFile ($template, "<");
310              
311 0         0 while ($_ = $in->getline)
312             {
313 0 0       0 my ($sym) = /^\#\s*\w+\s+(\w+)/
314             or next;
315 0         0 delete $symbol{$sym};
316             }
317             }
318             }
319              
320 0         0 my $suggest_ac_define = 1;
321              
322 0         0 foreach (sort keys %symbol)
323             {
324 0         0 msg 'syntax', "missing template: $_";
325 0 0       0 if ($suggest_ac_define)
326             {
327 0         0 msg 'syntax', "Use AC_DEFINE([$_], [], [Description])";
328 0         0 $suggest_ac_define = 0;
329             }
330             }
331 0 0       0 exit 1
332             if keys %symbol;
333             }
334              
335 0         0 update_file ("$tmp/config.hin", "$config_h_in", $force);
336              
337             ### Setup "GNU" style for perl-mode and cperl-mode.
338             ## Local Variables:
339             ## perl-indent-level: 2
340             ## perl-continued-statement-offset: 2
341             ## perl-continued-brace-offset: 0
342             ## perl-brace-offset: 0
343             ## perl-brace-imaginary-offset: 0
344             ## perl-label-offset: -2
345             ## cperl-indent-level: 2
346             ## cperl-brace-offset: 0
347             ## cperl-continued-brace-offset: 0
348             ## cperl-label-offset: -2
349             ## cperl-extra-newline-before-brace: t
350             ## cperl-merge-trailing-else: nil
351             ## cperl-continued-statement-offset: 2
352             ## End: