Hello,

algol68g saw some further developments recently with a major version
released some time ago.  Among various things, it also includes the fix
for the usleep issue we found :)

https://jmvdveer.home.xs4all.nl/en.download.algol-68-genie-current.html

The build system changed slightly.  Now there's a Makefile.bsd which
should allows us to avoid using autotools, but it builds only a
stripped-down version of the interpreter and has some further issues of
its own, so I'm not sticking with the autotools.

The configure script does some things wrong, like checking for compiler
features that are not actually used (and fails) or failing to picking up
ncurses.

The dependency on GSL has been dropped because a68g needs a newer
version that we have.  To avoid surprises when devel/gsl will be
eventually updated, I'm explicitly disabling gsl support for now.

Tests are all passing on amd64 and i386 with the only exception of
19-quicksort-parallel.a68 that fails because it spawns more threads than
allowed to.

Compiling algol68 code however doesn't work:

% echo 'print (("hello world", new line))' > hello.a68
% a68g --compile hello.a68
% ./hello
a68g:./.a68g.tmp.hello.so: undefined symbol 'common'
a68g:./.a68g.tmp.hello.so: undefined symbol 'single_step'
a68g: exiting: ./src/a68g/a68g.c: 506: cannot resolve symbol, Cannot load
specified object

The compiler works in a peculiar way.  It translates (part?) of the
source code into C which is then compiled into a shared library.  The
produced executable just spawns a68g with the correct flags so it
dlopen(3)s the shared library and executes the code.

The issue is that the produced shared object has references (`common'
and `single_step') to symbols that should be provided by the binary but
are not actually exported:

% nm .a68g.tmp.hello.so
00002618 c _DYNAMIC
00001580 t __llvm_retpoline_r11
00002610 r __retguard_507
         U common
000013d0 T genie_closed_55
00000000 F hello.c
         U pthread_self
         U single_step
% nm /usr/local/bin/a68g | grep single_step
% nm /usr/local/bin/a68g | grep common

and I have zero idea of how to avoid this.

In the hope something stands out, here's the two chunk of code from
a68g.c where the executable is produced

 442       ASSERT (snprintf (options, SNPRINTF_SIZE,
               "%s -g -I${TRUEPREFIX}/include", optimisation_option ()) >= 0);
 443 #if defined (HAVE_PIC)
 444       bufcat (options, " ", BUFFER_SIZE);
 445       bufcat (options, HAVE_PIC, BUFFER_SIZE);
 446 #endif
 447       ASSERT (snprintf (cmd, SNPRINTF_SIZE, "cc %s -c -o \"%s\" \"%s\"",
               options, FILE_BINARY_NAME (&A68_JOB),
               FILE_OBJECT_NAME (&A68_JOB)) >= 0);
 448       ABEND (system (cmd) != 0, ERROR_ACTION, cmd);
 449       ASSERT (snprintf (cmd, SNPRINTF_SIZE,
               "ld -export-dynamic -shared -o \"%s\" \"%s\"",
               FILE_LIBRARY_NAME (&A68_JOB),
               FILE_BINARY_NAME (&A68_JOB)) >= 0);
 450       ABEND (system (cmd) != 0, ERROR_ACTION, cmd);
 451       a68_rm (FILE_BINARY_NAME (&A68_JOB));

and loaded

 501 // First load a68g itself so compiler code can resolve a68g symbols.
 502       a68_lib = dlopen (NULL, RTLD_NOW | RTLD_GLOBAL);
 503       ABEND (a68_lib == NULL, ERROR_RESOLVE, dlerror ());
 504 // Then load compiler code.
 505       compile_lib = dlopen (libname, RTLD_NOW | RTLD_GLOBAL);
 506       ABEND (compile_lib == NULL, ERROR_RESOLVE, dlerror ());


Cheers,

Omar Polo

Index: Makefile
===================================================================
RCS file: /home/cvs/ports/lang/algol68g/Makefile,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile
--- Makefile    7 Nov 2021 20:33:01 -0000       1.4
+++ Makefile    25 Jan 2022 10:48:46 -0000
@@ -1,8 +1,7 @@
 # $OpenBSD: Makefile,v 1.4 2021/11/07 20:33:01 bcallah Exp $
 
 COMMENT =      Algol 68 Genie compiler-interpreter
-DISTNAME =     algol68g-2.8.5
-REVISION =     0
+DISTNAME =     algol68g-3.0.2
 CATEGORIES =   lang
 
 HOMEPAGE =     https://jmvdveer.home.xs4all.nl/algol.html
@@ -13,15 +12,23 @@ PERMIT_PACKAGE =    Yes
 
 MASTER_SITES = https://jmvdveer.home.xs4all.nl/
 
-WANTLIB += c curses gsl gslcblas m pthread readline
+WANTLIB += c curses m pthread readline
 
-LIB_DEPENDS =  devel/gsl
+CONFIGURE_STYLE =      autoconf
 
-CONFIGURE_STYLE =      gnu
-CONFIGURE_ARGS =       --disable-plotutils --disable-postgresql
-CONFIGURE_ENV =                CPPFLAGS="${CPPFLAGS} -I${LOCALBASE}/include" \
-                       LDFLAGS="${LDFLAGS} -L${LOCALBASE}/lib"
+# wants gsl >= 2.5
+CONFIGURE_ARGS =       --disable-gsl \
+                       --disable-plotutils \
+                       --disable-postgresql
 
-NO_TEST =      Yes
+AUTOCONF_VERSION =     2.69
+
+# the configure needs to be writeable otherwise autoconf
+# fails to re-gen it.
+post-extract:
+       chmod +w ${WRKSRC}/configure
+
+post-configure:
+       ${SUBST_CMD} ${WRKSRC}/src/a68g/a68g.c
 
 .include <bsd.port.mk>
Index: distinfo
===================================================================
RCS file: /home/cvs/ports/lang/algol68g/distinfo,v
retrieving revision 1.2
diff -u -p -r1.2 distinfo
--- distinfo    14 Aug 2018 00:50:17 -0000      1.2
+++ distinfo    24 Jan 2022 14:11:29 -0000
@@ -1,2 +1,2 @@
-SHA256 (algol68g-2.8.5.tar.gz) = D3V8ZKg0L+OOxQG95oth0m0FHf/UV0LKWLcoipnH4tg=
-SIZE (algol68g-2.8.5.tar.gz) = 543905
+SHA256 (algol68g-3.0.2.tar.gz) = OtZ/QPLuptrZAC22IsPMwUp10cwgNQHjEr/252AJTvs=
+SIZE (algol68g-3.0.2.tar.gz) = 621164
Index: patches/patch-configure
===================================================================
RCS file: patches/patch-configure
diff -N patches/patch-configure
--- patches/patch-configure     14 Aug 2018 00:50:17 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,375 +0,0 @@
-$OpenBSD: patch-configure,v 1.2 2018/08/14 00:50:17 bcallah Exp $
-
-Enable compiler on OpenBSD (regenerated configure script)
-
-Index: configure
---- configure.orig
-+++ configure
-@@ -708,7 +708,6 @@ infodir
- docdir
- oldincludedir
- includedir
--runstatedir
- localstatedir
- sharedstatedir
- sysconfdir
-@@ -792,7 +791,6 @@ datadir='${datarootdir}'
- sysconfdir='${prefix}/etc'
- sharedstatedir='${prefix}/com'
- localstatedir='${prefix}/var'
--runstatedir='${localstatedir}/run'
- includedir='${prefix}/include'
- oldincludedir='/usr/include'
- docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
-@@ -1045,15 +1043,6 @@ do
-   | -silent | --silent | --silen | --sile | --sil)
-     silent=yes ;;
- 
--  -runstatedir | --runstatedir | --runstatedi | --runstated \
--  | --runstate | --runstat | --runsta | --runst | --runs \
--  | --run | --ru | --r)
--    ac_prev=runstatedir ;;
--  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
--  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
--  | --run=* | --ru=* | --r=*)
--    runstatedir=$ac_optarg ;;
--
-   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
-     ac_prev=sbindir ;;
-   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
-@@ -1191,7 +1180,7 @@ fi
- for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
-               datadir sysconfdir sharedstatedir localstatedir includedir \
-               oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
--              libdir localedir mandir runstatedir
-+              libdir localedir mandir
- do
-   eval ac_val=\$$ac_var
-   # Remove trailing slashes.
-@@ -1344,7 +1333,6 @@ Fine tuning of the installation directories:
-   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
-   --sharedstatedir=DIR    modifiable architecture-independent data 
[PREFIX/com]
-   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
--  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
-   --libdir=DIR            object code libraries [EPREFIX/lib]
-   --includedir=DIR        C header files [PREFIX/include]
-   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
-@@ -2383,10 +2371,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
- 
- 
- 
--# Check whether $1 is in dl.
--
--
--
- #
- # Platform ids.
- #
-@@ -2601,15 +2585,15 @@ $as_echo "netbsd" >&6; }
- #
- # OpenBSD.
- #
--*86-*-openbsd* | *86_64-*-openbsd*)
-+i386-*-openbsd* | amd64-*-openbsd* | x86_64-*-openbsd* | arm*-*-openbsd* | 
aarch64-*-openbsd*)
- 
- $as_echo "#define HAVE_OPENBSD 1" >>confdefs.h
- 
--  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: configuring 
interpreter-only on OpenBSD" >&5
--$as_echo "$as_me: WARNING: configuring interpreter-only on OpenBSD" >&2;}
-+
-+$as_echo "#define HAVE_IEEE_754 1" >>confdefs.h
-+
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: openbsd" >&5
- $as_echo "openbsd" >&6; }
--  enable_compiler=no
-   ;;
- #
- # Others, untested.
-@@ -18564,287 +18548,6 @@ fi
- 
- 
- $as_echo "#define HAVE_POSTGRESQL 1" >>confdefs.h
--
--  fi
--fi
--
--if test "x$enable_compiler" = "xyes"; then
--  { $as_echo "$as_me:${as_lineno-$LINENO}: Dynamic loader..." >&5
--$as_echo "$as_me: Dynamic loader..." >&6;}
--  for ac_header in dlfcn.h
--do :
--  ac_fn_c_check_header_mongrel "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" 
"$ac_includes_default"
--if test "x$ac_cv_header_dlfcn_h" = xyes; then :
--  cat >>confdefs.h <<_ACEOF
--#define HAVE_DLFCN_H 1
--_ACEOF
--
--fi
--
--done
--
--  ac_fn_c_check_decl "$LINENO" "dlopen" "ac_cv_have_decl_dlopen" "
--#include <dlfcn.h>
--
--"
--if test "x$ac_cv_have_decl_dlopen" = xyes; then :
--
--else
--  enable_compiler=no
--fi
--
--  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
--$as_echo_n "checking for dlopen in -ldl... " >&6; }
--if ${ac_cv_lib_dl_dlopen+:} false; then :
--  $as_echo_n "(cached) " >&6
--else
--  ac_check_lib_save_LIBS=$LIBS
--LIBS="-ldl  $LIBS"
--cat confdefs.h - <<_ACEOF >conftest.$ac_ext
--/* end confdefs.h.  */
--
--/* Override any GCC internal prototype to avoid an error.
--   Use char because int might match the return type of a GCC
--   builtin and then its argument prototype would still apply.  */
--#ifdef __cplusplus
--extern "C"
--#endif
--char dlopen ();
--int
--main ()
--{
--return dlopen ();
--  ;
--  return 0;
--}
--_ACEOF
--if ac_fn_c_try_link "$LINENO"; then :
--  ac_cv_lib_dl_dlopen=yes
--else
--  ac_cv_lib_dl_dlopen=no
--fi
--rm -f core conftest.err conftest.$ac_objext \
--    conftest$ac_exeext conftest.$ac_ext
--LIBS=$ac_check_lib_save_LIBS
--fi
--{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
--$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
--if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
--  a68g_unexpected=yes
--else
--  enable_compiler=no
--fi
--
--
--  if test "x$enable_compiler" = "xyes"; then
--    ac_fn_c_check_decl "$LINENO" "dlsym" "ac_cv_have_decl_dlsym" "
--#include <dlfcn.h>
--
--"
--if test "x$ac_cv_have_decl_dlsym" = xyes; then :
--
--else
--  enable_compiler=no
--fi
--
--  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlsym in -ldl" >&5
--$as_echo_n "checking for dlsym in -ldl... " >&6; }
--if ${ac_cv_lib_dl_dlsym+:} false; then :
--  $as_echo_n "(cached) " >&6
--else
--  ac_check_lib_save_LIBS=$LIBS
--LIBS="-ldl  $LIBS"
--cat confdefs.h - <<_ACEOF >conftest.$ac_ext
--/* end confdefs.h.  */
--
--/* Override any GCC internal prototype to avoid an error.
--   Use char because int might match the return type of a GCC
--   builtin and then its argument prototype would still apply.  */
--#ifdef __cplusplus
--extern "C"
--#endif
--char dlsym ();
--int
--main ()
--{
--return dlsym ();
--  ;
--  return 0;
--}
--_ACEOF
--if ac_fn_c_try_link "$LINENO"; then :
--  ac_cv_lib_dl_dlsym=yes
--else
--  ac_cv_lib_dl_dlsym=no
--fi
--rm -f core conftest.err conftest.$ac_objext \
--    conftest$ac_exeext conftest.$ac_ext
--LIBS=$ac_check_lib_save_LIBS
--fi
--{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlsym" >&5
--$as_echo "$ac_cv_lib_dl_dlsym" >&6; }
--if test "x$ac_cv_lib_dl_dlsym" = xyes; then :
--  a68g_unexpected=yes
--else
--  enable_compiler=no
--fi
--
--
--    ac_fn_c_check_decl "$LINENO" "dlerror" "ac_cv_have_decl_dlerror" "
--#include <dlfcn.h>
--
--"
--if test "x$ac_cv_have_decl_dlerror" = xyes; then :
--
--else
--  enable_compiler=no
--fi
--
--  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlerror in -ldl" >&5
--$as_echo_n "checking for dlerror in -ldl... " >&6; }
--if ${ac_cv_lib_dl_dlerror+:} false; then :
--  $as_echo_n "(cached) " >&6
--else
--  ac_check_lib_save_LIBS=$LIBS
--LIBS="-ldl  $LIBS"
--cat confdefs.h - <<_ACEOF >conftest.$ac_ext
--/* end confdefs.h.  */
--
--/* Override any GCC internal prototype to avoid an error.
--   Use char because int might match the return type of a GCC
--   builtin and then its argument prototype would still apply.  */
--#ifdef __cplusplus
--extern "C"
--#endif
--char dlerror ();
--int
--main ()
--{
--return dlerror ();
--  ;
--  return 0;
--}
--_ACEOF
--if ac_fn_c_try_link "$LINENO"; then :
--  ac_cv_lib_dl_dlerror=yes
--else
--  ac_cv_lib_dl_dlerror=no
--fi
--rm -f core conftest.err conftest.$ac_objext \
--    conftest$ac_exeext conftest.$ac_ext
--LIBS=$ac_check_lib_save_LIBS
--fi
--{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlerror" >&5
--$as_echo "$ac_cv_lib_dl_dlerror" >&6; }
--if test "x$ac_cv_lib_dl_dlerror" = xyes; then :
--  a68g_unexpected=yes
--else
--  enable_compiler=no
--fi
--
--
--    ac_fn_c_check_decl "$LINENO" "dlclose" "ac_cv_have_decl_dlclose" "
--#include <dlfcn.h>
--
--"
--if test "x$ac_cv_have_decl_dlclose" = xyes; then :
--
--else
--  enable_compiler=no
--fi
--
--  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlclose in -ldl" >&5
--$as_echo_n "checking for dlclose in -ldl... " >&6; }
--if ${ac_cv_lib_dl_dlclose+:} false; then :
--  $as_echo_n "(cached) " >&6
--else
--  ac_check_lib_save_LIBS=$LIBS
--LIBS="-ldl  $LIBS"
--cat confdefs.h - <<_ACEOF >conftest.$ac_ext
--/* end confdefs.h.  */
--
--/* Override any GCC internal prototype to avoid an error.
--   Use char because int might match the return type of a GCC
--   builtin and then its argument prototype would still apply.  */
--#ifdef __cplusplus
--extern "C"
--#endif
--char dlclose ();
--int
--main ()
--{
--return dlclose ();
--  ;
--  return 0;
--}
--_ACEOF
--if ac_fn_c_try_link "$LINENO"; then :
--  ac_cv_lib_dl_dlclose=yes
--else
--  ac_cv_lib_dl_dlclose=no
--fi
--rm -f core conftest.err conftest.$ac_objext \
--    conftest$ac_exeext conftest.$ac_ext
--LIBS=$ac_check_lib_save_LIBS
--fi
--{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlclose" >&5
--$as_echo "$ac_cv_lib_dl_dlclose" >&6; }
--if test "x$ac_cv_lib_dl_dlclose" = xyes; then :
--  a68g_unexpected=yes
--else
--  enable_compiler=no
--fi
--
--
--  fi
--  if test "x$enable_compiler" = "xyes"; then
--    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
--$as_echo_n "checking for dlopen in -ldl... " >&6; }
--if ${ac_cv_lib_dl_dlopen+:} false; then :
--  $as_echo_n "(cached) " >&6
--else
--  ac_check_lib_save_LIBS=$LIBS
--LIBS="-ldl  $LIBS"
--cat confdefs.h - <<_ACEOF >conftest.$ac_ext
--/* end confdefs.h.  */
--
--/* Override any GCC internal prototype to avoid an error.
--   Use char because int might match the return type of a GCC
--   builtin and then its argument prototype would still apply.  */
--#ifdef __cplusplus
--extern "C"
--#endif
--char dlopen ();
--int
--main ()
--{
--return dlopen ();
--  ;
--  return 0;
--}
--_ACEOF
--if ac_fn_c_try_link "$LINENO"; then :
--  ac_cv_lib_dl_dlopen=yes
--else
--  ac_cv_lib_dl_dlopen=no
--fi
--rm -f core conftest.err conftest.$ac_objext \
--    conftest$ac_exeext conftest.$ac_ext
--LIBS=$ac_check_lib_save_LIBS
--fi
--{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
--$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
--if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
--  cat >>confdefs.h <<_ACEOF
--#define HAVE_LIBDL 1
--_ACEOF
--
--  LIBS="-ldl $LIBS"
--
--fi
--
--
--$as_echo "#define HAVE_DL 1" >>confdefs.h
- 
-   fi
- fi
Index: patches/patch-configure_ac
===================================================================
RCS file: patches/patch-configure_ac
diff -N patches/patch-configure_ac
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-configure_ac  25 Jan 2022 11:14:55 -0000
@@ -0,0 +1,102 @@
+$OpenBSD$
+
+* don't disable the compiler
+* avoid unnecessary checks for compiler features that are not used and
+  that breaks the build (at least with clang.)
+* don't check for stdscr that way, it fails and disables ncurses support
+* use AC_SEARCH_LIBS for dlopen
+
+Index: configure.ac
+--- configure.ac.orig
++++ configure.ac
+@@ -245,9 +245,6 @@ case "$host" in
+ #
+ *86-*-openbsd* | *86_64-*-openbsd*) 
+   AC_DEFINE(BUILD_BSD, 1, [Define this if OpenBSD was detected]) 
+-  AC_MSG_WARN([configuring interpreter-only])
+-  AC_MSG_RESULT([openbsd])
+-  enable_compiler=no
+   ;;
+ #
+ # Haiku.
+@@ -311,60 +308,8 @@ AC_CHECK_PROG(a68g_exists, a68g, "yes")
+ 
+ AC_MSG_NOTICE([C compiler...])
+ AC_LANG(C)
+-AC_PROG_CC([gcc clang])
+-# AC_PROG_CC([clang])
+-if test "x$GCC" != "xyes"; then
+-  a68g_ac_compiler=no
+-  AC_MSG_WARN([gcc is the preferred C compiler; configuring interpreter-only])
+-else
+-  AC_DEFINE(HAVE_GCC, 1, [Define this if GCC was detected]) 
+-  CFLAGS="-g -O2 -Wall"
+-  A68G_AC_PROG_CC_CFLAGS([-Wshadow])
+-  A68G_AC_PROG_CC_CFLAGS([-Wunused-variable])
+-  A68G_AC_PROG_CC_CFLAGS([-Wunused-parameter])
+-  A68G_AC_PROG_CC_CFLAGS([-Wno-long-long])
+-  A68G_AC_PROG_CC_CFLAGS([-fno-diagnostics-color])
+-#
+-# Test on gcc capabilities.
+-#
+-  AC_MSG_CHECKING([__attribute__((aligned())) supported])
+-  AC_RUN_IFELSE([AC_LANG_PROGRAM([], [typedef int aint 
__attribute__((aligned(8)));])],
+-  [AC_MSG_RESULT(yes)],
+-  [AC_MSG_RESULT(no)
+-   AC_MSG_FAILURE([stop -- C compiler does not support __attribute__aligned 
directive])],
+-  [])
+-  AC_MSG_CHECKING([attribute inline supported])
+-  AC_RUN_IFELSE([AC_LANG_PROGRAM([], [inline void skip (void) {;}])],
+-  [AC_MSG_RESULT(yes)],
+-  [AC_MSG_RESULT(no)
+-   AC_MSG_FAILURE([stop -- C compiler does not support __attribute__aligned 
directive])],
+-  [])
+-#
+-# Check -Wl,--export-dynamic, needed for creating shared objects.
+-#
+-# Check whether we can link to a particular function, not just whether we can 
link.
+-# In fact, we must actually check that the resulting program runs.
+-#
+-    a68g_ac_arg="-Wl,--export-dynamic"
+-    AC_MSG_CHECKING([if $CC accepts $a68g_ac_arg])
+-    a68g_ac_save_LDFLAGS=$LDFLAGS
+-    LDFLAGS="$a68g_ac_save_LDFLAGS $a68g_ac_arg"
+-    AC_RUN_IFELSE([AC_LANG_PROGRAM([extern void exit (); void (*fptr) () = 
exit;],[])],
+-      [AC_MSG_RESULT(yes)
+-       AC_DEFINE(HAVE_EXPORT_DYNAMIC, 1, [Define this if EXPORT_DYNAMIC is 
recognised]) 
+-      ],
+-      [AC_MSG_RESULT(no)
+-       AC_MSG_WARN([--export-dynamic is not accepted; configuring 
interpreter-only])
+-       a68g_ac_compiler=no
+-       LDFLAGS=$a68g_ac_save_LDFLAGS
+-      ],
+-      [AC_MSG_RESULT(assuming no)
+-       AC_MSG_WARN([--export-dynamic is not accepted; configuring 
interpreter-only])
+-       a68g_ac_compiler=no
+-       LDFLAGS=$a68g_ac_save_LDFLAGS
+-      ]
+-    )
+-  fi
++AC_PROG_CC
++
+   AM_CONDITIONAL([EXPORT_DYNAMIC], [test "x$a68g_ac_compiler" = "xyes"])
+ #
+ # Optionally, tune for a specific processor.
+@@ -702,8 +647,6 @@ if test "x$enable_curses" = "xyes"; then
+     AC_CHECK_HEADERS([ncurses/curses.h], [enable_curses=yes], [], [])
+   fi
+   if test "x$enable_curses" = "xyes"; then
+-    AC_CHECK_LIB([tinfo], [stdscr], [], [enable_curses=no])
+-    AC_CHECK_LIB([tic], [stdscr], [], [enable_curses=no])
+     AC_CHECK_LIB([ncurses], [initscr], [], [enable_curses=no])
+     if test "x$enable_curses" = "xyes"; then
+       if test "x$enable_readline" = "xyes"; then
+@@ -739,7 +682,7 @@ if test "x$enable_compiler" = "xyes"; then
+   libdl_found=no
+   AC_MSG_NOTICE([Dynamic loader via libdl...])
+   AC_CHECK_HEADERS([dlfcn.h])
+-  AC_CHECK_LIB([dl], [dlopen], [], enable_compiler=no)
++  AC_SEARCH_LIBS([dlopen], [dl dld], [], enable_compiler=no)
+   if test "x$enable_compiler" = "xyes"; then
+     AC_DEFINE(HAVE_DL, 1, [Define this if a good DL installation was 
detected]) 
+     libdl_found=yes
Index: patches/patch-source_a68g_c
===================================================================
RCS file: patches/patch-source_a68g_c
diff -N patches/patch-source_a68g_c
--- patches/patch-source_a68g_c 14 Aug 2018 00:50:17 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-$OpenBSD: patch-source_a68g_c,v 1.2 2018/08/14 00:50:17 bcallah Exp $
-
-Enable compiler on OpenBSD.
-
-Index: source/a68g.c
---- source/a68g.c.orig
-+++ source/a68g.c
-@@ -903,7 +903,7 @@ Accept various silent extensions.
- /*
- Compilation on Linux, FreeBSD or NetBSD using gcc
- */
--#if (defined HAVE_LINUX || defined HAVE_FREEBSD || defined HAVE_NETBSD)
-+#if (defined HAVE_LINUX || defined HAVE_FREEBSD || defined HAVE_NETBSD || 
defined HAVE_OPENBSD)
- #if defined HAVE_TUNING
-       ASSERT (snprintf (options, SNPRINTF_SIZE, "%s %s %s -g", extra_inc, 
optimisation, HAVE_TUNING) >= 0);
- #else
-@@ -1679,7 +1679,7 @@ set_options (OPTION_LIST_T * i, BOOL_T cmd_line)
-               a68g_exit (EXIT_SUCCESS);
-             }
- #endif
--#if (! defined HAVE_LINUX)
-+#if (! (defined HAVE_LINUX || defined HAVE_OPENBSD))
-             if (eq (q, "linux")) {
-               WRITELN (STDOUT_FILENO, "linux required - exiting graciously");
-               a68g_exit (EXIT_SUCCESS);
-@@ -1832,7 +1832,7 @@ set_options (OPTION_LIST_T * i, BOOL_T cmd_line)
-         }
- /* COMPILE and NOCOMPILE switch on/off compilation */
-         else if (eq (p, "Compile")) {
--#if defined HAVE_LINUX
-+#if defined HAVE_LINUX || defined HAVE_OPENBSD
-           OPTION_COMPILE (&program) = A68_TRUE;
-           OPTION_OPTIMISE (&program) = A68_TRUE;
-           OPTION_OPT_LEVEL (&program) = 2;
-@@ -1885,7 +1885,7 @@ set_options (OPTION_LIST_T * i, BOOL_T cmd_line)
-         }
- /* RUN-SCRIPT runs a comiled .sh script */
-         else if (eq (p, "RUN-SCRIPT")) {
--#if defined HAVE_LINUX
-+#if defined HAVE_LINUX || defined HAVE_OPENBSD
-           FORWARD (i);
-           if (i != NO_OPTION_LIST) {
-             if (!name_set) {
-@@ -1908,7 +1908,7 @@ set_options (OPTION_LIST_T * i, BOOL_T cmd_line)
-         }
- /* RUN-QUOTE-SCRIPT runs a comiled .sh script */
-         else if (eq (p, "RUN-QUOTE-SCRIPT")) {
--#if defined HAVE_LINUX
-+#if defined HAVE_LINUX || defined HAVE_OPENBSD
-           FORWARD (i);
-           if (i != NO_OPTION_LIST) {
-             if (!name_set) {
Index: patches/patch-source_a68g_h
===================================================================
RCS file: patches/patch-source_a68g_h
diff -N patches/patch-source_a68g_h
--- patches/patch-source_a68g_h 14 Aug 2018 00:50:17 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,25 +0,0 @@
-$OpenBSD: patch-source_a68g_h,v 1.2 2018/08/14 00:50:17 bcallah Exp $
-
-Enable compiler on OpenBSD.
-
-Index: source/a68g.h
---- source/a68g.h.orig
-+++ source/a68g.h
-@@ -54,7 +54,7 @@ Top level include file.
- #undef HAVE_COMPILER
- #elif ((defined HAVE_LINUX || defined HAVE_MAC_OS_X) && defined HAVE_DL)
- #define HAVE_COMPILER 1
--#elif (defined HAVE_FREEBSD || defined HAVE_NETBSD)
-+#elif (defined HAVE_FREEBSD || defined HAVE_NETBSD || defined HAVE_OPENBSD)
- #define HAVE_COMPILER 1
- #else
- #undef HAVE_COMPILER
-@@ -63,7 +63,7 @@ Top level include file.
- /* Can we access the internet? */
- 
- #if (defined HAVE_NETDB_H && defined HAVE_NETINET_IN_H && defined 
HAVE_SYS_SOCKET_H)
--#if (defined HAVE_LINUX || defined HAVE_MAC_OS_X || defined HAVE_FREEBSD || 
defined HAVE_NETBSD)
-+#if (defined HAVE_LINUX || defined HAVE_MAC_OS_X || defined HAVE_FREEBSD || 
defined HAVE_NETBSD || defined HAVE_OPENBSD)
- #define HAVE_HTTP
- #endif
- #endif
Index: patches/patch-source_genie_c
===================================================================
RCS file: patches/patch-source_genie_c
diff -N patches/patch-source_genie_c
--- patches/patch-source_genie_c        7 Nov 2021 20:33:01 -0000       1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,17 +0,0 @@
-$OpenBSD: patch-source_genie_c,v 1.1 2021/11/07 20:33:01 bcallah Exp $
-
-Ignore usleep(3) return value.
-It can only fail with EINTR and shouldn't stop execution.
-
-Index: source/genie.c
---- source/genie.c.orig
-+++ source/genie.c
-@@ -7204,7 +7204,7 @@ genie_down_sema (NODE_T * p)
-         }
-         UNLOCK_THREAD;
- /* Waiting a bit relaxes overhead */
--        ASSERT (usleep (10) == 0);
-+        usleep (10);
-         LOCK_THREAD;
- /* Garbage may be collected, so recalculate 'k' */
-         k = DEREF (A68_INT, &s);
Index: patches/patch-src_a68g_a68g_c
===================================================================
RCS file: patches/patch-src_a68g_a68g_c
diff -N patches/patch-src_a68g_a68g_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_a68g_a68g_c       25 Jan 2022 11:15:32 -0000
@@ -0,0 +1,23 @@
+$OpenBSD$
+
+* fix compiler include search path
+* don't hardcode gcc
+
+Index: src/a68g/a68g.c
+--- src/a68g/a68g.c.orig
++++ src/a68g/a68g.c
+@@ -437,12 +439,12 @@ static void compiler_interpreter (void)
+ // Build shared library using gcc.
+ // TODO: One day this should be all portable between platforms.
+ // Compilation on Linux, FreeBSD or NetBSD using gcc
+-      ASSERT (snprintf (options, SNPRINTF_SIZE, "%s -ggdb", 
optimisation_option ()) >= 0);
++      ASSERT (snprintf (options, SNPRINTF_SIZE, "%s -g 
-I${TRUEPREFIX}/include", optimisation_option ()) >= 0);
+ #if defined (HAVE_PIC)
+       bufcat (options, " ", BUFFER_SIZE);
+       bufcat (options, HAVE_PIC, BUFFER_SIZE);
+ #endif
+-      ASSERT (snprintf (cmd, SNPRINTF_SIZE, "gcc %s -c -o \"%s\" \"%s\"", 
options, FILE_BINARY_NAME (&A68_JOB), FILE_OBJECT_NAME (&A68_JOB)) >= 0);
++      ASSERT (snprintf (cmd, SNPRINTF_SIZE, "cc %s -c -o \"%s\" \"%s\"", 
options, FILE_BINARY_NAME (&A68_JOB), FILE_OBJECT_NAME (&A68_JOB)) >= 0);
+       ABEND (system (cmd) != 0, ERROR_ACTION, cmd);
+       ASSERT (snprintf (cmd, SNPRINTF_SIZE, "ld -export-dynamic -shared -o 
\"%s\" \"%s\"", FILE_LIBRARY_NAME (&A68_JOB), FILE_BINARY_NAME (&A68_JOB)) >= 
0);
+       ABEND (system (cmd) != 0, ERROR_ACTION, cmd);
Index: patches/patch-src_a68g_options_c
===================================================================
RCS file: patches/patch-src_a68g_options_c
diff -N patches/patch-src_a68g_options_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_a68g_options_c    24 Jan 2022 15:50:56 -0000
@@ -0,0 +1,56 @@
+$OpenBSD$
+
+allow "linux-only" stuff...
+
+Index: src/a68g/options.c
+--- src/a68g/options.c.orig
++++ src/a68g/options.c
+@@ -701,16 +701,12 @@ BOOL_T set_options (OPTION_LIST_T * i, BOOL_T cmd_line
+         }
+ // COMPILE and NOCOMPILE switch on/off compilation.
+         else if (eq (p, "Compile")) {
+-#if defined (BUILD_LINUX)
+           OPTION_COMPILE (&A68_JOB) = A68_TRUE;
+           OPTION_COMPILE_CHECK (&A68_JOB) = A68_TRUE;
+           if (OPTION_OPT_LEVEL (&A68_JOB) < OPTIMISE_1) {
+             OPTION_OPT_LEVEL (&A68_JOB) = OPTIMISE_1;
+           }
+           OPTION_RUN_SCRIPT (&A68_JOB) = A68_FALSE;
+-#else
+-          option_error (start_l, start_c, "linux-only option");
+-#endif
+         } else if (eq (p, "NOCompile") || eq (p, "NO-Compile")) {
+           OPTION_COMPILE (&A68_JOB) = A68_FALSE;
+           OPTION_RUN_SCRIPT (&A68_JOB) = A68_FALSE;
+@@ -745,7 +741,6 @@ BOOL_T set_options (OPTION_LIST_T * i, BOOL_T cmd_line
+         }
+ // RUN-SCRIPT runs a compiled .sh script.
+         else if (eq (p, "RUN-SCRIPT")) {
+-#if defined (BUILD_LINUX)
+           FORWARD (i);
+           if (i != NO_OPTION_LIST) {
+             if (!name_set) {
+@@ -760,13 +755,9 @@ BOOL_T set_options (OPTION_LIST_T * i, BOOL_T cmd_line
+           skip = A68_TRUE;
+           OPTION_RUN_SCRIPT (&A68_JOB) = A68_TRUE;
+           OPTION_COMPILE (&A68_JOB) = A68_FALSE;
+-#else
+-          option_error (start_l, start_c, "linux-only option");
+-#endif
+         }
+ // RUN-QUOTE-SCRIPT runs a compiled .sh script.
+         else if (eq (p, "RUN-QUOTE-SCRIPT")) {
+-#if defined (BUILD_LINUX)
+           FORWARD (i);
+           if (i != NO_OPTION_LIST) {
+             if (!name_set) {
+@@ -782,9 +773,6 @@ BOOL_T set_options (OPTION_LIST_T * i, BOOL_T cmd_line
+           OPTION_RUN_SCRIPT (&A68_JOB) = A68_TRUE;
+           OPTION_STROPPING (&A68_JOB) = QUOTE_STROPPING;
+           OPTION_COMPILE (&A68_JOB) = A68_FALSE;
+-#else
+-          option_error (start_l, start_c, "linux-only option");
+-#endif
+         }
+ // RERUN re-uses an existing .so file.
+         else if (eq (p, "RERUN")) {
Index: patches/patch-src_include_a68g-platform_h
===================================================================
RCS file: patches/patch-src_include_a68g-platform_h
diff -N patches/patch-src_include_a68g-platform_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_include_a68g-platform_h   24 Jan 2022 15:57:32 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+a68g-config.bsd.h is only installed when using Makefile.bsd
+
+Index: src/include/a68g-platform.h
+--- src/include/a68g-platform.h.orig
++++ src/include/a68g-platform.h
+@@ -24,8 +24,6 @@
+ 
+ #if defined (BUILD_WIN32)
+ #include "a68g-config.win32.h"
+-#elif defined (BUILD_BSD)
+-#include "a68g-config.bsd.h"
+ #else
+ #include "a68g-config.h"
+ #endif
Index: patches/patch-src_include_a68g_h
===================================================================
RCS file: patches/patch-src_include_a68g_h
diff -N patches/patch-src_include_a68g_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_include_a68g_h    24 Jan 2022 15:42:04 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+enable the compiler
+
+Index: src/include/a68g.h
+--- src/include/a68g.h.orig
++++ src/include/a68g.h
+@@ -32,7 +32,7 @@
+ 
+ // Build switches depending on platform.
+ 
+-#if (defined (BUILD_LINUX) && defined (HAVE_GCC) && defined (HAVE_DL))
++#ifdef __OpenBSD__
+ #  define BUILD_A68_COMPILER
+ #else
+ // Untested, so disabled.
Index: pkg/PLIST
===================================================================
RCS file: /home/cvs/ports/lang/algol68g/pkg/PLIST,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 PLIST
--- pkg/PLIST   29 Jun 2017 15:56:14 -0000      1.1.1.1
+++ pkg/PLIST   24 Jan 2022 15:11:03 -0000
@@ -1,11 +1,44 @@
 @comment $OpenBSD: PLIST,v 1.1.1.1 2017/06/29 15:56:14 bcallah Exp $
 @bin bin/a68g
 include/algol68g/
+include/algol68g/a68g-common.h
+include/algol68g/a68g-compiler.h
 include/algol68g/a68g-config.h
+include/algol68g/a68g-defines.h
+include/algol68g/a68g-diagnostics.h
+include/algol68g/a68g-double.h
+include/algol68g/a68g-enums.h
+include/algol68g/a68g-environ.h
+include/algol68g/a68g-frames.h
+include/algol68g/a68g-generic.h
+include/algol68g/a68g-genie.h
+include/algol68g/a68g-includes.h
+include/algol68g/a68g-level-3.h
+include/algol68g/a68g-lib.h
+include/algol68g/a68g-listing.h
+include/algol68g/a68g-masks.h
+include/algol68g/a68g-math.h
+include/algol68g/a68g-mp.h
+include/algol68g/a68g-nil.h
+include/algol68g/a68g-numbers.h
+include/algol68g/a68g-optimiser.h
+include/algol68g/a68g-options.h
+include/algol68g/a68g-parser.h
+include/algol68g/a68g-physics.h
+include/algol68g/a68g-platform.h
+include/algol68g/a68g-postulates.h
+include/algol68g/a68g-prelude-gsl.h
+include/algol68g/a68g-prelude-mathlib.h
+include/algol68g/a68g-prelude.h
+include/algol68g/a68g-stack.h
+include/algol68g/a68g-stddef.h
+include/algol68g/a68g-transput.h
+include/algol68g/a68g-types.h
 include/algol68g/a68g.h
 @man man/man1/a68g.1
 share/doc/algol68g/
 share/doc/algol68g/AUTHORS
 share/doc/algol68g/COPYING
+share/doc/algol68g/LICENSE
 share/doc/algol68g/NEWS
 share/doc/algol68g/README

Reply via email to