]> sourceware.org Git - automake.git/commitdiff
* lib/Automake/Options.pm: New file.
authorAlexandre Duret-Lutz <adl@gnu.org>
Thu, 7 Aug 2003 20:30:04 +0000 (20:30 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Thu, 7 Aug 2003 20:30:04 +0000 (20:30 +0000)
* lib/Automake/Makefile.am (dist_perllib_DATA): Add Options.pm.
* automake.in (FOREIGN, GNU, GNITS, $default_strictness)
($default_strictness_name, $strictness, $strictness_name)
(%options, %global_options, process_option_list)
(set_strictness): Remove, now in Options.pm.
(initialize_per_input): Call Automake::Options::reset.
(handle_options, get_object_extension, get_object_extension)
(handle_languages, handle_single_transform_list, handle_compile)
(handle_texinfo_helper, handle_man_pages, handle_dist)
(handle_configure, do_check_merge_target)
(handle_factored_dependencies, handle_tests)
(handle_minor_options, scan_autoconf_traces, check_cygnus)
(lang_sub_obj, lang_c_rewrite, lang_c_finish, rule_define)
(make_paragraphs, am_install_var, parse_arguments): Adjust
to set and read options via the new interface.

ChangeLog
automake.in
lib/Automake/Makefile.am
lib/Automake/Makefile.in
lib/Automake/Options.pm [new file with mode: 0644]
stamp-vti
version.texi

index 8d6d88e4ebfade8b872b4bda37a46756197045cb..e27b45ec7ddccce02793d207c3ac27d2fcdf7f96 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2003-08-07  Alexandre Duret-Lutz  <adl@gnu.org>
+
+       * lib/Automake/Options.pm: New file.
+       * lib/Automake/Makefile.am (dist_perllib_DATA): Add Options.pm.
+       * automake.in (FOREIGN, GNU, GNITS, $default_strictness)
+       ($default_strictness_name, $strictness, $strictness_name)
+       (%options, %global_options, process_option_list)
+       (set_strictness): Remove, now in Options.pm.
+       (initialize_per_input): Call Automake::Options::reset.
+       (handle_options, get_object_extension, get_object_extension)
+       (handle_languages, handle_single_transform_list, handle_compile)
+       (handle_texinfo_helper, handle_man_pages, handle_dist)
+       (handle_configure, do_check_merge_target)
+       (handle_factored_dependencies, handle_tests)
+       (handle_minor_options, scan_autoconf_traces, check_cygnus)
+       (lang_sub_obj, lang_c_rewrite, lang_c_finish, rule_define)
+       (make_paragraphs, am_install_var, parse_arguments): Adjust
+       to set and read options via the new interface.
+
 2003-08-07  Raja R Harinath  <harinath@acm.org>
 
        * Makefile.am (maintainer-check): Update perllibdir.
index 3f1ee13aae482a33bcfbdcfbab35dd7bf4c90e7d..f92d8e13f35e1aeb09d754f619c6eb7c05ae65e9 100755 (executable)
@@ -131,6 +131,7 @@ use Automake::FileUtils;
 use Automake::Location;
 use Automake::Condition qw/TRUE FALSE/;
 use Automake::DisjConditions;
+use Automake::Options;
 use Automake::Version;
 use Automake::Variable;
 use Automake::VarDef;
@@ -193,11 +194,6 @@ my $DASH_D_PATTERN = "(^|\\s)-d(\\s|\$)";
 my $EXEC_DIR_PATTERN =
   '^(?:bin|sbin|libexec|sysconf|localstate|lib|pkglib|.*exec.*)' . "\$";
 
-# Constants to define the "strictness" level.
-use constant FOREIGN => 0;
-use constant GNU     => 1;
-use constant GNITS   => 2;
-
 # Values for AC_CANONICAL_*
 use constant AC_CANONICAL_HOST   => 1;
 use constant AC_CANONICAL_SYSTEM => 2;
@@ -276,12 +272,6 @@ use constant INTERNAL => new Automake::Location;
 # TRUE if we should always generate Makefile.in.
 my $force_generation = 1;
 
-# Strictness level as set on command line.
-my $default_strictness = GNU;
-
-# Name of strictness level, as set on command line.
-my $default_strictness_name = 'gnu';
-
 # From the Perl manual.
 my $symlink_exists = (eval 'symlink ("", "");', $@ eq '');
 
@@ -557,16 +547,6 @@ my %directory_map;
 # All .P files.
 my %dep_files;
 
-# Strictness levels.
-my $strictness;
-my $strictness_name;
-
-# Automake options.
-# Values are the Automake::Location of the definition, except
-# for 'ansi2knr' whose value is a pair [filename, Location].
-my %options;                   # From AUTOMAKE_OPTIONS
-my %global_options;            # From AM_INIT_AUTOMAKE or the command line.
-
 # This is a list of all targets to run during "make dist".
 my @dist_targets;
 
@@ -693,7 +673,8 @@ sub initialize_per_input ()
 
     @suffixes = ();
 
-    Automake::Variable::reset ();
+    Automake::Options::reset;
+    Automake::Variable::reset;
 
     %targets = ();
     %target_source = ();
@@ -768,11 +749,6 @@ sub initialize_per_input ()
 
     %dep_files = ();
 
-    $strictness = $default_strictness;
-    $strictness_name = $default_strictness_name;
-
-    %options = ();
-
     @dist_targets = ();
 
     %de_ansi_files = ();
@@ -1154,81 +1130,15 @@ sub backname ($)
 
 ################################################################
 
-# $BOOL
-# process_option_list (\%OPTIONS, $WHERE, @OPTIONS)
-# -------------------------------------------------
-# Process a list of options.  Return 1 on error, 0 otherwise.
-# \%OPTIONS is the hash to fill with options data, $WHERE is
-# the location where @OPTIONS occured.
-sub process_option_list (\%$@)
-{
-  my ($options, $where, @list) = @_;
-
-  foreach (@list)
-    {
-      $options->{$_} = $where;
-      if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
-       {
-         &set_strictness ($_);
-       }
-      elsif (/^(.*\/)?ansi2knr$/)
-       {
-         # An option like "../lib/ansi2knr" is allowed.  With no
-         # path prefix, we assume the required programs are in this
-         # directory.  We save the actual option for later.
-         $options->{'ansi2knr'} = [$_, $where];
-       }
-      elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
-            || $_ eq 'dist-shar' || $_ eq 'dist-zip'
-            || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
-            || $_ eq 'no-dist-gzip'
-            || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
-            || $_ eq 'readme-alpha' || $_ eq 'check-news'
-            || $_ eq 'subdir-objects' || $_ eq 'nostdinc'
-            || $_ eq 'no-exeext' || $_ eq 'no-define'
-            || $_ eq 'std-options'
-            || $_ eq 'cygnus' || $_ eq 'no-dependencies')
-       {
-         # Explicitly recognize these.
-       }
-      elsif (/^\d+\.\d+(?:\.\d+)?[a-z]?(?:-[A-Za-z0-9]+)?$/)
-       {
-         # Got a version number.
-         if (Automake::Version::check ($VERSION, $&))
-           {
-             error ($where, "require Automake $_, but have $VERSION",
-                    uniq_scope => US_GLOBAL);
-               return 1;
-           }
-       }
-      elsif (/^(?:--warnings=|-W)(.*)$/)
-       {
-         foreach my $cat (split (',', $1))
-           {
-             msg 'unsupported', $where, "unknown warning category `$cat'"
-               if switch_warning $cat;
-           }
-       }
-      else
-       {
-         error ($where, "option `$_' not recognized",
-                uniq_scope => US_GLOBAL);
-         return 1;
-       }
-    }
-}
 
 # Handle AUTOMAKE_OPTIONS variable.  Return 1 on error, 0 otherwise.
 sub handle_options
 {
-  %options = %global_options;
-
   my $var = var ('AUTOMAKE_OPTIONS');
   if ($var)
     {
       # FIXME: We should disallow conditional definitions of AUTOMAKE_OPTIONS.
-      if (process_option_list (%options,
-                              $var->rdef (TRUE)->location,
+      if (process_option_list ($var->rdef (TRUE)->location,
                               $var->value_as_list_recursive (TRUE)))
        {
          return 1;
@@ -1237,9 +1147,9 @@ sub handle_options
 
   if ($strictness == GNITS)
     {
-      $options{'readme-alpha'} = 1;
-      $options{'std-options'} = 1;
-      $options{'check-news'} = 1;
+      set_option ('readme-alpha', INTERNAL);
+      set_option ('std-options', INTERNAL);
+      set_option ('check-news', INTERNAL);
     }
 
   return 0;
@@ -1260,7 +1170,7 @@ sub get_object_extension
 
     # Check for automatic de-ANSI-fication.
     $extension = '$U' . $extension
-      if $options{'ansi2knr'};
+      if option 'ansi2knr';
 
     $get_object_extension_was_run = 1;
 
@@ -1271,7 +1181,7 @@ sub get_object_extension
 # Call finish function for each language that was used.
 sub handle_languages
 {
-    if (! $options{'no-dependencies'})
+    if (! option 'no-dependencies')
     {
        # Include auto-dep code.  Don't include it if DEP_FILES would
        # be empty.
@@ -1339,7 +1249,7 @@ sub handle_languages
        my $fpfx = ($pfx eq '') ? 'CC' : $pfx;
 
        my ($AMDEP, $FASTDEP) =
-         ($options{'no-dependencies'} || $lang->autodep eq 'no')
+         (option 'no-dependencies' || $lang->autodep eq 'no')
          ? ('FALSE', 'FALSE') : ('AMDEP', "am__fastdep$fpfx");
 
        my %transform = ('EXT'     => $ext,
@@ -1352,7 +1262,7 @@ sub handle_languages
                                   => (count_files_for_language ($lang->name) > 1));
 
        # Generate the appropriate rules for this extension.
-       if (((! $options{'no-dependencies'}) && $lang->autodep ne 'no')
+       if (((! option 'no-dependencies') && $lang->autodep ne 'no')
            || defined $lang->compile)
        {
            # Some C compilers don't support -c -o.  Use it only if really
@@ -1361,7 +1271,7 @@ sub handle_languages
            $output_flag = '-o'
              if (! $output_flag
                  && $lang->name eq 'c'
-                 && $options{'subdir-objects'});
+                 && option 'subdir-objects');
 
            # Compute a possible derived extension.
            # This is not used by depend2.am.
@@ -1823,7 +1733,7 @@ sub handle_single_transform_list ($$$$@)
                 my $obj_sans_ext = substr ($object, 0,
                                           - length ($this_obj_ext));
                my $full_ansi = $full;
-               if ($lang->ansi && $options{'ansi2knr'})
+               if ($lang->ansi && option 'ansi2knr')
                  {
                    $full_ansi =~ s/$KNOWN_EXTENSIONS_PATTERN$/\$U$&/;
                    $obj_sans_ext .= '$U';
@@ -1956,7 +1866,7 @@ sub handle_single_transform_list ($$$$@)
                 # .deps directory is created.
                push (@dep_list,
                      require_build_directory ($directory . '/$(DEPDIR)'))
-                 unless $options{'no-dependencies'};
+                 unless option 'no-dependencies';
             }
 
             &pretty_print_rule ($object . ':', "\t", @dep_list)
@@ -2287,7 +2197,7 @@ sub handle_compile ()
 
     # Boilerplate.
     my $default_includes = '';
-    if (! $options{'nostdinc'})
+    if (! option 'nostdinc')
       {
        $default_includes = ' -I. -I$(srcdir)';
 
@@ -2328,9 +2238,9 @@ sub handle_compile ()
     $output_rules .= "$coms$rules";
 
     # Check for automatic de-ANSI-fication.
-    if ($options{'ansi2knr'})
+    if (option 'ansi2knr')
       {
-       my ($ansi2knr_filename, $ansi2knr_where) = @{$options{'ansi2knr'}};
+       my ($ansi2knr_filename, $ansi2knr_where) = @{option 'ansi2knr'};
        my $ansi2knr_dir = '';
 
        require_variables ($ansi2knr_where, "option `ansi2knr' is used",
@@ -3065,7 +2975,7 @@ sub handle_texinfo_helper ($)
       $texinfodir = ('$(srcdir)/'
                     . dirname (variable_value ('TEXINFO_TEX')));
     }
-  elsif ($options{'cygnus'})
+  elsif (option 'cygnus')
     {
       $texinfodir = '$(top_srcdir)/../texinfo';
       define_variable ('TEXINFO_TEX', "$texinfodir/texinfo.tex", INTERNAL);
@@ -3085,7 +2995,7 @@ sub handle_texinfo_helper ($)
 
   push (@dist_targets, 'dist-info');
 
-  if (! $options{'no-installinfo'})
+  if (! option 'no-installinfo')
     {
       # Make sure documentation is made and installed first.  Use
       # $(INFO_DEPS), not 'info', because otherwise recursive makes
@@ -3107,7 +3017,7 @@ sub handle_texinfo_helper ($)
   # Do some error checking.  Note that this file is not required
   # when in Cygnus mode; instead we defined TEXINFO_TEX explicitly
   # up above.
-  if ($need_texi_file && ! $options{'no-texinfo.tex'})
+  if ($need_texi_file && ! option 'no-texinfo.tex')
     {
       if ($need_texi_file > 1)
        {
@@ -3212,7 +3122,7 @@ sub handle_man_pages
                                 MANS => "@mans");
 
   push (@all, '$(MANS)')
-    unless $options{'no-installman'};
+    unless option 'no-installman';
 }
 
 # Handle DATA variables.
@@ -3332,15 +3242,15 @@ sub handle_dist
 
   # `make dist' isn't used in a Cygnus-style tree.
   # Omit the rules so that people don't try to use them.
-  return if $options{'cygnus'};
+  return if option 'cygnus';
 
   # At least one of the archive formats must be enabled.
   if ($relative_dir eq '.')
     {
-      my $archive_defined = $options{'no-dist-gzip'} ? 0 : 1;
+      my $archive_defined = option 'no-dist-gzip' ? 0 : 1;
       $archive_defined ||=
-       grep { $options{"dist-$_"} } ('shar', 'zip', 'tarZ', 'bzip2');
-      error ($options{'no-dist-gzip'},
+       grep { option "dist-$_" } ('shar', 'zip', 'tarZ', 'bzip2');
+      error (option 'no-dist-gzip',
             "no-dist-gzip specified but no dist-* specified, "
             . "at least one archive format must be enabled")
        unless $archive_defined;
@@ -3672,9 +3582,9 @@ sub handle_configure ($$@)
      'MAKEFILE-IN'         => $infile,
      'MAKEFILE-IN-DEPS'    => "@include_stack",
      'MAKEFILE-AM'         => $amfile,
-     STRICTNESS            => $global_options{'cygnus'}
+     STRICTNESS            => global_option 'cygnus'
                                 ? 'cygnus' : $strictness_name,
-     'USE-DEPS'            => $global_options{'no-dependencies'}
+     'USE-DEPS'            => global_option 'no-dependencies'
                                 ? ' --ignore-deps' : '',
      'MAKEFILE-AM-SOURCES' =>  "$input$colon_infile",
      'REGEN-ACLOCAL-M4'    => $regen_aclocal_m4,
@@ -4134,7 +4044,7 @@ sub do_check_merge_target ()
     }
 
   # In --cygnus mode, check doesn't depend on all.
-  if ($options{'cygnus'})
+  if (option 'cygnus')
     {
       # Just run the local check rules.
       pretty_print_rule ('check-am:', "\t\t", @check);
@@ -4246,7 +4156,7 @@ sub handle_factored_dependencies
   reject_target ('install-info-local',
                 "`install-info-local' target defined but "
                 . "`no-installinfo' option not in use")
-    unless $options{'no-installinfo'};
+    unless option 'no-installinfo';
 
   # Install the -local hooks.
   foreach (keys %dependencies)
@@ -4321,7 +4231,7 @@ sub handle_tests_dejagnu
 # Handle TESTS variable and other checks.
 sub handle_tests
 {
-  if ($options{'dejagnu'})
+  if (option 'dejagnu')
     {
       &handle_tests_dejagnu;
     }
@@ -4416,7 +4326,7 @@ sub handle_java
 # Handle some of the minor options.
 sub handle_minor_options
 {
-  if ($options{'readme-alpha'})
+  if (option 'readme-alpha')
     {
       if ($relative_dir eq '.')
        {
@@ -4644,8 +4554,8 @@ sub scan_autoconf_traces ($)
          elsif (defined $args[1])
            {
              exit $exit_code
-               if (process_option_list (%global_options, $where,
-                                        split (' ', $args[1])));
+               if (process_global_option_list ($where,
+                                               split (' ', $args[1])));
            }
        }
       elsif ($macro eq 'AM_MAINTAINER_MODE')
@@ -4744,11 +4654,12 @@ sub scan_autoconf_files
 # Set up for Cygnus mode.
 sub check_cygnus
 {
-  return unless $options{'cygnus'};
+  my $cygnus = option 'cygnus';
+  return unless $cygnus;
 
-  &set_strictness ('foreign');
-  $options{'no-installinfo'} = $options{'cygnus'};
-  $options{'no-dependencies'} = $options{'cygnus'};
+  set_strictness ('foreign');
+  set_option ('no-installinfo', $cygnus);
+  set_option ('no-dependencies', $cygnus);
 
   err_ac "`AM_MAINTAINER_MODE' required when --cygnus specified"
     if !$seen_maint_mode;
@@ -4773,9 +4684,9 @@ sub check_gnu_standards
 
   for my $opt ('no-installman', 'no-installinfo')
     {
-      msg ('error-gnu', $options{$opt},
+      msg ('error-gnu', option $opt,
           "option `$opt' disallowed by GNU standards")
-       if $options{$opt};
+       if option $opt;
     }
 }
 
@@ -4808,7 +4719,7 @@ sub check_gnits_standards
 # when a subdir object should be used.
 sub lang_sub_obj
 {
-    return $options{'subdir-objects'} ? LANG_SUBDIR : LANG_PROCESS;
+    return option 'subdir-objects' ? LANG_SUBDIR : LANG_PROCESS;
 }
 
 # Rewrite a single C source file.
@@ -4816,14 +4727,14 @@ sub lang_c_rewrite
 {
   my ($directory, $base, $ext) = @_;
 
-  if ($options{'ansi2knr'} && $base =~ /_$/)
+  if (option 'ansi2knr' && $base =~ /_$/)
     {
       # FIXME: include line number in error.
       err_am "C source file `$base.c' would be deleted by ansi2knr rules";
     }
 
   my $r = LANG_PROCESS;
-  if ($options{'subdir-objects'})
+  if (option 'subdir-objects')
     {
       $r = LANG_SUBDIR;
       $base = $directory . '/' . $base
@@ -4957,7 +4868,7 @@ sub lang_c_finish
        }
     }
 
-    if ($options{'ansi2knr'} && keys %de_ansi_files)
+    if (option 'ansi2knr' && keys %de_ansi_files)
     {
        # Make all _.c files depend on their corresponding .c files.
        my @objects;
@@ -5570,7 +5481,7 @@ sub rule_define ($$$$$)
       && $target_name{$noexe}{$cond} ne $target)
     {
       # The no-exeext option enables this feature.
-      if (! $options{'no-exeext'})
+      if (! option 'no-exeext')
        {
          msg ('obsolete', $targets{$noexe}{$cond},
               "deprecated feature: target `$noexe' overrides "
@@ -6169,19 +6080,19 @@ sub make_paragraphs ($%)
   my $command =
     "s/$IGNORE_PATTERN//gm;"
     . transform (%transform,
-                'CYGNUS'      => defined $options{'cygnus'},
+                'CYGNUS'      => !! option 'cygnus',
                 'MAINTAINER-MODE'
                 => $seen_maint_mode ? subst ('MAINTAINER_MODE_TRUE') : '',
 
-                'BZIP2'       => $options{'dist-bzip2'} || 0,
-                'COMPRESS'    => $options{'dist-tarZ'} || 0,
-                'GZIP'        => $options{'no-dist-gzip'} ? 0 : 1,
-                'SHAR'        => $options{'dist-shar'} || 0,
-                'ZIP'         => $options{'dist-zip'} || 0,
+                'BZIP2'       => !! option 'dist-bzip2',
+                'COMPRESS'    => !! option 'dist-tarZ',
+                'GZIP'        =>  ! option 'no-dist-gzip',
+                'SHAR'        => !! option 'dist-shar',
+                'ZIP'         => !! option 'dist-zip',
 
-                'INSTALL-INFO' => !$options{'no-installinfo'},
-                'INSTALL-MAN'  => !$options{'no-installman'},
-                'CK-NEWS'      => $options{'check-news'} || 0,
+                'INSTALL-INFO' =>  ! option 'no-installinfo',
+                'INSTALL-MAN'  =>  ! option 'no-installman',
+                'CK-NEWS'      => !! option 'check-news',
 
                 'SUBDIRS'      => !! var ('SUBDIRS'),
                 'TOPDIR'       => backname ($relative_dir),
@@ -6736,8 +6647,7 @@ sub am_install_var
       # If so, with install-exec? (or install-data?).
       my $exec_p = ($nodir_name =~ /$EXEC_DIR_PATTERN/o);
 
-      my $check_options_p = $install_p
-       && defined $options{'std-options'};
+      my $check_options_p = $install_p && !! option 'std-options';
 
       # Use the location of the currently processed variable as context.
       $where->push_context ("while processing `$one_name'");
@@ -7296,30 +7206,6 @@ sub generate_makefile
 ################################################################
 
 
-# Set strictness.
-sub set_strictness
-{
-  $strictness_name = $_[0];
-
-  Automake::ChannelDefs::set_strictness ($strictness_name);
-
-  if ($strictness_name eq 'gnu')
-    {
-      $strictness = GNU;
-    }
-  elsif ($strictness_name eq 'gnits')
-    {
-      $strictness = GNITS;
-    }
-  elsif ($strictness_name eq 'foreign')
-    {
-      $strictness = FOREIGN;
-    }
-  else
-    {
-      prog_error "level `$strictness_name' not recognized\n";
-    }
-}
 
 
 ################################################################
@@ -7441,11 +7327,11 @@ sub parse_arguments ()
      'libdir:s'        => \$libdir,
      'gnu'             => sub { set_strictness ('gnu'); },
      'gnits'           => sub { set_strictness ('gnits'); },
-     'cygnus'          => sub { $global_options{'cygnus'} = $cli_where; },
+     'cygnus'          => sub { set_global_option ('cygnus', $cli_where); },
      'foreign'          => sub { set_strictness ('foreign'); },
-     'include-deps'    => sub { delete $global_options{'no-dependencies'}; },
-     'i|ignore-deps'   => sub { $global_options{'no-dependencies'}
-                                = $cli_where; },
+     'include-deps'    => sub { unset_global_option ('no-dependencies'); },
+     'i|ignore-deps'   => sub { set_global_option ('no-dependencies',
+                                                   $cli_where); },
      'no-force'        => sub { $force_generation = 0; },
      'f|force-missing'  => \$force_missing,
      'o|output-dir:s'  => \$output_directory,
@@ -7522,10 +7408,6 @@ sub parse_arguments ()
       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;
 }
 
 ################################################################
index f6a3a157de2465b00dc1e6e589037ca9a8953b8c..2d3ed5d0d789e15ac0fa05c8d735ab961fae906a 100644 (file)
@@ -29,6 +29,7 @@ dist_perllib_DATA = \
   FileUtils.pm \
   General.pm \
   Location.pm \
+  Options.pm \
   Struct.pm \
   Variable.pm \
   VarDef.pm \
index ba2ee30321e40f5ce4d75d971dd07a3f973a2bf2..6b24e85051cf8e7c3302509fff99f4296e872667 100644 (file)
@@ -139,6 +139,7 @@ dist_perllib_DATA = \
   FileUtils.pm \
   General.pm \
   Location.pm \
+  Options.pm \
   Struct.pm \
   Variable.pm \
   VarDef.pm \
diff --git a/lib/Automake/Options.pm b/lib/Automake/Options.pm
new file mode 100644 (file)
index 0000000..b1dd680
--- /dev/null
@@ -0,0 +1,363 @@
+# Copyright (C) 2003  Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+package Automake::Options;
+
+use strict;
+use Exporter;
+use Automake::Config;
+use Automake::ChannelDefs;
+use Automake::Channels;
+use Automake::Version;
+
+use vars qw (@ISA @EXPORT);
+
+@ISA = qw (Exporter);
+@EXPORT = qw (option global_option
+             set_option set_global_option
+             unset_option unset_global_option
+             process_option_list process_global_option_list
+             set_strictness $strictness $strictness_name
+             &FOREIGN &GNU &GNITS);
+
+=head1 NAME
+
+Automake::Options - keep track of Automake options
+
+=head1 SYNOPSIS
+
+  use Automake::Options;
+
+  # Option lookup and setting.
+  $opt = option 'name';
+  $opt = global_option 'name';
+  set_option 'name', 'value';
+  set_global_option 'name', 'value';
+  unset_option 'name';
+  unset_global_option 'name';
+
+  # Batch option setting.
+  process_option_list $location, @names;
+  process_global_option_list $location, @names;
+
+  # Strictness lookup and setting.
+  set_strictness 'foreign';
+  set_strictness 'gnu';
+  set_strictness 'gnits';
+  if ($strictness >= GNU) { ... }
+  print "$strictness_name\n";
+
+=head1 DESCRIPTION
+
+This packages manages Automake's options and strictness settings.
+Options can be either local or global.  Local options are set using an
+C<AUTOMAKE_OPTIONS> variable in a F<Makefile.am> and apply only to
+this F<Makefile.am>.  Global options are set from the command line or
+passed as an argument to C<AM_INIT_AUTOMAKE>, they apply to all
+F<Makefile.am>s.
+
+=cut
+
+# Values are the Automake::Location of the definition, except
+# for 'ansi2knr' whose value is a pair [filename, Location].
+use vars '%_options';          # From AUTOMAKE_OPTIONS
+use vars '%_global_options';   # from AM_INIT_AUTOMAKE or the command line.
+
+=head2 Constants
+
+=over 4
+
+=item FOREIGN
+
+=item GNU
+
+=item GNITS
+
+Strictness constants used as values for C<$strictness>.
+
+=back
+
+=cut
+
+# Constants to define the "strictness" level.
+use constant FOREIGN => 0;
+use constant GNU     => 1;
+use constant GNITS   => 2;
+
+=head2 Variables
+
+=over 4
+
+=item C<$strictness>
+
+The current stricness.  One of C<FOREIGN>, C<GNU>, or C<GNITS>.
+
+=item C<$strictness_name>
+
+The current stricness name.  One of C<'foreign'>, C<'gnu'>, or C<'gnits'>.
+
+=back
+
+=cut
+
+# Strictness levels.
+use vars qw ($strictness $strictness_name);
+
+# Strictness level as set on command line.
+use vars qw ($_default_strictness $_default_strictness_name);
+
+
+=head2 Functions
+
+=over 4
+
+=item C<Automake::Options::reset>
+
+Reset the options variables for the next F<Makefile.am>.
+
+In other words, this gets rid of all local options in use by the
+previous F<Makefile.am>.
+
+=cut
+
+sub reset ()
+{
+  %_options = %_global_options;
+  # The first time we are run,
+  # remember the current setting as the default.
+  if (defined $_default_strictness)
+    {
+      $strictness = $_default_strictness;
+      $strictness_name = $_default_strictness_name;
+    }
+  else
+    {
+      $_default_strictness = $strictness;
+      $_default_strictness_name = $strictness_name;
+    }
+}
+
+=item C<$value = option ($name)>
+
+=item C<$value = global_option ($name)>
+
+Query the state of an option.  If the option is unset, this
+returns the empty list.  Otherwise it returns the option's value,
+as set by C<set_option> or C<set_global_option>.
+
+Not that C<global_option> should be used only when it is
+important to make sure an option hasn't been set locally.
+Otherwise C<option> should be the standard function to
+check for options (be they global or local).
+
+=cut
+
+sub option ($)
+{
+  my ($name) = @_;
+  return () unless defined $_options{$name};
+  return $_options{$name};
+}
+
+sub global_option ($)
+{
+  my ($name) = @_;
+  return () unless defined $_global_options{$name};
+  return $_global_options{$name};
+}
+
+=item C<set_option ($name, $value)>
+
+=item C<set_global_option ($name, $value)>
+
+Set an option.  By convention, C<$value> is usually the location
+of the option definition.
+
+=cut
+
+sub set_option ($$)
+{
+  my ($name, $value) = @_;
+  $_options{$name} = $value;
+}
+
+sub set_global_option ($$)
+{
+  my ($name, $value) = @_;
+  $_global_options{$name} = $value;
+}
+
+
+=item C<unset_option ($name)>
+
+=item C<unset_global_option ($name)>
+
+Unset an option.
+
+=cut
+
+sub unset_option ($)
+{
+  my ($name) = @_;
+  delete $_options{$name};
+}
+
+sub unset_global_option ($)
+{
+  my ($name) = @_;
+  delete $_global_options{$name};
+}
+
+
+=item C<process_option_list ($where, @options)>
+
+=item C<process_global_option_list ($where, @options)>
+
+Process Automake's option lists.  C<@options> should be a list of
+words, as they occur in C<AUTOMAKE_OPTIONS> or C<AM_INIT_AUTOMAKE>.
+
+Return 1 on error, 0 otherwise.
+
+=cut
+
+# $BOOL
+# _process_option_list (\%OPTIONS, $WHERE, @OPTIONS)
+# -------------------------------------------------
+# Process a list of options.  Return 1 on error, 0 otherwise.
+# \%OPTIONS is the hash to fill with options data, $WHERE is
+# the location where @OPTIONS occured.
+sub _process_option_list (\%$@)
+{
+  my ($options, $where, @list) = @_;
+
+  foreach (@list)
+    {
+      $options->{$_} = $where;
+      if ($_ eq 'gnits' || $_ eq 'gnu' || $_ eq 'foreign')
+       {
+         set_strictness ($_);
+       }
+      elsif (/^(.*\/)?ansi2knr$/)
+       {
+         # An option like "../lib/ansi2knr" is allowed.  With no
+         # path prefix, we assume the required programs are in this
+         # directory.  We save the actual option for later.
+         $options->{'ansi2knr'} = [$_, $where];
+       }
+      elsif ($_ eq 'no-installman' || $_ eq 'no-installinfo'
+            || $_ eq 'dist-shar' || $_ eq 'dist-zip'
+            || $_ eq 'dist-tarZ' || $_ eq 'dist-bzip2'
+            || $_ eq 'no-dist-gzip'
+            || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
+            || $_ eq 'readme-alpha' || $_ eq 'check-news'
+            || $_ eq 'subdir-objects' || $_ eq 'nostdinc'
+            || $_ eq 'no-exeext' || $_ eq 'no-define'
+            || $_ eq 'std-options'
+            || $_ eq 'cygnus' || $_ eq 'no-dependencies')
+       {
+         # Explicitly recognize these.
+       }
+      elsif (/^\d+\.\d+(?:\.\d+)?[a-z]?(?:-[A-Za-z0-9]+)?$/)
+       {
+         # Got a version number.
+         if (Automake::Version::check ($VERSION, $&))
+           {
+             error ($where, "require Automake $_, but have $VERSION",
+                    uniq_scope => US_GLOBAL);
+             return 1;
+           }
+       }
+      elsif (/^(?:--warnings=|-W)(.*)$/)
+       {
+         foreach my $cat (split (',', $1))
+           {
+             msg 'unsupported', $where, "unknown warning category `$cat'"
+               if switch_warning $cat;
+           }
+       }
+      else
+       {
+         error ($where, "option `$_' not recognized",
+                uniq_scope => US_GLOBAL);
+         return 1;
+       }
+    }
+  return 0;
+}
+
+sub process_option_list ($@)
+{
+  my ($where, @list) = @_;
+  return _process_option_list (%_options, $where, @list);
+}
+
+sub process_global_option_list ($@)
+{
+  my ($where, @list) = @_;
+  return _process_option_list (%_global_options, $where, @list);
+}
+
+=item C<set_strictness ($name)>
+
+Set the current strictness level.
+C<$name> should be one of C<'foreign'>, C<'gnu'>, or C<'gnits'>.
+
+=cut
+
+# Set strictness.
+sub set_strictness ($)
+{
+  $strictness_name = $_[0];
+
+  Automake::ChannelDefs::set_strictness ($strictness_name);
+
+  if ($strictness_name eq 'gnu')
+    {
+      $strictness = GNU;
+    }
+  elsif ($strictness_name eq 'gnits')
+    {
+      $strictness = GNITS;
+    }
+  elsif ($strictness_name eq 'foreign')
+    {
+      $strictness = FOREIGN;
+    }
+  else
+    {
+      prog_error "level `$strictness_name' not recognized\n";
+    }
+}
+
+1;
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
index 02eaec661db57a3824f1e00df1bf4d61d92e7907..03e1d2b64371161c21becbccad33f877c2d98025 100644 (file)
--- a/stamp-vti
+++ b/stamp-vti
@@ -1,4 +1,4 @@
-@set UPDATED 5 August 2003
-@set UPDATED-MONTH August 2003
+@set UPDATED 31 July 2003
+@set UPDATED-MONTH July 2003
 @set EDITION 1.7a
 @set VERSION 1.7a
index 02eaec661db57a3824f1e00df1bf4d61d92e7907..03e1d2b64371161c21becbccad33f877c2d98025 100644 (file)
@@ -1,4 +1,4 @@
-@set UPDATED 5 August 2003
-@set UPDATED-MONTH August 2003
+@set UPDATED 31 July 2003
+@set UPDATED-MONTH July 2003
 @set EDITION 1.7a
 @set VERSION 1.7a
This page took 0.062104 seconds and 5 git commands to generate.