Subject: [bug#75807] [PATCH,WIP] Support for the Algol 68 language

From: "Jose E. Marchesi" <[email-masked]>
Date: Sun, 26 Jan 2025 00:56:56 +0100

Hello.

New version of the patch below.  Differences from previous versions:

- The GA68 variable has been renamed to A68.  (This has been also
  changed in the corresponding autoconf patches.)
- Added a section 'Algol 68 Support' to the manual.
- Added a test t/a68-demo.sh.

commit c33511e6df2b23de3040484a56cc0efdff5c0691
Author: Jose E. Marchesi <[email-masked]>
Date:   Fri Jan 24 00:20:27 2025 +0100

    Add support for the Algol 68 programming language.
    
    * NEWS: Add entry for Algol 68.
    * doc/automake.texi (Algol 68 Support): New section.
    * bin/automake.in: Call register_language for Algol 68.
      (resolve_linker): handle A68LINK.
      (%_am_macro_for_cond): Add entry for am__fastdepGA68.
    * configure.ac: Look for ga68 and set GNU_GA68 and GNU_A68FLAGS if fuond.
    * lib/Automake/Variable.pm (%_ac_macro_for_var): Add entries for GA68
      and GA68FLAGS.
    * t/a68-demo.sh: New test.

diff --git a/NEWS b/NEWS
index b4c50ffc6..9da978c39 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ please see NEWS-future and start following the advice there now.
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 New in 1.x:
 
+* New supported languages:
+
+  - Support for Algol 68 has been added; based on the GNU Algol 68 compiler.
+
 * Miscellaneous changes
 
    - Only require the presence of an ABOUT-NLS file at the 'gnits'
diff --git a/bin/automake.in b/bin/automake.in
index 5d3e7c766..f7451e3f8 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -1023,6 +1023,24 @@ register_language ('name' => 'java',
 		   'pure' => 1,
 		   'extensions' => ['.java', '.class', '.zip', '.jar']);
 
+# Algol 68 in GCC
+register_language ('name' => 'a68',
+                   'Name' => 'Algol 68',
+                   'config_vars' => ['A68'],
+                   'linker' => 'A68LINK',
+                   'link' => '$(A68LD) $(AM_A68FLAGS) $(A68FLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@',
+		   'flags' => ['A68FLAGS'],
+		   'compile' => '$(A68) $(AM_A68FLAGS) $(A68FLAGS)',
+		   'ccer' => 'A68',
+		   'compiler' => 'A68COMPILE',
+		   'compile_flag' => '-c',
+		   'output_flag' => '-o',
+		   'libtool_tag' => 'A68',
+		   'lder' => 'A68LD',
+		   'ld' => '$(A68)',
+		   'pure' => 1,
+		   'extensions' => ['.a68']);
+
 ################################################################
 
 # Error reporting functions.
@@ -5564,7 +5582,7 @@ EOF
 	  if (0 == keys %libtool_tags)
 	    {
 	      # Hardcode the tags supported by Libtool 1.5.
-	      %libtool_tags = (CC => 1, CXX => 1, GCJ => 1, F77 => 1);
+	      %libtool_tags = (CC => 1, CXX => 1, GCJ => 1, F77 => 1, A68 => 1);
 	    }
 	}
     }
@@ -6057,7 +6075,7 @@ sub resolve_linker
 {
     my (%linkers) = @_;
 
-    foreach my $l (qw(GCJLINK OBJCXXLINK CXXLINK F77LINK FCLINK OBJCLINK UPCLINK))
+    foreach my $l (qw(GCJLINK A68LINK OBJCXXLINK CXXLINK F77LINK FCLINK OBJCLINK UPCLINK))
     {
 	return $l if defined $linkers{$l};
     }
@@ -6176,11 +6194,12 @@ my %_am_macro_for_cond =
   (
   AMDEP => "one of the compiler tests\n"
 	   . "    AC_PROG_CC, AC_PROG_CXX, AC_PROG_OBJC, AC_PROG_OBJCXX,\n"
-	   . "    AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC",
+	   . "    AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC, AM_PROG_A68",
   am__fastdepCC => 'AC_PROG_CC',
   am__fastdepCCAS => 'AM_PROG_AS',
   am__fastdepCXX => 'AC_PROG_CXX',
   am__fastdepGCJ => 'AM_PROG_GCJ',
+  am__fastdepA68 => 'AM_PROG_A68',
   am__fastdepOBJC => 'AC_PROG_OBJC',
   am__fastdepOBJCXX => 'AC_PROG_OBJCXX',
   am__fastdepUPC => 'AM_PROG_UPC'
diff --git a/configure.ac b/configure.ac
index 0a9e1904e..27fe4a328 100644
--- a/configure.ac
+++ b/configure.ac
@@ -565,6 +565,16 @@ if test "$GNU_F77" != false; then
         _AM_SKIP_COMP_TESTS([GNU Fortran 77])])
 fi
 
+# GNU Algol 68 compiler.
+AC_ARG_VAR([GNU_A68],    [GNU Algol 68 compiler])
+AC_ARG_VAR([GNU_A68FLAGS], [GNU Algol 68 compiler flags])
+AC_CHECK_TOOLS([GNU_A68], [ga68], [false])
+if test "$GNU_A68" != false; then
+   AS_IF([AM_RUN_LOG([$GNU_A68 --version && $GNU_A68 -v])], [],
+   [AC_MSG_WARN([botched installation for GNU Algol 68 compiler])
+   _AM_SKIP_COMP_TESTS([GNU Algol 68])])
+fi
+
 # GNU Java compiler.
 AC_ARG_VAR([GNU_GCJ], [GNU Java compiler])
 AC_ARG_VAR([GNU_GCJFLAGS], [GNU Java compiler flags])
diff --git a/doc/automake.texi b/doc/automake.texi
index a5b993007..4f848e7af 100644
--- a/doc/automake.texi
+++ b/doc/automake.texi
@@ -230,6 +230,7 @@ Building Programs and Libraries
 * Fortran 9x Support::          Compiling Fortran 9x sources
 * Java Support with gcj::       Compiling Java sources using gcj
 * Vala Support::                Compiling Vala sources
+* Algol 68 Support::            Compiling Algol 68 sources
 * Support for Other Languages:: Compiling other languages
 * Dependencies::                Automatic dependency tracking
 * EXEEXT::                      Support for executable extensions
@@ -4848,6 +4849,7 @@ to build programs and libraries.
 * Fortran 9x Support::          Compiling Fortran 9x sources
 * Java Support with gcj::       Compiling Java sources using gcj
 * Vala Support::                Compiling Vala sources
+* Algol 68 Support::            Compiling Algol 68 sources
 * Support for Other Languages::  Compiling other languages
 * Dependencies::                Automatic dependency tracking
 * EXEEXT::                      Support for executable extensions
@@ -7178,6 +7180,41 @@ Note that currently, you cannot use per-target @code{*_VALAFLAGS}
 (@pxref{Renamed Objects}) to produce different C files from one Vala
 source file.
 
+@node Algol 68 Support
+@comment  node-name,  next,  previous,  up
+@section Algol 68 Support
+
+@cindex Algol 68 support
+@cindex Support for Algol 68
+
+Automake includes support for Algol 68, using GCC.
+
+Any package including Algol 68 code must define the output variable
+@code{A68} in @file{configure.ac}; the simplest way to do this is to use
+the @code{AC_PROG_A68} macro (@pxref{Particular Programs, , Particular
+Program Checks, autoconf, The Autoconf Manual}).
+
+A few additional variables are defined when a Fortran 77 source file is
+seen:
+
+@vtable @code
+
+@item A68
+The name of the Algol 68 compiler.
+
+@item A68FLAGS
+Any flags to pass to the Algol 68 compiler.
+
+@item AM_A68FLAGS
+The maintainer's variant of @code{FFLAGS}.
+
+@item A68COMPILE
+The command used to compile an Algol 68 source file.  The file name is
+appended to form the complete command line.
+
+@item A68LINK
+The command used to link a pure Algol 68 program or shared library.
+@end vtable
 
 @node Support for Other Languages
 @comment  node-name,  next,  previous,  up
diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm
index 6e90b81f2..7608de23d 100644
--- a/lib/Automake/Variable.pm
+++ b/lib/Automake/Variable.pm
@@ -183,6 +183,8 @@ my %_ac_macro_for_var =
    CXX => 'AC_PROG_CXX',
    CXXFLAGS => 'AC_PROG_CXX',
    F77 => 'AC_PROG_F77',
+   A68 => 'AC_PROG_A68',
+   A68FLAGS => 'AC_PROG_A68',
    FFLAGS => 'AC_PROG_F77',
    FC => 'AC_PROG_FC',
    FCFLAGS => 'AC_PROG_FC',
diff --git a/t/a68-demo.sh b/t/a68-demo.sh
new file mode 100644
index 000000000..c2966d4ea
--- /dev/null
+++ b/t/a68-demo.sh
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 2012-2025 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 <https://www.gnu.org/licenses/>.
+
+# Demo on Algol 68 support.
+
+required=ga68
+am_create_testdir=empty
+. test-init.sh
+
+cat > configure.ac << 'END'
+AC_INIT([GNU Algol 68 Demo], [1.0], [[email-masked]])
+AC_CONFIG_SRCDIR([play.a68])
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE
+AC_PROG_A68
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+
+bin_PROGRAMS = work play
+play_SOURCES = play.a68
+work_SOURCES = work.a68
+
+.PHONY: test-objs
+check-local: test-objs
+test-objs:
+	test -f play.$(OBJEXT)
+	test -f work.$(OBJEXT)
+END
+
+mkdir sub build-aux
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+cat > work.a68 << 'END'
+PROGRAM (puts ("We are working :-(\n"); 0)
+END
+
+cat > play.a68 << 'END'
+PROGRAM (puts ("We are playing :-)\n"); 0)
+END
+
+./configure
+$MAKE
+$MAKE test-objs
+
+if ! cross_compiling; then
+  unindent > exp.play << 'END'
+    We are playing :-)
+END
+  unindent > exp.work << 'END'
+    We are working :-(
+END
+  for p in play work; do
+    # The program must run correctly (exit status = 0).
+    ./$p
+    # And it must have the expected output.  Note that we strip extra
+    # CR characters (if any), to cater to MinGW programs on MSYS.
+    # See automake bug#14493.
+    ./$p | tr -d '\015' > got.$p || { cat got.$p; exit 1; }
+    cat exp.$p
+    cat got.$p
+    diff exp.$p got.$p
+  done
+fi
+
+$MAKE distcheck
+
+: