autoconf-patches
[Top][All Lists]
Advanced

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

[PATCH V4] Support for the Algol 68 language


From: Jose E. Marchesi
Subject: [PATCH V4] Support for the Algol 68 language
Date: Thu, 01 May 2025 18:12:19 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

[Changes from V3:
 - Rename A68FLAGS to A68CFLAGS as mandated by the GCS.
   Automake support has been updated accordingly upstream.
 Changes from V2:
 - Call the language 'Algol 68', not 'A68'.
 - Rename A68 shell variable to A68C.
 - Rename macro AC_PROG_A68 to AC_PROG_A68C.
 - Clarify where to get ga68 in the manual.
 - Adapt to latest language changes.
 Changes from V1:
 - Variables GA68* renamed to A68*.]

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 A68CFLAGS.
    (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 A68C and A68CFLAGS.
    * NEWS: Update.
---
 NEWS                     |   3 +
 doc/autoconf.texi        |  52 ++++++++++++-
 lib/autoconf/a68.m4      | 153 +++++++++++++++++++++++++++++++++++++++
 lib/autoconf/autoconf.m4 |   1 +
 lib/freeze.mk            |   1 +
 lib/local.mk             |   1 +
 tests/a68.at             |  33 +++++++++
 tests/local.at           |   2 +-
 tests/local.mk           |   3 +
 tests/suite.at           |   2 +
 10 files changed, 247 insertions(+), 4 deletions(-)
 create mode 100644 lib/autoconf/a68.m4
 create mode 100644 tests/a68.at

diff --git a/NEWS b/NEWS
index 1e4e513e..41666059 100644
--- 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 A68C and A68CFLAGS.
+
 *** AC_PROG_AWK now also checks for busybox awk.
 
 *** AC_USE_SYSTEM_EXTENSIONS now defines _COSMO_SOURCE for Cosmopolitan Libc.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 7b156b82..2ea1a732 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -416,6 +416,7 @@ Compilers and Preprocessors
 * Erlang Compiler and Interpreter::  Likewise
 * Fortran Compiler::            Likewise
 * Go Compiler::                 Likewise
+* Algol 68 Compiler::           Likewise
 
 Writing Tests
 
@@ -2742,7 +2743,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
@@ -2785,6 +2786,13 @@ Debugging and optimization options for the Go compiler.  
It acts like
 @code{CFLAGS}, but for Go instead of C.
 @end defvar
 
+@defvar A68CFLAGS
+@evindex A68CFLAGS
+@ovindex A68CFLAGS
+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{A68C} is set; if so, then set output variable @code{A68C}
+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{A68C} 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{A68CFLAGS} was not already set, set it to
+@option{-g -O2}.  If your package does not like this default,
+@code{A68CFLAGS} may be set before @code{AC_PROG_A68}l
+@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{A68C} and use extension @file{.a68} for
+test programs.  Use compilation flags @code{A68CFLAGS}.
 @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
index 00000000..ca93818a
--- /dev/null
+++ b/lib/autoconf/a68.m4
@@ -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], [A68C], [],
+[ac_ext=a68
+ac_compile='$A68C -c $A68CFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
+ac_link='$A68C -o conftest$ac_exeext $A68CFLAGS $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_A68C])])
+
+# AC_PROG_A68C
+# ------------
+AN_MAKEVAR([A68C], [AC_PROG_A68C])
+AN_PROGRAM([ga68], [AC_PROG_A68C])
+AC_DEFUN([AC_PROG_A68C],
+[AC_LANG_PUSH(Algol 68)dnl
+AC_ARG_VAR([A68C], [Algol 68 compiler command])dnl
+AC_ARG_VAR([A68CFLAGS], [Algol 68 compiler flags])dnl
+_AC_ARG_VAR_LDFLAGS()dnl
+m4_ifval([$1],
+      [AC_CHECK_TOOLS(A68C, [$1])],
+[AC_CHECK_TOOL(A68C, ga68)
+if test -z "$A68C"; then
+  if test -n "$ac_tool_prefix"; then
+    AC_CHECK_PROG(A68C, [${ac_tool_prefix}ga68], [$ac_tool_prefix}ga68])
+  fi
+fi
+if test -z "$A68C"; then
+  AC_CHECK_PROG(A68C, 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
+A68CFLAGS="-g -O2"
+AC_LANG_POP(Algol 68)dnl
+])# AC_PROG_A68C
diff --git a/lib/autoconf/autoconf.m4 b/lib/autoconf/autoconf.m4
index c2b6aea3..d79888e9 100644
--- a/lib/autoconf/autoconf.m4
+++ b/lib/autoconf/autoconf.m4
@@ -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])
diff --git a/lib/freeze.mk b/lib/freeze.mk
index 8239080e..9535306f 100644
--- a/lib/freeze.mk
+++ b/lib/freeze.mk
@@ -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         \
diff --git a/lib/local.mk b/lib/local.mk
index 98a7f36a..62440dd0 100644
--- a/lib/local.mk
+++ b/lib/local.mk
@@ -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
index 00000000..e9ac00fc
--- /dev/null
+++ b/tests/a68.at
@@ -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
+]])
diff --git a/tests/local.at b/tests/local.at
index 6bf31ab3..5fcaa8c8 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -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],
+      
[A68C|A68CFLAGS|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],
diff --git a/tests/local.mk b/tests/local.mk
index 6a2c06a8..77808f7d 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -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 \
diff --git a/tests/suite.at b/tests/suite.at
index 17fca508..1600bf32 100644
--- a/tests/suite.at
+++ b/tests/suite.at
@@ -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])
-- 
2.30.2




reply via email to

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