| 1 | #! @PERL@
|
|---|
| 2 | # -*- Perl -*-
|
|---|
| 3 | # @configure_input@
|
|---|
| 4 |
|
|---|
| 5 | eval 'case $# in 0) exec @PERL@ -S "$0";; *) exec @PERL@ -S "$0" "$@";; esac'
|
|---|
| 6 | if 0;
|
|---|
| 7 |
|
|---|
| 8 | # autoheader -- create `config.h.in' from `configure.ac'
|
|---|
| 9 |
|
|---|
| 10 | # Copyright (C) 1992, 1993, 1994, 1996, 1998, 1999, 2000, 2001, 2002,
|
|---|
| 11 | # 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
|---|
| 12 |
|
|---|
| 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 2, or (at your option)
|
|---|
| 16 | # any later version.
|
|---|
| 17 |
|
|---|
| 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.
|
|---|
| 22 |
|
|---|
| 23 | # You should have received a copy of the GNU General Public License
|
|---|
| 24 | # along with this program; if not, write to the Free Software
|
|---|
| 25 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|---|
| 26 | # 02110-1301, USA.
|
|---|
| 27 |
|
|---|
| 28 | # Written by Roland McGrath.
|
|---|
| 29 | # Rewritten in Perl by Akim Demaille.
|
|---|
| 30 |
|
|---|
| 31 | BEGIN
|
|---|
| 32 | {
|
|---|
| 33 | my $datadir = $ENV{'autom4te_perllibdir'} || '@datadir@';
|
|---|
| 34 | $datadir =~ s/\/\@unixroot/$ENV{'UNIXROOT'}/; # The EMX built perl doesn't know @unixroot.
|
|---|
| 35 | unshift @INC, "$datadir";
|
|---|
| 36 |
|
|---|
| 37 | # Override SHELL. On DJGPP SHELL may not be set to a shell
|
|---|
| 38 | # that can handle redirection and quote arguments correctly,
|
|---|
| 39 | # e.g.: COMMAND.COM. For DJGPP always use the shell that configure
|
|---|
| 40 | # has detected.
|
|---|
| 41 | $ENV{'SHELL'} = '@SHELL@' if ($^O eq 'dos');
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | use Autom4te::ChannelDefs;
|
|---|
| 45 | use Autom4te::Channels;
|
|---|
| 46 | use Autom4te::Configure_ac;
|
|---|
| 47 | use Autom4te::FileUtils;
|
|---|
| 48 | use Autom4te::General;
|
|---|
| 49 | use Autom4te::XFile;
|
|---|
| 50 | use strict;
|
|---|
| 51 |
|
|---|
| 52 | # Using `do FILE', we need `local' vars.
|
|---|
| 53 | use vars qw ($config_h %verbatim %symbol);
|
|---|
| 54 |
|
|---|
| 55 | # Lib files.
|
|---|
| 56 | my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@';
|
|---|
| 57 | $autom4te =~ s/\/\@unixroot/$ENV{'UNIXROOT'}/; # The EMX built perl doesn't know @unixroot.
|
|---|
| 58 | local $config_h;
|
|---|
| 59 | my $config_h_in;
|
|---|
| 60 | my @prepend_include;
|
|---|
| 61 | my @include;
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 | # $HELP
|
|---|
| 65 | # -----
|
|---|
| 66 | $help = "Usage: $0 [OPTION] ... [TEMPLATE-FILE]
|
|---|
| 67 |
|
|---|
| 68 | Create a template file of C \`\#define\' statements for \`configure\' to
|
|---|
| 69 | use. To this end, scan TEMPLATE-FILE, or \`configure.ac\' if present,
|
|---|
| 70 | or else \`configure.in\'.
|
|---|
| 71 |
|
|---|
| 72 | -h, --help print this help, then exit
|
|---|
| 73 | -V, --version print version number, then exit
|
|---|
| 74 | -v, --verbose verbosely report processing
|
|---|
| 75 | -d, --debug don\'t remove temporary files
|
|---|
| 76 | -f, --force consider all files obsolete
|
|---|
| 77 | -W, --warnings=CATEGORY report the warnings falling in CATEGORY
|
|---|
| 78 |
|
|---|
| 79 | " . Autom4te::ChannelDefs::usage () . "
|
|---|
| 80 |
|
|---|
| 81 | Library directories:
|
|---|
| 82 | -B, --prepend-include=DIR prepend directory DIR to search path
|
|---|
| 83 | -I, --include=DIR append directory DIR to search path
|
|---|
| 84 |
|
|---|
| 85 | Report bugs to <bug-autoconf\@gnu.org>.
|
|---|
| 86 | ";
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | # $VERSION
|
|---|
| 90 | # --------
|
|---|
| 91 | $version = "autoheader (@PACKAGE_NAME@) @VERSION@
|
|---|
| 92 | Copyright (C) 2006 Free Software Foundation, Inc.
|
|---|
| 93 | This is free software. You may redistribute copies of it under the terms of
|
|---|
| 94 | the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
|
|---|
| 95 | There is NO WARRANTY, to the extent permitted by law.
|
|---|
| 96 |
|
|---|
| 97 | Written by Roland McGrath and Akim Demaille.
|
|---|
| 98 | ";
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 | ## ---------- ##
|
|---|
| 102 | ## Routines. ##
|
|---|
| 103 | ## ---------- ##
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 | # parse_args ()
|
|---|
| 107 | # -------------
|
|---|
| 108 | # Process any command line arguments.
|
|---|
| 109 | sub parse_args ()
|
|---|
| 110 | {
|
|---|
| 111 | my $srcdir;
|
|---|
| 112 |
|
|---|
| 113 | parse_WARNINGS;
|
|---|
| 114 | getopt ('I|include=s' => \@include,
|
|---|
| 115 | 'B|prepend-include=s' => \@prepend_include,
|
|---|
| 116 | 'W|warnings=s' => \&parse_warnings);
|
|---|
| 117 |
|
|---|
| 118 | if (! @ARGV)
|
|---|
| 119 | {
|
|---|
| 120 | my $configure_ac = require_configure_ac;
|
|---|
| 121 | push @ARGV, $configure_ac;
|
|---|
| 122 | }
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 | ## -------------- ##
|
|---|
| 127 | ## Main program. ##
|
|---|
| 128 | ## -------------- ##
|
|---|
| 129 |
|
|---|
| 130 | mktmpdir ('ah');
|
|---|
| 131 | switch_warning 'obsolete';
|
|---|
| 132 | parse_args;
|
|---|
| 133 |
|
|---|
| 134 | # Preach.
|
|---|
| 135 | my $config_h_top = find_file ("config.h.top?",
|
|---|
| 136 | reverse (@prepend_include), @include);
|
|---|
| 137 | my $config_h_bot = find_file ("config.h.bot?",
|
|---|
| 138 | reverse (@prepend_include), @include);
|
|---|
| 139 | my $acconfig_h = find_file ("acconfig.h?",
|
|---|
| 140 | reverse (@prepend_include), @include);
|
|---|
| 141 | if ($config_h_top || $config_h_bot || $acconfig_h)
|
|---|
| 142 | {
|
|---|
| 143 | my $msg = << "END";
|
|---|
| 144 | Using auxiliary files such as \`acconfig.h\', \`config.h.bot\'
|
|---|
| 145 | and \`config.h.top\', to define templates for \`config.h.in\'
|
|---|
| 146 | is deprecated and discouraged.
|
|---|
| 147 |
|
|---|
| 148 | Using the third argument of \`AC_DEFINE\' and
|
|---|
| 149 | \`AC_DEFINE_UNQUOTED\' allows one to define a template without
|
|---|
| 150 | \`acconfig.h\':
|
|---|
| 151 |
|
|---|
| 152 | AC_DEFINE([NEED_FUNC_MAIN], 1,
|
|---|
| 153 | [Define if a function \`main\' is needed.])
|
|---|
| 154 |
|
|---|
| 155 | More sophisticated templates can also be produced, see the
|
|---|
| 156 | documentation.
|
|---|
| 157 | END
|
|---|
| 158 | $msg =~ s/^ /WARNING: /gm;
|
|---|
| 159 | msg 'obsolete', $msg;
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | # Set up autoconf.
|
|---|
| 163 | my $autoconf = "'$autom4te' --language=autoconf ";
|
|---|
| 164 | $autoconf .= join (' ', map { "--include='$_'" } @include);
|
|---|
| 165 | $autoconf .= join (' ', map { "--prepend-include='$_'" } @prepend_include);
|
|---|
| 166 | $autoconf .= ' --debug' if $debug;
|
|---|
| 167 | $autoconf .= ' --force' if $force;
|
|---|
| 168 | $autoconf .= ' --verbose' if $verbose;
|
|---|
| 169 |
|
|---|
| 170 | # ----------------------- #
|
|---|
| 171 | # Real work starts here. #
|
|---|
| 172 | # ----------------------- #
|
|---|
| 173 |
|
|---|
| 174 | # Source what the traces are trying to tell us.
|
|---|
| 175 | verb "$me: running $autoconf to trace from $ARGV[0]";
|
|---|
| 176 | xsystem ("$autoconf"
|
|---|
| 177 | # If you change this list, update the
|
|---|
| 178 | # `Autoheader-preselections' section of autom4te.in.
|
|---|
| 179 | . ' --trace AC_CONFIG_HEADERS:\'$$config_h ||= \'"\'"\'$1\'"\'"\';\''
|
|---|
| 180 | . ' --trace AH_OUTPUT:\'$$verbatim{\'"\'"\'$1\'"\'"\'} = \'"\'"\'$2\'"\'"\';\''
|
|---|
| 181 | . ' --trace AC_DEFINE_TRACE_LITERAL:\'$$symbol{\'"\'"\'$1\'"\'"\'} = 1;\''
|
|---|
| 182 | . " $ARGV[0] >$tmp/traces.pl");
|
|---|
| 183 |
|
|---|
| 184 | local (%verbatim, %symbol);
|
|---|
| 185 | debug "$me: \`do'ing $tmp/traces.pl:\n" . `sed 's/^/| /' $tmp/traces.pl`;
|
|---|
| 186 | do "$tmp/traces.pl";
|
|---|
| 187 | warn "couldn't parse $tmp/traces.pl: $@" if $@;
|
|---|
| 188 | unless ($config_h)
|
|---|
| 189 | {
|
|---|
| 190 | error "error: AC_CONFIG_HEADERS not found in $ARGV[0]";
|
|---|
| 191 | exit 1;
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | # We template only the first CONFIG_HEADER.
|
|---|
| 195 | $config_h =~ s/ .*//;
|
|---|
| 196 | # Support "outfile[:infile]", defaulting infile="outfile.in".
|
|---|
| 197 | ($config_h, $config_h_in) = split (':', $config_h, 2);
|
|---|
| 198 | $config_h_in ||= "$config_h.in";
|
|---|
| 199 |
|
|---|
| 200 | # %SYMBOL might contain things like `F77_FUNC(name,NAME)', but we keep
|
|---|
| 201 | # only the name of the macro.
|
|---|
| 202 | %symbol = map { s/\(.*//; $_ => 1 } keys %symbol;
|
|---|
| 203 |
|
|---|
| 204 | my $out = new Autom4te::XFile (">$tmp/config.hin");
|
|---|
| 205 |
|
|---|
| 206 | # Don't write "do not edit" -- it will get copied into the
|
|---|
| 207 | # config.h, which it's ok to edit.
|
|---|
| 208 | print $out "/* $config_h_in. Generated from $ARGV[0] by autoheader. */\n";
|
|---|
| 209 |
|
|---|
| 210 | # Dump the top.
|
|---|
| 211 | if ($config_h_top)
|
|---|
| 212 | {
|
|---|
| 213 | my $in = new Autom4te::XFile ($config_h_top);
|
|---|
| 214 | while ($_ = $in->getline)
|
|---|
| 215 | {
|
|---|
| 216 | print $out $_;
|
|---|
| 217 | }
|
|---|
| 218 | }
|
|---|
| 219 |
|
|---|
| 220 | # Dump `acconfig.h', except for its bottom portion.
|
|---|
| 221 | if ($acconfig_h)
|
|---|
| 222 | {
|
|---|
| 223 | my $in = new Autom4te::XFile ($acconfig_h);
|
|---|
| 224 | while ($_ = $in->getline)
|
|---|
| 225 | {
|
|---|
| 226 | last if /\@BOTTOM\@/;
|
|---|
| 227 | next if /\@TOP\@/;
|
|---|
| 228 | print $out $_;
|
|---|
| 229 | }
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | # Dump the templates from `configure.ac'.
|
|---|
| 233 | foreach (sort keys %verbatim)
|
|---|
| 234 | {
|
|---|
| 235 | print $out "\n$verbatim{$_}\n";
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | # Dump bottom portion of `acconfig.h'.
|
|---|
| 239 | if ($acconfig_h)
|
|---|
| 240 | {
|
|---|
| 241 | my $in = new Autom4te::XFile ($acconfig_h);
|
|---|
| 242 | my $dump = 0;
|
|---|
| 243 | while ($_ = $in->getline)
|
|---|
| 244 | {
|
|---|
| 245 | print $out $_ if $dump;
|
|---|
| 246 | $dump = 1 if /\@BOTTOM\@/;
|
|---|
| 247 | }
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | # Dump the bottom.
|
|---|
| 251 | if ($config_h_bot)
|
|---|
| 252 | {
|
|---|
| 253 | my $in = new Autom4te::XFile ($config_h_bot);
|
|---|
| 254 | while ($_ = $in->getline)
|
|---|
| 255 | {
|
|---|
| 256 | print $out $_;
|
|---|
| 257 | }
|
|---|
| 258 | }
|
|---|
| 259 |
|
|---|
| 260 | $out->close;
|
|---|
| 261 |
|
|---|
| 262 | # Check that all the symbols have a template.
|
|---|
| 263 | {
|
|---|
| 264 | my $in = new Autom4te::XFile ("$tmp/config.hin");
|
|---|
| 265 | my $suggest_ac_define = 1;
|
|---|
| 266 | while ($_ = $in->getline)
|
|---|
| 267 | {
|
|---|
| 268 | my ($symbol) = /^\#\s*\w+\s+(\w+)/
|
|---|
| 269 | or next;
|
|---|
| 270 | delete $symbol{$symbol};
|
|---|
| 271 | }
|
|---|
| 272 | foreach (sort keys %symbol)
|
|---|
| 273 | {
|
|---|
| 274 | msg 'syntax', "warning: missing template: $_";
|
|---|
| 275 | if ($suggest_ac_define)
|
|---|
| 276 | {
|
|---|
| 277 | msg 'syntax', "Use AC_DEFINE([$_], [], [Description])";
|
|---|
| 278 | $suggest_ac_define = 0;
|
|---|
| 279 | }
|
|---|
| 280 |
|
|---|
| 281 | }
|
|---|
| 282 | exit 1
|
|---|
| 283 | if keys %symbol;
|
|---|
| 284 | }
|
|---|
| 285 |
|
|---|
| 286 | update_file ("$tmp/config.hin", "$config_h_in", $force);
|
|---|
| 287 |
|
|---|
| 288 | ### Setup "GNU" style for perl-mode and cperl-mode.
|
|---|
| 289 | ## Local Variables:
|
|---|
| 290 | ## perl-indent-level: 2
|
|---|
| 291 | ## perl-continued-statement-offset: 2
|
|---|
| 292 | ## perl-continued-brace-offset: 0
|
|---|
| 293 | ## perl-brace-offset: 0
|
|---|
| 294 | ## perl-brace-imaginary-offset: 0
|
|---|
| 295 | ## perl-label-offset: -2
|
|---|
| 296 | ## cperl-indent-level: 2
|
|---|
| 297 | ## cperl-brace-offset: 0
|
|---|
| 298 | ## cperl-continued-brace-offset: 0
|
|---|
| 299 | ## cperl-label-offset: -2
|
|---|
| 300 | ## cperl-extra-newline-before-brace: t
|
|---|
| 301 | ## cperl-merge-trailing-else: nil
|
|---|
| 302 | ## cperl-continued-statement-offset: 2
|
|---|
| 303 | ## End:
|
|---|