]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Support for the Algol 68 language master
authorJose E. Marchesi <jemarch@gnu.org>
Thu, 28 Aug 2025 19:30:16 +0000 (21:30 +0200)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 26 Oct 2025 15:24:20 +0000 (08:24 -0700)
This patch adds support for the Algol 68 programming language to
Autoconf.  It is based on the Algol 68 GCC front-end, which is
currently under development [1].  The front-end is temporarily hosted
in the sourceware forge until integration in GCC is completed [3].

Note that the GCC Algol 68 front-end is not yet integrated in the main
compiler, so it is developed and distributed off-tree.  See
https://gcc.gnu.org/wiki/Algol68FrontEnd.  Additional information
about the Algol 68 programming language, and how it is being evolved
by the GNU Algol 68 Working Group can be found at
https://algol68-lang.org.

Automake support for Algol 68 has been already pushed as of 2 February
2025.

[1] https://gcc.gnu.org/wiki/Algol68FrontEnd
[2] https://inbox.sourceware.org/gcc-patches/20250101020952.18404-1-jose.marchesi@oracle.com/T/#t
[3] https://forge.sourceforge.org/gcc/gcc-a68

    Add support for the Algol68 programming language.

    * lib/autoconf/a68.m4: New file.
    * lib/autoconf/autoconf.m4: Include autoconf/a68.m4.
    * lib/autoconf/Makefile.am (dist_autoconflib_DATA): Add a68.m4.
    * lib/freeze.mk (autoconf_m4f_dependencies): Add
    $(src_libdir)/autoconf/a68.m4.
    * doc/autoconf.texi: Rebuild menus.
    (Preset Output Variables): Mention Algol 68.  Document A68FLAGS.
    (Algol 68 Compiler): New subsection.
    (Language Choice): Mention Algol 68.
    (Generating Sources): Likewise.
    (Running the Preprocessor): Likewise.
    * tests/a68.at: New file.
    * tests/suite.at: Include a68.at.
    * tests/local.at (_AT_CHECK_ENV): Add A68 and A68FLAGS.
    * NEWS: Update.

NEWS
doc/autoconf.texi
lib/autoconf/a68.m4 [new file with mode: 0644]
lib/autoconf/autoconf.m4
lib/freeze.mk
lib/local.mk
tests/a68.at [new file with mode: 0644]
tests/local.at
tests/local.mk
tests/suite.at

diff --git a/NEWS b/NEWS
index 8c323887f5a2f801e947cebf96204bfaba722e13..fb6762ad85f7a3de96eb2d9f89795b5dfab56ef9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,9 @@ GNU Autoconf NEWS - User visible changes.
   The autom4te, autoscan and ifnames programs now recognize the two
   preprocessor directives, which were introduced in C23 and C++23.
 
+*** Support for the Algol 68 programming language has been added.
+  The new macro AC_LANG_A68 sets variables A68 and A68FLAGS.
+
 *** AC_PROG_AWK now also checks for busybox awk.
 
 *** AC_USE_SYSTEM_EXTENSIONS now defines _COSMO_SOURCE for Cosmopolitan Libc.
index 93611008a81aa88f667b5f6d21b545d3c0e07a92..eb0967f03cc11208dfd9e28d842bdc7e61aafd28 100644 (file)
@@ -417,6 +417,7 @@ Compilers and Preprocessors
 * Erlang Compiler and Interpreter::  Likewise
 * Fortran Compiler::            Likewise
 * Go Compiler::                 Likewise
+* Algol 68 Compiler::           Likewise
 
 Writing Tests
 
@@ -2743,7 +2744,7 @@ programs to test for Fortran 77 features.
 Options for the linker.  If it is not set
 in the environment when @command{configure} runs, the default value is empty.
 @command{configure} uses this variable when linking programs to test for
-C, C++, Objective C, Objective C++, Fortran, and Go features.
+features in C, C++, Objective C, Objective C++, Fortran, Go, and Algol 68.
 
 This variable's contents should contain options like @option{-s} and
 @option{-L} that affect only the behavior of the linker.  Please see the
@@ -2786,6 +2787,13 @@ Debugging and optimization options for the Go compiler.  It acts like
 @code{CFLAGS}, but for Go instead of C.
 @end defvar
 
+@defvar A68FLAGS
+@evindex A68FLAGS
+@ovindex A68FLAGS
+Debugging and optimization options for the Algol 68 compiler.  It acts
+like @code{CFLAGS}, but for Algol 68 instead of C.
+@end defvar
+
 @defvar builddir
 @ovindex builddir
 Rigorously equal to @samp{.}.  Added for symmetry only.
@@ -7094,6 +7102,7 @@ compiling.
 * Erlang Compiler and Interpreter::  Likewise
 * Fortran Compiler::            Likewise
 * Go Compiler::                 Likewise
+* Algol 68 Compiler::           Likewise
 @end menu
 
 @node Specific Compiler Characteristics
@@ -8635,6 +8644,38 @@ If output variable @code{GOFLAGS} was not already set, set it to
 @end defmac
 
 
+@node Algol 68 Compiler
+@subsection Algol 68 Compiler
+@cindex Algol 68
+
+Autoconf provides basic support for the Algol 68 programming language
+when using the @code{ga68} compiler.
+
+Note that the GCC Algol 68 front-end is not yet integrated in the main
+compiler, so it is developed and distributed off-tree.  See
+@url{https://gcc.gnu.org/wiki/Algol68FrontEnd}.  Additional information
+about the Algol 68 programming language, and how it is being evolved by
+the GNU Algol 68 Working Group can be found at
+@url{https://algol68-lang.org}.
+
+@defmac AC_PROG_A68 (@ovar{compiler-search-list})
+Find the Algol 68 compiler to use.  Check whether the environment
+variable @code{A68} is set; if so, then set output variable @code{A68}
+to its value.
+
+Otherwise, if the macro is invoked without an argument, then search for
+an Algol 68 compiler named @code{ga68}.  If it is not found, then as a
+last resort set @code{A68} to @code{ga68}.
+
+This macro may be invoked with an optional first argument which, if
+specified, must be a blank-separated list of Algol 68 compilers to
+search for.
+
+If output variable @code{A68FLAGS} was not already set, set it to
+@option{-g -O2}.  If your package does not like this default,
+@code{A68FLAGS} may be set before @code{AC_PROG_A68}.
+@end defmac
+
 @node System Services
 @section System Services
 
@@ -9185,6 +9226,10 @@ extension @file{.mm} for test programs.  Use compilation flags:
 @item Go
 Do compilation tests using @code{GOC} and use extension @file{.go} for
 test programs.  Use compilation flags @code{GOFLAGS}.
+
+@item Algol 68
+Do compilation tests using @code{A68} and use extension @file{.a68} for
+test programs.  Use compilation flags @code{A68FLAGS}.
 @end table
 @end defmac
 
@@ -9432,7 +9477,8 @@ on a system with @command{gcc} installed, results in:
 const char hw[] = "Hello, World\n";
 @end example
 
-When the test language is Fortran, Erlang, or Go, the @code{AC_DEFINE}
+When the test language is Fortran, Erlang, Go, or Algol 68,
+the @code{AC_DEFINE}
 definitions are not automatically translated into constants in the
 source code by this macro.
 
@@ -9557,7 +9603,7 @@ Nevertheless, if you need to run the preprocessor, then use
 @code{AC_PREPROC_IFELSE}.
 
 The macros described in this section cannot be used for tests in Erlang,
-Fortran, or Go, since those languages require no preprocessor.
+Fortran, Go, or Algol 68 since those languages require no preprocessor.
 
 @anchor{AC_PREPROC_IFELSE}
 @defmac AC_PREPROC_IFELSE (@var{input}, @ovar{action-if-true}, @
diff --git a/lib/autoconf/a68.m4 b/lib/autoconf/a68.m4
new file mode 100644 (file)
index 0000000..12d366c
--- /dev/null
@@ -0,0 +1,153 @@
+# This file is part of Autoconf.                       -*- Autoconf -*-
+# Algol 68 language support.
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This file is part of Autoconf.  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 of the License, 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.
+#
+# Under Section 7 of GPL version 3, you are granted additional
+# permissions described in the Autoconf Configure Script Exception,
+# version 3.0, as published by the Free Software Foundation.
+#
+# You should have received a copy of the GNU General Public License
+# and a copy of the Autoconf Configure Script Exception along with
+# this program; see the files COPYINGv3 and COPYING.EXCEPTION
+# respectively.  If not, see <https://www.gnu.org/licenses/> and
+# <https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob_plain;f=COPYING.EXCEPTION>.
+
+# Algol 68 support contributed by Jose E. Marchesi.
+
+# ------------------- #
+# Language selection.
+# ------------------- #
+
+# AC_LANG(Algol 68)
+# -----------------
+AC_LANG_DEFINE([Algol 68], [a68], [A68], [A68], [],
+[ac_ext=a68
+ac_compile='$A68 -c $A68FLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
+ac_link='$A68 -o conftest$ac_exeext $A68FLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
+ac_compiler_gnu=yes
+])
+
+# AC_LANG_A68
+# -----------
+AU_DEFUN([AC_LANG_A68], [AC_LANG(Algol 68)])
+
+# ------------------- #
+# Producing programs.
+# ------------------- #
+
+# AC_LANG_PROGRAM(Algol 68)([PROLOGUE], [BODY])
+# ---------------------------------------------
+m4_define([AC_LANG_PROGRAM(Algol 68)],
+[$1
+begin $2 m4_ifnblank([$2],[;])
+      skip
+end])
+
+# _AC_LANG_IO_PROGRAM(Algol 68)
+# -----------------------------
+# Produce source that performs I/O.
+m4_define([_AC_LANG_IO_PROGRAM(Algol 68)],
+[AC_LANG_PROGRAM([],
+[if int fd = fcreate ("conftest.out", 8r0777); fd = -1
+ then perror ("error creating conftest.out")
+ elif fclose (fd) = -1 then perror ("error closing conftest.out")
+ fi
+])])
+
+# AC_LANG_CALL(Algol 68)(PROLOGUE, FUNCTION)
+# ------------------------------------------
+# Avoid conflicting decl of main.
+m4_define([AC_LANG_CALL(Algol 68)],
+[AC_LANG_PROGRAM([],[])])
+
+# AC_LANG_FUNC_LINK_TRY(Algol 68)(FUNCTION)
+# -----------------------------------------
+# Try to link a program which calls FUNCTION.
+m4_define([AC_LANG_FUNC_LINK_TRY(Algol 68)],
+[AC_LANG_PROGRAM([],[])])
+
+# AC_LANG_BOOL_COMPILE_TRY(Algol 68)(PROLOGUE, EXPRESSION)
+# --------------------------------------------------------
+# Return a program which is valid if EXPRESSION is nonzero.
+m4_define([AC_LANG_BOOL_COMPILE_TRY(Algol 68)],
+[AC_LANG_PROGRAM([], [@<:@$2@:>@INT test multiple;
+                     0])])
+
+# AC_LANG_INT_SAVE(Algol 68)(PROLOGUE, EXPRESSION)
+# ------------------------------------------------
+m4_define([AC_LANG_INT_SAVE(Algol 68)],
+[AC_LANG_PROGRAM([
+proc itoa = (int i) string:
+      begin if i = 0
+           then "0"
+           else int n := ABS i;
+                string res;
+                while n /= 0
+                do int rem = n %* 10;
+                   res := (REPR (rem > 9 | (rem - 10) + ABS "a"
+                                 | rem + ABS "0")
+                           + res);
+                   n %:= 10
+                od;
+                (i < 0 | "-" + res | res)
+           fi
+      end;
+
+int ret := 0;
+int fd = fopen ("conftest.val", file o wronly)/
+(fd = -1 | ret := 1; stop);
+(fputs (fd, itoa ($2)) = 0 | ret := 1; stop)
+])])
+
+# ---------------------- #
+# Looking for compilers. #
+# ---------------------- #
+
+# AC_LANG_COMPILER(Algol 68)
+# --------------------------
+AC_DEFUN([AC_LANG_COMPILER(Algol 68)],
+[AC_REQUIRE([AC_PROG_A68])])
+
+# AC_PROG_A68
+# ------------
+AN_MAKEVAR([A68], [AC_PROG_A68])
+AN_PROGRAM([ga68], [AC_PROG_A68])
+AC_DEFUN([AC_PROG_A68],
+[AC_LANG_PUSH(Algol 68)dnl
+AC_ARG_VAR([A68], [Algol 68 compiler command])dnl
+AC_ARG_VAR([A68FLAGS], [Algol 68 compiler flags])dnl
+_AC_ARG_VAR_LDFLAGS()dnl
+m4_ifval([$1],
+      [AC_CHECK_TOOLS(A68, [$1])],
+[AC_CHECK_TOOL(A68, ga68)
+if test -z "$A68"; then
+  if test -n "$ac_tool_prefix"; then
+    AC_CHECK_PROG(A68, [${ac_tool_prefix}ga68], [$ac_tool_prefix}ga68])
+  fi
+fi
+if test -z "$A68"; then
+  AC_CHECK_PROG(A68, ga68, ga68, , , false)
+fi
+])
+
+# Provide some information about the compiler.
+_AS_ECHO_LOG([checking for _AC_LANG compiler version])
+set X $ac_compile
+ac_compiler=$[2]
+_AC_DO_LIMIT([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
+m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
+m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
+A68FLAGS="-g -O2"
+AC_LANG_POP(Algol 68)dnl
+])# AC_PROG_A68
index c2b6aea3d79b45806a66621bdbbb316da1bca753..d79888e9eb447366c00fd1637c3d7c7c4662dbfd 100644 (file)
@@ -44,6 +44,7 @@ m4_include([autoconf/c.m4])
 m4_include([autoconf/erlang.m4])
 m4_include([autoconf/fortran.m4])
 m4_include([autoconf/go.m4])
+m4_include([autoconf/a68.m4])
 m4_include([autoconf/functions.m4])
 m4_include([autoconf/headers.m4])
 m4_include([autoconf/types.m4])
index 8239080e2a7de03001844b8a15b89a3afe80813f..9535306f7a900b2c55dca495ccfc27714d519fc7 100644 (file)
@@ -89,6 +89,7 @@ autoconf_m4f_dependencies =                   \
        $(src_libdir)/autoconf/fortran.m4       \
        $(src_libdir)/autoconf/erlang.m4        \
        $(src_libdir)/autoconf/go.m4            \
+       $(src_libdir)/autoconf/a68.m4           \
        $(src_libdir)/autoconf/functions.m4     \
        $(src_libdir)/autoconf/headers.m4       \
        $(src_libdir)/autoconf/types.m4         \
index 98a7f36a608af0e4f7d7174aa893e8855f6fdcde..62440dd0752868dda86037898ab2d43514585f55 100644 (file)
@@ -95,6 +95,7 @@ dist_autoconflib_DATA = \
   lib/autoconf/fortran.m4 \
   lib/autoconf/functions.m4 \
   lib/autoconf/go.m4 \
+  lib/autoconf/a68.m4 \
   lib/autoconf/headers.m4 \
   lib/autoconf/types.m4 \
   lib/autoconf/libs.m4 \
diff --git a/tests/a68.at b/tests/a68.at
new file mode 100644 (file)
index 0000000..e9ac00f
--- /dev/null
@@ -0,0 +1,33 @@
+#                                                      -*- Autotest -*-
+
+AT_BANNER([Algol 68 low level compiling and utility macros.])
+
+# Copyright (C) 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 3 of the License, 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/>.
+
+
+# Since the macros which compile are required by most tests, check
+# them first.  But remember that looking for a compiler is even more
+# primitive, so check those first.
+
+
+## ------------------- ##
+## Algol 68 Compiler.  ##
+## ------------------- ##
+
+AT_CHECK_MACRO([Algol 68],
+[[AC_LANG(Algol 68)
+AC_LANG_COMPILER
+]])
index 6bf31ab328f62d57875b281a14d89103d94abe4c..05cfdb39cc763cfb62584a022db080b93b3fa7b9 100644 (file)
@@ -581,7 +581,7 @@ if test -f state-env.before && test -f state-env.after; then
     ($EGREP -v '^(m4_join([|],
       [a[cs]_.*],
       [(exec_)?prefix|DEFS|CONFIG_STATUS],
-      [CC|CFLAGS|CPPFLAGS|CPP|GCC|CXX|CXXFLAGS|CXXCPP|GXX|F77|FFLAGS|FLIBS|G77],
+      [A68|A68FLAGS|CC|CFLAGS|CPPFLAGS|CPP|GCC|CXX|CXXFLAGS|CXXCPP|GXX|F77|FFLAGS|FLIBS|G77],
       [ERL|ERLC|ERLCFLAGS|ERLANG_PATH_ERL|ERLANG_ROOT_DIR|ERLANG_LIB_DIR],
       [ERLANG_LIB_DIR_.*|ERLANG_LIB_VER_.*|ERLANG_INSTALL_LIB_DIR],
       [ERLANG_INSTALL_LIB_DIR_.*|ERLANG_ERTS_VER|OBJC|OBJCPP|OBJCFLAGS],
index 6a2c06a81f7f041cf6671967dc8010639b733039..77808f7dec204df3e8c7ec00a86fdf8583b98d81 100644 (file)
@@ -92,6 +92,7 @@ TESTSUITE_GENERATED_AT = \
   tests/acerlang.at \
   tests/acfortran.at \
   tests/acgo.at \
+  tests/aca68.at \
   tests/acgeneral.at \
   tests/acstatus.at \
   tests/acautoheader.at \
@@ -116,6 +117,7 @@ TESTSUITE_HAND_AT = \
   tests/erlang.at \
   tests/fortran.at \
   tests/go.at \
+  tests/a68.at \
   tests/semantics.at \
   tests/autoscan.at \
   tests/foreign.at
@@ -198,6 +200,7 @@ AUTOCONF_FILES = $(autoconfdir)/general.m4 \
                 $(autoconfdir)/erlang.m4 \
                 $(autoconfdir)/fortran.m4 \
                 $(autoconfdir)/go.m4 \
+                $(autoconfdir)/a68.m4 \
                 $(autoconfdir)/headers.m4 \
                 $(autoconfdir)/libs.m4 \
                 $(autoconfdir)/types.m4 \
index 17fca50860a67fbc28b71e70fcbcadebd251c43a..1600bf32b145a19e69c4c4640e1b615f31cbe6ff 100644 (file)
@@ -55,6 +55,8 @@ m4_include([erlang.at])
 m4_include([acerlang.at])
 m4_include([go.at])
 m4_include([acgo.at])
+m4_include([a68.at])
+m4_include([aca68.at])
 
 # Checking that AC_CHECK_FOO macros work properly.
 m4_include([semantics.at])