From: Alexandre Duret-Lutz Date: Thu, 22 May 2003 17:50:10 +0000 (+0000) Subject: * automake.in: Move the "main" code at the end. X-Git-Tag: Release-1-7b~179 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32394497827a8a6641637ebfac9a291a51cb09d0;p=thirdparty%2Fautomake.git * automake.in: Move the "main" code at the end. (parse_arguments): Move near the end. ($KNOWN_EXTENSIONS_PATTERN, @known_extensions_list, accept_extensions, var_SUFFIXES_trigger): Move these definitions before any call to register_language. (am_file): Move the definition with all other global variables, do not use local to define it. * Makefile.am (maintainer-check): Expect no `local' in Automake. --- diff --git a/ChangeLog b/ChangeLog index f3e33b6f8..c76b21c20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2003-05-22 Alexandre Duret-Lutz + + * automake.in: Move the "main" code at the end. + (parse_arguments): Move near the end. + ($KNOWN_EXTENSIONS_PATTERN, @known_extensions_list, + accept_extensions, var_SUFFIXES_trigger): Move these definitions + before any call to register_language. + (am_file): Move the definition with all other global variables, + do not use local to define it. + * Makefile.am (maintainer-check): Expect no `local' in Automake. + 2003-05-21 Alexandre Duret-Lutz * lib/Automake/Wrap.pm, lib/Automake/tests/Wrap.pl: New files. diff --git a/Makefile.am b/Makefile.am index 4fcd05e58..cfad0e491 100644 --- a/Makefile.am +++ b/Makefile.am @@ -159,22 +159,12 @@ maintainer-check: automake aclocal echo "Don't use \`local' with parens: use several \`local' above." >&2; \ exit 1; \ fi -## Up to now we manage to limit to 1 use of local, but for `local $_;'. - @locals=`grep -v '^[ \t]*local \$$_;' $(srcdir)/automake.in | \ - grep -c '^[ \t]*local [^*]'`; \ - case $$locals in \ - [0] ) \ - echo "Wow, congrats! There are no \`local' now!." >&2; \ - echo "Please update Makefile.am (maintainer-check)." >&2; \ - exit 1; \ - ;; \ - 1 ) ;; \ - * ) \ - echo "Too many \`local'! Are you sure you need $$locals of them?" >&2; \ - echo "Up to now 1 was enough." >&2; \ - exit 1; \ - ;; \ - esac +## Allow only `local $_' in Automake. + @if grep -v '^[ \t]*local \$$_;' $(srcdir)/automake.in | \ + grep '^[ \t]*local [^*]'; then \ + echo "Please avoid \`local'." 1>&2; \ + exit 1; \ + fi ## Don't let AMDEP_TRUE substitution appear in automake.in. @if grep '@AMDEP''_TRUE@' $(srcdir)/automake.in; then \ echo "Don't put AMDEP_TRUE substitution in automake.in" 1>&2; \ diff --git a/Makefile.in b/Makefile.in index 7cc30da61..65adba7dc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -827,21 +827,11 @@ maintainer-check: automake aclocal echo "Don't use \`local' with parens: use several \`local' above." >&2; \ exit 1; \ fi - @locals=`grep -v '^[ \t]*local \$$_;' $(srcdir)/automake.in | \ - grep -c '^[ \t]*local [^*]'`; \ - case $$locals in \ - [0] ) \ - echo "Wow, congrats! There are no \`local' now!." >&2; \ - echo "Please update Makefile.am (maintainer-check)." >&2; \ - exit 1; \ - ;; \ - 1 ) ;; \ - * ) \ - echo "Too many \`local'! Are you sure you need $$locals of them?" >&2; \ - echo "Up to now 1 was enough." >&2; \ - exit 1; \ - ;; \ - esac + @if grep -v '^[ \t]*local \$$_;' $(srcdir)/automake.in | \ + grep '^[ \t]*local [^*]'; then \ + echo "Please avoid \`local'." 1>&2; \ + exit 1; \ + fi @if grep '@AMDEP''_TRUE@' $(srcdir)/automake.in; then \ echo "Don't put AMDEP_TRUE substitution in automake.in" 1>&2; \ exit 1; \ diff --git a/automake.in b/automake.in index eff902f24..751391c1b 100755 --- a/automake.in +++ b/automake.in @@ -487,6 +487,9 @@ my $suffix_rules_default; # been checked for. This variable is local to the "require file" # functions. my %require_file_found = (); + +# The name of the Makefile currently being processed. +my $am_file = 'BUG'; ################################################################ @@ -717,6 +720,41 @@ my %gen_varname = (); # the named of the helper variable used to append to VAR in CONDITIONS. my %appendvar = (); +################################################################ + +# Pattern that matches all know input extensions (i.e. extensions used +# by the languages supported by Automake). Using this pattern +# (instead of `\..*$') to match extensions allows Automake to support +# dot-less extensions. +my $KNOWN_EXTENSIONS_PATTERN = ""; +my @known_extensions_list = (); + +# accept_extensions (@EXTS) +# ------------------------- +# Update $KNOWN_EXTENSIONS_PATTERN to recognize the extensions +# listed @EXTS. Extensions should contain a dot if needed. +sub accept_extensions (@) +{ + push @known_extensions_list, @_; + $KNOWN_EXTENSIONS_PATTERN = + '(?:' . join ('|', map (quotemeta, @known_extensions_list)) . ')'; +} + +# var_SUFFIXES_trigger ($TYPE, $VALUE) +# ------------------------------------ +# This is called automagically by macro_define() when SUFFIXES +# is defined ($TYPE eq '') or appended ($TYPE eq '+'). +# The work here needs to be performed as a side-effect of the +# macro_define() call because SUFFIXES definitions impact +# on $KNOWN_EXTENSIONS_PATTERN, and $KNOWN_EXTENSIONS_PATTERN +# are used when parsing the input am file. +sub var_SUFFIXES_trigger ($$) +{ + my ($type, $value) = @_; + accept_extensions (split (' ', $value)); +} + +################################################################ ## --------------------------------- ## ## Forward subroutine declarations. ## @@ -1092,53 +1130,6 @@ register_language ('name' => 'java', ################################################################ -# Parse the WARNINGS environment variable. -&parse_WARNINGS; - -# Parse command line. -&parse_arguments; - -# Do configure.ac scan only once. -&scan_autoconf_files; - -&fatal ("no `Makefile.am' found or specified\n") - if ! @input_files; - -my $automake_has_run = 0; - -do -{ - if ($automake_has_run) - { - &verb ('processing Makefiles another time to fix them up.'); - &prog_error ('running more than two times should never be needed.') - if $automake_has_run >= 2; - } - $automake_needs_to_reprocess_all_files = 0; - - # Now do all the work on each file. - # This guy must be local otherwise it's private to the loop. - use vars '$am_file'; - local $am_file; - foreach $am_file (@input_files) - { - if (! -f ($am_file . '.am')) - { - &error ("`$am_file.am' does not exist"); - } - else - { - &generate_makefile ($output_files{$am_file}, $am_file); - } - } - ++$automake_has_run; -} -while ($automake_needs_to_reprocess_all_files); - -exit $exit_code; - -################################################################ - # Error reporting functions. # err_var ($VARNAME, $MESSAGE, [%OPTIONS]) @@ -1311,141 +1302,6 @@ sub backname ($) ################################################################ -# Pattern that matches all know input extensions (i.e. extensions used -# by the languages supported by Automake). Using this pattern -# (instead of `\..*$') to match extensions allows Automake to support -# dot-less extensions. -my $KNOWN_EXTENSIONS_PATTERN = ""; -my @known_extensions_list = (); - -# accept_extensions (@EXTS) -# ------------------------- -# Update $KNOWN_EXTENSIONS_PATTERN to recognize the extensions -# listed @EXTS. Extensions should contain a dot if needed. -sub accept_extensions (@) -{ - push @known_extensions_list, @_; - $KNOWN_EXTENSIONS_PATTERN = - '(?:' . join ('|', map (quotemeta, @known_extensions_list)) . ')'; -} - -# var_SUFFIXES_trigger ($TYPE, $VALUE) -# ------------------------------------ -# This is called automagically by macro_define() when SUFFIXES -# is defined ($TYPE eq '') or appended ($TYPE eq '+'). -# The work here needs to be performed as a side-effect of the -# macro_define() call because SUFFIXES definitions impact -# on $KNOWN_EXTENSIONS_PATTERN, and $KNOWN_EXTENSIONS_PATTERN -# are used when parsing the input am file. -sub var_SUFFIXES_trigger ($$) -{ - my ($type, $value) = @_; - accept_extensions (split (' ', $value)); -} - -################################################################ - - -# Parse command line. -sub parse_arguments () -{ - # Start off as gnu. - &set_strictness ('gnu'); - - my %options = - ( - 'libdir:s' => \$libdir, - 'gnu' => sub { &set_strictness ('gnu'); }, - 'gnits' => sub { &set_strictness ('gnits'); }, - 'cygnus' => \$cygnus_mode, - 'foreign' => sub { &set_strictness ('foreign'); }, - 'include-deps' => sub { $cmdline_use_dependencies = 1; }, - 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; }, - 'no-force' => sub { $force_generation = 0; }, - 'f|force-missing' => \$force_missing, - 'o|output-dir:s' => \$output_directory, - 'a|add-missing' => \$add_missing, - 'c|copy' => \$copy_missing, - 'v|verbose' => sub { setup_channel 'verb', silent => 0; }, - 'W|warnings:s' => \&parse_warnings, - # These long options (--Werror and --Wno-error) for backward - # compatibility. Use -Werror and -Wno-error today. - 'Werror' => sub { parse_warnings 'W', 'error'; }, - 'Wno-error' => sub { parse_warnings 'W', 'no-error'; }, - ); - - use Getopt::Long; - Getopt::Long::config ("bundling", "pass_through"); - - # See if --version or --help is used. We want to process these before - # anything else because the GNU Coding Standards require us to - # `exit 0' after processing these options, and we can't garanty this - # if we treat other options first. (Handling other options first - # could produce error diagnostics, and in this condition it is - # confusing if Automake `exit 0'.) - my %options_1st_pass = - ( - 'version' => \&version, - 'help' => \&usage, - # Recognize all other options (and their arguments) but do nothing. - map { $_ => sub {} } (keys %options) - ); - my @ARGV_backup = @ARGV; - Getopt::Long::GetOptions %options_1st_pass - or exit 1; - @ARGV = @ARGV_backup; - - # Now *really* process the options. This time we know - # that --help and --version are not present. - Getopt::Long::GetOptions %options - or exit 1; - - if (defined $output_directory) - { - msg 'obsolete', "`--output-dir' is deprecated\n"; - } - else - { - # In the next release we'll remove this entirely. - $output_directory = '.'; - } - - foreach my $arg (@ARGV) - { - if ($arg =~ /^-./) - { - fatal ("unrecognized option `$arg'\n" - . "Try `$0 --help' for more information."); - } - - # Handle $local:$input syntax. Note that we only examine the - # first ":" file to see if it is automake input; the rest are - # just taken verbatim. We still keep all the files around for - # dependency checking, however. - my ($local, $input, @rest) = split (/:/, $arg); - if (! $input) - { - $input = $local; - } - else - { - # Strip .in; later on .am is tacked on. That is how the - # automake input file is found. Maybe not the best way, but - # it is easy to explain. - $input =~ s/\.in$// - or fatal "invalid input file name `$arg'\n."; - } - push (@input_files, $input); - $output_files{$input} = join (':', ($local, @rest)); - } - - # Take global strictness from whatever we currently have set. - $default_strictness = $strictness; - $default_strictness_name = $strictness_name; -} - -################################################################ - # Generate a Makefile.in given the name of the corresponding Makefile and # the name of the file output by config.status. sub generate_makefile @@ -8834,6 +8690,151 @@ EOF exit 0; } +################################################################ + +# Parse command line. +sub parse_arguments () +{ + # Start off as gnu. + &set_strictness ('gnu'); + + my %options = + ( + 'libdir:s' => \$libdir, + 'gnu' => sub { &set_strictness ('gnu'); }, + 'gnits' => sub { &set_strictness ('gnits'); }, + 'cygnus' => \$cygnus_mode, + 'foreign' => sub { &set_strictness ('foreign'); }, + 'include-deps' => sub { $cmdline_use_dependencies = 1; }, + 'i|ignore-deps' => sub { $cmdline_use_dependencies = 0; }, + 'no-force' => sub { $force_generation = 0; }, + 'f|force-missing' => \$force_missing, + 'o|output-dir:s' => \$output_directory, + 'a|add-missing' => \$add_missing, + 'c|copy' => \$copy_missing, + 'v|verbose' => sub { setup_channel 'verb', silent => 0; }, + 'W|warnings:s' => \&parse_warnings, + # These long options (--Werror and --Wno-error) for backward + # compatibility. Use -Werror and -Wno-error today. + 'Werror' => sub { parse_warnings 'W', 'error'; }, + 'Wno-error' => sub { parse_warnings 'W', 'no-error'; }, + ); + use Getopt::Long; + Getopt::Long::config ("bundling", "pass_through"); + + # See if --version or --help is used. We want to process these before + # anything else because the GNU Coding Standards require us to + # `exit 0' after processing these options, and we can't garanty this + # if we treat other options first. (Handling other options first + # could produce error diagnostics, and in this condition it is + # confusing if Automake `exit 0'.) + my %options_1st_pass = + ( + 'version' => \&version, + 'help' => \&usage, + # Recognize all other options (and their arguments) but do nothing. + map { $_ => sub {} } (keys %options) + ); + my @ARGV_backup = @ARGV; + Getopt::Long::GetOptions %options_1st_pass + or exit 1; + @ARGV = @ARGV_backup; + + # Now *really* process the options. This time we know + # that --help and --version are not present. + Getopt::Long::GetOptions %options + or exit 1; + + if (defined $output_directory) + { + msg 'obsolete', "`--output-dir' is deprecated\n"; + } + else + { + # In the next release we'll remove this entirely. + $output_directory = '.'; + } + + foreach my $arg (@ARGV) + { + if ($arg =~ /^-./) + { + fatal ("unrecognized option `$arg'\n" + . "Try `$0 --help' for more information."); + } + + # Handle $local:$input syntax. Note that we only examine the + # first ":" file to see if it is automake input; the rest are + # just taken verbatim. We still keep all the files around for + # dependency checking, however. + my ($local, $input, @rest) = split (/:/, $arg); + if (! $input) + { + $input = $local; + } + else + { + # Strip .in; later on .am is tacked on. That is how the + # automake input file is found. Maybe not the best way, but + # it is easy to explain. + $input =~ s/\.in$// + or fatal "invalid input file name `$arg'\n."; + } + push (@input_files, $input); + $output_files{$input} = join (':', ($local, @rest)); + } + + # Take global strictness from whatever we currently have set. + $default_strictness = $strictness; + $default_strictness_name = $strictness_name; +} + +################################################################ + +# Parse the WARNINGS environment variable. +parse_WARNINGS; + +# Parse command line. +parse_arguments; + +# Do configure.ac scan only once. +scan_autoconf_files; + +fatal "no `Makefile.am' found or specified\n" + if ! @input_files; + +my $automake_has_run = 0; + +do +{ + if ($automake_has_run) + { + verb 'processing Makefiles another time to fix them up.'; + prog_error 'running more than two times should never be needed.' + if $automake_has_run >= 2; + } + $automake_needs_to_reprocess_all_files = 0; + + # Now do all the work on each file. + foreach my $file (@input_files) + { + $am_file = $file; + if (! -f ($am_file . '.am')) + { + error "`$am_file.am' does not exist"; + } + else + { + generate_makefile ($output_files{$am_file}, $am_file); + } + } + ++$automake_has_run; +} +while ($automake_needs_to_reprocess_all_files); + +exit $exit_code; + + ### Setup "GNU" style for perl-mode and cperl-mode. ## Local Variables: ## perl-indent-level: 2