]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/aclocal.m4
ncurses 6.2 - patch 20200229
[ncurses.git] / test / aclocal.m4
index 8bac16a992f6c57c5e3fe1a8a5f3a01204d0ef9c..d3a395f190860e00ef44a9f170e1071b89f4b822 100644 (file)
@@ -1,5 +1,6 @@
 dnl***************************************************************************
-dnl Copyright (c) 2003-2018,2019 Free Software Foundation, Inc.              *
+dnl Copyright 2018-2019,2020 Thomas E. Dickey                                *
+dnl Copyright 2003-2017,2018 Free Software Foundation, Inc.                  *
 dnl                                                                          *
 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
 dnl copy of this software and associated documentation files (the            *
@@ -26,7 +27,7 @@ dnl sale, use or other dealings in this Software without prior written       *
 dnl authorization.                                                           *
 dnl***************************************************************************
 dnl
-dnl $Id: aclocal.m4,v 1.168 2019/12/31 14:02:08 tom Exp $
+dnl $Id: aclocal.m4,v 1.177 2020/02/27 10:21:59 tom Exp $
 dnl
 dnl Author: Thomas E. Dickey
 dnl
@@ -36,7 +37,9 @@ dnl These macros are maintained separately from NCURSES.  The copyright on
 dnl this file applies to the aggregation of macros and does not affect use of
 dnl these macros in other applications.
 dnl
-dnl See http://invisible-island.net/autoconf/ for additional information.
+dnl See these pages for additional information:
+dnl            https://invisible-island.net/autoconf/
+dnl            https://invisible-island.net/autoconf/my-autoconf.html
 dnl
 dnl ---------------------------------------------------------------------------
 dnl ---------------------------------------------------------------------------
@@ -597,7 +600,7 @@ cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
 fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_CONST_X_STRING version: 1 updated: 2019/04/08 17:50:29
+dnl CF_CONST_X_STRING version: 3 updated: 2020/01/11 18:39:22
 dnl -----------------
 dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
 dnl character-strings.
@@ -618,6 +621,10 @@ dnl when compiling the library and compiling using the library, to tell the
 dnl compiler that String is const.
 AC_DEFUN([CF_CONST_X_STRING],
 [
+AC_REQUIRE([AC_PATH_XTRA])
+
+CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
+
 AC_TRY_COMPILE(
 [
 #include <stdlib.h>
@@ -639,6 +646,8 @@ AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
                ])
 ])
 
+CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
+
 case $cf_cv_const_x_string in
 (no)
        CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
@@ -672,7 +681,7 @@ done
 test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map,[Define as needed to override ncurses prefix _nc_])
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_CURSES_CHECK_DATA version: 7 updated: 2018/01/03 04:47:33
+dnl CF_CURSES_CHECK_DATA version: 9 updated: 2020/02/08 21:00:26
 dnl --------------------
 dnl Check if curses.h defines the given data/variable.
 dnl Use this after CF_NCURSES_CONFIG or CF_CURSES_CONFIG.
@@ -685,9 +694,9 @@ for cf_data in $1
 do
 AC_MSG_CHECKING(for data $cf_data declaration in ${cf_cv_ncurses_header:-curses.h})
 
-AC_TRY_COMPILE(CF__CURSES_HEAD,[
-void *foo = &($cf_data)
-],[cf_result=yes
+AC_TRY_COMPILE(CF__CURSES_HEAD,
+CF__CURSES_DATA(foo,$cf_data)
+,[cf_result=yes
 ],[cf_result=no])
 AC_MSG_RESULT($cf_result)
 
@@ -703,8 +712,7 @@ else
 extern char $cf_data;
 int main(void)
 {
-       void *foo = &($cf_data);
-       fprintf(stderr, "testing linkage of $cf_data:%p\n", (void *)foo);
+       ]CF__CURSES_DATA(foo,$cf_data)[
        ${cf_cv_main_return:-return}(foo == 0);
 }],[cf_result=yes
 ],[cf_result=no],[
@@ -712,8 +720,7 @@ int main(void)
        AC_TRY_LINK(CF__CURSES_HEAD
 [extern char $cf_data;],[
        do {
-               void *foo = &($cf_data);
-               fprintf(stderr, "testing linkage of $cf_data:%p\n", (void *)foo);
+               ]CF__CURSES_DATA(foo,$cf_data)[
                ${cf_cv_main_return:-return}(foo == 0);
        } while (0)
 ],[cf_result=yes],[cf_result=no])
@@ -1677,12 +1684,13 @@ CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_GCC_WARNINGS version: 36 updated: 2019/09/07 13:38:36
+dnl CF_GCC_WARNINGS version: 37 updated: 2020/01/05 20:04:12
 dnl ---------------
 dnl Check if the compiler supports useful warning options.  There's a few that
 dnl we don't use, simply because they're too noisy:
 dnl
 dnl    -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
+dnl    -Winline (usually not worthwhile)
 dnl    -Wredundant-decls (system headers make this too noisy)
 dnl    -Wtraditional (combines too many unrelated messages, only a few useful)
 dnl    -Wwrite-strings (too noisy, but should review occasionally).  This
@@ -1738,7 +1746,7 @@ then
                fi
        done
        CFLAGS="$cf_save_CFLAGS"
-elif test "$GCC" = yes
+elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
 then
        AC_CHECKING([for $CC warning options])
        cf_save_CFLAGS="$CFLAGS"
@@ -1760,7 +1768,7 @@ then
                Wpointer-arith \
                Wshadow \
                Wstrict-prototypes \
-               Wundef $cf_gcc_warnings $cf_warn_CONST $1
+               Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
        do
                CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
                if AC_TRY_EVAL(ac_compile); then
@@ -2341,7 +2349,7 @@ printf("old\n");
        ,[$1=no])
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_NCURSES_CONFIG version: 21 updated: 2018/06/20 20:23:13
+dnl CF_NCURSES_CONFIG version: 23 updated: 2020/02/27 05:21:59
 dnl -----------------
 dnl Tie together the configure-script macros for ncurses, preferring these in
 dnl order:
@@ -2363,11 +2371,47 @@ if test "x${PKG_CONFIG:=none}" != xnone; then
                AC_MSG_CHECKING(if the $cf_ncuconfig_root package files work)
                cf_have_ncuconfig=unknown
 
+               cf_save_CFLAGS="$CFLAGS"
                cf_save_CPPFLAGS="$CPPFLAGS"
                cf_save_LIBS="$LIBS"
 
-               CF_ADD_CFLAGS(`$PKG_CONFIG --cflags $cf_ncuconfig_root`)
-               CF_ADD_LIBS(`$PKG_CONFIG --libs $cf_ncuconfig_root`)
+               cf_pkg_cflags=`$PKG_CONFIG --cflags $cf_ncuconfig_root`
+               cf_pkg_libs=`$PKG_CONFIG --libs $cf_ncuconfig_root`
+
+               # while -W for passing linker flags is prevalent, it is not "standard". 
+               # At least one wrapper for c89/c99 (in Apple's xcode) has its own
+               # incompatible _and_ non-standard -W option which gives an error.  Work
+               # around that pitfall.
+               case "x${CC}@@${cf_pkg_libs}@${cf_pkg_cflags}" in
+               (x*c[[89]]9@@*-W*)
+                       CF_ADD_CFLAGS($cf_pkg_cflags)
+                       CF_ADD_LIBS($cf_pkg_libs)
+
+                       AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
+                               [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
+                               [AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
+                                       int main(void)
+                                       { char *xx = curses_version(); return (xx == 0); }],
+                                       [cf_test_ncuconfig=yes],
+                                       [cf_test_ncuconfig=no],
+                                       [cf_test_ncuconfig=maybe])],
+                               [cf_test_ncuconfig=no])
+
+                       CFLAGS="$cf_save_CFLAGS"
+                       CPPFLAGS="$cf_save_CPPFLAGS"
+                       LIBS="$cf_save_LIBS"
+
+                       if test "x$cf_test_ncuconfig" != xyes; then
+                               cf_temp=`echo "x$cf_pkg_cflags" | sed -e s/^x// -e 's/-W[[^     ]]*//g'`
+                               cf_pkg_cflags="$cf_temp"
+                               cf_temp=`echo "x$cf_pkg_libs" | sed -e s/^x// -e 's/-W[[^       ]]*//g'`
+                               cf_pkg_libs="$cf_temp"
+                       fi
+                       ;;
+               esac
+
+               CF_ADD_CFLAGS($cf_pkg_cflags)
+               CF_ADD_LIBS($cf_pkg_libs)
 
                AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
                        [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
@@ -3129,6 +3173,17 @@ $1=`echo "$2" | \
                -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_RESTORE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:47:45
+dnl ---------------------
+dnl Restore flags saved in CF_SAVE_XTRA_FLAGS
+dnl $1 = name of current macro
+define([CF_RESTORE_XTRA_FLAGS],
+[
+LIBS="$cf_save_LIBS_$1"
+CFLAGS="$cf_save_CFLAGS_$1"
+CPPFLAGS="$cf_save_CPPFLAGS_$1"
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_RPATH_HACK version: 11 updated: 2013/09/01 13:02:00
 dnl -------------
 AC_DEFUN([CF_RPATH_HACK],
@@ -3246,6 +3301,31 @@ CF_VERBOSE(...checked $1 [$]$1)
 AC_SUBST(EXTRA_LDFLAGS)
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF_SAVE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:46:44
+dnl ------------------
+dnl Use this macro to save CFLAGS/CPPFLAGS/LIBS before checks against X headers
+dnl and libraries which do not update those variables.
+dnl
+dnl $1 = name of current macro
+define([CF_SAVE_XTRA_FLAGS],
+[
+cf_save_LIBS_$1="$LIBS"
+cf_save_CFLAGS_$1="$CFLAGS"
+cf_save_CPPFLAGS_$1="$CPPFLAGS"
+LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
+for cf_X_CFLAGS in $X_CFLAGS
+do
+       case "x$cf_X_CFLAGS" in
+       x-[[IUD]]*)
+               CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS"
+               ;;
+       *)
+               CFLAGS="$CFLAGS $cf_X_CFLAGS"
+               ;;
+       esac
+done
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF_SIGWINCH version: 2 updated: 2019/03/23 19:54:44
 dnl -----------
 dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
@@ -3305,9 +3385,9 @@ done
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_SIG_ATOMIC_T version: 3 updated: 2012/10/04 20:12:20
+dnl CF_SIG_ATOMIC_T version: 4 updated: 2020/01/18 12:30:44
 dnl ---------------
-dnl signal handler, but there are some gcc depedencies in that recommendation.
+dnl signal handler, but there are some gcc dependencies in that recommendation.
 dnl Try anyway.
 AC_DEFUN([CF_SIG_ATOMIC_T],
 [
@@ -4171,12 +4251,13 @@ if test -z "$cf_x_athena_lib" ; then
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
-dnl CF_X_ATHENA_CPPFLAGS version: 6 updated: 2018/06/20 20:23:13
+dnl CF_X_ATHENA_CPPFLAGS version: 8 updated: 2020/01/16 05:21:56
 dnl --------------------
 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
 AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
 [
+AC_REQUIRE([AC_PATH_XTRA])
 cf_x_athena_root=ifelse([$1],,Xaw,[$1])
 cf_x_athena_inc=""
 
@@ -4187,10 +4268,9 @@ for cf_path in default \
        /usr/local
 do
        if test -z "$cf_x_athena_inc" ; then
-               cf_save="$CPPFLAGS"
+               CF_SAVE_XTRA_FLAGS([CF_X_ATHENA_CPPFLAGS])
                cf_test=X11/$cf_x_athena_root/SimpleMenu.h
                if test $cf_path != default ; then
-                       CPPFLAGS="$cf_save"
                        CF_APPEND_TEXT(CPPFLAGS,-I$cf_path/include)
                        AC_MSG_CHECKING(for $cf_test in $cf_path)
                else
@@ -4202,24 +4282,23 @@ do
                        [cf_result=yes],
                        [cf_result=no])
                AC_MSG_RESULT($cf_result)
+               CF_RESTORE_XTRA_FLAGS([CF_X_ATHENA_CPPFLAGS])
                if test "$cf_result" = yes ; then
-                       cf_x_athena_inc=$cf_path
+                       test "$cf_path"  = default && cf_x_athena_inc=default
+                       test "$cf_path" != default && cf_x_athena_inc=$cf_path/include
                        break
-               else
-                       CPPFLAGS="$cf_save"
                fi
        fi
 done
 
 if test -z "$cf_x_athena_inc" ; then
-       AC_MSG_WARN(
-[Unable to successfully find Athena header files with test program])
+       AC_MSG_WARN([Unable to find Athena header files])
 elif test "$cf_x_athena_inc" != default ; then
        CF_APPEND_TEXT(CPPFLAGS,-I$cf_x_athena_inc)
 fi
 ])
 dnl ---------------------------------------------------------------------------
-dnl CF_X_ATHENA_LIBS version: 12 updated: 2011/07/17 19:55:02
+dnl CF_X_ATHENA_LIBS version: 13 updated: 2020/01/11 18:16:10
 dnl ----------------
 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
@@ -4244,29 +4323,26 @@ do
                "-l$cf_lib -lXpm -lXmu" \
                "-l${cf_lib}_s -lXmu_s"
        do
-               if test -z "$cf_x_athena_lib" ; then
-                       cf_save="$LIBS"
-                       cf_test=XawSimpleMenuAddGlobalActions
-                       if test $cf_path != default ; then
-                               CF_ADD_LIBS(-L$cf_path/lib $cf_libs)
-                               AC_MSG_CHECKING(for $cf_libs in $cf_path)
-                       else
-                               CF_ADD_LIBS($cf_libs)
-                               AC_MSG_CHECKING(for $cf_test in $cf_libs)
-                       fi
-                       AC_TRY_LINK([
+               test -n "$cf_x_athena_lib" && break
+
+               CF_SAVE_XTRA_FLAGS([CF_X_ATHENA_LIBS])
+               cf_test=XawSimpleMenuAddGlobalActions
+               test "$cf_path" != default && cf_libs="-L$cf_path/lib $cf_libs"
+               CF_ADD_LIBS($cf_libs)
+               AC_MSG_CHECKING(for $cf_test in $cf_libs)
+               AC_TRY_LINK([
 #include <X11/Intrinsic.h>
 #include <X11/$cf_x_athena_root/SimpleMenu.h>
 ],[
 $cf_test((XtAppContext) 0)],
-                               [cf_result=yes],
-                               [cf_result=no])
-                       AC_MSG_RESULT($cf_result)
-                       if test "$cf_result" = yes ; then
-                               cf_x_athena_lib="$cf_libs"
-                               break
-                       fi
-                       LIBS="$cf_save"
+                       [cf_result=yes],
+                       [cf_result=no])
+               AC_MSG_RESULT($cf_result)
+               CF_RESTORE_XTRA_FLAGS([CF_X_ATHENA_LIBS])
+
+               if test "$cf_result" = yes ; then
+                       cf_x_athena_lib="$cf_libs"
+                       break
                fi
        done # cf_libs
                test -n "$cf_x_athena_lib" && break
@@ -4278,6 +4354,7 @@ if test -z "$cf_x_athena_lib" ; then
 [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
 fi
 
+CF_ADD_LIBS($cf_x_athena_lib)
 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
 ])
@@ -4391,6 +4468,24 @@ to makefile.])
 fi
 ])dnl
 dnl ---------------------------------------------------------------------------
+dnl CF__CURSES_DATA version: 2 updated: 2020/02/08 21:00:26
+dnl ---------------
+dnl Attempt to make a copy of a curses data item.  This is needed in the
+dnl check-data configure tests when using ncurses, because the symbol may be
+dnl actually a function return-value.  That could happen if the linker is
+dnl broken (does not resolve data-only references), or if ncurses is configured
+dnl to support re-entrant code.
+dnl $1 = target
+dnl $2 = source
+define([CF__CURSES_DATA],[
+#if defined($2) && ((defined(NCURSES_WRAPPED_VAR) && (NCURSES_VERSION_PATCH < 20200208)) || defined(NCURSES_BROKEN_LINKER) || defined(NCURSES_REENTRANT))
+       const void *$1 = (const void *)($2);
+#else
+       const void *$1 = &($2);
+#endif
+       fprintf(stderr, "testing linkage of $2:%p\n", (const void *)$1);
+])dnl
+dnl ---------------------------------------------------------------------------
 dnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
 dnl ---------------
 dnl Define a reusable chunk which includes <curses.h> and <term.h> when they