Re: Implementing notrans_man_MANS

View: New views
20 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

Parent Message unknown Re: Implementing notrans_man_MANS

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 19 Feb 2008, Ralf Wildenhues wrote:

>> How should I proceed, once all that is finished? Email to you and/or
>> automake bugzilla?
>
> automake-patches@... is best.
>
>> Are unified diffs against the autoamke-1.10.1 tarball OK?
>
> Yes.
>
>> What about re-indenting existing code?
>
> Please as a separate patch if possible, and please following the
> already-used style.
Hallo Ralf,

attached are five patches (the diffs are actually against the result of
applying your patch for PR 516 from 2008-01-22):

1. patch-02-notrans_MANS-reindent:

Reindentation of a section in automake.in, anticipating an additional
foreach loop (it was less work to do this first).

2. patch-03-notrans_MANS-impl:

The actual implementation of `notrans_'. The patch looks awful but the
logic in the resulting patched file should be reasonably clear.

At the same time the dependencies for `install-man%SECTION%' have been
revised. All make variables not used in Makefile.am are omitted from the
install/uninstall rules. All those used in the rules also appear as
dependencies.

One consequence: "make dist_man_MANS='bar.1 baz.5' install-man" will only
work well if `dist_man_MANS' is used in Makefile.am and Automake has
generated the relevant (!notrans_) part of the install-man1 and
install-man5 rules. So ... ?

3. patch-04-notrans_MANS-doc:

Texinfo documentation for the notrans_ prefix.

4. patch-05-notrans_MANS-test:

Two new test cases for missing dependencies and the notrans_ prefix.

5. automake-1.10.1-ChangeLog:

Proposed ChangeLog entry.

==============

Please feel free to revise the wording in texinfo, comments, and/or
ChangeLog.

regards
Peter Breitenlohner <peb@...>
        Prepare for implementation of notrans_man_MANS: anticipate
        an additional foreach loop and reindent accordingly.

        Note: `diff -b' yields nothing.

diff -ur -N automake-1.10.1.orig/automake.in automake-1.10.1/automake.in
--- automake-1.10.1.orig/automake.in 2008-01-21 23:11:41.000000000 +0100
+++ automake-1.10.1/automake.in 2008-02-19 18:07:41.000000000 +0100
@@ -3366,42 +3366,42 @@
   my (%sections, %vlist);
   # We handle nodist_ for uniformity.  man pages aren't distributed
   # by default so it isn't actually very important.
-  foreach my $pfx ('', 'dist_', 'nodist_')
-    {
-      # Add more sections as needed.
-      foreach my $section ('0'..'9', 'n', 'l')
+      foreach my $pfx ('', 'dist_', 'nodist_')
  {
-  my $varname = $pfx . 'man' . $section . '_MANS';
-  if (var ($varname))
+  # Add more sections as needed.
+  foreach my $section ('0'..'9', 'n', 'l')
     {
-      $sections{$section} = 1;
-      $varname = '$(' . $varname . ')';
-      $vlist{$varname} = 1;
+      my $varname = $pfx . 'man' . $section . '_MANS';
+      if (var ($varname))
+ {
+  $sections{$section} = 1;
+  $varname = '$(' . $varname . ')';
+  $vlist{$varname} = 1;
 
-      &push_dist_common ($varname)
- if $pfx eq 'dist_';
+  &push_dist_common ($varname)
+    if $pfx eq 'dist_';
+ }
     }
- }
 
-      my $varname = $pfx . 'man_MANS';
-      my $var = var ($varname);
-      if ($var)
- {
-  foreach ($var->value_as_list_recursive)
+  my $varname = $pfx . 'man_MANS';
+  my $var = var ($varname);
+  if ($var)
     {
-      # A page like `foo.1c' goes into man1dir.
-      if (/\.([0-9a-z])([a-z]*)$/)
+      foreach ($var->value_as_list_recursive)
  {
-  $sections{$1} = 1;
+  # A page like `foo.1c' goes into man1dir.
+  if (/\.([0-9a-z])([a-z]*)$/)
+    {
+      $sections{$1} = 1;
+    }
  }
-    }
 
-  $varname = '$(' . $varname . ')';
-  $vlist{$varname} = 1;
-  &push_dist_common ($varname)
-    if $pfx eq 'dist_';
+      $varname = '$(' . $varname . ')';
+      $vlist{$varname} = 1;
+      &push_dist_common ($varname)
+ if $pfx eq 'dist_';
+    }
  }
-    }
 
   return unless %sections;
 

diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/automake.in automake-1.10.1/automake.in
--- automake-1.10.1.orig/automake.in 2008-02-19 18:07:41.000000000 +0100
+++ automake-1.10.1/automake.in 2008-02-20 01:52:26.000000000 +0100
@@ -3363,27 +3363,38 @@
   # Find all the sections in use.  We do this by first looking for
   # "standard" sections, and then looking for any additional
   # sections used in man_MANS.
-  my (%sections, %vlist);
+  my (%sections, %nsections, %tsections, %nvlist, %tvlist, %nsvlist, %tsvlist);
   # We handle nodist_ for uniformity.  man pages aren't distributed
   # by default so it isn't actually very important.
+  foreach my $npfx ('', 'notrans_')
+    {
       foreach my $pfx ('', 'dist_', 'nodist_')
  {
   # Add more sections as needed.
   foreach my $section ('0'..'9', 'n', 'l')
     {
-      my $varname = $pfx . 'man' . $section . '_MANS';
+      my $varname = $npfx . $pfx . 'man' . $section . '_MANS';
       if (var ($varname))
  {
   $sections{$section} = 1;
   $varname = '$(' . $varname . ')';
-  $vlist{$varname} = 1;
+  if ($npfx eq 'notrans_')
+    {
+      $nsections{$section} = 1;
+      $nsvlist{$varname} = 1;
+    }
+  else
+    {
+      $tsections{$section} = 1;
+      $tsvlist{$varname} = 1;
+    }
 
   &push_dist_common ($varname)
     if $pfx eq 'dist_';
  }
     }
 
-  my $varname = $pfx . 'man_MANS';
+  my $varname = $npfx . $pfx . 'man_MANS';
   my $var = var ($varname);
   if ($var)
     {
@@ -3393,28 +3404,81 @@
   if (/\.([0-9a-z])([a-z]*)$/)
     {
       $sections{$1} = 1;
+      if ($npfx eq 'notrans_')
+ {
+  $nsections{$1} = 1;
+ }
+      else
+ {
+  $tsections{$1} = 1;
+ }
     }
  }
 
       $varname = '$(' . $varname . ')';
-      $vlist{$varname} = 1;
+      if ($npfx eq 'notrans_')
+ {
+  $nvlist{$varname} = 1;
+ }
+      else
+ {
+  $tvlist{$varname} = 1;
+ }
       &push_dist_common ($varname)
  if $pfx eq 'dist_';
     }
  }
+    }
 
   return unless %sections;
 
+  # Build section independent variables (see mans.am).
+  my $notry = %nvlist;
+  my @notrz = sort keys %nvlist;
+  my $dotry = %tvlist;
+  my @dotrz = sort keys %tvlist;
+
   # Now for each section, generate an install and uninstall rule.
   # Sort sections so output is deterministic.
   foreach my $section (sort keys %sections)
     {
+      # Build section dependent variables (see mans.am).
+      my $notr = $notry || exists $nsections{$section};
+      my $dotr = $dotry || exists $tsections{$section};
+      my (%nslist, %tslist);
+      my $expr = 'man' . $section . '_MANS';
+      foreach my $varname (keys %nsvlist)
+ {
+  if ($varname =~ /$expr/)
+    {
+      $nslist{$varname} = 1;
+    }
+ }
+      foreach my $varname (keys %tsvlist)
+ {
+  if ($varname =~ /$expr/)
+    {
+      $tslist{$varname} = 1;
+    }
+ }
+      my @notrx = sort keys %nslist;
+      my @dotrx = sort keys %tslist;
+      my @deps = sort (keys %nvlist, keys %tvlist, keys %nslist, keys %tslist);
       $output_rules .= &file_contents ('mans',
        new Automake::Location,
-       SECTION => $section);
+       SECTION => $section,
+       DEPS => "@deps",
+       NOTR => $notr,
+       NOTRX => "@notrx",
+       NOTRY => $notry,
+       NOTRZ => "@notrz",
+       DOTR => $dotr,
+       DOTRX => "@dotrx",
+       DOTRY => $dotry,
+       DOTRZ => "@dotrz");
     }
 
-  my @mans = sort keys %vlist;
+  my @mans = sort (keys %nvlist, keys %tvlist, keys %nsvlist, keys %tsvlist);
   $output_vars .= file_contents ('mans-vars',
  new Automake::Location,
  MANS => "@mans");
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/lib/am/mans.am automake-1.10.1/lib/am/mans.am
--- automake-1.10.1.orig/lib/am/mans.am 2008-02-20 09:38:10.000000000 +0100
+++ automake-1.10.1/lib/am/mans.am 2008-02-20 00:50:53.000000000 +0100
@@ -16,6 +16,20 @@
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
 
+## Parameters:
+## SECTION string man section
+## DEPS string dependencies
+##
+## NOTR bool have notrans_ MANS
+## NOTRX string notrans_ man%SECTION%_MANS (if any)
+## NOTRY bool have notrans_ man_MANS
+## NOTRZ string notrans_ man_MANS
+##
+## DOTR bool same
+## DOTRX string  as above
+## DOTRY bool    without
+## DOTRZ string      notrans_
+
 man%SECTION%dir = $(mandir)/man%SECTION%
 
 ## ------------ ##
@@ -29,37 +43,65 @@
 ?INSTALL-MAN?install-data-am: install-man
 ?INSTALL-MAN?am__installdirs += "$(DESTDIR)$(man%SECTION%dir)"
 .PHONY install-man: install-man%SECTION%
-install-man%SECTION%: $(man%SECTION%_MANS) $(man_MANS)
+install-man%SECTION%: %DEPS%
  @$(NORMAL_INSTALL)
  test -z "$(man%SECTION%dir)" || $(MKDIR_P) "$(DESTDIR)$(man%SECTION%dir)"
- @list='$(man%SECTION%_MANS) $(dist_man%SECTION%_MANS) $(nodist_man%SECTION%_MANS)'; \
+## Handle MANS with notrans_ prefix
+?NOTR? @list='%NOTRX%'; \
+## Extract all items from notrans_man_MANS that should go in this section.
+## This must be done dynamically to support conditionals.
+?NOTRY? l2='%NOTRZ%'; \
+?NOTRY? for i in $$l2; do \
+?NOTRY?  case "$$i" in \
+## Have to accept files like `foo.1c'.
+?NOTRY?    *.%SECTION%*) list="$$list $$i" ;; \
+?NOTRY?  esac; \
+?NOTRY? done; \
+?NOTR? for i in $$list; do \
+## Find the file.
+?NOTR?  if test -f $$i; then file=$$i; \
+?NOTR?  else file=$(srcdir)/$$i; fi; \
+## Change the extension if needed.
+?NOTR?  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+?NOTR?  case "$$ext" in \
+?NOTR?    %SECTION%*) ;; \
+?NOTR?    *) ext='%SECTION%' ;; \
+?NOTR?  esac; \
+## Extract basename of man page and append extension.
+?NOTR?  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+?NOTR?  inst=`echo $$inst | sed -e 's/^.*\///'`.$$ext; \
+?NOTR?  echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
+?NOTR?  $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
+?NOTR? done
+## Handle MANS without notrans_ prefix
+?DOTR? @list='%DOTRX%'; \
 ## Extract all items from man_MANS that should go in this section.
 ## This must be done dynamically to support conditionals.
- l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
- for i in $$l2; do \
-  case "$$i" in \
+?DOTRY? l2='%DOTRZ%'; \
+?DOTRY? for i in $$l2; do \
+?DOTRY?  case "$$i" in \
 ## Have to accept files like `foo.1c'.
-    *.%SECTION%*) list="$$list $$i" ;; \
-  esac; \
- done; \
- for i in $$list; do \
+?DOTRY?    *.%SECTION%*) list="$$list $$i" ;; \
+?DOTRY?  esac; \
+?DOTRY? done; \
+?DOTR? for i in $$list; do \
 ## Find the file.
-  if test -f $$i; then file=$$i; \
-  else file=$(srcdir)/$$i; fi; \
+?DOTR?  if test -f $$i; then file=$$i; \
+?DOTR?  else file=$(srcdir)/$$i; fi; \
 ## Change the extension if needed.
-  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
-  case "$$ext" in \
-    %SECTION%*) ;; \
-    *) ext='%SECTION%' ;; \
-  esac; \
+?DOTR?  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+?DOTR?  case "$$ext" in \
+?DOTR?    %SECTION%*) ;; \
+?DOTR?    *) ext='%SECTION%' ;; \
+?DOTR?  esac; \
 ## Extract basename of man page and run it through the program rename
 ## transform.
-  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
-  inst=`echo $$inst | sed -e 's/^.*\///'`; \
-  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
-  echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
-  $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
- done
+?DOTR?  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+?DOTR?  inst=`echo $$inst | sed -e 's/^.*\///'`; \
+?DOTR?  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+?DOTR?  echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
+?DOTR?  $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
+?DOTR? done
 
 
 ## -------------- ##
@@ -72,28 +114,53 @@
 .PHONY uninstall-man: uninstall-man%SECTION%
 uninstall-man%SECTION%:
  @$(NORMAL_UNINSTALL)
- @list='$(man%SECTION%_MANS) $(dist_man%SECTION%_MANS) $(nodist_man%SECTION%_MANS)'; \
+## Handle MANS with notrans_ prefix
+?NOTR? @list='%NOTRX%'; \
+## Extract all items from notrans_man_MANS that should go in this section.
+## This must be done dynamically to support conditionals.
+?NOTRY? l2='%NOTRZ%'; \
+?NOTRY? for i in $$l2; do \
+?NOTRY?  case "$$i" in \
+## Have to accept files like `foo.1c'.
+?NOTRY?    *.%SECTION%*) list="$$list $$i" ;; \
+?NOTRY?  esac; \
+?NOTRY? done; \
+?NOTR? for i in $$list; do \
+## Change the extension if needed.
+?NOTR?  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+?NOTR?  case "$$ext" in \
+?NOTR?    %SECTION%*) ;; \
+?NOTR?    *) ext='%SECTION%' ;; \
+?NOTR?  esac; \
+## Extract basename of man page and append extension.
+?NOTR?  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+?NOTR?  inst=`echo $$inst | sed -e 's/^.*\///'`.$$ext; \
+?NOTR?  echo " rm -f '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
+?NOTR?  rm -f "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
+?NOTR? done
+## Handle MANS without notrans_ prefix
+?DOTR? @list='%DOTRX%'; \
 ## Extract all items from man_MANS that should go in this section.
 ## This must be done dynamically to support conditionals.
- l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
- for i in $$l2; do \
-  case "$$i" in \
+?DOTRY? l2='%DOTRZ%'; \
+?DOTRY? for i in $$l2; do \
+?DOTRY?  case "$$i" in \
 ## Have to accept files like `foo.1c'.
-    *.%SECTION%*) list="$$list $$i" ;; \
-  esac; \
- done; \
- for i in $$list; do \
+?DOTRY?    *.%SECTION%*) list="$$list $$i" ;; \
+?DOTRY?  esac; \
+?DOTRY? done; \
+?DOTR? for i in $$list; do \
 ## Change the extension if needed.
-  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
-  case "$$ext" in \
-    %SECTION%*) ;; \
-    *) ext='%SECTION%' ;; \
-  esac; \
+?DOTR?  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+?DOTR?  case "$$ext" in \
+?DOTR?    %SECTION%*) ;; \
+?DOTR?    *) ext='%SECTION%' ;; \
+?DOTR?  esac; \
 ## Extract basename of man page and run it through the program rename
 ## transform.
-  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
-  inst=`echo $$inst | sed -e 's/^.*\///'`; \
-  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
-  echo " rm -f '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
-  rm -f "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
- done
+?DOTR?  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+?DOTR?  inst=`echo $$inst | sed -e 's/^.*\///'`; \
+?DOTR?  inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+?DOTR?  echo " rm -f '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
+?DOTR?  rm -f "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
+?DOTR? done

diff -ur -N automake-1.10.1.orig/doc/automake.texi automake-1.10.1/doc/automake.texi
--- automake-1.10.1.orig/doc/automake.texi 2008-01-21 23:41:02.000000000 +0100
+++ automake-1.10.1/doc/automake.texi 2008-02-19 20:52:29.000000000 +0100
@@ -1962,8 +1962,9 @@
 
 Some primaries also allow additional prefixes that control other
 aspects of @command{automake}'s behavior.  The currently defined prefixes
-are @samp{dist_}, @samp{nodist_}, and @samp{nobase_}.  These prefixes
-are explained later (@pxref{Program and Library Variables}).
+are @samp{dist_}, @samp{nodist_}, @samp{nobase_}, and @samp{notrans_}.
+These prefixes are explained later (@pxref{Program and Library Variables})
+(@pxref{Man pages}).
 
 
 @node Canonicalization
@@ -7633,6 +7634,34 @@
 The @code{nobase_} prefix is meaningless for man pages and is
 disallowed.
 
+@vindex notrans_
+@cindex @code{notrans_} prefix
+@cindex Man page renaming, avoiding
+@cindex Avoiding man page renaming
+
+The GNU Build System provides means to automatically rename executables
+before they are installed.  By default, the same renaming rules (if any) are
+applied to the basenames of man pages.  However, this can be avoided by use
+of the @code{notrans_} prefix.  For instance here is how to install two man
+pages for an executable @samp{foo} (to be renamed) allowing to access a
+library function @samp{foo()} (not to be renamed) from the command line.
+
+@example
+man1_MANS = foo.1
+notrans_man3_MANS = foo.3
+@end example
+
+@cindex @code{notrans_} and @code{dist_} or @code{nodist_}
+@cindex @code{dist_} and @code{notrans_}
+@cindex @code{nodist_} and @code{notrans_}
+
+@samp{notrans_} must be specified first when used in conjunction with
+either @samp{dist_} or @samp{nodist_} (@pxref{Dist}).  For instance:
+
+@example
+notrans_dist_man_MANS = foo.3
+@end example
+
 
 @node Install
 @chapter What Gets Installed

diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/tests/Makefile.am automake-1.10.1/tests/Makefile.am
--- automake-1.10.1.orig/tests/Makefile.am 2008-02-20 09:38:10.000000000 +0100
+++ automake-1.10.1/tests/Makefile.am 2008-02-20 11:28:35.000000000 +0100
@@ -362,6 +362,7 @@
 man.test \
 man2.test \
 man3.test \
+man4.test \
 mclean.test \
 mdate.test \
 mdate2.test \
@@ -393,6 +394,7 @@
 noinstdir.test \
 nolink.test \
 nostdinc.test \
+notrans.test \
 number.test \
 objc.test \
 objc2.test \
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/tests/Makefile.in automake-1.10.1/tests/Makefile.in
--- automake-1.10.1.orig/tests/Makefile.in 2008-02-20 09:38:10.000000000 +0100
+++ automake-1.10.1/tests/Makefile.in 2008-02-20 11:28:38.000000000 +0100
@@ -494,6 +494,7 @@
 man.test \
 man2.test \
 man3.test \
+man4.test \
 mclean.test \
 mdate.test \
 mdate2.test \
@@ -525,6 +526,7 @@
 noinstdir.test \
 nolink.test \
 nostdinc.test \
+notrans.test \
 number.test \
 objc.test \
 objc2.test \
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/tests/man4.test automake-1.10.1/tests/man4.test
--- automake-1.10.1.orig/tests/man4.test 1970-01-01 01:00:00.000000000 +0100
+++ automake-1.10.1/tests/man4.test 2008-02-20 10:07:12.000000000 +0100
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2008  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 3, 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/>.
+
+# Check that dist_man1_MANS appears as dependency for install-man1.
+
+. ./defs || exit 1
+
+set -e
+
+cat > Makefile.am << 'END'
+dist_man_MANS = foo.1
+END
+
+cat >>configure.in <<'END'
+AC_OUTPUT
+END
+
+: > foo.1
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^install-man1:' Makefile.in | grep '\$(dist_man_MANS)'
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/tests/notrans.test automake-1.10.1/tests/notrans.test
--- automake-1.10.1.orig/tests/notrans.test 1970-01-01 01:00:00.000000000 +0100
+++ automake-1.10.1/tests/notrans.test 2008-02-20 11:25:40.000000000 +0100
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2008  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 3, 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/>.
+
+# Check notrans_ prefix for MANS primary.
+
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'EOF'
+dist_man_MANS = foo.1
+notrans_man_MANS = foo.5
+
+test-install: install
+ test -f inst/man/man1/gnu-foo.1
+ test -f inst/man/man5/foo.5
+EOF
+
+: > foo.1
+: > foo.5
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure --program-prefix=gnu- --prefix `pwd`/inst --mandir `pwd`/inst/man
+$MAKE
+$MAKE test-install
+$MAKE uninstall
+test `find inst/man -type f -print | wc -l` = 0
+
+# Opportunistically test for installdirs.
+rm -rf inst
+$MAKE installdirs
+test -d inst/man/man1
+test -d inst/man/man5

2008-02-20  Peter Breitenlohner  <peb@...>

        * automake.in (handle_man_pages), lib/am/mans.am: Implement
        notrans_ prefix for MANS primary and rework dependencies for
        install-man%SECTION%; use only vars defined in Makefile.am.
        * tests/man4.test: New test (install-man%SECTION% dependencies).
        * tests/notrans.test: New test (notrans_ prefix).
        * tests/Makefile.am: Update.
        * doc/automake.texi: Document notrans_ prefix.


Re: Implementing notrans_man_MANS

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Peter,

* Peter Breitenlohner wrote on Wed, Feb 20, 2008 at 02:20:04PM CET:
>
> attached are five patches (the diffs are actually against the result of
> applying your patch for PR 516 from 2008-01-22):

Thanks for your work in this, and sorry for the delay.  I saw that your
paperwork is now complete, thanks!

> 2. patch-03-notrans_MANS-impl:
>
> The actual implementation of `notrans_'. The patch looks awful but the
> logic in the resulting patched file should be reasonably clear.

Indeed.  ;-)

> At the same time the dependencies for `install-man%SECTION%' have been
> revised. All make variables not used in Makefile.am are omitted from the
> install/uninstall rules. All those used in the rules also appear as
> dependencies.
>
> One consequence: "make dist_man_MANS='bar.1 baz.5' install-man" will only
> work well if `dist_man_MANS' is used in Makefile.am and Automake has
> generated the relevant (!notrans_) part of the install-man1 and
> install-man5 rules. So ... ?

Yeah, that kind of thing is to be expected from automake-active
variables.  Not new in this patch.

> Please feel free to revise the wording in texinfo, comments, and/or
> ChangeLog.

Well, here's a review of your patches.  If you have time to address the
comments, that would be great, otherwise I will eventually do it.

> diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/automake.in automake-1.10.1/automake.in
> --- automake-1.10.1.orig/automake.in 2008-02-19 18:07:41.000000000 +0100
> +++ automake-1.10.1/automake.in 2008-02-20 01:52:26.000000000 +0100
> @@ -3363,27 +3363,38 @@
>    # Find all the sections in use.  We do this by first looking for
>    # "standard" sections, and then looking for any additional
>    # sections used in man_MANS.
> -  my (%sections, %vlist);
> +  my (%sections, %nsections, %tsections, %nvlist, %tvlist, %nsvlist, %tsvlist);

Variable naming seems, uhm, a bit hard to read, starting from ugly names
and putting more on top.  ;-)

>    # We handle nodist_ for uniformity.  man pages aren't distributed
>    # by default so it isn't actually very important.
> +  foreach my $npfx ('', 'notrans_')
> +    {
>        foreach my $pfx ('', 'dist_', 'nodist_')
>   {
>    # Add more sections as needed.
>    foreach my $section ('0'..'9', 'n', 'l')

This triple loop is already at 72 iterations.  Not good for performance.
If this grows further, we may have to access variables in a different
manner here.

>      {
> -      my $varname = $pfx . 'man' . $section . '_MANS';
> +      my $varname = $npfx . $pfx . 'man' . $section . '_MANS';
[...]

> --- automake-1.10.1.orig/lib/am/mans.am 2008-02-20 09:38:10.000000000 +0100
> +++ automake-1.10.1/lib/am/mans.am 2008-02-20 00:50:53.000000000 +0100
> @@ -16,6 +16,20 @@
>  ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
>  ## 02110-1301, USA.
>  
> +## Parameters:
> +## SECTION string man section
> +## DEPS string dependencies
> +##
> +## NOTR bool have notrans_ MANS
> +## NOTRX string notrans_ man%SECTION%_MANS (if any)
> +## NOTRY bool have notrans_ man_MANS
> +## NOTRZ string notrans_ man_MANS
> +##
> +## DOTR bool same
> +## DOTRX string  as above
> +## DOTRY bool    without
> +## DOTRZ string      notrans_

What is the rationale for NOTRY, do the X, Y, Z suffixes have any
meaning?  I understand NO and DO prefixes.  So what about using
   NOTR_SECT_MANS     instead of  NOTRX
   NOTR_NOSECT_MANS   instead of  NOTRZ
consequently
   NOTR_NS            instead of  NOTRY

and likewise DOTR*?  For NOTR and DOTR see below.

>  man%SECTION%dir = $(mandir)/man%SECTION%
>  
>  ## ------------ ##
> @@ -29,37 +43,65 @@
>  ?INSTALL-MAN?install-data-am: install-man
>  ?INSTALL-MAN?am__installdirs += "$(DESTDIR)$(man%SECTION%dir)"
>  .PHONY install-man: install-man%SECTION%
> -install-man%SECTION%: $(man%SECTION%_MANS) $(man_MANS)
> +install-man%SECTION%: %DEPS%
>   @$(NORMAL_INSTALL)
>   test -z "$(man%SECTION%dir)" || $(MKDIR_P) "$(DESTDIR)$(man%SECTION%dir)"
> - @list='$(man%SECTION%_MANS) $(dist_man%SECTION%_MANS) $(nodist_man%SECTION%_MANS)'; \
> +## Handle MANS with notrans_ prefix
> +?NOTR? @list='%NOTRX%'; \
> +## Extract all items from notrans_man_MANS that should go in this section.
> +## This must be done dynamically to support conditionals.
> +?NOTRY? l2='%NOTRZ%'; \
> +?NOTRY? for i in $$l2; do \
> +?NOTRY?  case "$$i" in \
> +## Have to accept files like `foo.1c'.
> +?NOTRY?    *.%SECTION%*) list="$$list $$i" ;; \
> +?NOTRY?  esac; \
> +?NOTRY? done; \
> +?NOTR? for i in $$list; do \
> +## Find the file.
> +?NOTR?  if test -f $$i; then file=$$i; \
> +?NOTR?  else file=$(srcdir)/$$i; fi; \
> +## Change the extension if needed.
> +?NOTR?  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
> +?NOTR?  case "$$ext" in \
> +?NOTR?    %SECTION%*) ;; \
> +?NOTR?    *) ext='%SECTION%' ;; \
> +?NOTR?  esac; \
> +## Extract basename of man page and append extension.
> +?NOTR?  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
> +?NOTR?  inst=`echo $$inst | sed -e 's/^.*\///'`.$$ext; \
> +?NOTR?  echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
> +?NOTR?  $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
> +?NOTR? done

Note to self: should rewrite the above when applying the multi-file
install.

Also, the whole thing would probably be a lot more readable if the
?NOTR?/?DOTR? prefixes vanished and were replaced by full rules, wrapped
in `if %?NOTRANS_MANS%'.  That would be a better name for NOTR, and
since it would then only appear a couple of times, it could be longer
without pain, too.

[...]

> diff -ur -N automake-1.10.1.orig/doc/automake.texi automake-1.10.1/doc/automake.texi
> --- automake-1.10.1.orig/doc/automake.texi 2008-01-21 23:41:02.000000000 +0100
> +++ automake-1.10.1/doc/automake.texi 2008-02-19 20:52:29.000000000 +0100
> @@ -1962,8 +1962,9 @@
>  
>  Some primaries also allow additional prefixes that control other
>  aspects of @command{automake}'s behavior.  The currently defined prefixes
> -are @samp{dist_}, @samp{nodist_}, and @samp{nobase_}.  These prefixes
> -are explained later (@pxref{Program and Library Variables}).
> +are @samp{dist_}, @samp{nodist_}, @samp{nobase_}, and @samp{notrans_}.
> +These prefixes are explained later (@pxref{Program and Library Variables})
> +(@pxref{Man pages}).
>  
>  
>  @node Canonicalization
> @@ -7633,6 +7634,34 @@
>  The @code{nobase_} prefix is meaningless for man pages and is
>  disallowed.
>  
> +@vindex notrans_
> +@cindex @code{notrans_} prefix
> +@cindex Man page renaming, avoiding
> +@cindex Avoiding man page renaming
> +
> +The GNU Build System provides means to automatically rename executables
> +before they are installed.

This is duplication from the Renaming node.  I'd prefer something like
  Executables and manpages may be renamed upon installation
  (@pxref{Renaming}).

and then continue with

> [T]his can be avoided by use
> +of the @code{notrans_} prefix.  For instance here is how to install two man
> +pages for an executable @samp{foo} (to be renamed) allowing to access a
> +library function @samp{foo()} (not to be renamed) from the command line.

and the Renaming node should be fixed to state:
  The GNU Build System provides means to automatically rename
  executables and manpages before they are installed.

and cross-ref back.

> +@samp{notrans_} must be specified first when used in conjunction with
> +either @samp{dist_} or @samp{nodist_} (@pxref{Dist}).  For instance:

Can this limitation be lifted (without making the code much slower)?

> --- automake-1.10.1.orig/tests/man4.test 1970-01-01 01:00:00.000000000 +0100
> +++ automake-1.10.1/tests/man4.test 2008-02-20 10:07:12.000000000 +0100
[...]
> +
> +# Check that dist_man1_MANS appears as dependency for install-man1.

This comment does not match the code below.

> +
> +. ./defs || exit 1
> +
> +set -e
> +
> +cat > Makefile.am << 'END'
> +dist_man_MANS = foo.1
> +END
> +
> +cat >>configure.in <<'END'
> +AC_OUTPUT
> +END
> +
> +: > foo.1
> +
> +$ACLOCAL
> +$AUTOMAKE
> +
> +grep '^install-man1:' Makefile.in | grep '\$(dist_man_MANS)'
> diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/tests/notrans.test automake-1.10.1/tests/notrans.test
> --- automake-1.10.1.orig/tests/notrans.test 1970-01-01 01:00:00.000000000 +0100
> +++ automake-1.10.1/tests/notrans.test 2008-02-20 11:25:40.000000000 +0100
> @@ -0,0 +1,53 @@
[...]

> +
> +# Check notrans_ prefix for MANS primary.
> +
> +. ./defs || exit 1
> +
> +set -e
> +
> +cat >>configure.in <<'END'
> +AC_OUTPUT
> +END
> +
> +cat > Makefile.am << 'EOF'
> +dist_man_MANS = foo.1
> +notrans_man_MANS = foo.5

Let's have these as well:
  man3_MANS = bar.man
  notrans_man3_MANS = baz.man

(including testing for them further below), and also the
combinations of notrans_ with dist_ and nodist_.  Ideally,
we want to exercise every code path in mans.am and automake.in.

> +
> +test-install: install
> + test -f inst/man/man1/gnu-foo.1
> + test -f inst/man/man5/foo.5
> +EOF
> +
> +: > foo.1
> +: > foo.5
> +
> +$ACLOCAL
> +$AUTOCONF
> +$AUTOMAKE
> +
> +./configure --program-prefix=gnu- --prefix `pwd`/inst --mandir `pwd`/inst/man

Please quote instances of `pwd' for the master testsuite.

> +$MAKE
> +$MAKE test-install
> +$MAKE uninstall
> +test `find inst/man -type f -print | wc -l` = 0
> +
> +# Opportunistically test for installdirs.
> +rm -rf inst
> +$MAKE installdirs
> +test -d inst/man/man1
> +test -d inst/man/man5

> 2008-02-20  Peter Breitenlohner  <peb@...>
>
> * automake.in (handle_man_pages), lib/am/mans.am: Implement
> notrans_ prefix for MANS primary and rework dependencies for
> install-man%SECTION%; use only vars defined in Makefile.am.
> * tests/man4.test: New test (install-man%SECTION% dependencies).
> * tests/notrans.test: New test (notrans_ prefix).
> * tests/Makefile.am: Update.
> * doc/automake.texi: Document notrans_ prefix.



Re: Implementing notrans_man_MANS

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 5 Mar 2008, Ralf Wildenhues wrote:

> Well, here's a review of your patches.  If you have time to address the
> comments, that would be great, otherwise I will eventually do it.

Hi Ralf,

I will go through your comments and think most of them pose no problem. For
the moment just a few remarks/questions:

> This triple loop is already at 72 iterations.  Not good for performance.
> If this grows further, we may have to access variables in a different
> manner here.

I assume you are worried by the total number of 72 iterations, not by the
fact that they come from three nested loops.  Given the Automake
infrastructure (to the extent I understand it) I see no alternative.

>> +?NOTRY? l2='%NOTRZ%'; \
>> +?NOTRY? for i in $$l2; do \
>> .......
>> +?NOTR?  $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
>> +?NOTR? done
>
> Note to self: should rewrite the above when applying the multi-file
> install.

What is multi-file install? Maybe I don't need to know.

> Also, the whole thing would probably be a lot more readable if the
> ?NOTR?/?DOTR? prefixes vanished and were replaced by full rules, wrapped
> in `if %?NOTRANS_MANS%'.  That would be a better name for NOTR, and
> since it would then only appear a couple of times, it could be longer
> without pain, too.

I have tried to wrap the make rule fragments by something like
`if %?XXX%' but failed, maybe I got the syntax wrong.  However, from
some comments elsewhere I concluded that at present this is not possible.

Do you mean something like:
  install-man: install-man1 install-notrans-man1
  install-man1: trans_DEPENDENCIES
  trans_RULES
  install-notrans-man1: notrans_DEPENDENCIES
  notrans_RULES

That should not be too difficult. Shall I try it?

>> +@samp{notrans_} must be specified first when used in conjunction with
>> +either @samp{dist_} or @samp{nodist_} (@pxref{Dist}).  For instance:
>
> Can this limitation be lifted (without making the code much slower)?

I wouldn't know how, and there is an analogous limitation elsewhere:
nobase_dist_pkgdata_DATA

>> +./configure --program-prefix=gnu- --prefix `pwd`/inst --mandir `pwd`/inst/man
>
> Please quote instances of `pwd' for the master testsuite.

Like --prefix "`pwd`"/inst for Windows paths containing spaces? I just
copied this from transform.test. A quick grep shows there are still plenty
of unquoted pwd's around.

BTW: Which one is better: `--prefix PREFIX' or `--prefix=PREFIX'?

==================

In the meantime I have some ideas how to handle manpage translations. Mainly
an Autoconf/Automake macro and Makefile.am stuff, plus a little bit of help
from Automake.  To whom should I send this, when finished to write it up?

Regards Peter



Re: Implementing notrans_man_MANS

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Peter,

* Peter Breitenlohner wrote on Thu, Mar 06, 2008 at 10:43:20AM CET:
> On Wed, 5 Mar 2008, Ralf Wildenhues wrote:
>
>> This triple loop is already at 72 iterations.  Not good for performance.
>> If this grows further, we may have to access variables in a different
>> manner here.
>
> I assume you are worried by the total number of 72 iterations, not by the
> fact that they come from three nested loops.  Given the Automake
> infrastructure (to the extent I understand it) I see no alternative.

Your assumption is correct, and yes, I don't see a simple alternative
either.

>>> +?NOTRY? l2='%NOTRZ%'; \
>>> +?NOTRY? for i in $$l2; do \
>>> .......
>>> +?NOTR?  $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
>>> +?NOTR? done
>>
>> Note to self: should rewrite the above when applying the multi-file
>> install.
>
> What is multi-file install? Maybe I don't need to know.

You don't need to know, but I meant this:
<http://thread.gmane.org/gmane.comp.sysutils.automake.patches/2945/focus=3088>

>> Also, the whole thing would probably be a lot more readable if the
>> ?NOTR?/?DOTR? prefixes vanished and were replaced by full rules, wrapped
>> in `if %?NOTRANS_MANS%'.  That would be a better name for NOTR, and
>> since it would then only appear a couple of times, it could be longer
>> without pain, too.
>
> I have tried to wrap the make rule fragments by something like
> `if %?XXX%' but failed, maybe I got the syntax wrong.  However, from
> some comments elsewhere I concluded that at present this is not possible.

It is possible but only if you wrap whole rules.  You cannot wrap parts.
See depend2.am for examples.

> Do you mean something like:
> install-man: install-man1 install-notrans-man1
> install-man1: trans_DEPENDENCIES
> trans_RULES
> install-notrans-man1: notrans_DEPENDENCIES
> notrans_RULES

No.

>>> +@samp{notrans_} must be specified first when used in conjunction with
>>> +either @samp{dist_} or @samp{nodist_} (@pxref{Dist}).  For instance:
>>
>> Can this limitation be lifted (without making the code much slower)?
>
> I wouldn't know how, and there is an analogous limitation elsewhere:
> nobase_dist_pkgdata_DATA

Ah ok, I wasn't aware of that.

>>> +./configure --program-prefix=gnu- --prefix `pwd`/inst --mandir `pwd`/inst/man
>>
>> Please quote instances of `pwd' for the master testsuite.
>
> Like --prefix "`pwd`"/inst for Windows paths containing spaces? I just
> copied this from transform.test. A quick grep shows there are still plenty
> of unquoted pwd's around.

Not if you look in git master of Automake.

> BTW: Which one is better: `--prefix PREFIX' or `--prefix=PREFIX'?

Both are accepted.

> In the meantime I have some ideas how to handle manpage translations. Mainly
> an Autoconf/Automake macro and Makefile.am stuff, plus a little bit of help
> from Automake.  To whom should I send this, when finished to write it up?

Respective bits to auto{conf,make}-patches@..., please.

Thanks,
Ralf



Re: Implementing notrans_man_MANS

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 6 Mar 2008, Ralf Wildenhues wrote:

>>> Also, the whole thing would probably be a lot more readable if the
>>> ?NOTR?/?DOTR? prefixes vanished and were replaced by full rules, wrapped
>>> in `if %?NOTRANS_MANS%'.  That would be a better name for NOTR, and
>>> since it would then only appear a couple of times, it could be longer
>>> without pain, too.
>
>> Do you mean something like:
>> install-man: install-man1 install-notrans-man1
>> install-man1: trans_DEPENDENCIES
>> trans_RULES
>> install-notrans-man1: notrans_DEPENDENCIES
>> notrans_RULES
>
> No.

Hi Ralf,

what then? Maybe this:

if only trans
  install-man1: trans_DEPENDENCIES
  trans_RULES
as before, if only notrans
  install-man1: notrans_DEPENDENCIES
  notrans_RULES
or if both are present
  install-man1: trans_DEPENDENCIES notrans_DEPENDENCIES
  trans_RULES
  notrans_RULES

Pro: much simpler to read
Con: duplication of code, harder to maintain

or still something else. If so please indicate what.

Regards,
Peter



Re: Implementing notrans_man_MANS

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Peter Breitenlohner wrote on Thu, Mar 06, 2008 at 01:27:05PM CET:

> On Thu, 6 Mar 2008, Ralf Wildenhues wrote:
>
>>>> Also, the whole thing would probably be a lot more readable if the
>>>> ?NOTR?/?DOTR? prefixes vanished and were replaced by full rules, wrapped
>>>> in `if %?NOTRANS_MANS%'.  That would be a better name for NOTR, and
>>>> since it would then only appear a couple of times, it could be longer
>>>> without pain, too.
>>
>>> Do you mean something like:
>>> install-man: install-man1 install-notrans-man1
>>> install-man1: trans_DEPENDENCIES
>>> trans_RULES
>>> install-notrans-man1: notrans_DEPENDENCIES
>>> notrans_RULES
>>
>> No.

> what then? Maybe this:
>
> if only trans
> install-man1: trans_DEPENDENCIES
> trans_RULES
> as before, if only notrans
> install-man1: notrans_DEPENDENCIES
> notrans_RULES
> or if both are present
> install-man1: trans_DEPENDENCIES notrans_DEPENDENCIES
> trans_RULES
> notrans_RULES
>
> Pro: much simpler to read
> Con: duplication of code, harder to maintain
>
> or still something else. If so please indicate what.

Oh sorry, I was in a hurry and not thinking.  What I meant was that
while you can't wrap arbitrary lines ending in backslash-newline in `if
%?NOTRANS_MANS%/else/endif', you can do so at a finer grainage than
whole rules: it's just that it won't work after lines ending in
backslash.

To some extent this is independent of the question you ask about the
rule target names: whether you interleave trans and notrans in the .am
file and whether you give trans and notrans different target names need
not be dealt with at the same time.  So please for now leave you patch
as is, but only change all those NOTR/DOTR prefixes to use if/else/endif
(which includes a few lines of duplication in the .am file).

Clearer now?  If not, then I guess I can also patch that later.

Thanks,
Ralf



Re: Implementing notrans_man_MANS

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 6 Mar 2008, Ralf Wildenhues wrote:

> * Peter Breitenlohner wrote on Thu, Mar 06, 2008 at 01:27:05PM CET:
>> or still something else. If so please indicate what.
>
> Oh sorry, I was in a hurry and not thinking.  What I meant was that
> while you can't wrap arbitrary lines ending in backslash-newline in `if
> %?NOTRANS_MANS%/else/endif', you can do so at a finer grainage than
> whole rules: it's just that it won't work after lines ending in
> backslash.
>
> To some extent this is independent of the question you ask about the
> rule target names: whether you interleave trans and notrans in the .am
> file and whether you give trans and notrans different target names need
> not be dealt with at the same time.  So please for now leave you patch
> as is, but only change all those NOTR/DOTR prefixes to use if/else/endif
> (which includes a few lines of duplication in the .am file).
>
> Clearer now?  If not, then I guess I can also patch that later.
Hi Ralf,

yes, thanks. However, I can only use if/endif if/endif and not if/else/endif
because a section may have trans_ as well as notrans_ man pages.

=========================

Attached are revised versions of the three patches. I hope they take care of
all your earlier comments.

patch-03-notrans_MANS-impl:

The new variables names are more or less self explanatory (I hope).

I had to use
       @unsorted_deps = (keys %notrans_vars, keys %trans_vars,
                         keys %notrans_this_sect, keys %trans_this_sect);
       my @deps = sort @unsorted_deps;
instead of
       my @deps = sort (keys %notrans_vars, keys %trans_vars,
                        keys %notrans_this_sect, keys %trans_this_sect);
because this may give a perl warning [sort (...) used as function],
resulting in three test (instsh.tes, location.test, warnopts.test) to FAIL.

patch-04-notrans_MANS-doc:

I have slightly reworded the text preceding the example, and hope this
clarifies the intent.

patch-05-notrans_MANS-test:

notrans.test now contains all combinations. I have incorporated the checks
that used to be in man4.test into notrans.test, because otherwise there
would have been much repetition.  Hope this is OK.  If so, remember not to
mention man4.test in the ChangLog.  If not, I could make that two separate
tests.

The install-man depedndencies are checked either directly (inspecting
Makefile.in) or indirectly (letting make generate the files).

=========================

regards
Peter Breitenlohner <peb@...>
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/automake.in automake-1.10.1/automake.in
--- automake-1.10.1.orig/automake.in 2008-02-19 18:07:41.000000000 +0100
+++ automake-1.10.1/automake.in 2008-03-08 00:10:34.000000000 +0100
@@ -3363,27 +3363,39 @@
   # Find all the sections in use.  We do this by first looking for
   # "standard" sections, and then looking for any additional
   # sections used in man_MANS.
-  my (%sections, %vlist);
+  my (%sections, %notrans_sections, %trans_sections,
+      %notrans_vars, %trans_vars, %notrans_sect_vars, %trans_sect_vars);
   # We handle nodist_ for uniformity.  man pages aren't distributed
   # by default so it isn't actually very important.
+  foreach my $npfx ('', 'notrans_')
+    {
       foreach my $pfx ('', 'dist_', 'nodist_')
  {
   # Add more sections as needed.
   foreach my $section ('0'..'9', 'n', 'l')
     {
-      my $varname = $pfx . 'man' . $section . '_MANS';
+      my $varname = $npfx . $pfx . 'man' . $section . '_MANS';
       if (var ($varname))
  {
   $sections{$section} = 1;
   $varname = '$(' . $varname . ')';
-  $vlist{$varname} = 1;
+  if ($npfx eq 'notrans_')
+    {
+      $notrans_sections{$section} = 1;
+      $notrans_sect_vars{$varname} = 1;
+    }
+  else
+    {
+      $trans_sections{$section} = 1;
+      $trans_sect_vars{$varname} = 1;
+    }
 
   &push_dist_common ($varname)
     if $pfx eq 'dist_';
  }
     }
 
-  my $varname = $pfx . 'man_MANS';
+  my $varname = $npfx . $pfx . 'man_MANS';
   my $var = var ($varname);
   if ($var)
     {
@@ -3393,28 +3405,87 @@
   if (/\.([0-9a-z])([a-z]*)$/)
     {
       $sections{$1} = 1;
+      if ($npfx eq 'notrans_')
+ {
+  $notrans_sections{$1} = 1;
+ }
+      else
+ {
+  $trans_sections{$1} = 1;
+ }
     }
  }
 
       $varname = '$(' . $varname . ')';
-      $vlist{$varname} = 1;
+      if ($npfx eq 'notrans_')
+ {
+  $notrans_vars{$varname} = 1;
+ }
+      else
+ {
+  $trans_vars{$varname} = 1;
+ }
       &push_dist_common ($varname)
  if $pfx eq 'dist_';
     }
  }
+    }
 
   return unless %sections;
 
+  my @unsorted_deps;
+
+  # Build section independent variables.
+  my $have_notrans = %notrans_vars;
+  my @notrans_list = sort keys %notrans_vars;
+  my $have_trans = %trans_vars;
+  my @trans_list = sort keys %trans_vars;
+
   # Now for each section, generate an install and uninstall rule.
   # Sort sections so output is deterministic.
   foreach my $section (sort keys %sections)
     {
+      # Build section dependent variables.
+      my $notrans_mans = $have_notrans || exists $notrans_sections{$section};
+      my $trans_mans = $have_trans || exists $trans_sections{$section};
+      my (%notrans_this_sect, %trans_this_sect);
+      my $expr = 'man' . $section . '_MANS';
+      foreach my $varname (keys %notrans_sect_vars)
+ {
+  if ($varname =~ /$expr/)
+    {
+      $notrans_this_sect{$varname} = 1;
+    }
+ }
+      foreach my $varname (keys %trans_sect_vars)
+ {
+  if ($varname =~ /$expr/)
+    {
+      $trans_this_sect{$varname} = 1;
+    }
+ }
+      my @notrans_sect_list = sort keys %notrans_this_sect;
+      my @trans_sect_list = sort keys %trans_this_sect;
+      @unsorted_deps = (keys %notrans_vars, keys %trans_vars,
+                        keys %notrans_this_sect, keys %trans_this_sect);
+      my @deps = sort @unsorted_deps;
       $output_rules .= &file_contents ('mans',
        new Automake::Location,
-       SECTION => $section);
+       SECTION           => $section,
+       DEPS              => "@deps",
+       NOTRANS_MANS      => $notrans_mans,
+       NOTRANS_SECT_LIST => "@notrans_sect_list",
+       HAVE_NOTRANS      => $have_notrans,
+       NOTRANS_LIST      => "@notrans_list",
+       TRANS_MANS        => $trans_mans,
+       TRANS_SECT_LIST   => "@trans_sect_list",
+       HAVE_TRANS        => $have_trans,
+       TRANS_LIST        => "@trans_list");
     }
 
-  my @mans = sort keys %vlist;
+  @unsorted_deps  = (keys %notrans_vars, keys %trans_vars,
+                     keys %notrans_sect_vars, keys %trans_sect_vars);
+  my @mans = sort @unsorted_deps;
   $output_vars .= file_contents ('mans-vars',
  new Automake::Location,
  MANS => "@mans");
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/lib/am/mans.am automake-1.10.1/lib/am/mans.am
--- automake-1.10.1.orig/lib/am/mans.am 2008-02-20 09:38:10.000000000 +0100
+++ automake-1.10.1/lib/am/mans.am 2008-03-08 00:10:55.000000000 +0100
@@ -29,19 +29,50 @@
 ?INSTALL-MAN?install-data-am: install-man
 ?INSTALL-MAN?am__installdirs += "$(DESTDIR)$(man%SECTION%dir)"
 .PHONY install-man: install-man%SECTION%
-install-man%SECTION%: $(man%SECTION%_MANS) $(man_MANS)
+install-man%SECTION%: %DEPS%
  @$(NORMAL_INSTALL)
  test -z "$(man%SECTION%dir)" || $(MKDIR_P) "$(DESTDIR)$(man%SECTION%dir)"
- @list='$(man%SECTION%_MANS) $(dist_man%SECTION%_MANS) $(nodist_man%SECTION%_MANS)'; \
-## Extract all items from man_MANS that should go in this section.
+if %?NOTRANS_MANS%
+## Handle MANS with notrans_ prefix
+ @list='%NOTRANS_SECT_LIST%'; \
+## Extract all items from notrans_man_MANS that should go in this section.
 ## This must be done dynamically to support conditionals.
- l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
- for i in $$l2; do \
-  case "$$i" in \
+?HAVE_NOTRANS? l2='%NOTRANS_LIST%'; \
+?HAVE_NOTRANS? for i in $$l2; do \
+?HAVE_NOTRANS?  case "$$i" in \
 ## Have to accept files like `foo.1c'.
-    *.%SECTION%*) list="$$list $$i" ;; \
+?HAVE_NOTRANS?    *.%SECTION%*) list="$$list $$i" ;; \
+?HAVE_NOTRANS?  esac; \
+?HAVE_NOTRANS? done; \
+ for i in $$list; do \
+## Find the file.
+  if test -f $$i; then file=$$i; \
+  else file=$(srcdir)/$$i; fi; \
+## Change the extension if needed.
+  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+  case "$$ext" in \
+    %SECTION%*) ;; \
+    *) ext='%SECTION%' ;; \
   esac; \
- done; \
+## Extract basename of man page and append extension.
+  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+  inst=`echo $$inst | sed -e 's/^.*\///'`.$$ext; \
+  echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
+  $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
+ done
+endif %?NOTRANS_MANS%
+if %?TRANS_MANS%
+## Handle MANS without notrans_ prefix
+ @list='%TRANS_SECT_LIST%'; \
+## Extract all items from man_MANS that should go in this section.
+## This must be done dynamically to support conditionals.
+?HAVE_TRANS? l2='%TRANS_LIST%'; \
+?HAVE_TRANS? for i in $$l2; do \
+?HAVE_TRANS?  case "$$i" in \
+## Have to accept files like `foo.1c'.
+?HAVE_TRANS?    *.%SECTION%*) list="$$list $$i" ;; \
+?HAVE_TRANS?  esac; \
+?HAVE_TRANS? done; \
  for i in $$list; do \
 ## Find the file.
   if test -f $$i; then file=$$i; \
@@ -60,6 +91,7 @@
   echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
   $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
  done
+endif %?TRANS_MANS%
 
 
 ## -------------- ##
@@ -72,16 +104,44 @@
 .PHONY uninstall-man: uninstall-man%SECTION%
 uninstall-man%SECTION%:
  @$(NORMAL_UNINSTALL)
- @list='$(man%SECTION%_MANS) $(dist_man%SECTION%_MANS) $(nodist_man%SECTION%_MANS)'; \
-## Extract all items from man_MANS that should go in this section.
+if %?NOTRANS_MANS%
+## Handle MANS with notrans_ prefix
+ @list='%NOTRANS_SECT_LIST%'; \
+## Extract all items from notrans_man_MANS that should go in this section.
 ## This must be done dynamically to support conditionals.
- l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
- for i in $$l2; do \
-  case "$$i" in \
+?HAVE_NOTRANS? l2='%NOTRANS_LIST%'; \
+?HAVE_NOTRANS? for i in $$l2; do \
+?HAVE_NOTRANS?  case "$$i" in \
 ## Have to accept files like `foo.1c'.
-    *.%SECTION%*) list="$$list $$i" ;; \
+?HAVE_NOTRANS?    *.%SECTION%*) list="$$list $$i" ;; \
+?HAVE_NOTRANS?  esac; \
+?HAVE_NOTRANS? done; \
+ for i in $$list; do \
+## Change the extension if needed.
+  ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+  case "$$ext" in \
+    %SECTION%*) ;; \
+    *) ext='%SECTION%' ;; \
   esac; \
- done; \
+## Extract basename of man page and append extension.
+  inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+  inst=`echo $$inst | sed -e 's/^.*\///'`.$$ext; \
+  echo " rm -f '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
+  rm -f "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
+ done
+endif %?NOTRANS_MANS%
+if %?TRANS_MANS%
+## Handle MANS without notrans_ prefix
+ @list='%TRANS_SECT_LIST%'; \
+## Extract all items from man_MANS that should go in this section.
+## This must be done dynamically to support conditionals.
+?HAVE_TRANS? l2='%TRANS_LIST%'; \
+?HAVE_TRANS? for i in $$l2; do \
+?HAVE_TRANS?  case "$$i" in \
+## Have to accept files like `foo.1c'.
+?HAVE_TRANS?    *.%SECTION%*) list="$$list $$i" ;; \
+?HAVE_TRANS?  esac; \
+?HAVE_TRANS? done; \
  for i in $$list; do \
 ## Change the extension if needed.
   ext=`echo $$i | sed -e 's/^.*\\.//'`; \
@@ -97,3 +157,4 @@
   echo " rm -f '$(DESTDIR)$(man%SECTION%dir)/$$inst'"; \
   rm -f "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
  done
+endif %?TRANS_MANS%

diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/doc/automake.texi automake-1.10.1/doc/automake.texi
--- automake-1.10.1.orig/doc/automake.texi 2008-01-21 23:41:02.000000000 +0100
+++ automake-1.10.1/doc/automake.texi 2008-03-08 01:15:41.000000000 +0100
@@ -1034,7 +1034,8 @@
 @cindex Programs, renaming during installation
 
 The GNU Build System provides means to automatically rename
-executables before they are installed.  This is especially convenient
+executables and manpages before they are installed (@pxref{Man pages}).
+This is especially convenient
 when installing a GNU package on a system that already has a
 proprietary implementation you do not want to overwrite.  For instance,
 you may want to install GNU @command{tar} as @command{gtar} so you can
@@ -1962,8 +1963,9 @@
 
 Some primaries also allow additional prefixes that control other
 aspects of @command{automake}'s behavior.  The currently defined prefixes
-are @samp{dist_}, @samp{nodist_}, and @samp{nobase_}.  These prefixes
-are explained later (@pxref{Program and Library Variables}).
+are @samp{dist_}, @samp{nodist_}, @samp{nobase_}, and @samp{notrans_}.
+These prefixes are explained later (@pxref{Program and Library Variables})
+(@pxref{Man pages}).
 
 
 @node Canonicalization
@@ -7633,6 +7635,32 @@
 The @code{nobase_} prefix is meaningless for man pages and is
 disallowed.
 
+@vindex notrans_
+@cindex @code{notrans_} prefix
+@cindex Man page renaming, avoiding
+@cindex Avoiding man page renaming
+
+Executables and manpages may be renamed upon installation
+(@pxref{Renaming}).  For manpages this can be avoided by use of the
+@code{notrans_} prefix.  For instance, suppose an executable @samp{foo}
+allowing to access a library function @samp{foo()} from the command line.
+The way to avoid renaming of the @file{foo.3} manpage is:
+
+@example
+man_MANS = foo.1
+notrans_man_MANS = foo.3
+@end example
+
+@cindex @code{notrans_} and @code{dist_} or @code{nodist_}
+@cindex @code{dist_} and @code{notrans_}
+@cindex @code{nodist_} and @code{notrans_}
+
+@samp{notrans_} must be specified first when used in conjunction with
+either @samp{dist_} or @samp{nodist_} (@pxref{Dist}).  For instance:
+
+@example
+notrans_dist_man3_MANS = bar.3
+@end example
 
 @node Install
 @chapter What Gets Installed

diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/tests/Makefile.am automake-1.10.1/tests/Makefile.am
--- automake-1.10.1.orig/tests/Makefile.am 2008-02-20 09:38:10.000000000 +0100
+++ automake-1.10.1/tests/Makefile.am 2008-03-07 23:12:35.000000000 +0100
@@ -393,6 +393,7 @@
 noinstdir.test \
 nolink.test \
 nostdinc.test \
+notrans.test \
 number.test \
 objc.test \
 objc2.test \
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/tests/Makefile.in automake-1.10.1/tests/Makefile.in
--- automake-1.10.1.orig/tests/Makefile.in 2008-02-20 09:38:10.000000000 +0100
+++ automake-1.10.1/tests/Makefile.in 2008-03-07 23:12:37.000000000 +0100
@@ -525,6 +525,7 @@
 noinstdir.test \
 nolink.test \
 nostdinc.test \
+notrans.test \
 number.test \
 objc.test \
 objc2.test \
diff -ur -N -x 'automake.info*' -x version.texi -x stamp-vti automake-1.10.1.orig/tests/notrans.test automake-1.10.1/tests/notrans.test
--- automake-1.10.1.orig/tests/notrans.test 1970-01-01 01:00:00.000000000 +0100
+++ automake-1.10.1/tests/notrans.test 2008-03-07 23:08:42.000000000 +0100
@@ -0,0 +1,115 @@
+#! /bin/sh
+# Copyright (C) 2008  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 3, 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/>.
+
+# Check all notrans_, dist_, nodist_ prefix combinations for MANS
+# primary and install-man dependencies.
+
+. ./defs || exit 1
+
+set -e
+
+cat >>configure.in <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'EOF'
+man_MANS = foo.1
+dist_man_MANS = bar.2
+nodist_man_MANS = baz.3
+notrans_man_MANS = x-foo.4
+notrans_dist_man_MANS = x-bar.5
+notrans_nodist_man_MANS = x-baz.6
+man7_MANS = y-foo.man
+dist_man5_MANS = y-bar.man
+nodist_man4_MANS = y-baz.man
+notrans_man3_MANS = z-foo.man
+notrans_dist_man2_MANS = z-bar.man
+notrans_nodist_man1_MANS = z-baz.man
+
+# These two are ignored
+dist_notrans_man_MANS = nosuch.8
+nodist_notrans_man9_MANS = nosuch.man
+
+y-foo.man:
+ : >$@
+y-bar.man:
+ : >$@
+y-baz.man:
+ : >$@
+z-foo.man:
+ : >$@
+z-bar.man:
+ : >$@
+z-baz.man:
+ : >$@
+
+test-install: install
+ test -f inst/man/man1/gnu-foo.1
+ test -f inst/man/man2/gnu-bar.2
+ test -f inst/man/man3/gnu-baz.3
+ test -f inst/man/man4/x-foo.4
+ test -f inst/man/man5/x-bar.5
+ test -f inst/man/man6/x-baz.6
+ test -f inst/man/man7/gnu-y-foo.7
+ test -f inst/man/man5/gnu-y-bar.5
+ test -f inst/man/man4/gnu-y-baz.4
+ test -f inst/man/man3/z-foo.3
+ test -f inst/man/man2/z-bar.2
+ test -f inst/man/man1/z-baz.1
+ if test -d inst/man/man8; then (exit 1); else :; fi
+ if test -d inst/man/man9; then (exit 1); else :; fi
+EOF
+
+: > foo.1
+: > bar.2
+: > baz.3
+: > x-foo.4
+: > x-bar.5
+: > x-baz.6
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+grep '^install-man1:' Makefile.in | grep '\$(man_MANS)'
+grep '^install-man2:' Makefile.in | grep '\$(dist_man_MANS)'
+grep '^install-man3:' Makefile.in | grep '\$(nodist_man_MANS)'
+grep '^install-man4:' Makefile.in | grep '\$(notrans_man_MANS)'
+grep '^install-man5:' Makefile.in | grep '\$(notrans_dist_man_MANS)'
+grep '^install-man6:' Makefile.in | grep '\$(notrans_nodist_man_MANS)'
+
+if grep '^install-man8:' Makefile.in; then exit 1; else :; fi
+if grep '^install-man9:' Makefile.in; then exit 1; else :; fi
+
+./configure --program-prefix=gnu- --prefix "`pwd`"/inst --mandir "`pwd`"/inst/man
+$MAKE
+$MAKE test-install
+test `find inst/man -type f -print | wc -l` = 12
+$MAKE uninstall
+test `find inst/man -type f -print | wc -l` = 0
+
+# Opportunistically test for installdirs.
+rm -rf inst
+$MAKE installdirs
+test -d inst/man/man1
+test -d inst/man/man2
+test -d inst/man/man3
+test -d inst/man/man4
+test -d inst/man/man5
+test -d inst/man/man6
+test -d inst/man/man7
+if test -d inst/man/man8; then exit 1; else :; fi
+if test -d inst/man/man9; then exit 1; else :; fi

Re: Implementing notrans_man_MANS

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Peter,

* Peter Breitenlohner wrote on Mon, Mar 10, 2008 at 01:26:08PM CET:
>
> [...] I can only use if/endif if/endif and not if/else/endif
> because a section may have trans_ as well as notrans_ man pages.

Ah yes, sure.

> Attached are revised versions of the three patches. I hope they take
> care of all your earlier comments.

Yes, thank you, also for the detailed comments.  I've applied your
changes in 2 patches (the reindent, plus the actual change set), see
<http://git.savannah.gnu.org/gitweb/?p=automake.git;a=commit;h=f2eadff64fb4b3512b9ede4055cb9defb4b67dbe>
and its parent, with a minor change to your patch as below.  I also
added a NEWS entry.

> notrans.test now contains all combinations. I have incorporated the checks
> that used to be in man4.test into notrans.test, because otherwise there
> would have been much repetition.  Hope this is OK.  If so, remember not to
> mention man4.test in the ChangLog.  If not, I could make that two separate
> tests.

Having one test is fine, and it looks good, too.

I suppose we might want to change the MANS line and the install-manX
rules to be flattened, they already look pretty ugly in the Makefile.
But that can happen in a followup patch.

Cheers, and thanks again!
Ralf

> --- automake-1.10.1.orig/doc/automake.texi 2008-01-21 23:41:02.000000000 +0100
> +++ automake-1.10.1/doc/automake.texi 2008-03-08 01:15:41.000000000 +0100

> +Executables and manpages may be renamed upon installation
> +(@pxref{Renaming}).  For manpages this can be avoided by use of the
> +@code{notrans_} prefix.  For instance, suppose an executable @samp{foo}
> +allowing to access a library function @samp{foo()} from the command line.

The GCS specify to use function names without parentheses, so I removed
them after foo.



Re: Implementing notrans_man_MANS

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 11 Mar 2008, Ralf Wildenhues wrote:

> Having one test is fine, and it looks good, too.
>
> I suppose we might want to change the MANS line and the install-manX
> rules to be flattened, they already look pretty ugly in the Makefile.
> But that can happen in a followup patch.

Hello Ralf,

I guess that could mean a rule starting with
  install-man6: dist_man_MANS man_MANS nodist_man_MANS
  notrans_dist_man_MANS notrans_man_MANS \
  notrans_nodist_man_MANS notrans_nodist_man_MANS

If so, that would make
  grep '^install-man6:' Makefile.in | grep '\$(notrans_nodist_man_MANS)'
in the present notrans.test FAIL.

Maybe it would then be better that the notrans.test script creates none of
the files and have them all created by make rules. (At one time I was not
sure if Automake complains if some of these files are missing.)

To really test these dependencies one could even do:
  rm -f foo.1 z-baz.man
  $MAKE install-man1
  rm -f bar.2 z-bar.man
  $MAKE install-man2
and so on.

Regards,
Peter



Automake support for ObjC++

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

are there any plans that Automake supports ObjC++ (as implemented in
gcc-4.x)?

In TeXlive there is one program that requires one ObjC++ (.mm) file when
compiled for Mac OS X.

With present Automake (1.11) that requires an ugly hack:
(1) create a C++ wrapper including the .mm file
(2) define a separate static library containing just one object file with
this wrapper as source.
(3) adding '-ObjC++' to the CXXFLAGS for that library

All that would be much simpler, more transparent and less fragile with
ObjC++ support from Automake.

The implementation of such support seems to be fairly staightforward.
In case there are no such plans, I could prepare some patches for this.
Please let me know.

Regards
Peter Breitenlohner <peb@...>



Re: Automake support for ObjC++

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, 20 Jul 2009, Peter Breitenlohner wrote:

> are there any plans that Automake supports ObjC++ (as implemented in
> gcc-4.x)?

I forgot to mention: of course, this would require that Autoconf supports
ObjC++.  Are you aware of any plans into that direction?

Regards
Peter



Re: Automake support for ObjC++

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Peter,

* Peter Breitenlohner wrote on Mon, Jul 20, 2009 at 03:35:48PM CEST:
> On Mon, 20 Jul 2009, Peter Breitenlohner wrote:
>
> >are there any plans that Automake supports ObjC++ (as implemented in
> >gcc-4.x)?

AFAIK nobody else is working on patches yet; they would be very welcome.
I suppose adding ObjC++ support should be very straightforward.  Thanks.

> I forgot to mention: of course, this would require that Autoconf supports
> ObjC++.  Are you aware of any plans into that direction?

Nope.  Since 2.64 might not be far away, you might want to do this
first.  (Otherwise, there is also the possibility for an
AM_PROG_OBJCXX.)

Cheers,
Ralf



Re: Automake support for ObjC++

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 21 Jul 2009, Ralf Wildenhues wrote:

> AFAIK nobody else is working on patches yet; they would be very welcome.
> I suppose adding ObjC++ support should be very straightforward.  Thanks.

Hi Ralf,

in the meantime I have created a patch for Automake support of ObjC++. It
was indeed very straightforward.  In a small toy example this works to my
satifaction (of course only together with Autoconf from git plus the patch
from earlier today).

>> I forgot to mention: of course, this would require that Autoconf supports
>> ObjC++.  Are you aware of any plans into that direction?
>
> Nope.  Since 2.64 might not be far away, you might want to do this
> first.  (Otherwise, there is also the possibility for an
> AM_PROG_OBJCXX.)

If the Autoconf patch makes it into 2.64, that then will be a requirement
for ObjC++ support in Automake.

Otherwise it is still possible to slightly rewrite the present Automake
patch such that is uses AM_PROG_OBJCXX.  However, that still requires
autoconf-2.64 because otherwise aclocal can't trace the macro named
'AC_LANG(Objective C++)' which is part of A[CM]_PROG_OBJCXX.

Shall I send the patch right now so you can inspect it, or shall I wait
until autoconf-2.64 is released?

Regards
Peter



Re: Automake support for ObjC++

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Peter Breitenlohner wrote on Wed, Jul 22, 2009 at 05:29:52PM CEST:
>
> Shall I send the patch right now so you can inspect it, or shall I wait
> until autoconf-2.64 is released?

Feel free to send it, if you have it anyway.  More information can only
help.  But a review might be awhile.

Thanks,
Ralf



Re: [PATCH] Automake support for ObjC++

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 22 Jul 2009, Ralf Wildenhues wrote:

> * Peter Breitenlohner wrote on Wed, Jul 22, 2009 at 05:29:52PM CEST:
>>
>> Shall I send the patch right now so you can inspect it, or shall I wait
>> until autoconf-2.64 is released?
>
> Feel free to send it, if you have it anyway.  More information can only
> help.  ...

Hi Ralf,

here it is. But once again: WARNING: if you apply the patch you'll need
Autoconf with ObjC++ support.

Also attached is an extended version of my toy package testing the basic
(Autoconf and Automake) functionality.

> ...  But a review might be awhile.

Not really a problem.  I assume ObjC++ support will be for 1.12 and that
might still be quite some time away.  Any time estimate?

Regards
Peter
From b1f973dd2709b73d954aeb5ca11cb8c065e03397 Mon Sep 17 00:00:00 2001
From: Peter Breitenlohner <peb@...>
Date: Wed, 22 Jul 2009 16:30:51 +0200
Subject: [PATCH] Support for Objective C++

* automake.in: Register new language.
(lang_objcxx_rewrite): New subroutine.
(resolve_linker): Add OBJCXXLINK.
(%_am_macro_for_cond): Add am__fastdepOBJCXX and AC_PROG_OBJCXX
* (%-ac_macro_for_var): Add OBJCXX and OBJCXXFLAGS.
* m4/depend.m4 (_AM_DEPENDENCIES): Add OBJCXX.
* m4/init.m4 (AM_INIT_AUTOMAKE): Add AC_PROG_OBJCXX hook.

* tests/ext.test, tests/nodep2.test: Adjust.
* tests/objcxx.test, tests.objcxx2.test: New tests.
* tests/Makefile.am: Adjust.

* doc/automake.texi (Objective C++ Support): New node.
(How the Linker is Chosen, Support for Other Languages): Adjust.
* NEWS: Announce and require Autoconf 2.64 or better.

Signed-off-by: Peter Breitenlohner <peb@...>
---
 NEWS                     |   11 +++++++++
 automake.in              |   29 ++++++++++++++++++++++-
 doc/automake.texi        |   56 +++++++++++++++++++++++++++++++++++++++++++--
 lib/Automake/Variable.pm |    2 +
 m4/depend.m4             |    1 +
 m4/init.m4               |    4 +++
 tests/Makefile.am        |    2 +
 tests/ext.test           |    7 +++--
 tests/nodep2.test        |    6 +++-
 tests/objcxx.test        |   34 ++++++++++++++++++++++++++++
 tests/objcxx2.test       |   33 +++++++++++++++++++++++++++
 11 files changed, 175 insertions(+), 10 deletions(-)
 create mode 100755 tests/objcxx.test
 create mode 100755 tests/objcxx2.test

diff --git a/NEWS b/NEWS
index 7e14ed8..9bfdde9 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,14 @@
+* Version requirements:
+
+  - Autoconf 2.64 or greater is required.
+
+* Languages changes:
+
+  - New support for Objective C++:
+    - Autoconf's new AC_PROG_OBJCXX looks for a ObjC++ compiler.
+    - A new section of the manual documents the support.
+
+
 New in 1.11a:
 
 Bugs fixed in 1.11a:
diff --git a/automake.in b/automake.in
index bab8c42..8a5dc92 100755
--- a/automake.in
+++ b/automake.in
@@ -783,6 +783,24 @@ register_language ('name' => 'objc',
    'pure' => 1,
    'extensions' => ['.m']);
 
+# Objective C++.
+register_language ('name' => 'objcxx',
+   'Name' => 'Objective C++',
+   'config_vars' => ['OBJCXX'],
+   'linker' => 'OBJCXXLINK',
+   'link' => '$(OBJCXXLD) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
+   'autodep' => 'OBJCXX',
+   'flags' => ['OBJCXXFLAGS', 'CPPFLAGS'],
+   'compile' => '$(OBJCXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS)',
+   'ccer' => 'OBJCXX',
+   'compiler' => 'OBJCXXCOMPILE',
+   'compile_flag' => '-c',
+   'output_flag' => '-o',
+   'lder' => 'OBJCXXLD',
+   'ld' => '$(OBJCXX)',
+   'pure' => 1,
+   'extensions' => ['.mm']);
+
 # Unified Parallel C.
 register_language ('name' => 'upc',
    'Name' => 'Unified Parallel C',
@@ -5860,6 +5878,12 @@ sub lang_objc_rewrite
     return &lang_sub_obj;
 }
 
+# Rewrite a single Objective C++ file.
+sub lang_objcxx_rewrite
+{
+    return &lang_sub_obj;
+}
+
 # Rewrite a single Unified Parallel C file.
 sub lang_upc_rewrite
 {
@@ -6137,7 +6161,7 @@ sub resolve_linker
 {
     my (%linkers) = @_;
 
-    foreach my $l (qw(GCJLINK CXXLINK F77LINK FCLINK OBJCLINK UPCLINK))
+    foreach my $l (qw(GCJLINK OBJCXXLINK CXXLINK F77LINK FCLINK OBJCLINK UPCLINK))
     {
  return $l if defined $linkers{$l};
     }
@@ -6327,13 +6351,14 @@ sub make_conditional_string ($$)
 my %_am_macro_for_cond =
   (
   AMDEP => "one of the compiler tests\n"
-   . "    AC_PROG_CC, AC_PROG_CXX, AC_PROG_CXX, AC_PROG_OBJC,\n"
+   . "    AC_PROG_CC, AC_PROG_CXX, AC_PROG_OBJC, AC_PROG_OBJCXX,\n"
    . "    AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC",
   am__fastdepCC => 'AC_PROG_CC',
   am__fastdepCCAS => 'AM_PROG_AS',
   am__fastdepCXX => 'AC_PROG_CXX',
   am__fastdepGCJ => 'AM_PROG_GCJ',
   am__fastdepOBJC => 'AC_PROG_OBJC',
+  am__fastdepOBJCXX => 'AC_PROG_OBJCXX',
   am__fastdepUPC => 'AM_PROG_UPC'
   );
 
diff --git a/doc/automake.texi b/doc/automake.texi
index b3f4a76..2beec44 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -219,6 +219,7 @@ Building Programs and Libraries
 * Yacc and Lex::                Yacc and Lex support
 * C++ Support::                 Compiling C++ sources
 * Objective C Support::         Compiling Objective C sources
+* Objective C++ Support::       Compiling Objective C++ sources
 * Unified Parallel C Support::  Compiling Unified Parallel C sources
 * Assembly Support::            Compiling assembly sources
 * Fortran 77 Support::          Compiling Fortran 77 sources
@@ -2906,6 +2907,11 @@ Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
 This is required if any Objective C source is included.  @xref{Particular
 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
 
+@item AC_PROG_OBJCXX
+This is required if any Objective C++ source is included.
+@xref{Particular Programs, , Particular Program Checks, autoconf,
+The Autoconf Manual}.
+
 @item AC_PROG_F77
 This is required if any Fortran 77 source is included.  This macro is
 distributed with Autoconf version 2.13 and later.  @xref{Particular
@@ -4535,6 +4541,7 @@ to build programs and libraries.
 * Yacc and Lex::                Yacc and Lex support
 * C++ Support::                 Compiling C++ sources
 * Objective C Support::         Compiling Objective C sources
+* Objective C++ Support::       Compiling Objective C++ sources
 * Unified Parallel C Support::  Compiling Unified Parallel C sources
 * Assembly Support::            Compiling assembly sources
 * Fortran 77 Support::          Compiling Fortran 77 sources
@@ -5628,6 +5635,7 @@ maude_LINK = $(CCLD) -magic -o $@@
 @itemx maude_GCJFLAGS
 @itemx maude_LFLAGS
 @itemx maude_OBJCFLAGS
+@itemx maude_OBJCXXFLAGS
 @itemx maude_RFLAGS
 @itemx maude_UPCFLAGS
 @itemx maude_YFLAGS
@@ -5645,6 +5653,7 @@ Automake.  These @dfn{per-target compilation flags} are
 @samp{_GCJFLAGS},
 @samp{_LFLAGS},
 @samp{_OBJCFLAGS},
+@samp{_OBJCXXFLAGS},
 @samp{_RFLAGS},
 @samp{_UPCFLAGS}, and
 @samp{_YFLAGS}.
@@ -6197,6 +6206,41 @@ The command used to actually link an Objective C program.
 @end vtable
 
 
+@node Objective C++ Support
+@section Objective C++ Support
+
+@cindex Objective C++ support
+@cindex Support for Objective C++
+
+Automake includes some support for Objective C++.
+
+Any package including Objective C++ code must define the output variable
+@code{OBJCXX} in @file{configure.ac}; the simplest way to do this is to
+use the @code{AC_PROG_OBJCXX} macro (@pxref{Particular Programs, ,
+Particular Program Checks, autoconf, The Autoconf Manual}).
+
+A few additional variables are defined when an Objective C++ source file
+is seen:
+
+@vtable @code
+@item OBJCXX
+The name of the Objective C++ compiler.
+
+@item OBJCXXFLAGS
+Any flags to pass to the Objective C++ compiler.
+
+@item AM_OBJCXXFLAGS
+The maintainer's variant of @code{OBJCXXFLAGS}.
+
+@item OBJCXXCOMPILE
+The command used to actually compile an Objective C++ source file.  The
+file name is appended to form the complete command line.
+
+@item OBJCXXLINK
+The command used to actually link an Objective C++ program.
+@end vtable
+
+
 @node Unified Parallel C Support
 @section Unified Parallel C Support
 
@@ -6463,6 +6507,9 @@ parentheses are the variables containing the link command.)
 @vindex GCJLINK
 Native Java (@code{GCJLINK})
 @item
+@vindex OBJCXXLINK
+Objective C++ (@code{OBJCXXLINK})
+@item
 @vindex CXXLINK
 C++ (@code{CXXLINK})
 @item
@@ -6664,7 +6711,8 @@ source file.
 @section Support for Other Languages
 
 Automake currently only includes full support for C, C++ (@pxref{C++
-Support}), Objective C (@pxref{Objective C Support}), Fortran 77
+Support}), Objective C (@pxref{Objective C Support}), Objective C++
+(@pxref{Objective C++ Support}), Fortran 77
 (@pxref{Fortran 77 Support}), Fortran 9x (@pxref{Fortran 9x Support}),
 and Java (@pxref{Java Support}).  There is only rudimentary support for other
 languages, support for which will be improved based on user demand.
@@ -10896,6 +10944,7 @@ flags, not appended.
 @cindex @code{AM_LFLAGS} and @code{LFLAGS}
 @cindex @code{AM_LIBTOOLFLAGS} and @code{LIBTOOLFLAGS}
 @cindex @code{AM_OBJCFLAGS} and @code{OBJCFLAGS}
+@cindex @code{AM_OBJCXXFLAGS} and @code{OBJCXXFLAGS}
 @cindex @code{AM_RFLAGS} and @code{RFLAGS}
 @cindex @code{AM_UPCFLAGS} and @code{UPCFLAGS}
 @cindex @code{AM_YFLAGS} and @code{YFLAGS}
@@ -10910,6 +10959,7 @@ flags, not appended.
 @cindex @code{LFLAGS} and @code{AM_LFLAGS}
 @cindex @code{LIBTOOLFLAGS} and @code{AM_LIBTOOLFLAGS}
 @cindex @code{OBJCFLAGS} and @code{AM_OBJCFLAGS}
+@cindex @code{OBJCXXFLAGS} and @code{AM_OBJCXXFLAGS}
 @cindex @code{RFLAGS} and @code{AM_RFLAGS}
 @cindex @code{UPCFLAGS} and @code{AM_UPCFLAGS}
 @cindex @code{YFLAGS} and @code{AM_YFLAGS}
@@ -10919,8 +10969,8 @@ mostly discuss @code{CPPFLAGS} in our examples, but actually the
 answer holds for all the compile flags used in Automake:
 @code{CCASFLAGS}, @code{CFLAGS}, @code{CPPFLAGS}, @code{CXXFLAGS},
 @code{FCFLAGS}, @code{FFLAGS}, @code{GCJFLAGS}, @code{LDFLAGS},
-@code{LFLAGS}, @code{LIBTOOLFLAGS}, @code{OBJCFLAGS}, @code{RFLAGS},
-@code{UPCFLAGS}, and @code{YFLAGS}.
+@code{LFLAGS}, @code{LIBTOOLFLAGS}, @code{OBJCFLAGS},
+@code{OBJCXXFLAGS}, @code{RFLAGS}, @code{UPCFLAGS}, and @code{YFLAGS}.
 
 @code{CPPFLAGS}, @code{AM_CPPFLAGS}, and @code{mumble_CPPFLAGS} are
 three variables that can be used to pass flags to the C preprocessor
diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm
index 1e24bb2..654fa5d 100644
--- a/lib/Automake/Variable.pm
+++ b/lib/Automake/Variable.pm
@@ -185,6 +185,8 @@ my %_ac_macro_for_var =
    FCFLAGS => 'AC_PROG_FC',
    OBJC => 'AC_PROG_OBJC',
    OBJCFLAGS => 'AC_PROG_OBJC',
+   OBJCXX => 'AC_PROG_OBJCXX',
+   OBJCXXFLAGS => 'AC_PROG_OBJCXX',
    RANLIB => 'AC_PROG_RANLIB',
    UPC => 'AM_PROG_UPC',
    UPCFLAGS => 'AM_PROG_UPC',
diff --git a/m4/depend.m4 b/m4/depend.m4
index efe8643..5ec7fc7 100644
--- a/m4/depend.m4
+++ b/m4/depend.m4
@@ -34,6 +34,7 @@ AC_REQUIRE([AM_DEP_TRACK])dnl
 ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
        [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
        [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+       [$1], OBJCXX, [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
        [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
        [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
                    [depcc="$$1"   am_compiler_list=])
diff --git a/m4/init.m4 b/m4/init.m4
index 365c9ac..c2b02c5 100644
--- a/m4/init.m4
+++ b/m4/init.m4
@@ -99,6 +99,10 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJC],
   [_AM_DEPENDENCIES(OBJC)],
   [define([AC_PROG_OBJC],
   defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+  [_AM_DEPENDENCIES(OBJCXX)],
+  [define([AC_PROG_OBJCXX],
+  defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES(OBJCXX)])])dnl
 ])
 _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
 dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 62529a6..06a119e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -474,6 +474,8 @@ notrans.test \
 number.test \
 objc.test \
 objc2.test \
+objcxx.test \
+objcxx2.test \
 obsolete.test \
 order.test \
 outdir.test \
diff --git a/tests/ext.test b/tests/ext.test
index 929afd5..8f70883 100755
--- a/tests/ext.test
+++ b/tests/ext.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 1999, 2001, 2002, 2006  Free Software Foundation, Inc.
+# Copyright (C) 1999, 2001, 2002, 2006, 2009  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
@@ -22,18 +22,19 @@ cat >> configure.in << 'END'
 AC_PROG_F77
 AC_PROG_FC
 AC_PROG_OBJC
+AC_PROG_OBJCXX
 AM_PROG_UPC
 END
 
 cat > Makefile.am << 'END'
 bin_PROGRAMS = foo
-foo_SOURCES = 1.f 2.for 3.f90 4.f95 5.F 6.F90 7.F95 8.r 9.m 10.upc
+foo_SOURCES = 1.f 2.for 3.f90 4.f95 5.F 6.F90 7.F95 8.r 9.m 10.mm 11.upc
 END
 
 $ACLOCAL || Exit 1
 $AUTOMAKE || Exit 1
 
-for ext in f for f90 f95 F F90 F95 r m upc
+for ext in f for f90 f95 F F90 F95 r m mm upc
 do
    grep "^$ext\.o:" Makefile.in && Exit 1
 done
diff --git a/tests/nodep2.test b/tests/nodep2.test
index 53bcaad..e36fb59 100755
--- a/tests/nodep2.test
+++ b/tests/nodep2.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2006  Free Software Foundation, Inc.
+# Copyright (C) 2006, 2009  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
@@ -22,7 +22,7 @@ set -e
 
 cat > Makefile.am << 'END'
 bin_PROGRAMS = foo
-foo_SOURCES = a.c b.cpp c.m d.S e.java f.upc
+foo_SOURCES = a.c b.cpp c.m cxx.mm d.S e.java f.upc
 END
 
 cat > configure.in << 'END'
@@ -32,6 +32,7 @@ AC_CONFIG_FILES([Makefile])
 AC_PROG_CC
 AC_PROG_CXX
 AC_PROG_OBJC
+AC_PROG_OBJCXX
 AM_PROG_AS
 AM_PROG_GCJ
 AM_PROG_UPC
@@ -41,6 +42,7 @@ END
 : > a.c
 : > b.cpp
 : > c.m
+: > cxx.mm
 : > d.S
 : > e.java
 : > f.upc
diff --git a/tests/objcxx.test b/tests/objcxx.test
new file mode 100755
index 0000000..2dafeb5
--- /dev/null
+++ b/tests/objcxx.test
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2009  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/>.
+
+# Test that `.mm' extension works.
+# From Ralf Corsepius (for C++).
+
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_OBJCXX
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = hello
+hello_SOURCES = hello.mm
+END
+
+$ACLOCAL || Exit 1
+$AUTOMAKE || Exit 1
+
+grep '^\.SUFFIXES:.*\.mm' Makefile.in
diff --git a/tests/objcxx2.test b/tests/objcxx2.test
new file mode 100755
index 0000000..558db21
--- /dev/null
+++ b/tests/objcxx2.test
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 2009  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/>.
+
+# Test that Automake suggests using AC_PROG_OBJCXX if Objective C++
+# sources are used.
+
+. ./defs || Exit 1
+
+set -e
+
+echo AC_PROG_CC >>configure.in
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = hello
+hello_SOURCES = hello.mm
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep AC_PROG_OBJCXX stderr
--
1.6.3.3



play-1.1.tar.gz (95K) Download Attachment

[SPAM] Re: [PATCH] Automake support for ObjC++

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 23 Jul 2009, Peter Breitenlohner wrote:

> On Wed, 22 Jul 2009, Ralf Wildenhues wrote:
>
>> Feel free to send it, if you have it anyway.  More information can only
>> help.  ...
>
> here it is. ......

Hi Ralf,

now that autoconf-2.64 is released, here a revised version of the patch I
sent you last week.

This new version requires autoconf-2.64 (otherwise aclocal fails) and
defines AM_PROG_OBJCXX.  A hook for AC_PROG_OBJCXX, eventually to be defined
by Autoconf, is already in place.

Regards
Peter
From 8b198f23a2fc30cd4405a3594cc73a3e0ae3e3ba Mon Sep 17 00:00:00 2001
From: Peter Breitenlohner <peb@...>
Date: Tue, 28 Jul 2009 15:12:42 +0200
Subject: [PATCH] Support for Objective C++

* m4/objcxx.m4: New Autoconf macros for Objective C++ language.
* m4/Makefile.am: Adjust.
* configure.ac: Require Autoconf 2.64 or better.

* automake.in: Register new language.
(lang_objcxx_rewrite): New subroutine.
(resolve_linker): Add OBJCXXLINK.
(%_am_macro_for_cond): Add am__fastdepOBJCXX and AM_PROG_OBJCXX.
* (%-ac_macro_for_var): Add OBJCXX and OBJCXXFLAGS.
* m4/depend.m4 (_AM_DEPENDENCIES): Add OBJCXX.
* m4/init.m4 (AM_INIT_AUTOMAKE): Add AC_PROG_OBJCXX hook.

* tests/ext.test, tests/nodep2.test: Adjust.
* tests/objcxx.test, tests.objcxx2.test: New tests.
* tests/Makefile.am: Adjust.

* doc/automake.texi (Objective C++ Support): New node.
(Public Macros): Documnet AM_PROG_OBCJXX, OBJCXX, and OBJCXXFLAGS.
(How the Linker is Chosen, Support for Other Languages): Adjust.
* NEWS: Announce and require Autoconf 2.64 or better.

Signed-off-by: Peter Breitenlohner <peb@...>
---
 NEWS                     |   10 +++
 automake.in              |   29 +++++++-
 configure.ac             |    2 +
 doc/automake.texi        |   63 +++++++++++++++-
 lib/Automake/Variable.pm |    2 +
 m4/Makefile.am           |    1 +
 m4/depend.m4             |    5 +-
 m4/init.m4               |    6 +-
 m4/objcxx.m4             |  182 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/Makefile.am        |    2 +
 tests/ext.test           |    7 +-
 tests/nodep2.test        |    6 +-
 tests/objcxx.test        |   34 +++++++++
 tests/objcxx2.test       |   33 ++++++++
 14 files changed, 369 insertions(+), 13 deletions(-)
 create mode 100644 m4/objcxx.m4
 create mode 100755 tests/objcxx.test
 create mode 100755 tests/objcxx2.test

diff --git a/NEWS b/NEWS
index 7e14ed8..0ec2d6d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,15 @@
 New in 1.11a:
 
+* Version requirements:
+
+  - Autoconf 2.64 or greater is required.
+
+* Languages changes:
+
+  - New support for Objective C++:
+    - AM_PROG_OBJCXX looks for a ObjC++ compiler.
+    - A new section of the manual documents the support.
+
 Bugs fixed in 1.11a:
 
 * Bugs introduced by 1.11:
diff --git a/automake.in b/automake.in
index bab8c42..c6d172c 100755
--- a/automake.in
+++ b/automake.in
@@ -783,6 +783,24 @@ register_language ('name' => 'objc',
    'pure' => 1,
    'extensions' => ['.m']);
 
+# Objective C++.
+register_language ('name' => 'objcxx',
+   'Name' => 'Objective C++',
+   'config_vars' => ['OBJCXX'],
+   'linker' => 'OBJCXXLINK',
+   'link' => '$(OBJCXXLD) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
+   'autodep' => 'OBJCXX',
+   'flags' => ['OBJCXXFLAGS', 'CPPFLAGS'],
+   'compile' => '$(OBJCXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCXXFLAGS) $(OBJCXXFLAGS)',
+   'ccer' => 'OBJCXX',
+   'compiler' => 'OBJCXXCOMPILE',
+   'compile_flag' => '-c',
+   'output_flag' => '-o',
+   'lder' => 'OBJCXXLD',
+   'ld' => '$(OBJCXX)',
+   'pure' => 1,
+   'extensions' => ['.mm']);
+
 # Unified Parallel C.
 register_language ('name' => 'upc',
    'Name' => 'Unified Parallel C',
@@ -5860,6 +5878,12 @@ sub lang_objc_rewrite
     return &lang_sub_obj;
 }
 
+# Rewrite a single Objective C++ file.
+sub lang_objcxx_rewrite
+{
+    return &lang_sub_obj;
+}
+
 # Rewrite a single Unified Parallel C file.
 sub lang_upc_rewrite
 {
@@ -6137,7 +6161,7 @@ sub resolve_linker
 {
     my (%linkers) = @_;
 
-    foreach my $l (qw(GCJLINK CXXLINK F77LINK FCLINK OBJCLINK UPCLINK))
+    foreach my $l (qw(GCJLINK OBJCXXLINK CXXLINK F77LINK FCLINK OBJCLINK UPCLINK))
     {
  return $l if defined $linkers{$l};
     }
@@ -6327,13 +6351,14 @@ sub make_conditional_string ($$)
 my %_am_macro_for_cond =
   (
   AMDEP => "one of the compiler tests\n"
-   . "    AC_PROG_CC, AC_PROG_CXX, AC_PROG_CXX, AC_PROG_OBJC,\n"
+   . "    AC_PROG_CC, AC_PROG_CXX, AC_PROG_OBJC, AM_PROG_OBJCXX,\n"
    . "    AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC",
   am__fastdepCC => 'AC_PROG_CC',
   am__fastdepCCAS => 'AM_PROG_AS',
   am__fastdepCXX => 'AC_PROG_CXX',
   am__fastdepGCJ => 'AM_PROG_GCJ',
   am__fastdepOBJC => 'AC_PROG_OBJC',
+  am__fastdepOBJCXX => 'AM_PROG_OBJCXX',
   am__fastdepUPC => 'AM_PROG_UPC'
   );
 
diff --git a/configure.ac b/configure.ac
index e017678..6d07c44 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,6 +16,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+dnl Require Autoconf 2.64 for quoting names of traced macros.
+AC_PREREQ(2.64)
 AC_INIT([GNU Automake], [1.11a], [bug-automake@...])
 
 AC_CONFIG_SRCDIR(automake.in)
diff --git a/doc/automake.texi b/doc/automake.texi
index b3f4a76..3acf5eb 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -219,6 +219,7 @@ Building Programs and Libraries
 * Yacc and Lex::                Yacc and Lex support
 * C++ Support::                 Compiling C++ sources
 * Objective C Support::         Compiling Objective C sources
+* Objective C++ Support::       Compiling Objective C++ sources
 * Unified Parallel C Support::  Compiling Unified Parallel C sources
 * Assembly Support::            Compiling assembly sources
 * Fortran 77 Support::          Compiling Fortran 77 sources
@@ -2906,6 +2907,10 @@ Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
 This is required if any Objective C source is included.  @xref{Particular
 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
 
+@item AM_PROG_OBJCXX
+This is required if any Objective C++ source is included.  @xref{Public
+Macros}.
+
 @item AC_PROG_F77
 This is required if any Fortran 77 source is included.  This macro is
 distributed with Autoconf version 2.13 and later.  @xref{Particular
@@ -3876,6 +3881,15 @@ Program Checks, autoconf, The Autoconf Manual}), but uses the
 @command{missing} script on systems that do not have @command{lex}.
 HP-UX 10 is one such system.
 
+@item AM_PROG_OBJCXX([@var{compiler-search-list}]
+@acindex AM_PROG_OBJCXX
+@vindex OBJCXX
+@vindex OBJCXXFLAGS
+Determine an Objective C++ compiler to use.  If @code{OBJCXX} is not already
+set in the environment, check for Objective C++ compilers.  Set output
+variables @code{OBJCXX} and @code{OBJCXXFLAGS}. The default
+@var{compiler-search-list} is @samp{g++ objc++ objcxx c++}.
+
 @item AM_PROG_GCJ
 @acindex AM_PROG_GCJ
 @vindex GCJ
@@ -4535,6 +4549,7 @@ to build programs and libraries.
 * Yacc and Lex::                Yacc and Lex support
 * C++ Support::                 Compiling C++ sources
 * Objective C Support::         Compiling Objective C sources
+* Objective C++ Support::       Compiling Objective C++ sources
 * Unified Parallel C Support::  Compiling Unified Parallel C sources
 * Assembly Support::            Compiling assembly sources
 * Fortran 77 Support::          Compiling Fortran 77 sources
@@ -5628,6 +5643,7 @@ maude_LINK = $(CCLD) -magic -o $@@
 @itemx maude_GCJFLAGS
 @itemx maude_LFLAGS
 @itemx maude_OBJCFLAGS
+@itemx maude_OBJCXXFLAGS
 @itemx maude_RFLAGS
 @itemx maude_UPCFLAGS
 @itemx maude_YFLAGS
@@ -5645,6 +5661,7 @@ Automake.  These @dfn{per-target compilation flags} are
 @samp{_GCJFLAGS},
 @samp{_LFLAGS},
 @samp{_OBJCFLAGS},
+@samp{_OBJCXXFLAGS},
 @samp{_RFLAGS},
 @samp{_UPCFLAGS}, and
 @samp{_YFLAGS}.
@@ -6197,6 +6214,40 @@ The command used to actually link an Objective C program.
 @end vtable
 
 
+@node Objective C++ Support
+@section Objective C++ Support
+
+@cindex Objective C++ support
+@cindex Support for Objective C++
+
+Automake includes some support for Objective C++.
+
+Any package including Objective C++ code must define the output variable
+@code{OBJCXX} in @file{configure.ac}; the simplest way to do this is to
+use the @code{AM_PROG_OBJCXX} macro (@pxref{Public Macros}).
+
+A few additional variables are defined when an Objective C++ source file
+is seen:
+
+@vtable @code
+@item OBJCXX
+The name of the Objective C++ compiler.
+
+@item OBJCXXFLAGS
+Any flags to pass to the Objective C++ compiler.
+
+@item AM_OBJCXXFLAGS
+The maintainer's variant of @code{OBJCXXFLAGS}.
+
+@item OBJCXXCOMPILE
+The command used to actually compile an Objective C++ source file.  The
+file name is appended to form the complete command line.
+
+@item OBJCXXLINK
+The command used to actually link an Objective C++ program.
+@end vtable
+
+
 @node Unified Parallel C Support
 @section Unified Parallel C Support
 
@@ -6463,6 +6514,9 @@ parentheses are the variables containing the link command.)
 @vindex GCJLINK
 Native Java (@code{GCJLINK})
 @item
+@vindex OBJCXXLINK
+Objective C++ (@code{OBJCXXLINK})
+@item
 @vindex CXXLINK
 C++ (@code{CXXLINK})
 @item
@@ -6664,7 +6718,8 @@ source file.
 @section Support for Other Languages
 
 Automake currently only includes full support for C, C++ (@pxref{C++
-Support}), Objective C (@pxref{Objective C Support}), Fortran 77
+Support}), Objective C (@pxref{Objective C Support}), Objective C++
+(@pxref{Objective C++ Support}), Fortran 77
 (@pxref{Fortran 77 Support}), Fortran 9x (@pxref{Fortran 9x Support}),
 and Java (@pxref{Java Support}).  There is only rudimentary support for other
 languages, support for which will be improved based on user demand.
@@ -10896,6 +10951,7 @@ flags, not appended.
 @cindex @code{AM_LFLAGS} and @code{LFLAGS}
 @cindex @code{AM_LIBTOOLFLAGS} and @code{LIBTOOLFLAGS}
 @cindex @code{AM_OBJCFLAGS} and @code{OBJCFLAGS}
+@cindex @code{AM_OBJCXXFLAGS} and @code{OBJCXXFLAGS}
 @cindex @code{AM_RFLAGS} and @code{RFLAGS}
 @cindex @code{AM_UPCFLAGS} and @code{UPCFLAGS}
 @cindex @code{AM_YFLAGS} and @code{YFLAGS}
@@ -10910,6 +10966,7 @@ flags, not appended.
 @cindex @code{LFLAGS} and @code{AM_LFLAGS}
 @cindex @code{LIBTOOLFLAGS} and @code{AM_LIBTOOLFLAGS}
 @cindex @code{OBJCFLAGS} and @code{AM_OBJCFLAGS}
+@cindex @code{OBJCXXFLAGS} and @code{AM_OBJCXXFLAGS}
 @cindex @code{RFLAGS} and @code{AM_RFLAGS}
 @cindex @code{UPCFLAGS} and @code{AM_UPCFLAGS}
 @cindex @code{YFLAGS} and @code{AM_YFLAGS}
@@ -10919,8 +10976,8 @@ mostly discuss @code{CPPFLAGS} in our examples, but actually the
 answer holds for all the compile flags used in Automake:
 @code{CCASFLAGS}, @code{CFLAGS}, @code{CPPFLAGS}, @code{CXXFLAGS},
 @code{FCFLAGS}, @code{FFLAGS}, @code{GCJFLAGS}, @code{LDFLAGS},
-@code{LFLAGS}, @code{LIBTOOLFLAGS}, @code{OBJCFLAGS}, @code{RFLAGS},
-@code{UPCFLAGS}, and @code{YFLAGS}.
+@code{LFLAGS}, @code{LIBTOOLFLAGS}, @code{OBJCFLAGS},
+@code{OBJCXXFLAGS}, @code{RFLAGS}, @code{UPCFLAGS}, and @code{YFLAGS}.
 
 @code{CPPFLAGS}, @code{AM_CPPFLAGS}, and @code{mumble_CPPFLAGS} are
 three variables that can be used to pass flags to the C preprocessor
diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm
index 1e24bb2..b4efbbd 100644
--- a/lib/Automake/Variable.pm
+++ b/lib/Automake/Variable.pm
@@ -185,6 +185,8 @@ my %_ac_macro_for_var =
    FCFLAGS => 'AC_PROG_FC',
    OBJC => 'AC_PROG_OBJC',
    OBJCFLAGS => 'AC_PROG_OBJC',
+   OBJCXX => 'AM_PROG_OBJCXX',
+   OBJCXXFLAGS => 'AM_PROG_OBJCXX',
    RANLIB => 'AC_PROG_RANLIB',
    UPC => 'AM_PROG_UPC',
    UPCFLAGS => 'AM_PROG_UPC',
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 3ea8840..0e8aa2a 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -43,6 +43,7 @@ minuso.m4 \
 missing.m4 \
 mkdirp.m4 \
 multi.m4 \
+objcxx.m4 \
 obsol-gt.m4 \
 obsol-lt.m4 \
 obsolete.m4 \
diff --git a/m4/depend.m4 b/m4/depend.m4
index efe8643..431c638 100644
--- a/m4/depend.m4
+++ b/m4/depend.m4
@@ -6,7 +6,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 10
+# serial 11
 
 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
@@ -18,7 +18,7 @@
 # _AM_DEPENDENCIES(NAME)
 # ----------------------
 # See how the compiler implements dependency checking.
-# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
 # We try a few techniques and use that to set a single cache variable.
 #
 # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
@@ -34,6 +34,7 @@ AC_REQUIRE([AM_DEP_TRACK])dnl
 ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
        [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
        [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+       [$1], OBJCXX, [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
        [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
        [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
                    [depcc="$$1"   am_compiler_list=])
diff --git a/m4/init.m4 b/m4/init.m4
index 365c9ac..537b5e1 100644
--- a/m4/init.m4
+++ b/m4/init.m4
@@ -7,7 +7,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 16
+# serial 17
 
 # This macro actually does too much.  Some checks are only needed if
 # your package does certain things.  But this isn't really a big deal.
@@ -99,6 +99,10 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJC],
   [_AM_DEPENDENCIES(OBJC)],
   [define([AC_PROG_OBJC],
   defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+  [_AM_DEPENDENCIES(OBJCXX)],
+  [m4_ifdef([AC_PROG_OBJCXX], [define([AC_PROG_OBJCXX],
+  defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES(OBJCXX)])])])dnl
 ])
 _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
 dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
diff --git a/m4/objcxx.m4 b/m4/objcxx.m4
new file mode 100644
index 0000000..2962b7c
--- /dev/null
+++ b/m4/objcxx.m4
@@ -0,0 +1,182 @@
+# Autoconf support for the Objective C++ language.
+
+# Copyright (C) 2009 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 1
+
+## -------------------------------- ##
+## 1d. The Objective C++ language.  ##
+## -------------------------------- ##
+
+
+# In case Autoconf has already defined the Objective C++ language
+# we must undefine these before defining them again (via m4_copy).
+m4_ifdef([AC_PROG_OBJCXX],
+[
+m4_undefine([AC_LANG_CONFTEST(Objective C++)])
+m4_undefine([AC_LANG_SOURCE(Objective C++)])
+m4_undefine([AC_LANG_PROGRAM(Objective C++)])
+m4_undefine([AC_LANG_CALL(Objective C++)])
+m4_undefine([AC_LANG_FUNC_LINK_TRY(Objective C++)])
+m4_undefine([AC_LANG_BOOL_COMPILE_TRY(Objective C++)])
+m4_undefine([AC_LANG_INT_SAVE(Objective C++)])
+m4_undefine([_AC_LANG_IO_PROGRAM(Objective C++)])
+])
+
+# AC_LANG(Objective C++)
+# ----------------------
+AC_LANG_DEFINE([Objective C++], [objcxx], [OBJCXX], [C++],
+[ac_ext=mm
+ac_cpp='$OBJCXXCPP $CPPFLAGS'
+ac_compile='$OBJCXX -c $OBJCXXFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
+ac_link='$OBJCXX -o conftest$ac_exeext $OBJCXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
+ac_compiler_gnu=$ac_cv_objcxx_compiler_gnu
+])
+
+
+
+# -------------------------------- #
+# 3d. The Objective C++ compiler.  #
+# -------------------------------- #
+
+
+# AC_LANG_PREPROC(Objective C++)
+# ------------------------------
+# Find the Objective C++ preprocessor.  Must be AC_DEFUN'd to be AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_PREPROC(Objective C++)],
+[AC_REQUIRE([AM_PROG_OBJCXXCPP])])
+
+
+# AM_PROG_OBJCXXCPP
+# -----------------
+# Find a working Objective C++ preprocessor.
+AC_DEFUN([AM_PROG_OBJCXXCPP],
+[AC_REQUIRE([AM_PROG_OBJCXX])dnl
+AC_ARG_VAR([OBJCXXCPP],   [Objective C++ preprocessor])dnl
+_AC_ARG_VAR_CPPFLAGS()dnl
+AC_LANG_PUSH(Objective C++)dnl
+AC_MSG_CHECKING([how to run the Objective C++ preprocessor])
+if test -z "$OBJCXXCPP"; then
+  AC_CACHE_VAL(ac_cv_prog_OBJCXXCPP,
+  [dnl
+    # Double quotes because OBJCXXCPP needs to be expanded
+    for OBJCXXCPP in "$OBJCXX -E" "/lib/cpp"
+    do
+      _AC_PROG_PREPROC_WORKS_IFELSE([break])
+    done
+    ac_cv_prog_OBJCXXCPP=$OBJCXXCPP
+  ])dnl
+  OBJCXXCPP=$ac_cv_prog_OBJCXXCPP
+else
+  ac_cv_prog_OBJCXXCPP=$OBJCXXCPP
+fi
+AC_MSG_RESULT([$OBJCXXCPP])
+_AC_PROG_PREPROC_WORKS_IFELSE([],
+  [AC_MSG_FAILURE([Objective C++ preprocessor "$OBJCXXCPP" fails sanity check])])
+AC_SUBST(OBJCXXCPP)dnl
+AC_LANG_POP(Objective C++)dnl
+])# AM_PROG_OBJCXXCPP
+
+
+# AC_LANG_COMPILER(Objective C++)
+# -------------------------------
+# Find the Objective C++ compiler.  Must be AC_DEFUN'd to be AC_REQUIRE'able.
+AC_DEFUN([AC_LANG_COMPILER(Objective C++)],
+[AC_REQUIRE([AM_PROG_OBJCXX])])
+
+
+
+# AM_PROG_OBJCXX([LIST-OF-COMPILERS])
+# ---------------------------------
+# LIST-OF-COMPILERS is a space separated list of Objective C++ compilers to
+# search for (if not specified, a default list is used).  This just gives
+# the user an opportunity to specify an alternative search list for the
+# Objective C++ compiler.
+# FIXME: this list is pure guesswork
+# objc++ maybe "standard" name for OBJCXX.
+# objcxx maybe "alternate" name.
+# c++    Native C++ compiler (for instance, Apple).
+AN_MAKEVAR([OBJCXX],  [AM_PROG_OBJCXX])
+AN_PROGRAM([objc++],  [AM_PROG_OBJCXX])
+AN_PROGRAM([objcxx],  [AM_PROG_OBJCXX])
+AC_DEFUN([AM_PROG_OBJCXX],
+[AC_LANG_PUSH(Objective C++)dnl
+AC_ARG_VAR([OBJCXX],      [Objective C++ compiler command])dnl
+AC_ARG_VAR([OBJCXXFLAGS], [Objective C++ compiler flags])dnl
+_AC_ARG_VAR_LDFLAGS()dnl
+_AC_ARG_VAR_LIBS()dnl
+_AC_ARG_VAR_CPPFLAGS()dnl
+_AC_ARG_VAR_PRECIOUS([OBJCXX])dnl
+AC_CHECK_TOOLS(OBJCXX,
+       [m4_default([$1], [g++ objc++ objcxx c++])],
+       g++)
+# Provide some information about the compiler.
+_AS_ECHO_LOG([checking for _AC_LANG compiler version])
+set X $ac_compile
+ac_compiler=$[2]
+for ac_option in --version -v -V -qversion; do
+  _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
+done
+
+m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
+m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
+_AC_LANG_COMPILER_GNU
+if test $ac_compiler_gnu = yes; then
+  GOBJCXX=yes
+else
+  GOBJCXX=
+fi
+_AM_PROG_OBJCXX_G
+AC_LANG_POP(Objective C++)dnl
+_AM_IF_OPTION([no-dependencies],,
+              [_AM_DEPENDENCIES(OBJCXX)])dnl
+])# AM_PROG_OBJCXX
+
+
+# _AM_PROG_OBJCXX_G
+# -----------------
+# Check whether -g works, even if OBJCFLAGS is set, in case the package
+# plays around with OBJCFLAGS (such as to build both debugging and
+# normal versions of a library), tasteless as that idea is.
+# Don't consider -g to work if it generates warnings when plain compiles don't.
+m4_define([_AM_PROG_OBJCXX_G],
+[ac_test_OBJCXXFLAGS=${OBJCXXFLAGS+set}
+ac_save_OBJCXXFLAGS=$OBJCXXFLAGS
+AC_CACHE_CHECK(whether $OBJCXX accepts -g, ac_cv_prog_objcxx_g,
+  [ac_save_objcxx_werror_flag=$ac_objcxx_werror_flag
+   ac_objcxx_werror_flag=yes
+   ac_cv_prog_objcxx_g=no
+   OBJCXXFLAGS="-g"
+   _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+     [ac_cv_prog_objcxx_g=yes],
+     [OBJCXXFLAGS=""
+      _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+ [],
+ [ac_objcxx_werror_flag=$ac_save_objcxx_werror_flag
+ OBJCXXFLAGS="-g"
+ _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+   [ac_cv_prog_objcxx_g=yes])])])
+   ac_objcxx_werror_flag=$ac_save_objcx_werror_flag])
+if test "$ac_test_OBJCXXFLAGS" = set; then
+  OBJCXXFLAGS=$ac_save_OBJCXXFLAGS
+elif test $ac_cv_prog_objcxx_g = yes; then
+  if test "$GOBJCXX" = yes; then
+    OBJCXXFLAGS="-g -O2"
+  else
+    OBJCXXFLAGS="-g"
+  fi
+else
+  if test "$GOBJCXX" = yes; then
+    OBJCXXFLAGS="-O2"
+  else
+    OBJCXXFLAGS=
+  fi
+fi[]dnl
+])# _AM_PROG_OBJCXX_G
+
+
+
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 62529a6..06a119e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -474,6 +474,8 @@ notrans.test \
 number.test \
 objc.test \
 objc2.test \
+objcxx.test \
+objcxx2.test \
 obsolete.test \
 order.test \
 outdir.test \
diff --git a/tests/ext.test b/tests/ext.test
index 929afd5..3b1bd85 100755
--- a/tests/ext.test
+++ b/tests/ext.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 1999, 2001, 2002, 2006  Free Software Foundation, Inc.
+# Copyright (C) 1999, 2001, 2002, 2006, 2009  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
@@ -22,18 +22,19 @@ cat >> configure.in << 'END'
 AC_PROG_F77
 AC_PROG_FC
 AC_PROG_OBJC
+AM_PROG_OBJCXX
 AM_PROG_UPC
 END
 
 cat > Makefile.am << 'END'
 bin_PROGRAMS = foo
-foo_SOURCES = 1.f 2.for 3.f90 4.f95 5.F 6.F90 7.F95 8.r 9.m 10.upc
+foo_SOURCES = 1.f 2.for 3.f90 4.f95 5.F 6.F90 7.F95 8.r 9.m 10.mm 11.upc
 END
 
 $ACLOCAL || Exit 1
 $AUTOMAKE || Exit 1
 
-for ext in f for f90 f95 F F90 F95 r m upc
+for ext in f for f90 f95 F F90 F95 r m mm upc
 do
    grep "^$ext\.o:" Makefile.in && Exit 1
 done
diff --git a/tests/nodep2.test b/tests/nodep2.test
index 53bcaad..6b0cc84 100755
--- a/tests/nodep2.test
+++ b/tests/nodep2.test
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2006  Free Software Foundation, Inc.
+# Copyright (C) 2006, 2009  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
@@ -22,7 +22,7 @@ set -e
 
 cat > Makefile.am << 'END'
 bin_PROGRAMS = foo
-foo_SOURCES = a.c b.cpp c.m d.S e.java f.upc
+foo_SOURCES = a.c b.cpp c.m cxx.mm d.S e.java f.upc
 END
 
 cat > configure.in << 'END'
@@ -32,6 +32,7 @@ AC_CONFIG_FILES([Makefile])
 AC_PROG_CC
 AC_PROG_CXX
 AC_PROG_OBJC
+AM_PROG_OBJCXX
 AM_PROG_AS
 AM_PROG_GCJ
 AM_PROG_UPC
@@ -41,6 +42,7 @@ END
 : > a.c
 : > b.cpp
 : > c.m
+: > cxx.mm
 : > d.S
 : > e.java
 : > f.upc
diff --git a/tests/objcxx.test b/tests/objcxx.test
new file mode 100755
index 0000000..c8075e6
--- /dev/null
+++ b/tests/objcxx.test
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2009  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/>.
+
+# Test that `.mm' extension works.
+# From Ralf Corsepius (for C++).
+
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AM_PROG_OBJCXX
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = hello
+hello_SOURCES = hello.mm
+END
+
+$ACLOCAL || Exit 1
+$AUTOMAKE || Exit 1
+
+grep '^\.SUFFIXES:.*\.mm' Makefile.in
diff --git a/tests/objcxx2.test b/tests/objcxx2.test
new file mode 100755
index 0000000..ed07283
--- /dev/null
+++ b/tests/objcxx2.test
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 2009  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/>.
+
+# Test that Automake suggests using AM_PROG_OBJCXX if Objective C++
+# sources are used.
+
+. ./defs || Exit 1
+
+set -e
+
+echo AC_PROG_CC >>configure.in
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = hello
+hello_SOURCES = hello.mm
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep AM_PROG_OBJCXX stderr
--
1.6.3.3


Re: [PATCH] Automake support for ObjC++

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 28 Jul 2009, Peter Breitenlohner wrote:

> now that autoconf-2.64 is released, here a revised version of the patch I
> sent you last week.
>
> This new version requires autoconf-2.64 (otherwise aclocal fails) and
> defines AM_PROG_OBJCXX.  A hook for AC_PROG_OBJCXX, eventually to be defined
> by Autoconf, is already in place.

Hi Ralf,

I have done some more testing of this patch, with and without the
corresponding patch for Automake-2.64 as well as with and without Libtool.
Doing this I came across this question:

Should the ObjC++ language set --tag=CXX for libtool, i.e. should the ObjC++
language definition specify 'libtool_tag' => 'CXX' or should it not?

And somewhat related: should ObjC specify 'libtool_tag' => 'CC'?

Regards
Peter



Re: [PATCH] Automake support for ObjC++

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Peter,

* Peter Breitenlohner wrote on Wed, Aug 05, 2009 at 10:23:37AM CEST:
> On Tue, 28 Jul 2009, Peter Breitenlohner wrote:
>
> >now that autoconf-2.64 is released, here a revised version of the patch I
> >sent you last week.
> >
> >This new version requires autoconf-2.64 (otherwise aclocal fails) and
> >defines AM_PROG_OBJCXX.  A hook for AC_PROG_OBJCXX, eventually to be defined
> >by Autoconf, is already in place.

> I have done some more testing of this patch, with and without the
> corresponding patch for Automake-2.64

and I still haven't looked at the patch at all.  :-/

> as well as with and without
> Libtool. Doing this I came across this question:
>
> Should the ObjC++ language set --tag=CXX for libtool, i.e. should the ObjC++
> language definition specify 'libtool_tag' => 'CXX' or should it not?
>
> And somewhat related: should ObjC specify 'libtool_tag' => 'CC'?

Both don't really sound right.  The Right Thing[tm] would be for Libtool
to introduce new tags for both languages.  At least if there is a chance
that the compilers from the C and C++ ones, respectively.

For now, I guess it would be sufficient however to set libtool_tag to CC
and CXX, respectively (can you please test that?).  We definitely need
to fix Libtool func_mode_compile to support the .mm .M and maybe also
the .mi .mii extensions however.

Automake should probably not use or discourage .M as that will cause
problems on case-insensitive systems.  Your patch doesn't seem to use
it, good.

Cheers,
Ralf



Re: [PATCH] Automake support for ObjC++

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Peter, and sorry for the delay.

* Peter Breitenlohner wrote on Tue, Jul 28, 2009 at 05:18:11PM CEST:
> now that autoconf-2.64 is released, here a revised version of the patch I
> sent you last week.

Thanks.

> This new version requires autoconf-2.64 (otherwise aclocal fails) and
> defines AM_PROG_OBJCXX.  A hook for AC_PROG_OBJCXX, eventually to be defined
> by Autoconf, is already in place.

Would you be so nice as to respin and simplify the patch under the
assumption that AC_PROG_OBJCXX exists?  I think it should be sufficient
to just require new enough Autoconf for this to work, that way we can
avoid all the duplication and so on.  This patch is targets 1.12 rather
than 1.11.1 anyway.  Maybe it can even omit the objcxx.m4 file
completely?

The other thing I'd like to see either in this patch or in a followup
one is your play-1.1 test rewritten as an Automake testsuite addition,
so that we have one full build test (including distcheck).  (I can do
that if you don't want to.)

(I think a similar note applies to the configure.ac part of play-1.0 and
the Autoconf testsuite.  If you have any issues with this, or don't want
to do the work, ping me and I'll look into it.)

Otherwise, this patch seems to be in pretty good shape.

Thanks,
Ralf

> From 8b198f23a2fc30cd4405a3594cc73a3e0ae3e3ba Mon Sep 17 00:00:00 2001
> From: Peter Breitenlohner <peb@...>
> Date: Tue, 28 Jul 2009 15:12:42 +0200
> Subject: [PATCH] Support for Objective C++
>
> * m4/objcxx.m4: New Autoconf macros for Objective C++ language.
> * m4/Makefile.am: Adjust.
> * configure.ac: Require Autoconf 2.64 or better.
>
> * automake.in: Register new language.
> (lang_objcxx_rewrite): New subroutine.
> (resolve_linker): Add OBJCXXLINK.
> (%_am_macro_for_cond): Add am__fastdepOBJCXX and AM_PROG_OBJCXX.
> * (%-ac_macro_for_var): Add OBJCXX and OBJCXXFLAGS.
> * m4/depend.m4 (_AM_DEPENDENCIES): Add OBJCXX.
> * m4/init.m4 (AM_INIT_AUTOMAKE): Add AC_PROG_OBJCXX hook.
>
> * tests/ext.test, tests/nodep2.test: Adjust.
> * tests/objcxx.test, tests.objcxx2.test: New tests.
> * tests/Makefile.am: Adjust.
>
> * doc/automake.texi (Objective C++ Support): New node.
> (Public Macros): Documnet AM_PROG_OBCJXX, OBJCXX, and OBJCXXFLAGS.
> (How the Linker is Chosen, Support for Other Languages): Adjust.
> * NEWS: Announce and require Autoconf 2.64 or better.
>
> Signed-off-by: Peter Breitenlohner <peb@...>



Re: [PATCH] Automake support for ObjC++

by Peter Breitenlohner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 15 Sep 2009, Ralf Wildenhues wrote:

>> This new version requires autoconf-2.64 (otherwise aclocal fails) and
>> defines AM_PROG_OBJCXX.  A hook for AC_PROG_OBJCXX, eventually to be defined
>> by Autoconf, is already in place.
>
> Would you be so nice as to respin and simplify the patch under the
> assumption that AC_PROG_OBJCXX exists?  I think it should be sufficient
> to just require new enough Autoconf for this to work, that way we can
> avoid all the duplication and so on.  This patch is targets 1.12 rather
> than 1.11.1 anyway.  Maybe it can even omit the objcxx.m4 file
> completely?

OK, I will leave out all the AM_PROG_OBJCXX stuff and pretend that
AC_PROG_OBJCXX exists.  However, as long as Autoconf doesn't provide it,
we'll need the objcxx.m4 file to provide AC_PROG_OBJCXX; otherwise how could
one do any tests.

> The other thing I'd like to see either in this patch or in a followup
> one is your play-1.1 test rewritten as an Automake testsuite addition,
> so that we have one full build test (including distcheck).  (I can do
> that if you don't want to.)
>
> (I think a similar note applies to the configure.ac part of play-1.0 and
> the Autoconf testsuite.  If you have any issues with this, or don't want
> to do the work, ping me and I'll look into it.)

What precisely did you have in mind? I suppose just a somewhat cleaned up
version of my old tarball(s), such that you can use them in an Automake
testsuite addition.  I'll do that it may take a little time (few weeks).

=================

Two completely unrelated items:

(1) I noticed that 'make uninstallcheck' does test for leftover installed
files but not for symlinks (same for distcleancheck).  I stumbled onto this
because I had some symlinks installed via install-exec-hook but (due to a
typo) not uninstalled via uninstall-hook; to my surprise this was never
reported by distcheck.

I suppose this is a bug and the fix is extremely trivial.  Shall I send a
separate report with patch or can you simply modify the definition of both
distuninstallcheck_listfiles and distcleancheck_listfiles into
  'find . -type f -o -type l -print'
plus appropriate corrections to the manual?

(2) The manual says that INCLUDES does the same job as AM_CPPFLAGS (or any
per-target _CPPFLAGS' variable if it is used), and is an older name for the
same functionality, and that INCLUDES is deprecated.

The first part is more or less true. However, I wish that INCLUDES were not
deprecated because it is sometimes convenient to use both, as e.g.,
  INCLUDES = -Isome_dir # common flags
  AM_CPPFLAGS = -UPROG # additional flags (default)
  prog1_CPPFLAGS = -Dprog1 # additional flags for prog1
  prog2_CPPFLAGS = -Dprog2 # additional flags for prog2
Of course, one could rewrite this as
  includes = -Isome_dir
  AM_CPPFLAGS = $(includes) -UPROG
  prog1_CPPFLAGS = $(includes) -Dprog1
  prog2_CPPFLAGS = $(includes) -Dprog2
but why drop some (at least marginally) useful functionality.

=================

Regards
Peter Breitenlohner <peb@...>


< Prev | 1 - 2 | Next >