From: Sergei Golovan
Description: Patch updates configure.in to avoid some obsolete
 macros. Also, it fixes a few code snippets to compile by GCC 14,
 and fixes an AWK script which extracts Tcl major version from tcl.h.
 Also, it removes the "g" suffix from the libraries with enabled
 symbols. For Debian package we enable symbols, and then strip them
 into a separate debug package.
Date: Fri, 23 May 2025 15:24:53 +0300
Forwarded: yes
Bug: https://sourceforge.net/p/blt/patches/37/

--- a/configure.in
+++ b/configure.in
@@ -1,10 +1,11 @@
 
 define([AC_CACHE_LOAD], )dnl
 define([AC_CACHE_SAVE], )dnl
-AC_INIT(src/bltInitCmd.c)
-AC_CONFIG_HEADER(src/config.h)
+AC_INIT
+AC_CONFIG_SRCDIR([src/bltInitCmd.c])
+AC_CONFIG_HEADERS([src/config.h])
 AC_CONFIG_AUX_DIR(cf)
-AC_PREREQ(2.0)  
+AC_PREREQ([2.71])  
 
 # -----------------------------------------------------------------------
 #
@@ -277,11 +278,11 @@
     blt_platform_win32="yes"
     blt_platform_macosx="no"
     AC_MSG_CHECKING([if using MinGW compiler])
-    AC_TRY_COMPILE([], [
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
 #ifndef __MINGW32__
     _cc_is_not_mingw_
 #endif
-], [blt_have_mingw=yes], [blt_have_mingw=no])
+]])],[blt_have_mingw=yes],[blt_have_mingw=no])
     AC_MSG_RESULT([$blt_have_mingw])
     ;;
   *darwin*)
@@ -299,11 +300,11 @@
   blt_have_gcc="yes"
 else
   AC_MSG_CHECKING([if C compiler is really gcc])
-    AC_TRY_COMPILE([], [
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
 #ifndef __GNUC__
     _cc_is_not_gcc_
 #endif
-], [blt_have_gcc=yes], [blt_have_gcc=no])
+]])],[blt_have_gcc=yes],[blt_have_gcc=no])
   AC_MSG_RESULT([$blt_have_gcc])
 fi
 
@@ -394,7 +395,7 @@
 
 build_shared="yes"
 if test $blt_enable_symbols = "yes" ; then
-  LIB_SUFFIX=g
+  LIB_SUFFIX=
 fi
 
 # -----------------------------------------------------------------------
@@ -437,9 +438,24 @@
 # -----------------------------------------------------------------------
 # Headers
 # -----------------------------------------------------------------------
-AC_HEADER_STDC
+AC_CHECK_INCLUDES_DEFAULT
+AC_PROG_EGREP
+
 AC_HEADER_SYS_WAIT
-AC_HEADER_TIME
+m4_warn([obsolete],
+[Update your code to rely only on HAVE_SYS_TIME_H,
+then remove this warning and the obsolete code below it.
+All current systems provide time.h; it need not be checked for.
+Not all systems provide sys/time.h, but those that do, all allow
+you to include it and time.h simultaneously.])dnl
+AC_CHECK_HEADERS_ONCE([sys/time.h])
+# Obsolete code to be removed.
+if test $ac_cv_header_sys_time_h = yes; then
+  AC_DEFINE([TIME_WITH_SYS_TIME],[1],[Define to 1 if you can safely include both <sys/time.h>
+	     and <time.h>.  This macro is obsolete.])
+fi
+# End of obsolete code.
+
 
 AC_CHECK_HEADERS(inttypes.h)
 if test "${ac_cv_header_inttypes_h}" = "yes" ; then 
@@ -613,17 +629,17 @@
 
 AC_MSG_CHECKING([whether DBL_EPSILON is defined in float.h])
 AC_CACHE_VAL(blt_cv_found_dbl_epsilon,
-    AC_TRY_COMPILE([
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #ifdef HAVE_FLOAT_H
 #include <float.h>
 #endif
-], [
+]], [[
 #ifdef DBL_EPSILON
  exit(0);
 #else
  exit(1);
 #endif
-], blt_cv_found_dbl_epsilon=yes, blt_cv_found_dbl_epsilon=no) 
+]])],[blt_cv_found_dbl_epsilon=yes],[blt_cv_found_dbl_epsilon=no]) 
 )
 AC_MSG_RESULT([${blt_cv_found_dbl_epsilon}])
 
@@ -633,7 +649,9 @@
   CFLAGS="-lm"
   AC_MSG_CHECKING([whether DBL_EPSILON can be computed.])
   BLT_RUN_WITH_OUTPUT([blt_cv_dbl_epsilon], [
-main () {
+#include <stdio.h>
+#include <stdlib.h>
+int main () {
     double e, u;
     /* 
      *  Check the smallest value such that 1.0 + x != 1.0.
@@ -670,8 +688,8 @@
 
 AC_MSG_CHECKING([whether union wait is defined correctly])
 AC_CACHE_VAL(blt_cv_struct_wait_works,
-    AC_TRY_COMPILE([#include <sys/types.h> 
-#include <sys/wait.h>], [
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 
+#include <sys/wait.h>]], [[
     /* 
      *  Check whether <sys/wait.h> defines the type "union wait" 
      *  correctly.  It's needed because of weirdness in HP-UX where 
@@ -681,16 +699,14 @@
     union wait x;
     WIFEXITED(x);       /* Generates compiler error if WIFEXITED
                          * uses an int. */
-], 
-        [blt_cv_struct_wait_works="yes"], 
-        [blt_cv_struct_wait_works="no"]))
+]])],[blt_cv_struct_wait_works="yes"],[blt_cv_struct_wait_works="no"]))
 
 if test "${blt_cv_struct_wait_works}" = "yes"; then
     AC_DEFINE([HAVE_UNION_WAIT], 1, [Define if 'wait' is a union.])
 fi
 AC_MSG_RESULT([$blt_cv_struct_wait_works])
 
-AC_CHECKING(for ptyranges)
+AS_MESSAGE([checking for ptyranges...])
 if test -d /dev/ptym ; then
     pdir='/dev/ptym'
 else
@@ -838,17 +854,17 @@
 AC_CHECK_FUNCS(shmget shmat shmctl shmdt)
 AC_CHECK_FUNCS(localtime_r)
 
-AC_HAVE_FUNCS(drand48 srand48 finite isnan ceil floor round)
+AC_CHECK_FUNCS([drand48 srand48 finite isnan ceil floor round])
 
 # For HPUX it's a little more complicated to search for isfinite
 AC_MSG_CHECKING([for isfinite])
 AC_CACHE_VAL(blt_cv_have_isfinite,
-    AC_TRY_LINK([#include <math.h>], [
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[
 double x = 1.0;
 if (isfinite(x)) {
    return 0;
 }
-], [blt_cv_have_isfinite="yes"], [blt_cv_have_isfinite="no"]))
+]])],[blt_cv_have_isfinite="yes"],[blt_cv_have_isfinite="no"]))
 
 if test "${blt_cv_have_isfinite}" = "yes"; then
     AC_DEFINE([HAVE_ISFINITE], 1, [Define if we have a working 'isinfinite'.])
@@ -1044,7 +1060,7 @@
     fi
   done
   if test "x${TCL_INC_DIR}" = "x" ; then
-    AC_ERROR([Can't find tcl.h header file.])
+    AC_MSG_ERROR(Can't find tcl.h header file.)
   fi
 fi
 
@@ -1064,7 +1080,7 @@
 CPPFLAGS=${TCL_INCLUDE_SPEC}
 AC_CHECK_HEADERS(tcl.h, [found=yes], [found=no])
 if test "${found}" = "no" ; then
-  AC_ERROR([Can't find tcl.h in \"${TCL_INC_DIR}\"])
+  AC_MSG_ERROR(Can't find tcl.h in "${TCL_INC_DIR}")
 fi
 TCL_INC_SPEC=${TCL_INCLUDE_SPEC}
 
@@ -1113,12 +1129,12 @@
     fi         
     CPPFLAGS="${TCL_INC_SPEC} ${TCL_LIB_SPEC}"
     AC_MSG_CHECKING([for Tcl library spec])
-    AC_TRY_COMPILE([
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
       #include <tcl.h>
-    ], [
+    ]], [[
       Tcl_Interp *interp;
       interp = Tcl_CreateInterp();
-    ], [found=yes], [found=no])
+    ]])],[found=yes],[found=no])
     AC_MSG_RESULT([${TCL_LIB_SPEC}])
     CPPFLAGS=${save_CPPFLAGS}
     if test "$found" = "yes" ; then 
@@ -1128,7 +1144,7 @@
 done
 
 if test "$found" = "no" ; then 
-   AC_ERROR([Can't find tcl library in \"${LIBDIRS}\"])
+   AC_MSG_ERROR(Can't find tcl library in "${LIBDIRS}")
 fi
 
 # Tk library.
@@ -1166,7 +1182,7 @@
     fi
   done
   if test "x${TK_INC_DIR}" = "x" ; then
-    AC_ERROR([Can't find tk.h header file.])
+    AC_MSG_ERROR(Can't find tk.h header file.)
   fi
 fi
 
@@ -1187,7 +1203,7 @@
 CPPFLAGS="${TCL_INCLUDE_SPEC} ${TK_INCLUDE_SPEC}"
 AC_CHECK_HEADERS(tk.h, [found=yes], [found=no])
 if test "${found}" = "no" ; then
-  AC_ERROR([Can't find tk.h in \"${TK_INC_DIR}\"])
+  AC_MSG_ERROR(Can't find tk.h in "${TK_INC_DIR}")
 fi
 TK_INC_SPEC=${TK_INCLUDE_SPEC}
 
@@ -1236,14 +1252,14 @@
     fi         
     CPPFLAGS="${TCL_INC_SPEC} ${TCL_LIB_SPEC} ${TK_INC_SPEC} ${TK_LIB_SPEC}"
     AC_MSG_CHECKING([for Tk library spec])
-    AC_TRY_COMPILE([
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
       #include <tcl.h>
       #include <tk.h>
-    ], [
+    ]], [[
       Tcl_Interp *interp;
       interp = Tcl_CreateInterp();
       Tk_Init(interp);
-    ], [found=yes], [found=no])
+    ]])],[found=yes],[found=no])
     AC_MSG_RESULT([${TK_LIB_SPEC}])
     CPPFLAGS=${save_CPPFLAGS}
     if test "$found" = "yes" ; then 
@@ -1253,7 +1269,7 @@
 done
 
 if test "$found" = "no" ; then 
-   AC_ERROR([Can't find tk library in \"${LIBDIRS}\"])
+   AC_MSG_ERROR(Can't find tk library in "${LIBDIRS}")
 fi
 
 # -----------------------------------------------------------------------
@@ -1452,7 +1468,7 @@
 elif test "$TCL_VERSION" = "$TK_VERSION" ; then
   :
 else
-  AC_ERROR([Mismatched Tcl/Tk versions ($TCL_VERSION != $TK_VERSION)])
+  AC_MSG_ERROR(Mismatched Tcl/Tk versions ($TCL_VERSION != $TK_VERSION))
 fi
 
 #--------------------------------------------------------------------
@@ -1566,7 +1582,7 @@
     AC_MSG_CHECKING([if ld accepts -single_module flag])
     save_LDFLAGS=$LDFLAGS
     LDFLAGS="$SO_LDFLAGS -Wl,-single_module"
-    AC_TRY_LINK(, [int i;], [single_module=yes], [single_module=no])
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])],[single_module=yes],[single_module=no])
     if test "${single_module}" = "yes" ; then 
       SO_LDFLAGS=$LDFLAGS
     fi
@@ -2042,5 +2058,5 @@
 ]
 )
 
-AC_OUTPUT()
+AC_OUTPUT
 
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -31,7 +31,7 @@
 AC_DEFUN(BLT_GET_SYMBOL,
 [AC_REQUIRE([AC_PROG_AWK])dnl
 cat > conftest.awk <<EOF
-[/^# *define *]$2[[ \t]]/ { print [\$][3] }
+[/^# *define *]$2[[ \t]]/ { print [\$][NF] }
 EOF
 $1=`${AWK} -f conftest.awk "$3"`
 rm -rf conftest*])
@@ -48,35 +48,35 @@
     lib_spec="-l$2"
     dir=""
     LIBS="${lib_spec} ${save_LIBS}"
-    AC_TRY_LINK([
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #ifdef __cplusplus
 extern "C"
 #endif
 char $3();
-], [$3()], eval "found=yes", eval "found=no")
+]],[[$3()]])], eval "found=yes", eval "found=no")
     if test "${found}" = "no" ; then
       # Then check locations based on exec_prefix 
       dir=${exec_prefix}/lib
       lib_spec="-L${dir} -l$2 $5"
       LIBS="${lib_spec} ${save_LIBS}"
-      AC_TRY_LINK([
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #ifdef __cplusplus
 extern "C"
 #endif
 char $3();
-], [$3()], eval "found=yes", eval "found=no")
+]],[[$3()]])], eval "found=yes", eval "found=no")
     fi
   else 
     # A path was specified.
     for dir in $4 $4/lib ; do 
       lib_spec="-L${dir} -l$2 $5"
       LIBS="${lib_spec} ${save_LIBS}"
-      AC_TRY_LINK([
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #ifdef __cplusplus
 extern "C"
 #endif
 char $3();
-], [$3()], eval "found=yes", eval "found=no")
+]],[[$3()]])], eval "found=yes", eval "found=no")
       if test "${found}" = "yes" ; then
 	break
       fi
