automake-ng
[Top][All Lists]
Advanced

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

[Automake-NG] [PATCH v2 1/2] var: format all options in the Makefile.in


From: Paolo Bonzini
Subject: [Automake-NG] [PATCH v2 1/2] var: format all options in the Makefile.in output
Date: Wed, 22 Aug 2012 12:44:41 +0200

Make sure that Makefile.in includes all options, both from
configure.ac and from Makefile.am.  This is useful to further
process options at Make execution time via GNU Make functions.

* automake.in (handle_options): Define am.automake-options.
* lib/Automake/Options.pm ($_version_regex): New global.
(_process_option_list): Use it.
(format_options): New function.
---
 automake.in             |  1 +
 lib/Automake/Options.pm | 43 +++++++++++++++++++++++++++++++--
 t/option-out.sh         | 63 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 file modificati, 105 inserzioni(+), 2 rimozioni(-)
 create mode 100755 t/option-out.sh

diff --git a/automake.in b/automake.in
index 1799875..96873f4 100644
--- a/automake.in
+++ b/automake.in
@@ -1190,6 +1190,7 @@ sub handle_options
       set_option ('check-news', INTERNAL);
     }
 
+  define_variable ('am.automake-options', INTERNAL, format_options ());
   return 0;
 }
 
diff --git a/lib/Automake/Options.pm b/lib/Automake/Options.pm
index 77e9cbd..8dd8176 100644
--- a/lib/Automake/Options.pm
+++ b/lib/Automake/Options.pm
@@ -28,7 +28,7 @@ use vars qw (@ISA @EXPORT);
 @ISA = qw (Exporter);
 @EXPORT = qw (option global_option
               set_option set_global_option
-              unset_option unset_global_option
+              unset_option unset_global_option format_options
               process_option_list process_global_option_list
               set_strictness $strictness $strictness_name
               &FOREIGN &GNU &GNITS);
@@ -81,6 +81,7 @@ use vars '$_options_processed';
 # Whether process_global_option_list has already been called.
 use vars '$_global_options_processed';
 
+use vars '$_version_regex';
 =head2 Constants
 
 =over 4
@@ -245,6 +246,14 @@ Return 1 on error, 0 otherwise.
 
 =cut
 
+=item C<format_options ()>
+
+Formats the combination of the current global and local options,
+returning the result as a string.  The version options are
+replaced by the version of Automake that produced the Makefile.
+
+=cut
+
 # _option_must_be_from_configure ($OPTION, $WHERE)
 # ----------------------------------------------
 # Check that the $OPTION given in location $WHERE is specified with
@@ -336,7 +345,7 @@ sub _process_option_list (\%@)
               last;
             }
         }
-      elsif (/^\d+\.\d+(?:\.\d+)?[a-z]?(?:-[A-Za-z0-9]+)?$/)
+      elsif ($_ =~ $_version_regex)
         {
           # Got a version number.
           if (Automake::Version::check ($VERSION, $&))
@@ -370,6 +379,35 @@ sub _process_option_list (\%@)
   return 0;
 }
 
+sub format_options()
+{
+  my @out = ($VERSION, 'ng');
+
+  foreach (keys %_options)
+    {
+      if ($_ eq 'filename-length-max')
+        {
+          push @out, $_options{$_}->[1];
+        }
+      elsif ($_ =~ $_version_regex || $_ eq 'ng' )
+        {
+          # AUTOMAKE_OPTIONS in Makefile.in includes the actual version
+          # number, not the required one.
+          next;
+        }
+      elsif (/^(?:--warnings=|-W)(.*)$/)
+        {
+          next;
+        }
+      else
+        {
+          push @out, $_;
+        }
+    }
+
+  return join (' ', @out);
+}
+
 sub process_option_list (@)
 {
   prog_error "local options already processed"
@@ -418,6 +456,7 @@ sub set_strictness ($)
     }
 }
 
+$_version_regex = qr/^\d+\.\d+(?:\.\d+)?[a-z]?(?:-[A-Za-z0-9]+)?$/;
 1;
 
 ### Setup "GNU" style for perl-mode and cperl-mode.
diff --git a/t/option-out.sh b/t/option-out.sh
new file mode 100755
index 0000000..89784df
--- /dev/null
+++ b/t/option-out.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2012 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, see <http://www.gnu.org/licenses/>.
+
+# Automake-NG should set Makefile.in's am.automake-options variable to
+# the full set of options, from both configure and Makefile.am.  It
+# should also include the current version and the "ng" token.
+
+. ./defs || exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE([gnu foreign])
+AC_CONFIG_FILES([Makefile])
+END
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+grep automake-options.*=.*ng Makefile.in
+grep automake-options.*=.*gnu Makefile.in
+grep automake-options.*=.*foreign Makefile.in
+
+# Test combination of configure and Makefile.am values
+echo AUTOMAKE_OPTIONS = serial-tests > Makefile.am
+$AUTOMAKE
+grep automake-options.*=.*ng Makefile.in
+grep automake-options.*=.*gnu Makefile.in
+grep automake-options.*=.*foreign Makefile.in
+grep automake-options.*=.*serial-tests Makefile.in
+
+# Test concatenation of Makefile.am values
+echo AUTOMAKE_OPTIONS += color-tests >> Makefile.am
+$AUTOMAKE
+grep automake-options.*=.*ng Makefile.in
+grep automake-options.*=.*gnu Makefile.in
+grep automake-options.*=.*foreign Makefile.in
+grep automake-options.*=.*serial-tests Makefile.in
+grep automake-options.*=.*color-tests Makefile.in
+
+# Conditional assignments must be rejected.
+echo 'AM_CONDITIONAL([FOO], [true])' >> configure.ac
+cat > Makefile.am <<END
+if FOO
+AUTOMAKE_OPTIONS = serial-tests
+endif
+END
+
+AUTOMAKE_fails
-- 
1.7.11.2





reply via email to

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