autoconf-patches
[Top][All Lists]
Advanced

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

[PATCH,WIP] Support for the Algol 68 language


From: Jose E. Marchesi
Subject: [PATCH,WIP] Support for the Algol 68 language
Date: Fri, 24 Jan 2025 01:13:36 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Hello.

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]. A WIP series got sent to gcc-patches in January
[2], and the front-end is temporarily hosted in the sourceware forge
until integration in GCC is completed [3].

The full language is (almost) already implemented, the compiler is
useful and I plan to send official patches for inclusion in GCC 16 very
soon.

In the meanwhile, I would like to have both autoconf and automake
support ready to be added upstream once the front-end lands.

This WIP seems to work well for me, but almost certainly I am doing
something wrong, so comments are welcome.

I am also sending a patch to automake-patches with the Automake support.
Salud!

[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/jemarch/a68-gcc

    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 and aca68.at.
    * tests/local.at (_AT_CHECK_ENV): Add GA68 and A68FLAGS.
    * tests/Makefile.am (TESTSUITE_GENERATED_AT): Add
    $(srcdir)/aca68.at.
    (TESTSUITE_HAND_AT): Add a68.at.
    (AUTOCONF_FILES): Add $(autoconfdir)/a68.m4.
    * NEWS: Update.

diff --git a/NEWS b/NEWS
index b859fff6..fda4f68c 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ GNU Autoconf NEWS - User visible changes.
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** Support for the Algol 68 programming language has been added.  The new macro
+   AC_LANG_A68 sets variables GA68 and A68FLAGS.
+
 ** Backward incompatibilities
 
 *** AC_PROG_CC now prefers C23 if available.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 4b0cf08d..bcdd14be 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
 
@@ -2741,7 +2742,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.
+C, C++, Objective C, Objective C++, Fortran, Go and Algol 68 features.
 
 This variable's contents should contain options like @option{-s} and
 @option{-L} that affect only the behavior of the linker.  Please see the
@@ -2784,6 +2785,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 Algol68 instead of C.
+@end defvar
+
 @defvar builddir
 @ovindex builddir
 Rigorously equal to @samp{.}.  Added for symmetry only.
@@ -7088,6 +7096,7 @@ compiling.
 * Erlang Compiler and Interpreter::  Likewise
 * Fortran Compiler::            Likewise
 * Go Compiler::                 Likewise
+* Algol 68 Compiler::           Likewise
 @end menu
 
 @node Specific Compiler Characteristics
@@ -8629,6 +8638,31 @@ 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.
+
+@defmac AC_PROG_A68 (@ovar{compiler-search-list})
+Find the Algol 68 compiler to use.  Check whether the environment
+variable @code{GA68} is set; if so, then set output variable @code{GA68}
+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{GA68} 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}l
+@end defmac
+
 @node System Services
 @section System Services
 
@@ -9179,6 +9213,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{GA68} and use extension @file{.a68} for
+test programs.  Use compilation flags @code{A68FLAGS}.
 @end table
 @end defmac
 
@@ -9426,9 +9464,9 @@ 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}
-definitions are not automatically translated into constants in the
-source code by this macro.
+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.
 
 @defmac AC_LANG_PROGRAM (@var{prologue}, @var{body})
 @acindex{LANG_PROGRAM}
@@ -9551,7 +9589,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..c556d13e
--- /dev/null
+++ b/lib/autoconf/a68.m4
@@ -0,0 +1,155 @@
+# This file is part of Autoconf.                       -*- Autoconf -*-
+# Algol 68 language support.
+# Copyright (C) 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(a68)
+# -----------
+AC_LANG_DEFINE([A68], [a68], [A68], [GA68], [],
+[ac_ext=a68
+ac_compile='$GA68 -c $A68FLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
+ac_link='$GA68 -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(A68)])
+
+# ------------------- #
+# Producing programs.
+# ------------------- #
+
+# AC_LANG_PROGRAM(A68)([PROLOGUE], [BODY])
+# ----------------------------------------
+m4_define([AC_LANG_PROGRAM(A68)],
+[PROGRAM
+$1
+BEGIN
+$2
+ 0
+END])
+
+# _AC_LANG_IO_PROGRAM(A68)
+# ------------------------
+# Produce source that performs I/O.
+m4_define([_AC_LANG_IO_PROGRAM(A68)],
+[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(A68)(PROLOGUE, FUNCTION)
+# -------------------------------------
+# Avoid conflicting decl of main.
+m4_define([AC_LANG_CALL(A68)],
+[AC_LANG_PROGRAM([],[])])
+
+# AC_LANG_FUNC_LINK_TRY(A68)(FUNCTION)
+# ------------------------------------
+# Try to link a program which calls FUNCTION.
+m4_define([AC_LANG_FUNC_LINK_TRY(A68)],
+[AC_LANG_PROGRAM([],[])])
+
+# AC_LANG_BOOL_COMPILE_TRY(A68)(PROLOGUE, EXPRESSION)
+# ---------------------------------------------------
+# Return a program which is valid if EXPRESSION is nonzero.
+m4_define([AC_LANG_BOOL_COMPILE_TRY(A68)],
+[AC_LANG_PROGRAM([], [@<:@$2@:>@INT test multiple;
+                      0])])
+
+# AC_LANG_INT_SAVE(A68)(PROLOGUE, EXPRESSION)
+# ------------------------------------------
+m4_define([AC_LANG_INT_SAVE(A68)],
+[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)/
+IF fd = -1 THEN ret := 1; stop FI;
+IF fputs (fd, itoa ($2)) = 0 THEN ret := 1; stop FI;
+stop:
+;
+])])
+
+# ---------------------- #
+# Looking for compilers. #
+# ---------------------- #
+
+# AC_LANG_COMPILER(A68)
+# ---------------------
+AC_DEFUN([AC_LANG_COMPILER(A68)],
+[AC_REQUIRE([AC_PROG_A68])])
+
+# AC_PROG_A68
+# -----------
+AN_MAKEVAR([GA68], [AC_PROG_A68])
+AN_PROGRAM([ga68], [AC_PROG_A68])
+AC_DEFUN([AC_PROG_A68],
+[AC_LANG_PUSH(A68)dnl
+AC_ARG_VAR([GA68],   [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(GA68, [$1])],
+[AC_CHECK_TOOL(GA68, ga68)
+if test -z "$GA68"; then
+  if test -n "$ac_tool_prefix"; then
+    AC_CHECK_PROG(GA68, [${ac_tool_prefix}ga68], [$ac_tool_prefix}ga68])
+  fi
+fi
+if test -z "$GA68"; then
+  AC_CHECK_PROG(GA68, 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(A68)dnl
+])# AC_PROG_A68
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..e65c128a 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 f44d629a..181c9cbf 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..b99b50d2
--- /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([A68],
+[[AC_LANG(A68)
+AC_LANG_COMPILER
+]])
diff --git a/tests/local.mk b/tests/local.mk
index 5c45d9ee..736c2da8 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])



reply via email to

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