automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

71-getopt.patch


From: Akim Demaille
Subject: 71-getopt.patch
Date: Sun, 25 Feb 2001 14:41:27 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        
        * automake.in: Don't pass arguments to...
        (&parse_arguments): Work on @ARGV.
        Use Getopt.
        Add support for `-f', `-V', `-A', `-h'.
        (&version): New.
        (&usage): Update.
        
Index: automake.in
--- automake.in Sat, 24 Feb 2001 17:23:00 +0100 akim (am/f/39_automake.i 1.78 
755)
+++ automake.in Sun, 25 Feb 2001 13:17:44 +0100 akim (am/f/39_automake.i 1.78 
755)
@@ -389,7 +389,7 @@
 
 
 # Parse command line.
-&parse_arguments (@ARGV);
+&parse_arguments;
 
 # Do configure.ac scan only once.
 &scan_autoconf_files;
@@ -507,129 +507,54 @@ sub backname ($)
 ################################################################
 
 # Parse command line.
-sub parse_arguments
+sub parse_arguments ()
 {
-    my (@arglist) = @_;
-
     # Start off as gnu.
     &set_strictness ('gnu');
 
-    while (@arglist)
-    {
-       if ($arglist[0] eq "--version")
-       {
-           print "automake (GNU $PACKAGE) $VERSION\n\n";
-           print "Copyright 2000, 2001 Free Software Foundation, Inc.\n";
-           print "This is free software; see the source for copying 
conditions.  There is NO\n";
-           print "warranty; not even for MERCHANTABILITY or FITNESS FOR A 
PARTICULAR PURPOSE.\n\n";
-           print "Written by Tom Tromey <address@hidden>\n";
-
-           exit 0;
-       }
-       elsif ($arglist[0] eq "--help")
-       {
-           &usage;
-       }
-       elsif ($arglist[0] =~ /^--amdir=(.+)$/)
-       {
-           $am_dir = $1;
-       }
-       elsif ($arglist[0] eq '--amdir')
-       {
-           &require_argument (@arglist);
-           shift (@arglist);
-           $am_dir = $arglist[0];
-       }
-       elsif ($arglist[0] eq '--gnu')
-       {
-           &set_strictness ('gnu');
-       }
-       elsif ($arglist[0] eq '--gnits')
-       {
-           &set_strictness ('gnits');
-       }
-       elsif ($arglist[0] eq '--cygnus')
-       {
-           $cygnus_mode = 1;
-       }
-       elsif ($arglist[0] eq '--foreign')
-       {
-           &set_strictness ('foreign');
-       }
-       elsif ($arglist[0] eq '--include-deps')
-       {
-           $cmdline_use_dependencies = 1;
-       }
-       elsif ($arglist[0] eq '--ignore-deps' || $arglist[0] eq '-i')
-       {
-           $cmdline_use_dependencies = 0;
-       }
-       elsif ($arglist[0] eq '--no-force')
-       {
-           $force_generation = 0;
-       }
-       elsif ($arglist[0] eq '--force-missing')
-       {
-           $force_missing = 1;
-       }
-       elsif ($arglist[0] =~ /^--output-dir=(.*)$/)
-       {
-           # Set output directory.
-           $output_directory = $1;
-       }
-       elsif ($arglist[0] eq '--output-dir' || $arglist[0] eq '-o')
-       {
-           &require_argument (@arglist);
-           shift (@arglist);
-           $output_directory = $arglist[0];
-       }
-       elsif ($arglist[0] eq '--add-missing' || $arglist[0] eq '-a')
-       {
-           $add_missing = 1;
-       }
-       elsif ($arglist[0] eq '--copy' || $arglist[0] eq '-c')
-       {
-           $copy_missing = 1;
-       }
-       elsif ($arglist[0] eq '--verbose' || $arglist[0] eq '-v')
-       {
-           $verbose = 1;
-       }
-       elsif ($arglist[0] eq '--')
-       {
-           # Stop option processing.
-           shift (@arglist);
-           push (@input_files, @arglist);
-           last;
-       }
-       elsif ($arglist[0] =~ /^-/)
-       {
-           die "automake: unrecognized option -- \`$arglist[0]'\nTry 
\`automake --help' for more information.\n";
-       }
-       else
-       {
-           # 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 (/:/, $arglist[0]);
-           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.  FIXME: should
-               # be error if .in is missing.
-               $input =~ s/\.in$//;
-           }
-           push (@input_files, $input);
-           $output_files{$input} = join (':', ($local, @rest));
+    use Getopt::Long;
+    Getopt::Long::config ("bundling");
+    Getopt::Long::GetOptions
+      (
+       'V|version'     => \&version,
+       'h|help'        => \&usage,
+       'A|amdir:s'     => \$am_dir,
+       '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'     => \$verbose
+      )
+       or exit 1;
+
+    foreach my $arg (@ARGV)
+    {
+      # 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 die "automake: invalid input file name \`$arg'\n.";
        }
-
-       shift (@arglist);
+      push (@input_files, $input);
+      $output_files{$input} = join (':', ($local, @rest));
     }
 
     # Take global strictness from whatever we currently have set.
@@ -637,14 +562,6 @@ sub parse_arguments
     $default_strictness_name = $strictness_name;
 }
 
-# Ensure argument exists, or die.
-sub require_argument
-{
-    my ($arg, @arglist) = @_;
-    die "automake: no argument given for option \`$arg'\n"
-       if ! @arglist;
-}
-
 ################################################################
 
 # Generate a Makefile.in given the name of the corresponding Makefile and
@@ -7650,11 +7567,11 @@ sub usage
 Generate Makefile.in for configure from Makefile.am
 
 Operation modes:
-      --help             print this help, then exit
-      --version          print version number, then exit
+  -h, --help             print this help, then exit
+  -V, --version          print version number, then exit
   -v, --verbose          verbosely list files processed
   -o, --output-dir=DIR   put generated Makefile.in's into DIR
-      --no-force        only update Makefile.in's that are out of date
+      --no-force         only update Makefile.in's that are out of date
 
 Dependency tracking:
   -i, --ignore-deps   disable dependency tracking code
@@ -7668,9 +7585,9 @@ sub usage
 
 Library files:
   -a, --add-missing     add missing standard files to package
-      --amdir=DIR       directory storing config files
+  -A, --amdir=DIR       directory storing config files
   -c, --copy            with -a, copy missing files (default is symlink)
-      --force-missing   force update of standard files
+  -f, --force-missing   force update of standard files
 EOF
 
     my ($last, @lcomm);
@@ -7712,4 +7629,22 @@ sub usage
     print "\nReport bugs to <address@hidden>.\n";
 
     exit 0;
+}
+
+# &version ()
+# -----------
+# Print version information
+sub version ()
+{
+  print <<EOF;
+automake (GNU $PACKAGE) $VERSION
+Written by Tom Tromey <address@hidden>.
+
+Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+EOF
+  exit 0;
+
 }
Index: automake.texi
--- automake.texi Sat, 17 Feb 2001 17:56:59 +0100 akim (am/f/34_automake.t 1.5 
644)
+++ automake.texi Sun, 25 Feb 2001 13:11:28 +0100 akim (am/f/34_automake.t 1.5 
644)
@@ -798,7 +798,9 @@ @node Invoking Automake, configure, Exam
 make a symbolic link pointing to its own copy of the missing file; this
 can be changed with @code{--copy}.
 
address@hidden address@hidden
address@hidden -A @var{dir}
address@hidden -A
address@hidden address@hidden
 @opindex --amdir
 Look for Automake data files in directory @var{dir} instead of in the
 installation directory.  This is typically used for debugging.
@@ -810,7 +812,9 @@ @node Invoking Automake, configure, Exam
 dist}; it should not be used otherwise.
 
 @item -c
address@hidden --copy
address@hidden -c
address@hidden --copy
address@hidden --copy
 When used with @code{--add-missing}, causes installed files to be
 copied.  The default is to make a symbolic link.
 
@@ -819,7 +823,9 @@ @node Invoking Automake, configure, Exam
 Causes the generated @file{Makefile.in}s to follow Cygnus rules, instead
 of GNU or Gnits rules.  For more information, see @ref{Cygnus}.
 
address@hidden --force-missing
address@hidden -f
address@hidden -f
address@hidden --force-missing
 @opindex --force-missing
 When used with @code{--add-missing}, causes standard files to be rebuilt
 even if they already exist in the source tree.  This involves removing
@@ -841,7 +847,8 @@ @node Invoking Automake, configure, Exam
 Set the global strictness to @samp{gnu}.  For more information, see
 @ref{Gnits}.  This is the default strictness.
 
address@hidden --help
address@hidden -h
address@hidden --help
 @opindex --help
 Print a summary of the command line options and exit.
 
@@ -895,6 +902,8 @@ @node Invoking Automake, configure, Exam
 Cause Automake to print information about which files are being read or
 created.
 
address@hidden -V
address@hidden -V
 @item --version
 @opindex --version
 Print the version number of Automake and exit.
Index: stamp-vti
--- stamp-vti Sat, 17 Feb 2001 17:56:59 +0100 akim (am/f/36_stamp-vti 1.5 644)
+++ stamp-vti Sun, 25 Feb 2001 13:16:31 +0100 akim (am/f/36_stamp-vti 1.5 644)
@@ -1,4 +1,4 @@
address@hidden UPDATED 15 February 2001
address@hidden UPDATED 25 February 2001
 @set UPDATED-MONTH February 2001
 @set EDITION 1.4e
 @set VERSION 1.4e
Index: version.texi
--- version.texi Sat, 17 Feb 2001 17:56:59 +0100 akim (am/f/35_version.te 1.5 
644)
+++ version.texi Sun, 25 Feb 2001 13:16:31 +0100 akim (am/f/35_version.te 1.5 
644)
@@ -1,4 +1,4 @@
address@hidden UPDATED 15 February 2001
address@hidden UPDATED 25 February 2001
 @set UPDATED-MONTH February 2001
 @set EDITION 1.4e
 @set VERSION 1.4e



reply via email to

[Prev in Thread] Current Thread [Next in Thread]