xref: /freebsd/contrib/dialog/aclocal.m4 (revision a96ef4501919d7ac08e94e98dc34b0bdd744802b)
14c8945a0SNathan Whitehorndnl macros used for DIALOG configure script
2*a96ef450SBaptiste Daroussindnl $Id: aclocal.m4,v 1.150 2021/01/11 09:03:36 tom Exp $
37a1c0d96SNathan Whitehorndnl ---------------------------------------------------------------------------
4*a96ef450SBaptiste Daroussindnl Copyright 1999-2020,2021 -- Thomas E. Dickey
57a1c0d96SNathan Whitehorndnl
67a1c0d96SNathan Whitehorndnl Permission is hereby granted, free of charge, to any person obtaining a
77a1c0d96SNathan Whitehorndnl copy of this software and associated documentation files (the
87a1c0d96SNathan Whitehorndnl "Software"), to deal in the Software without restriction, including
97a1c0d96SNathan Whitehorndnl without limitation the rights to use, copy, modify, merge, publish,
107a1c0d96SNathan Whitehorndnl distribute, distribute with modifications, sublicense, and/or sell
117a1c0d96SNathan Whitehorndnl copies of the Software, and to permit persons to whom the Software is
127a1c0d96SNathan Whitehorndnl furnished to do so, subject to the following conditions:
137a1c0d96SNathan Whitehorndnl
147a1c0d96SNathan Whitehorndnl The above copyright notice and this permission notice shall be included
157a1c0d96SNathan Whitehorndnl in all copies or portions of the Software.
167a1c0d96SNathan Whitehorndnl
177a1c0d96SNathan Whitehorndnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
187a1c0d96SNathan Whitehorndnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
197a1c0d96SNathan Whitehorndnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
207a1c0d96SNathan Whitehorndnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
217a1c0d96SNathan Whitehorndnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
227a1c0d96SNathan Whitehorndnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
237a1c0d96SNathan Whitehorndnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.
247a1c0d96SNathan Whitehorndnl
257a1c0d96SNathan Whitehorndnl Except as contained in this notice, the name(s) of the above copyright
267a1c0d96SNathan Whitehorndnl holders shall not be used in advertising or otherwise to promote the
277a1c0d96SNathan Whitehorndnl sale, use or other dealings in this Software without prior written
287a1c0d96SNathan Whitehorndnl authorization.
294c8945a0SNathan Whitehorndnl
304c8945a0SNathan Whitehorndnl see
31*a96ef450SBaptiste Daroussindnl https://invisible-island.net/autoconf/
324c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
334c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
34*a96ef450SBaptiste Daroussindnl AM_GNU_GETTEXT version: 15 updated: 2021/01/02 09:31:20
354c8945a0SNathan Whitehorndnl --------------
364c8945a0SNathan Whitehorndnl Usage: Just like AM_WITH_NLS, which see.
374c8945a0SNathan WhitehornAC_DEFUN([AM_GNU_GETTEXT],
384c8945a0SNathan Whitehorn  [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
394c8945a0SNathan Whitehorn   AC_REQUIRE([AC_CANONICAL_HOST])dnl
404c8945a0SNathan Whitehorn   AC_REQUIRE([AC_PROG_RANLIB])dnl
414c8945a0SNathan Whitehorn   AC_REQUIRE([AC_HEADER_STDC])dnl
424c8945a0SNathan Whitehorn   AC_REQUIRE([AC_C_INLINE])dnl
434c8945a0SNathan Whitehorn   AC_REQUIRE([AC_TYPE_OFF_T])dnl
444c8945a0SNathan Whitehorn   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
454c8945a0SNathan Whitehorn   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
464c8945a0SNathan Whitehorn   AC_REQUIRE([AC_FUNC_MMAP])dnl
474c8945a0SNathan Whitehorn   AC_REQUIRE([jm_GLIBC21])dnl
482a3e3873SBaptiste Daroussin   AC_REQUIRE([CF_PROG_CC])dnl
494c8945a0SNathan Whitehorn
504c8945a0SNathan Whitehorn   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
514c8945a0SNathan Whitehornstdlib.h string.h unistd.h sys/param.h])
524c8945a0SNathan Whitehorn   AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
534c8945a0SNathan Whitehorngetgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
544c8945a0SNathan Whitehornstrdup strtoul tsearch __argz_count __argz_stringify __argz_next])
554c8945a0SNathan Whitehorn
564c8945a0SNathan Whitehorn   AM_ICONV
574c8945a0SNathan Whitehorn   AM_LANGINFO_CODESET
584c8945a0SNathan Whitehorn   AM_LC_MESSAGES
594c8945a0SNathan Whitehorn   AM_WITH_NLS([$1],[$2],[$3],[$4])
604c8945a0SNathan Whitehorn
614c8945a0SNathan Whitehorn   if test "x$CATOBJEXT" != "x"; then
624c8945a0SNathan Whitehorn     if test "x$ALL_LINGUAS" = "x"; then
634c8945a0SNathan Whitehorn       LINGUAS=
644c8945a0SNathan Whitehorn     else
654c8945a0SNathan Whitehorn       AC_MSG_CHECKING(for catalogs to be installed)
664c8945a0SNathan Whitehorn       NEW_LINGUAS=
674c8945a0SNathan Whitehorn       for presentlang in $ALL_LINGUAS; do
684c8945a0SNathan Whitehorn         useit=no
694c8945a0SNathan Whitehorn         for desiredlang in ${LINGUAS-$ALL_LINGUAS}; do
704c8945a0SNathan Whitehorn           # Use the presentlang catalog if desiredlang is
714c8945a0SNathan Whitehorn           #   a. equal to presentlang, or
724c8945a0SNathan Whitehorn           #   b. a variant of presentlang (because in this case,
734c8945a0SNathan Whitehorn           #      presentlang can be used as a fallback for messages
744c8945a0SNathan Whitehorn           #      which are not translated in the desiredlang catalog).
754c8945a0SNathan Whitehorn           case "$desiredlang" in
76f4f33ea0SBaptiste Daroussin             ("$presentlang"*) useit=yes;;
774c8945a0SNathan Whitehorn           esac
784c8945a0SNathan Whitehorn         done
79*a96ef450SBaptiste Daroussin         if test "$useit" = yes; then
804c8945a0SNathan Whitehorn           NEW_LINGUAS="$NEW_LINGUAS $presentlang"
814c8945a0SNathan Whitehorn         fi
824c8945a0SNathan Whitehorn       done
834c8945a0SNathan Whitehorn       LINGUAS=$NEW_LINGUAS
844c8945a0SNathan Whitehorn       AC_MSG_RESULT($LINGUAS)
854c8945a0SNathan Whitehorn     fi
864c8945a0SNathan Whitehorn
874c8945a0SNathan Whitehorn     dnl Construct list of names of catalog files to be constructed.
884c8945a0SNathan Whitehorn     if test -n "$LINGUAS"; then
894c8945a0SNathan Whitehorn       for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
904c8945a0SNathan Whitehorn     fi
914c8945a0SNathan Whitehorn   fi
924c8945a0SNathan Whitehorn
934c8945a0SNathan Whitehorn   dnl Enable libtool support if the surrounding package wishes it.
944c8945a0SNathan Whitehorn   INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
954c8945a0SNathan Whitehorn   AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
964c8945a0SNathan Whitehorn])dnl
974c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
984c8945a0SNathan Whitehorndnl AM_ICONV version: 12 updated: 2007/07/30 19:12:03
994c8945a0SNathan Whitehorndnl --------
1004c8945a0SNathan Whitehorndnl Inserted as requested by gettext 0.10.40
1014c8945a0SNathan Whitehorndnl File from /usr/share/aclocal
1024c8945a0SNathan Whitehorndnl iconv.m4
1034c8945a0SNathan Whitehorndnl ====================
1044c8945a0SNathan Whitehorndnl serial AM2
1054c8945a0SNathan Whitehorndnl
1064c8945a0SNathan Whitehorndnl From Bruno Haible.
1074c8945a0SNathan Whitehorndnl
1084c8945a0SNathan Whitehorndnl ====================
1094c8945a0SNathan Whitehorndnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
1104c8945a0SNathan Whitehorndnl range of locations searched.  Retain the same cache-variable naming to
1114c8945a0SNathan Whitehorndnl allow reuse with the other gettext macros -Thomas E Dickey
1124c8945a0SNathan WhitehornAC_DEFUN([AM_ICONV],
1134c8945a0SNathan Whitehorn[
1144c8945a0SNathan Whitehorn  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
1154c8945a0SNathan Whitehorn  dnl those with the standalone portable GNU libiconv installed).
1164c8945a0SNathan Whitehorn
1174c8945a0SNathan Whitehorn  AC_ARG_WITH([libiconv-prefix],
1184c8945a0SNathan Whitehorn[  --with-libiconv-prefix=DIR
1194c8945a0SNathan Whitehorn                          search for libiconv in DIR/include and DIR/lib], [
1204c8945a0SNathan Whitehorn    CF_ADD_OPTIONAL_PATH($withval, libiconv)
1214c8945a0SNathan Whitehorn   ])
1224c8945a0SNathan Whitehorn
1234c8945a0SNathan Whitehorn  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
1244c8945a0SNathan Whitehorn    CF_FIND_LINKAGE(CF__ICONV_HEAD,
1254c8945a0SNathan Whitehorn      CF__ICONV_BODY,
1264c8945a0SNathan Whitehorn      iconv,
1274c8945a0SNathan Whitehorn      am_cv_func_iconv=yes,
1284c8945a0SNathan Whitehorn      am_cv_func_iconv=["no, consider installing GNU libiconv"])])
1294c8945a0SNathan Whitehorn
1304c8945a0SNathan Whitehorn  if test "$am_cv_func_iconv" = yes; then
1314c8945a0SNathan Whitehorn    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
1324c8945a0SNathan Whitehorn
1334c8945a0SNathan Whitehorn    AC_CACHE_CHECK([if the declaration of iconv() needs const.],
1344c8945a0SNathan Whitehorn		   am_cv_proto_iconv_const,[
1354c8945a0SNathan Whitehorn      AC_TRY_COMPILE(CF__ICONV_HEAD [
1364c8945a0SNathan Whitehornextern
1374c8945a0SNathan Whitehorn#ifdef __cplusplus
1384c8945a0SNathan Whitehorn"C"
1394c8945a0SNathan Whitehorn#endif
1404c8945a0SNathan Whitehorn#if defined(__STDC__) || defined(__cplusplus)
1414c8945a0SNathan Whitehornsize_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
1424c8945a0SNathan Whitehorn#else
1434c8945a0SNathan Whitehornsize_t iconv();
1444c8945a0SNathan Whitehorn#endif
1454c8945a0SNathan Whitehorn],[], am_cv_proto_iconv_const=no,
1464c8945a0SNathan Whitehorn      am_cv_proto_iconv_const=yes)])
1474c8945a0SNathan Whitehorn
1484c8945a0SNathan Whitehorn    if test "$am_cv_proto_iconv_const" = yes ; then
1494c8945a0SNathan Whitehorn      am_cv_proto_iconv_arg1="const"
1504c8945a0SNathan Whitehorn    else
1514c8945a0SNathan Whitehorn      am_cv_proto_iconv_arg1=""
1524c8945a0SNathan Whitehorn    fi
1534c8945a0SNathan Whitehorn
1544c8945a0SNathan Whitehorn    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
1554c8945a0SNathan Whitehorn      [Define as const if the declaration of iconv() needs const.])
1564c8945a0SNathan Whitehorn  fi
1574c8945a0SNathan Whitehorn
1584c8945a0SNathan Whitehorn  LIBICONV=
1594c8945a0SNathan Whitehorn  if test "$cf_cv_find_linkage_iconv" = yes; then
1604c8945a0SNathan Whitehorn    CF_ADD_INCDIR($cf_cv_header_path_iconv)
1614c8945a0SNathan Whitehorn    if test -n "$cf_cv_library_file_iconv" ; then
1624c8945a0SNathan Whitehorn      LIBICONV="-liconv"
1634c8945a0SNathan Whitehorn      CF_ADD_LIBDIR($cf_cv_library_path_iconv)
1644c8945a0SNathan Whitehorn    fi
1654c8945a0SNathan Whitehorn  fi
1664c8945a0SNathan Whitehorn
1674c8945a0SNathan Whitehorn  AC_SUBST(LIBICONV)
1684c8945a0SNathan Whitehorn])dnl
1694c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
170*a96ef450SBaptiste Daroussindnl AM_LANGINFO_CODESET version: 6 updated: 2021/01/01 16:53:59
1714c8945a0SNathan Whitehorndnl -------------------
1724c8945a0SNathan Whitehorndnl Inserted as requested by gettext 0.10.40
1734c8945a0SNathan Whitehorndnl File from /usr/share/aclocal
1744c8945a0SNathan Whitehorndnl codeset.m4
1754c8945a0SNathan Whitehorndnl ====================
1764c8945a0SNathan Whitehorndnl serial AM1
1774c8945a0SNathan Whitehorndnl
1784c8945a0SNathan Whitehorndnl From Bruno Haible.
1794c8945a0SNathan WhitehornAC_DEFUN([AM_LANGINFO_CODESET],
1804c8945a0SNathan Whitehorn[
1814c8945a0SNathan WhitehornAC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
1824c8945a0SNathan Whitehorn	[AC_TRY_LINK([#include <langinfo.h>],
183*a96ef450SBaptiste Daroussin	[char* cs = nl_langinfo(CODESET); (void)cs],
1844c8945a0SNathan Whitehorn	am_cv_langinfo_codeset=yes,
1854c8945a0SNathan Whitehorn	am_cv_langinfo_codeset=no)
1864c8945a0SNathan Whitehorn	])
187*a96ef450SBaptiste Daroussin	if test "$am_cv_langinfo_codeset" = yes; then
1884c8945a0SNathan Whitehorn		AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
1894c8945a0SNathan Whitehorn		[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
1904c8945a0SNathan Whitehorn	fi
1914c8945a0SNathan Whitehorn])dnl
1924c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
193*a96ef450SBaptiste Daroussindnl AM_LC_MESSAGES version: 6 updated: 2021/01/02 09:31:20
1944c8945a0SNathan Whitehorndnl --------------
1954c8945a0SNathan Whitehorndnl Inserted as requested by gettext 0.10.40
1964c8945a0SNathan Whitehorndnl File from /usr/share/aclocal
1974c8945a0SNathan Whitehorndnl lcmessage.m4
1984c8945a0SNathan Whitehorndnl ====================
1994c8945a0SNathan Whitehorndnl Check whether LC_MESSAGES is available in <locale.h>.
2004c8945a0SNathan Whitehorndnl Ulrich Drepper <drepper@cygnus.com>, 1995.
2014c8945a0SNathan Whitehorndnl
2024c8945a0SNathan Whitehorndnl This file can be copied and used freely without restrictions.  It can
2034c8945a0SNathan Whitehorndnl be used in projects which are not available under the GNU General Public
2044c8945a0SNathan Whitehorndnl License or the GNU Library General Public License but which still want
2054c8945a0SNathan Whitehorndnl to provide support for the GNU gettext functionality.
2064c8945a0SNathan Whitehorndnl Please note that the actual code of the GNU gettext library is covered
2074c8945a0SNathan Whitehorndnl by the GNU Library General Public License, and the rest of the GNU
2084c8945a0SNathan Whitehorndnl gettext package package is covered by the GNU General Public License.
2094c8945a0SNathan Whitehorndnl They are *not* in the public domain.
2104c8945a0SNathan Whitehorndnl
2114c8945a0SNathan Whitehorndnl serial 2
2124c8945a0SNathan Whitehorndnl
2134c8945a0SNathan WhitehornAC_DEFUN([AM_LC_MESSAGES],
214*a96ef450SBaptiste Daroussin[if test "$ac_cv_header_locale_h" = yes; then
2154c8945a0SNathan Whitehorn	AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
2164c8945a0SNathan Whitehorn		[AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
2174c8945a0SNathan Whitehorn		am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
218*a96ef450SBaptiste Daroussin	if test "$am_cv_val_LC_MESSAGES" = yes; then
2194c8945a0SNathan Whitehorn		AC_DEFINE(HAVE_LC_MESSAGES, 1,
2204c8945a0SNathan Whitehorn		[Define if your <locale.h> file defines LC_MESSAGES.])
2214c8945a0SNathan Whitehorn	fi
2224c8945a0SNathan Whitehornfi])dnl
2234c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
224*a96ef450SBaptiste Daroussindnl AM_PATH_PROG_WITH_TEST version: 10 updated: 2021/01/02 09:31:20
2254c8945a0SNathan Whitehorndnl ----------------------
2264c8945a0SNathan Whitehorndnl Inserted as requested by gettext 0.10.40
2274c8945a0SNathan Whitehorndnl File from /usr/share/aclocal
2284c8945a0SNathan Whitehorndnl progtest.m4
2294c8945a0SNathan Whitehorndnl ====================
2304c8945a0SNathan Whitehorndnl Search path for a program which passes the given test.
2314c8945a0SNathan Whitehorndnl Ulrich Drepper <drepper@cygnus.com>, 1996.
2324c8945a0SNathan Whitehorndnl
2334c8945a0SNathan Whitehorndnl This file can be copied and used freely without restrictions.  It can
2344c8945a0SNathan Whitehorndnl be used in projects which are not available under the GNU General Public
2354c8945a0SNathan Whitehorndnl License or the GNU Library General Public License but which still want
2364c8945a0SNathan Whitehorndnl to provide support for the GNU gettext functionality.
2374c8945a0SNathan Whitehorndnl Please note that the actual code of the GNU gettext library is covered
2384c8945a0SNathan Whitehorndnl by the GNU Library General Public License, and the rest of the GNU
2394c8945a0SNathan Whitehorndnl gettext package package is covered by the GNU General Public License.
2404c8945a0SNathan Whitehorndnl They are *not* in the public domain.
2414c8945a0SNathan Whitehorndnl
2424c8945a0SNathan Whitehorndnl serial 2
2434c8945a0SNathan Whitehorndnl
2444c8945a0SNathan Whitehorndnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
2454c8945a0SNathan Whitehorndnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
2464c8945a0SNathan WhitehornAC_DEFUN([AM_PATH_PROG_WITH_TEST],
2474c8945a0SNathan Whitehorn[# Extract the first word of "$2", so it can be a program name with args.
2484c8945a0SNathan WhitehornAC_REQUIRE([CF_PATHSEP])
2494c8945a0SNathan Whitehornset dummy $2; ac_word=[$]2
2504c8945a0SNathan WhitehornAC_MSG_CHECKING([for $ac_word])
2514c8945a0SNathan WhitehornAC_CACHE_VAL(ac_cv_path_$1,
2524c8945a0SNathan Whitehorn[case "[$]$1" in
253f4f33ea0SBaptiste Daroussin  ([[\\/]*|?:[\\/]]*)
2544c8945a0SNathan Whitehorn  ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
2554c8945a0SNathan Whitehorn  ;;
256f4f33ea0SBaptiste Daroussin  (*)
2574c8945a0SNathan Whitehorn  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
2584c8945a0SNathan Whitehorn  for ac_dir in ifelse([$5], , $PATH, [$5]); do
2594c8945a0SNathan Whitehorn    test -z "$ac_dir" && ac_dir=.
260*a96ef450SBaptiste Daroussin    if test -f "$ac_dir/$ac_word$ac_exeext" ; then
2614c8945a0SNathan Whitehorn      if [$3]; then
2624c8945a0SNathan Whitehorn	ac_cv_path_$1="$ac_dir/$ac_word$ac_exeext"
2634c8945a0SNathan Whitehorn	break
2644c8945a0SNathan Whitehorn      fi
2654c8945a0SNathan Whitehorn    fi
2664c8945a0SNathan Whitehorn  done
2674c8945a0SNathan Whitehorn  IFS="$ac_save_ifs"
2684c8945a0SNathan Whitehorndnl If no 4th arg is given, leave the cache variable unset,
2694c8945a0SNathan Whitehorndnl so AC_PATH_PROGS will keep looking.
2704c8945a0SNathan Whitehornifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
2714c8945a0SNathan Whitehorn])dnl
2724c8945a0SNathan Whitehorn  ;;
2734c8945a0SNathan Whitehornesac])dnl
2744c8945a0SNathan Whitehorn$1="$ac_cv_path_$1"
2754c8945a0SNathan Whitehornif test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
2764c8945a0SNathan Whitehorn  AC_MSG_RESULT([$]$1)
2774c8945a0SNathan Whitehornelse
2784c8945a0SNathan Whitehorn  AC_MSG_RESULT(no)
2794c8945a0SNathan Whitehornfi
2804c8945a0SNathan WhitehornAC_SUBST($1)dnl
2814c8945a0SNathan Whitehorn])dnl
2824c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
283*a96ef450SBaptiste Daroussindnl AM_WITH_NLS version: 31 updated: 2021/01/04 17:48:08
2844c8945a0SNathan Whitehorndnl -----------
2854c8945a0SNathan Whitehorndnl Inserted as requested by gettext 0.10.40
2864c8945a0SNathan Whitehorndnl File from /usr/share/aclocal
2874c8945a0SNathan Whitehorndnl gettext.m4
2884c8945a0SNathan Whitehorndnl ====================
2894c8945a0SNathan Whitehorndnl Macro to add for using GNU gettext.
2904c8945a0SNathan Whitehorndnl Ulrich Drepper <drepper@cygnus.com>, 1995.
2914c8945a0SNathan Whitehorndnl ====================
2924c8945a0SNathan Whitehorndnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
2934c8945a0SNathan Whitehorndnl range of locations searched.  Retain the same cache-variable naming to
2944c8945a0SNathan Whitehorndnl allow reuse with the other gettext macros -Thomas E Dickey
2954c8945a0SNathan Whitehorndnl ====================
2964c8945a0SNathan Whitehorndnl
2974c8945a0SNathan Whitehorndnl This file can be copied and used freely without restrictions.  It can
2984c8945a0SNathan Whitehorndnl be used in projects which are not available under the GNU General Public
2994c8945a0SNathan Whitehorndnl License or the GNU Library General Public License but which still want
3004c8945a0SNathan Whitehorndnl to provide support for the GNU gettext functionality.
3014c8945a0SNathan Whitehorndnl Please note that the actual code of the GNU gettext library is covered
3024c8945a0SNathan Whitehorndnl by the GNU Library General Public License, and the rest of the GNU
3034c8945a0SNathan Whitehorndnl gettext package package is covered by the GNU General Public License.
3044c8945a0SNathan Whitehorndnl They are *not* in the public domain.
3054c8945a0SNathan Whitehorndnl
3064c8945a0SNathan Whitehorndnl serial 10
3074c8945a0SNathan Whitehorndnl
3084c8945a0SNathan Whitehorndnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR], [ENABLED]).
3094c8945a0SNathan Whitehorndnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
3104c8945a0SNathan Whitehorndnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
3114c8945a0SNathan Whitehorndnl    depending on --{enable,disable}-{shared,static} and on the presence of
3124c8945a0SNathan Whitehorndnl    AM-DISABLE-SHARED). Otherwise, a static library
3134c8945a0SNathan Whitehorndnl    $(top_builddir)/intl/libintl.a will be created.
3144c8945a0SNathan Whitehorndnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
3154c8945a0SNathan Whitehorndnl    implementations (in libc or libintl) without the ngettext() function
3164c8945a0SNathan Whitehorndnl    will be ignored.
3174c8945a0SNathan Whitehorndnl LIBDIR is used to find the intl libraries.  If empty,
3184c8945a0SNathan Whitehorndnl    the value `$(top_builddir)/intl/' is used.
3194c8945a0SNathan Whitehorndnl ENABLED is used to control the default for the related --enable-nls, since
3204c8945a0SNathan Whitehorndnl    not all application developers want this feature by default, e.g., lynx.
3214c8945a0SNathan Whitehorndnl
3224c8945a0SNathan Whitehorndnl The result of the configuration is one of three cases:
3234c8945a0SNathan Whitehorndnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
3244c8945a0SNathan Whitehorndnl    and used.
3254c8945a0SNathan Whitehorndnl    Catalog format: GNU --> install in $(datadir)
3264c8945a0SNathan Whitehorndnl    Catalog extension: .mo after installation, .gmo in source tree
3274c8945a0SNathan Whitehorndnl 2) GNU gettext has been found in the system's C library.
3284c8945a0SNathan Whitehorndnl    Catalog format: GNU --> install in $(datadir)
3294c8945a0SNathan Whitehorndnl    Catalog extension: .mo after installation, .gmo in source tree
3304c8945a0SNathan Whitehorndnl 3) No internationalization, always use English msgid.
3314c8945a0SNathan Whitehorndnl    Catalog format: none
3324c8945a0SNathan Whitehorndnl    Catalog extension: none
3334c8945a0SNathan Whitehorndnl The use of .gmo is historical (it was needed to avoid overwriting the
3344c8945a0SNathan Whitehorndnl GNU format catalogs when building on a platform with an X/Open gettext),
3354c8945a0SNathan Whitehorndnl but we keep it in order not to force irrelevant filename changes on the
3364c8945a0SNathan Whitehorndnl maintainers.
3374c8945a0SNathan Whitehorndnl
3384c8945a0SNathan WhitehornAC_DEFUN([AM_WITH_NLS],
3394c8945a0SNathan Whitehorn[AC_MSG_CHECKING([whether NLS is requested])
3404c8945a0SNathan Whitehorn  dnl Default is enabled NLS
3414c8945a0SNathan Whitehorn  ifelse([$4],,[
3424c8945a0SNathan Whitehorn  AC_ARG_ENABLE(nls,
3434c8945a0SNathan Whitehorn    [  --disable-nls           do not use Native Language Support],
3444c8945a0SNathan Whitehorn    USE_NLS=$enableval, USE_NLS=yes)],[
3454c8945a0SNathan Whitehorn  AC_ARG_ENABLE(nls,
3464c8945a0SNathan Whitehorn    [  --enable-nls            use Native Language Support],
3474c8945a0SNathan Whitehorn    USE_NLS=$enableval, USE_NLS=no)])
3484c8945a0SNathan Whitehorn  AC_MSG_RESULT($USE_NLS)
3494c8945a0SNathan Whitehorn  AC_SUBST(USE_NLS)
3504c8945a0SNathan Whitehorn
3514c8945a0SNathan Whitehorn  BUILD_INCLUDED_LIBINTL=no
3524c8945a0SNathan Whitehorn  USE_INCLUDED_LIBINTL=no
3534c8945a0SNathan Whitehorn  INTLLIBS=
3544c8945a0SNathan Whitehorn
3554c8945a0SNathan Whitehorn  dnl If we use NLS figure out what method
3564c8945a0SNathan Whitehorn  if test "$USE_NLS" = "yes"; then
357f4f33ea0SBaptiste Daroussin    dnl We need to process the po/ directory.
358f4f33ea0SBaptiste Daroussin    POSUB=po
3594c8945a0SNathan Whitehorn    AC_DEFINE(ENABLE_NLS, 1,
3604c8945a0SNathan Whitehorn      [Define to 1 if translation of program messages to the user's native language
3614c8945a0SNathan Whitehorn is requested.])
3624c8945a0SNathan Whitehorn    AC_MSG_CHECKING([whether included gettext is requested])
3634c8945a0SNathan Whitehorn    AC_ARG_WITH(included-gettext,
3644c8945a0SNathan Whitehorn      [  --with-included-gettext use the GNU gettext library included here],
3654c8945a0SNathan Whitehorn      nls_cv_force_use_gnu_gettext=$withval,
3664c8945a0SNathan Whitehorn      nls_cv_force_use_gnu_gettext=no)
3674c8945a0SNathan Whitehorn    AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
3684c8945a0SNathan Whitehorn
3694c8945a0SNathan Whitehorn    nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
3704c8945a0SNathan Whitehorn    if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
3714c8945a0SNathan Whitehorn      dnl User does not insist on using GNU NLS library.  Figure out what
372f4f33ea0SBaptiste Daroussin      dnl to use.  If GNU gettext is available we use this.  Else we may have
3734c8945a0SNathan Whitehorn      dnl to fall back to GNU NLS library.
3744c8945a0SNathan Whitehorn      CATOBJEXT=NONE
3754c8945a0SNathan Whitehorn
376f4f33ea0SBaptiste Daroussin      dnl Save these (possibly-set) variables for reference.  If the user
377f4f33ea0SBaptiste Daroussin      dnl overrode these to provide full pathnames, then warn if not actually
378f4f33ea0SBaptiste Daroussin      dnl GNU gettext, but do not override their values.  Also, if they were
379f4f33ea0SBaptiste Daroussin      dnl overridden, suppress the part of the library test which prevents it
380f4f33ea0SBaptiste Daroussin      dnl from finding anything other than GNU gettext.  Doing this also
381f4f33ea0SBaptiste Daroussin      dnl suppresses a bogus search for the intl library.
382f4f33ea0SBaptiste Daroussin      cf_save_msgfmt_path="$MSGFMT"
383f4f33ea0SBaptiste Daroussin      cf_save_xgettext_path="$XGETTEXT"
384f4f33ea0SBaptiste Daroussin
385f4f33ea0SBaptiste Daroussin      dnl Search for GNU msgfmt in the PATH.
386f4f33ea0SBaptiste Daroussin      AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
387*a96ef450SBaptiste Daroussin          ["$ac_dir/$ac_word" --statistics /dev/null >/dev/null 2>&1], :)
388f4f33ea0SBaptiste Daroussin      AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
389f4f33ea0SBaptiste Daroussin      AC_SUBST(MSGFMT)
390f4f33ea0SBaptiste Daroussin
391f4f33ea0SBaptiste Daroussin      dnl Search for GNU xgettext in the PATH.
392f4f33ea0SBaptiste Daroussin      AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
393*a96ef450SBaptiste Daroussin          ["$ac_dir/$ac_word" --omit-header /dev/null >/dev/null 2>&1], :)
394f4f33ea0SBaptiste Daroussin
395f4f33ea0SBaptiste Daroussin      cf_save_OPTS_1="$CPPFLAGS"
396f4f33ea0SBaptiste Daroussin      if test "x$cf_save_msgfmt_path" = "x$MSGFMT" && \
397f4f33ea0SBaptiste Daroussin         test "x$cf_save_xgettext_path" = "x$XGETTEXT" ; then
398f4f33ea0SBaptiste Daroussin          CF_ADD_CFLAGS(-DIGNORE_MSGFMT_HACK)
399f4f33ea0SBaptiste Daroussin      fi
400f4f33ea0SBaptiste Daroussin
4014c8945a0SNathan Whitehorn      cf_save_LIBS_1="$LIBS"
4027a1c0d96SNathan Whitehorn      CF_ADD_LIBS($LIBICONV)
403f4f33ea0SBaptiste Daroussin
4044c8945a0SNathan Whitehorn      CF_FIND_LINKAGE(CF__INTL_HEAD,
405f4f33ea0SBaptiste Daroussin        CF__INTL_BODY($2),
4064c8945a0SNathan Whitehorn        intl,
4074c8945a0SNathan Whitehorn        cf_cv_func_gettext=yes,
4084c8945a0SNathan Whitehorn        cf_cv_func_gettext=no)
409f4f33ea0SBaptiste Daroussin
410f4f33ea0SBaptiste Daroussin      AC_MSG_CHECKING([for libintl.h and gettext()])
411f4f33ea0SBaptiste Daroussin      AC_MSG_RESULT($cf_cv_func_gettext)
412f4f33ea0SBaptiste Daroussin
4134c8945a0SNathan Whitehorn      LIBS="$cf_save_LIBS_1"
414f4f33ea0SBaptiste Daroussin      CPPFLAGS="$cf_save_OPTS_1"
4154c8945a0SNathan Whitehorn
4164c8945a0SNathan Whitehorn      if test "$cf_cv_func_gettext" = yes ; then
4172a3e3873SBaptiste Daroussin        AC_DEFINE(HAVE_LIBINTL_H,1,[Define to 1 if we have libintl.h])
4184c8945a0SNathan Whitehorn
4194c8945a0SNathan Whitehorn        dnl If an already present or preinstalled GNU gettext() is found,
4204c8945a0SNathan Whitehorn        dnl use it.  But if this macro is used in GNU gettext, and GNU
4214c8945a0SNathan Whitehorn        dnl gettext is already preinstalled in libintl, we update this
4224c8945a0SNathan Whitehorn        dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
4234c8945a0SNathan Whitehorn        if test "$PACKAGE" != gettext; then
4244c8945a0SNathan Whitehorn          AC_DEFINE(HAVE_GETTEXT, 1,
4254c8945a0SNathan Whitehorn              [Define if the GNU gettext() function is already present or preinstalled.])
4264c8945a0SNathan Whitehorn
4274c8945a0SNathan Whitehorn          CF_ADD_INCDIR($cf_cv_header_path_intl)
4284c8945a0SNathan Whitehorn
4294c8945a0SNathan Whitehorn          if test -n "$cf_cv_library_file_intl" ; then
4304c8945a0SNathan Whitehorn            dnl If iconv() is in a separate libiconv library, then anyone
4314c8945a0SNathan Whitehorn            dnl linking with libintl{.a,.so} also needs to link with
4324c8945a0SNathan Whitehorn            dnl libiconv.
4334c8945a0SNathan Whitehorn            INTLLIBS="$cf_cv_library_file_intl $LIBICONV"
4344c8945a0SNathan Whitehorn            CF_ADD_LIBDIR($cf_cv_library_path_intl,INTLLIBS)
4354c8945a0SNathan Whitehorn          fi
4364c8945a0SNathan Whitehorn
4374c8945a0SNathan Whitehorn          gt_save_LIBS="$LIBS"
4384c8945a0SNathan Whitehorn          LIBS="$LIBS $INTLLIBS"
4394c8945a0SNathan Whitehorn          AC_CHECK_FUNCS(dcgettext)
4404c8945a0SNathan Whitehorn          LIBS="$gt_save_LIBS"
4414c8945a0SNathan Whitehorn
4424c8945a0SNathan Whitehorn          CATOBJEXT=.gmo
4434c8945a0SNathan Whitehorn        fi
444f4f33ea0SBaptiste Daroussin      elif test -z "$MSGFMT" || test -z "$XGETTEXT" ; then
445f4f33ea0SBaptiste Daroussin        AC_MSG_WARN(disabling NLS feature)
446f4f33ea0SBaptiste Daroussin        sed -e /ENABLE_NLS/d confdefs.h >confdefs.tmp
447f4f33ea0SBaptiste Daroussin        mv confdefs.tmp confdefs.h
448f4f33ea0SBaptiste Daroussin        ALL_LINGUAS=
449f4f33ea0SBaptiste Daroussin        CATOBJEXT=.ignored
450f4f33ea0SBaptiste Daroussin        MSGFMT=":"
451f4f33ea0SBaptiste Daroussin        GMSGFMT=":"
452f4f33ea0SBaptiste Daroussin        XGETTEXT=":"
453f4f33ea0SBaptiste Daroussin        POSUB=
454f4f33ea0SBaptiste Daroussin        BUILD_INCLUDED_LIBINTL=no
455f4f33ea0SBaptiste Daroussin        USE_INCLUDED_LIBINTL=no
456f4f33ea0SBaptiste Daroussin        USE_NLS=no
457f4f33ea0SBaptiste Daroussin        nls_cv_use_gnu_gettext=no
4584c8945a0SNathan Whitehorn      fi
4594c8945a0SNathan Whitehorn
4604c8945a0SNathan Whitehorn      if test "$CATOBJEXT" = "NONE"; then
4614c8945a0SNathan Whitehorn        dnl GNU gettext is not found in the C library.
4624c8945a0SNathan Whitehorn        dnl Fall back on GNU gettext library.
463f4f33ea0SBaptiste Daroussin        nls_cv_use_gnu_gettext=maybe
4644c8945a0SNathan Whitehorn      fi
4654c8945a0SNathan Whitehorn    fi
4664c8945a0SNathan Whitehorn
467f4f33ea0SBaptiste Daroussin    if test "$nls_cv_use_gnu_gettext" != "no"; then
468f4f33ea0SBaptiste Daroussin      CATOBJEXT=.gmo
469*a96ef450SBaptiste Daroussin      if test -f "$srcdir/intl/libintl.h" ; then
4704c8945a0SNathan Whitehorn        dnl Mark actions used to generate GNU NLS library.
4714c8945a0SNathan Whitehorn        INTLOBJS="\$(GETTOBJS)"
4724c8945a0SNathan Whitehorn        BUILD_INCLUDED_LIBINTL=yes
4734c8945a0SNathan Whitehorn        USE_INCLUDED_LIBINTL=yes
4744c8945a0SNathan Whitehorn        INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
4754c8945a0SNathan Whitehorn        LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
476f4f33ea0SBaptiste Daroussin      elif test "$nls_cv_use_gnu_gettext" = "yes"; then
477f4f33ea0SBaptiste Daroussin        nls_cv_use_gnu_gettext=no
478f4f33ea0SBaptiste Daroussin        AC_MSG_WARN(no NLS library is packaged with this application)
479f4f33ea0SBaptiste Daroussin      fi
4804c8945a0SNathan Whitehorn    fi
4814c8945a0SNathan Whitehorn
4824c8945a0SNathan Whitehorn    dnl Test whether we really found GNU msgfmt.
4834c8945a0SNathan Whitehorn    if test "$GMSGFMT" != ":"; then
4844c8945a0SNathan Whitehorn      if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
4854c8945a0SNathan Whitehorn        : ;
4864c8945a0SNathan Whitehorn      else
487f4f33ea0SBaptiste Daroussin        AC_MSG_WARN([found msgfmt program is not GNU msgfmt])
4884c8945a0SNathan Whitehorn      fi
4894c8945a0SNathan Whitehorn    fi
4904c8945a0SNathan Whitehorn
4914c8945a0SNathan Whitehorn    dnl Test whether we really found GNU xgettext.
4924c8945a0SNathan Whitehorn    if test "$XGETTEXT" != ":"; then
4934c8945a0SNathan Whitehorn      if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
4944c8945a0SNathan Whitehorn        : ;
4954c8945a0SNathan Whitehorn      else
496f4f33ea0SBaptiste Daroussin        AC_MSG_WARN([found xgettext program is not GNU xgettext])
497f4f33ea0SBaptiste Daroussin      fi
4984c8945a0SNathan Whitehorn    fi
4994c8945a0SNathan Whitehorn  fi
5004c8945a0SNathan Whitehorn
501f4f33ea0SBaptiste Daroussin  if test "$XGETTEXT" != ":"; then
5024c8945a0SNathan Whitehorn    AC_OUTPUT_COMMANDS(
5034c8945a0SNathan Whitehorn     [for ac_file in $CONFIG_FILES; do
5044c8945a0SNathan Whitehorn
5054c8945a0SNathan Whitehorn        # Support "outfile[:infile[:infile...]]"
5064c8945a0SNathan Whitehorn        case "$ac_file" in
507f4f33ea0SBaptiste Daroussin          (*:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
5084c8945a0SNathan Whitehorn        esac
5094c8945a0SNathan Whitehorn
5104c8945a0SNathan Whitehorn        # PO directories have a Makefile.in generated from Makefile.inn.
511f4f33ea0SBaptiste Daroussin        case "$ac_file" in
512f4f33ea0SBaptiste Daroussin        (*/[Mm]akefile.in)
5134c8945a0SNathan Whitehorn          # Adjust a relative srcdir.
514*a96ef450SBaptiste Daroussin          ac_dir="`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`"
5154c8945a0SNathan Whitehorn          ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
516*a96ef450SBaptiste Daroussin          ac_dots="`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`"
517*a96ef450SBaptiste Daroussin          ac_base="`basename $ac_file .in`"
5184c8945a0SNathan Whitehorn          # In autoconf-2.13 it is called $ac_given_srcdir.
5194c8945a0SNathan Whitehorn          # In autoconf-2.50 it is called $srcdir.
5204c8945a0SNathan Whitehorn          test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
5214c8945a0SNathan Whitehorn
5224c8945a0SNathan Whitehorn          case "$ac_given_srcdir" in
523f4f33ea0SBaptiste Daroussin            (.)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
524f4f33ea0SBaptiste Daroussin            (/*) top_srcdir="$ac_given_srcdir" ;;
525f4f33ea0SBaptiste Daroussin            (*)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
5264c8945a0SNathan Whitehorn          esac
5274c8945a0SNathan Whitehorn
5284c8945a0SNathan Whitehorn          if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
5294c8945a0SNathan Whitehorn            rm -f "$ac_dir/POTFILES"
5304c8945a0SNathan Whitehorn            test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
5314c8945a0SNathan Whitehorn            sed -e "/^#/d" -e "/^[ 	]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
5324c8945a0SNathan Whitehorn            test -n "$as_me" && echo "$as_me: creating $ac_dir/$ac_base" || echo "creating $ac_dir/$ac_base"
5334c8945a0SNathan Whitehorn            sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/$ac_base.in" > "$ac_dir/$ac_base"
5344c8945a0SNathan Whitehorn          fi
5354c8945a0SNathan Whitehorn          ;;
5364c8945a0SNathan Whitehorn        esac
5374c8945a0SNathan Whitehorn      done])
5384c8945a0SNathan Whitehorn
5394c8945a0SNathan Whitehorn    dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
5404c8945a0SNathan Whitehorn    dnl to 'yes' because some of the testsuite requires it.
5414c8945a0SNathan Whitehorn    if test "$PACKAGE" = gettext; then
5424c8945a0SNathan Whitehorn      BUILD_INCLUDED_LIBINTL=yes
5434c8945a0SNathan Whitehorn    fi
5444c8945a0SNathan Whitehorn
5454c8945a0SNathan Whitehorn    dnl intl/plural.c is generated from intl/plural.y. It requires bison,
5464c8945a0SNathan Whitehorn    dnl because plural.y uses bison specific features. It requires at least
5474c8945a0SNathan Whitehorn    dnl bison-1.26 because earlier versions generate a plural.c that doesn't
5484c8945a0SNathan Whitehorn    dnl compile.
5494c8945a0SNathan Whitehorn    dnl bison is only needed for the maintainer (who touches plural.y). But in
5504c8945a0SNathan Whitehorn    dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
5514c8945a0SNathan Whitehorn    dnl the rule in general Makefile. Now, some people carelessly touch the
5524c8945a0SNathan Whitehorn    dnl files or have a broken "make" program, hence the plural.c rule will
5534c8945a0SNathan Whitehorn    dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
5544c8945a0SNathan Whitehorn    dnl present or too old.
5554c8945a0SNathan Whitehorn    if test "$nls_cv_use_gnu_gettext" = "yes"; then
5564c8945a0SNathan Whitehorn      AC_CHECK_PROGS([INTLBISON], [bison])
5574c8945a0SNathan Whitehorn      if test -z "$INTLBISON"; then
5584c8945a0SNathan Whitehorn        ac_verc_fail=yes
5594c8945a0SNathan Whitehorn      else
5604c8945a0SNathan Whitehorn        dnl Found it, now check the version.
5614c8945a0SNathan Whitehorn        AC_MSG_CHECKING([version of bison])
5624c8945a0SNathan Whitehornchangequote(<<,>>)dnl
5634c8945a0SNathan Whitehorn        ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
564*a96ef450SBaptiste Daroussin        case "$ac_prog_version" in
565f4f33ea0SBaptiste Daroussin          ('') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
566f4f33ea0SBaptiste Daroussin          (1.2[6-9]*|1.[3-9][0-9]*|[2-9].*)
5674c8945a0SNathan Whitehornchangequote([,])dnl
5684c8945a0SNathan Whitehorn             ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
569f4f33ea0SBaptiste Daroussin          (*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
5704c8945a0SNathan Whitehorn        esac
5714c8945a0SNathan Whitehorn      AC_MSG_RESULT([$ac_prog_version])
5724c8945a0SNathan Whitehorn      fi
573*a96ef450SBaptiste Daroussin      if test "$ac_verc_fail" = yes; then
5744c8945a0SNathan Whitehorn        INTLBISON=:
5754c8945a0SNathan Whitehorn      fi
5764c8945a0SNathan Whitehorn    fi
5774c8945a0SNathan Whitehorn
5784c8945a0SNathan Whitehorn    dnl These rules are solely for the distribution goal.  While doing this
5794c8945a0SNathan Whitehorn    dnl we only have to keep exactly one list of the available catalogs
5804c8945a0SNathan Whitehorn    dnl in configure.in.
5814c8945a0SNathan Whitehorn    for lang in $ALL_LINGUAS; do
5824c8945a0SNathan Whitehorn      GMOFILES="$GMOFILES $lang.gmo"
5834c8945a0SNathan Whitehorn      POFILES="$POFILES $lang.po"
5844c8945a0SNathan Whitehorn    done
585f4f33ea0SBaptiste Daroussin  fi
5864c8945a0SNathan Whitehorn
5874c8945a0SNathan Whitehorn  dnl Make all variables we use known to autoconf.
5884c8945a0SNathan Whitehorn  AC_SUBST(BUILD_INCLUDED_LIBINTL)
5894c8945a0SNathan Whitehorn  AC_SUBST(USE_INCLUDED_LIBINTL)
5904c8945a0SNathan Whitehorn  AC_SUBST(CATALOGS)
5914c8945a0SNathan Whitehorn  AC_SUBST(CATOBJEXT)
5924c8945a0SNathan Whitehorn  AC_SUBST(GMOFILES)
5934c8945a0SNathan Whitehorn  AC_SUBST(INTLLIBS)
5944c8945a0SNathan Whitehorn  AC_SUBST(INTLOBJS)
5954c8945a0SNathan Whitehorn  AC_SUBST(POFILES)
5964c8945a0SNathan Whitehorn  AC_SUBST(POSUB)
5974c8945a0SNathan Whitehorn
5984c8945a0SNathan Whitehorn  dnl For backward compatibility. Some configure.ins may be using this.
5994c8945a0SNathan Whitehorn  nls_cv_header_intl=
6004c8945a0SNathan Whitehorn  nls_cv_header_libgt=
6014c8945a0SNathan Whitehorn
6024c8945a0SNathan Whitehorn  dnl For backward compatibility. Some Makefiles may be using this.
6034c8945a0SNathan Whitehorn  DATADIRNAME=share
6044c8945a0SNathan Whitehorn  AC_SUBST(DATADIRNAME)
6054c8945a0SNathan Whitehorn
6064c8945a0SNathan Whitehorn  dnl For backward compatibility. Some Makefiles may be using this.
6074c8945a0SNathan Whitehorn  INSTOBJEXT=.mo
6084c8945a0SNathan Whitehorn  AC_SUBST(INSTOBJEXT)
6094c8945a0SNathan Whitehorn
6104c8945a0SNathan Whitehorn  dnl For backward compatibility. Some Makefiles may be using this.
6114c8945a0SNathan Whitehorn  GENCAT=gencat
6124c8945a0SNathan Whitehorn  AC_SUBST(GENCAT)
6134c8945a0SNathan Whitehorn])dnl
6144c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
615f4f33ea0SBaptiste Daroussindnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
6162a3e3873SBaptiste Daroussindnl ------------------
6172a3e3873SBaptiste Daroussindnl Conditionally generate script according to whether we're using a given autoconf.
6182a3e3873SBaptiste Daroussindnl
6192a3e3873SBaptiste Daroussindnl $1 = version to compare against
6202a3e3873SBaptiste Daroussindnl $2 = code to use if AC_ACVERSION is at least as high as $1.
6212a3e3873SBaptiste Daroussindnl $3 = code to use if AC_ACVERSION is older than $1.
6222a3e3873SBaptiste Daroussindefine([CF_ACVERSION_CHECK],
6232a3e3873SBaptiste Daroussin[
624f4f33ea0SBaptiste Daroussinifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
6252a3e3873SBaptiste Daroussinifdef([m4_version_compare],
6262a3e3873SBaptiste Daroussin[m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
6272a3e3873SBaptiste Daroussin[CF_ACVERSION_COMPARE(
6282a3e3873SBaptiste DaroussinAC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
6292a3e3873SBaptiste DaroussinAC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
6302a3e3873SBaptiste Daroussindnl ---------------------------------------------------------------------------
6312a3e3873SBaptiste Daroussindnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
6322a3e3873SBaptiste Daroussindnl --------------------
6332a3e3873SBaptiste Daroussindnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
6342a3e3873SBaptiste Daroussindnl                      MAJOR2, MINOR2, TERNARY2,
6352a3e3873SBaptiste Daroussindnl                      PRINTABLE2, not FOUND, FOUND)
6362a3e3873SBaptiste Daroussindefine([CF_ACVERSION_COMPARE],
6372a3e3873SBaptiste Daroussin[ifelse(builtin([eval], [$2 < $5]), 1,
6382a3e3873SBaptiste Daroussin[ifelse([$8], , ,[$8])],
6392a3e3873SBaptiste Daroussin[ifelse([$9], , ,[$9])])])dnl
6404c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
641*a96ef450SBaptiste Daroussindnl CF_ADD_CFLAGS version: 15 updated: 2020/12/31 10:54:15
6424c8945a0SNathan Whitehorndnl -------------
6434c8945a0SNathan Whitehorndnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
644*a96ef450SBaptiste Daroussindnl $1 = flags to add
645*a96ef450SBaptiste Daroussindnl $2 = if given makes this macro verbose.
6464c8945a0SNathan Whitehorndnl
6474c8945a0SNathan Whitehorndnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
6484c8945a0SNathan Whitehorndnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
6494c8945a0SNathan Whitehorndnl confused by the quotes (which require backslashes to keep them usable).
6504c8945a0SNathan WhitehornAC_DEFUN([CF_ADD_CFLAGS],
6514c8945a0SNathan Whitehorn[
6524c8945a0SNathan Whitehorncf_fix_cppflags=no
6534c8945a0SNathan Whitehorncf_new_cflags=
6544c8945a0SNathan Whitehorncf_new_cppflags=
6554c8945a0SNathan Whitehorncf_new_extra_cppflags=
6564c8945a0SNathan Whitehorn
6574c8945a0SNathan Whitehornfor cf_add_cflags in $1
6584c8945a0SNathan Whitehorndo
659*a96ef450SBaptiste Daroussincase "$cf_fix_cppflags" in
660f4f33ea0SBaptiste Daroussin(no)
661*a96ef450SBaptiste Daroussin	case "$cf_add_cflags" in
662f4f33ea0SBaptiste Daroussin	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
663*a96ef450SBaptiste Daroussin		case "$cf_add_cflags" in
664f4f33ea0SBaptiste Daroussin		(-D*)
665*a96ef450SBaptiste Daroussin			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
6664c8945a0SNathan Whitehorn
667f4f33ea0SBaptiste Daroussin			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
6684c8945a0SNathan Whitehorn				&& test -z "${cf_tst_cflags}" \
6694c8945a0SNathan Whitehorn				&& cf_fix_cppflags=yes
6704c8945a0SNathan Whitehorn
671*a96ef450SBaptiste Daroussin			if test "$cf_fix_cppflags" = yes ; then
672f4f33ea0SBaptiste Daroussin				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
6734c8945a0SNathan Whitehorn				continue
6744c8945a0SNathan Whitehorn			elif test "${cf_tst_cflags}" = "\"'" ; then
675f4f33ea0SBaptiste Daroussin				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
6764c8945a0SNathan Whitehorn				continue
6774c8945a0SNathan Whitehorn			fi
6784c8945a0SNathan Whitehorn			;;
6794c8945a0SNathan Whitehorn		esac
6804c8945a0SNathan Whitehorn		case "$CPPFLAGS" in
681f4f33ea0SBaptiste Daroussin		(*$cf_add_cflags)
6824c8945a0SNathan Whitehorn			;;
683f4f33ea0SBaptiste Daroussin		(*)
684*a96ef450SBaptiste Daroussin			case "$cf_add_cflags" in
685f4f33ea0SBaptiste Daroussin			(-D*)
6864c8945a0SNathan Whitehorn				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
6874c8945a0SNathan Whitehorn				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
6884c8945a0SNathan Whitehorn				;;
6894c8945a0SNathan Whitehorn			esac
690f4f33ea0SBaptiste Daroussin			CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
6914c8945a0SNathan Whitehorn			;;
6924c8945a0SNathan Whitehorn		esac
6934c8945a0SNathan Whitehorn		;;
694f4f33ea0SBaptiste Daroussin	(*)
695f4f33ea0SBaptiste Daroussin		CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
6964c8945a0SNathan Whitehorn		;;
6974c8945a0SNathan Whitehorn	esac
6984c8945a0SNathan Whitehorn	;;
699f4f33ea0SBaptiste Daroussin(yes)
700f4f33ea0SBaptiste Daroussin	CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
7014c8945a0SNathan Whitehorn
702*a96ef450SBaptiste Daroussin	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[[^"]]*"'\''//'`
7034c8945a0SNathan Whitehorn
704f4f33ea0SBaptiste Daroussin	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
7054c8945a0SNathan Whitehorn		&& test -z "${cf_tst_cflags}" \
7064c8945a0SNathan Whitehorn		&& cf_fix_cppflags=no
7074c8945a0SNathan Whitehorn	;;
7084c8945a0SNathan Whitehornesac
7094c8945a0SNathan Whitehorndone
7104c8945a0SNathan Whitehorn
7114c8945a0SNathan Whitehornif test -n "$cf_new_cflags" ; then
7127a1c0d96SNathan Whitehorn	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
713f4f33ea0SBaptiste Daroussin	CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
7144c8945a0SNathan Whitehornfi
7154c8945a0SNathan Whitehorn
7164c8945a0SNathan Whitehornif test -n "$cf_new_cppflags" ; then
7177a1c0d96SNathan Whitehorn	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
718f4f33ea0SBaptiste Daroussin	CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags)
7194c8945a0SNathan Whitehornfi
7204c8945a0SNathan Whitehorn
7214c8945a0SNathan Whitehornif test -n "$cf_new_extra_cppflags" ; then
7227a1c0d96SNathan Whitehorn	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
723f4f33ea0SBaptiste Daroussin	CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags)
7244c8945a0SNathan Whitehornfi
7254c8945a0SNathan Whitehorn
7264c8945a0SNathan WhitehornAC_SUBST(EXTRA_CPPFLAGS)
7274c8945a0SNathan Whitehorn
7284c8945a0SNathan Whitehorn])dnl
7294c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
730*a96ef450SBaptiste Daroussindnl CF_ADD_INCDIR version: 16 updated: 2020/12/31 20:19:42
7314c8945a0SNathan Whitehorndnl -------------
7324c8945a0SNathan Whitehorndnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
7334c8945a0SNathan Whitehorndnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
7344c8945a0SNathan Whitehorndnl but old versions (and some misinstalled ones) need that.  To make things
7354c8945a0SNathan Whitehorndnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
7364c8945a0SNathan Whitehorndnl the include-path).
7374c8945a0SNathan WhitehornAC_DEFUN([CF_ADD_INCDIR],
7384c8945a0SNathan Whitehorn[
7394c8945a0SNathan Whitehornif test -n "$1" ; then
7404c8945a0SNathan Whitehorn  for cf_add_incdir in $1
7414c8945a0SNathan Whitehorn  do
742*a96ef450SBaptiste Daroussin	while test "$cf_add_incdir" != /usr/include
7434c8945a0SNathan Whitehorn	do
744*a96ef450SBaptiste Daroussin	  if test -d "$cf_add_incdir"
7454c8945a0SNathan Whitehorn	  then
7464c8945a0SNathan Whitehorn		cf_have_incdir=no
7474c8945a0SNathan Whitehorn		if test -n "$CFLAGS$CPPFLAGS" ; then
7484c8945a0SNathan Whitehorn		  # a loop is needed to ensure we can add subdirs of existing dirs
7494c8945a0SNathan Whitehorn		  for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
7504c8945a0SNathan Whitehorn			if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
7514c8945a0SNathan Whitehorn			  cf_have_incdir=yes; break
7524c8945a0SNathan Whitehorn			fi
7534c8945a0SNathan Whitehorn		  done
7544c8945a0SNathan Whitehorn		fi
7554c8945a0SNathan Whitehorn
7564c8945a0SNathan Whitehorn		if test "$cf_have_incdir" = no ; then
7574c8945a0SNathan Whitehorn		  if test "$cf_add_incdir" = /usr/local/include ; then
7584c8945a0SNathan Whitehorn			if test "$GCC" = yes
7594c8945a0SNathan Whitehorn			then
7604c8945a0SNathan Whitehorn			  cf_save_CPPFLAGS=$CPPFLAGS
761f4f33ea0SBaptiste Daroussin			  CF_APPEND_TEXT(CPPFLAGS,-I$cf_add_incdir)
7624c8945a0SNathan Whitehorn			  AC_TRY_COMPILE([#include <stdio.h>],
7634c8945a0SNathan Whitehorn				  [printf("Hello")],
7644c8945a0SNathan Whitehorn				  [],
7654c8945a0SNathan Whitehorn				  [cf_have_incdir=yes])
7664c8945a0SNathan Whitehorn			  CPPFLAGS=$cf_save_CPPFLAGS
7674c8945a0SNathan Whitehorn			fi
7684c8945a0SNathan Whitehorn		  fi
7694c8945a0SNathan Whitehorn		fi
7704c8945a0SNathan Whitehorn
7714c8945a0SNathan Whitehorn		if test "$cf_have_incdir" = no ; then
7724c8945a0SNathan Whitehorn		  CF_VERBOSE(adding $cf_add_incdir to include-path)
7737a1c0d96SNathan Whitehorn		  ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
7744c8945a0SNathan Whitehorn
775*a96ef450SBaptiste Daroussin		  cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
7764c8945a0SNathan Whitehorn		  test "$cf_top_incdir" = "$cf_add_incdir" && break
7774c8945a0SNathan Whitehorn		  cf_add_incdir="$cf_top_incdir"
7784c8945a0SNathan Whitehorn		else
7794c8945a0SNathan Whitehorn		  break
7804c8945a0SNathan Whitehorn		fi
781f4f33ea0SBaptiste Daroussin	  else
782f4f33ea0SBaptiste Daroussin		break
7834c8945a0SNathan Whitehorn	  fi
7844c8945a0SNathan Whitehorn	done
7854c8945a0SNathan Whitehorn  done
7864c8945a0SNathan Whitehornfi
7874c8945a0SNathan Whitehorn])dnl
7884c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
7897a1c0d96SNathan Whitehorndnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
7907a1c0d96SNathan Whitehorndnl ----------
7917a1c0d96SNathan Whitehorndnl Add a library, used to enforce consistency.
7927a1c0d96SNathan Whitehorndnl
7937a1c0d96SNathan Whitehorndnl $1 = library to add, without the "-l"
7947a1c0d96SNathan Whitehorndnl $2 = variable to update (default $LIBS)
7957a1c0d96SNathan WhitehornAC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
7967a1c0d96SNathan Whitehorndnl ---------------------------------------------------------------------------
797*a96ef450SBaptiste Daroussindnl CF_ADD_LIBDIR version: 11 updated: 2020/12/31 20:19:42
7984c8945a0SNathan Whitehorndnl -------------
7994c8945a0SNathan Whitehorndnl	Adds to the library-path
8004c8945a0SNathan Whitehorndnl
8014c8945a0SNathan Whitehorndnl	Some machines have trouble with multiple -L options.
8024c8945a0SNathan Whitehorndnl
8034c8945a0SNathan Whitehorndnl $1 is the (list of) directory(s) to add
8044c8945a0SNathan Whitehorndnl $2 is the optional name of the variable to update (default LDFLAGS)
8054c8945a0SNathan Whitehorndnl
8064c8945a0SNathan WhitehornAC_DEFUN([CF_ADD_LIBDIR],
8074c8945a0SNathan Whitehorn[
8084c8945a0SNathan Whitehornif test -n "$1" ; then
8094c8945a0SNathan Whitehorn	for cf_add_libdir in $1
8104c8945a0SNathan Whitehorn	do
811*a96ef450SBaptiste Daroussin		if test "$cf_add_libdir" = /usr/lib ; then
8124c8945a0SNathan Whitehorn			:
813*a96ef450SBaptiste Daroussin		elif test -d "$cf_add_libdir"
8144c8945a0SNathan Whitehorn		then
8154c8945a0SNathan Whitehorn			cf_have_libdir=no
8164c8945a0SNathan Whitehorn			if test -n "$LDFLAGS$LIBS" ; then
8174c8945a0SNathan Whitehorn				# a loop is needed to ensure we can add subdirs of existing dirs
8184c8945a0SNathan Whitehorn				for cf_test_libdir in $LDFLAGS $LIBS ; do
8194c8945a0SNathan Whitehorn					if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
8204c8945a0SNathan Whitehorn						cf_have_libdir=yes; break
8214c8945a0SNathan Whitehorn					fi
8224c8945a0SNathan Whitehorn				done
8234c8945a0SNathan Whitehorn			fi
8244c8945a0SNathan Whitehorn			if test "$cf_have_libdir" = no ; then
8254c8945a0SNathan Whitehorn				CF_VERBOSE(adding $cf_add_libdir to library-path)
8267a1c0d96SNathan Whitehorn				ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
8274c8945a0SNathan Whitehorn			fi
8284c8945a0SNathan Whitehorn		fi
8294c8945a0SNathan Whitehorn	done
8304c8945a0SNathan Whitehornfi
8314c8945a0SNathan Whitehorn])dnl
8324c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
833*a96ef450SBaptiste Daroussindnl CF_ADD_LIBS version: 3 updated: 2019/11/02 16:47:33
8347a1c0d96SNathan Whitehorndnl -----------
835f4f33ea0SBaptiste Daroussindnl Add one or more libraries, used to enforce consistency.  Libraries are
836f4f33ea0SBaptiste Daroussindnl prepended to an existing list, since their dependencies are assumed to
837f4f33ea0SBaptiste Daroussindnl already exist in the list.
8387a1c0d96SNathan Whitehorndnl
8397a1c0d96SNathan Whitehorndnl $1 = libraries to add, with the "-l", etc.
8407a1c0d96SNathan Whitehorndnl $2 = variable to update (default $LIBS)
841f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_ADD_LIBS],[
842*a96ef450SBaptiste Daroussincf_add_libs="[$]ifelse($2,,LIBS,[$2])"
843*a96ef450SBaptiste Daroussin# reverse order
844*a96ef450SBaptiste Daroussincf_add_0lib=
845*a96ef450SBaptiste Daroussinfor cf_add_1lib in $1; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
846*a96ef450SBaptiste Daroussin# filter duplicates
847*a96ef450SBaptiste Daroussinfor cf_add_1lib in $cf_add_0lib; do
848*a96ef450SBaptiste Daroussin	for cf_add_2lib in $cf_add_libs; do
849*a96ef450SBaptiste Daroussin		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
850f4f33ea0SBaptiste Daroussin			cf_add_1lib=
851f4f33ea0SBaptiste Daroussin			break
852f4f33ea0SBaptiste Daroussin		fi
853f4f33ea0SBaptiste Daroussin	done
854*a96ef450SBaptiste Daroussin	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
855f4f33ea0SBaptiste Daroussindone
856f4f33ea0SBaptiste Daroussinifelse($2,,LIBS,[$2])="$cf_add_libs"
857f4f33ea0SBaptiste Daroussin])dnl
8587a1c0d96SNathan Whitehorndnl ---------------------------------------------------------------------------
859f4f33ea0SBaptiste Daroussindnl CF_ADD_LIB_AFTER version: 3 updated: 2013/07/09 21:27:22
860f4f33ea0SBaptiste Daroussindnl ----------------
861f4f33ea0SBaptiste Daroussindnl Add a given library after another, e.g., following the one it satisfies a
862f4f33ea0SBaptiste Daroussindnl dependency for.
863f4f33ea0SBaptiste Daroussindnl
864f4f33ea0SBaptiste Daroussindnl $1 = the first library
865f4f33ea0SBaptiste Daroussindnl $2 = its dependency
866f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_ADD_LIB_AFTER],[
867f4f33ea0SBaptiste DaroussinCF_VERBOSE(...before $LIBS)
868f4f33ea0SBaptiste DaroussinLIBS=`echo "$LIBS" | sed -e "s/[[ 	]][[ 	]]*/ /g" -e "s%$1 %$1 $2 %" -e 's%  % %g'`
869f4f33ea0SBaptiste DaroussinCF_VERBOSE(...after  $LIBS)
870f4f33ea0SBaptiste Daroussin])dnl
871f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
872f4f33ea0SBaptiste Daroussindnl CF_ADD_OPTIONAL_PATH version: 3 updated: 2015/05/10 19:52:14
8734c8945a0SNathan Whitehorndnl --------------------
8744c8945a0SNathan Whitehorndnl Add an optional search-path to the compile/link variables.
8754c8945a0SNathan Whitehorndnl See CF_WITH_PATH
8764c8945a0SNathan Whitehorndnl
8774c8945a0SNathan Whitehorndnl $1 = shell variable containing the result of --with-XXX=[DIR]
8784c8945a0SNathan Whitehorndnl $2 = module to look for.
8794c8945a0SNathan WhitehornAC_DEFUN([CF_ADD_OPTIONAL_PATH],[
880f4f33ea0SBaptiste Daroussincase "$1" in
881f4f33ea0SBaptiste Daroussin(no)
8824c8945a0SNathan Whitehorn	;;
883f4f33ea0SBaptiste Daroussin(yes)
8844c8945a0SNathan Whitehorn	;;
885f4f33ea0SBaptiste Daroussin(*)
8864c8945a0SNathan Whitehorn	CF_ADD_SEARCHPATH([$1], [AC_MSG_ERROR(cannot find $2 under $1)])
8874c8945a0SNathan Whitehorn	;;
8884c8945a0SNathan Whitehornesac
8894c8945a0SNathan Whitehorn])dnl
8904c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
891*a96ef450SBaptiste Daroussindnl CF_ADD_SEARCHPATH version: 6 updated: 2020/12/31 20:19:42
8924c8945a0SNathan Whitehorndnl -----------------
8934c8945a0SNathan Whitehorndnl Set $CPPFLAGS and $LDFLAGS with the directories given via the parameter.
8944c8945a0SNathan Whitehorndnl They can be either the common root of include- and lib-directories, or the
8954c8945a0SNathan Whitehorndnl lib-directory (to allow for things like lib64 directories).
8964c8945a0SNathan Whitehorndnl See also CF_FIND_LINKAGE.
8974c8945a0SNathan Whitehorndnl
8984c8945a0SNathan Whitehorndnl $1 is the list of colon-separated directory names to search.
8994c8945a0SNathan Whitehorndnl $2 is the action to take if a parameter does not yield a directory.
9004c8945a0SNathan WhitehornAC_DEFUN([CF_ADD_SEARCHPATH],
9014c8945a0SNathan Whitehorn[
9024c8945a0SNathan WhitehornAC_REQUIRE([CF_PATHSEP])
9034c8945a0SNathan Whitehornfor cf_searchpath in `echo "$1" | tr $PATH_SEPARATOR ' '`; do
904*a96ef450SBaptiste Daroussin	if test -d "$cf_searchpath/include" ; then
9054c8945a0SNathan Whitehorn		CF_ADD_INCDIR($cf_searchpath/include)
906*a96ef450SBaptiste Daroussin	elif test -d "$cf_searchpath/../include" ; then
9074c8945a0SNathan Whitehorn		CF_ADD_INCDIR($cf_searchpath/../include)
9084c8945a0SNathan Whitehorn	ifelse([$2],,,[else
9094c8945a0SNathan Whitehorn$2])
9104c8945a0SNathan Whitehorn	fi
911*a96ef450SBaptiste Daroussin	if test -d "$cf_searchpath/lib" ; then
9124c8945a0SNathan Whitehorn		CF_ADD_LIBDIR($cf_searchpath/lib)
913*a96ef450SBaptiste Daroussin	elif test -d "$cf_searchpath" ; then
9144c8945a0SNathan Whitehorn		CF_ADD_LIBDIR($cf_searchpath)
9154c8945a0SNathan Whitehorn	ifelse([$2],,,[else
9164c8945a0SNathan Whitehorn$2])
9174c8945a0SNathan Whitehorn	fi
9184c8945a0SNathan Whitehorndone
9194c8945a0SNathan Whitehorn])
9204c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
921*a96ef450SBaptiste Daroussindnl CF_ADD_SUBDIR_PATH version: 5 updated: 2020/12/31 20:19:42
9224c8945a0SNathan Whitehorndnl ------------------
9234c8945a0SNathan Whitehorndnl Append to a search-list for a nonstandard header/lib-file
9244c8945a0SNathan Whitehorndnl	$1 = the variable to return as result
9254c8945a0SNathan Whitehorndnl	$2 = the package name
9264c8945a0SNathan Whitehorndnl	$3 = the subdirectory, e.g., bin, include or lib
9274c8945a0SNathan Whitehorndnl $4 = the directory under which we will test for subdirectories
9284c8945a0SNathan Whitehorndnl $5 = a directory that we do not want $4 to match
9294c8945a0SNathan WhitehornAC_DEFUN([CF_ADD_SUBDIR_PATH],
9304c8945a0SNathan Whitehorn[
931f4f33ea0SBaptiste Daroussintest "x$4" != "x$5" && \
9324c8945a0SNathan Whitehorntest -d "$4" && \
933*a96ef450SBaptiste Daroussinifelse([$5],NONE,,[{ test -z "$5" || test "x$5" = xNONE || test "x$4" != "x$5"; } &&]) {
9344c8945a0SNathan Whitehorn	test -n "$verbose" && echo "	... testing for $3-directories under $4"
935*a96ef450SBaptiste Daroussin	test -d "$4/$3" &&          $1="[$]$1 $4/$3"
936*a96ef450SBaptiste Daroussin	test -d "$4/$3/$2" &&       $1="[$]$1 $4/$3/$2"
937*a96ef450SBaptiste Daroussin	test -d "$4/$3/$2/$3" &&    $1="[$]$1 $4/$3/$2/$3"
938*a96ef450SBaptiste Daroussin	test -d "$4/$2/$3" &&       $1="[$]$1 $4/$2/$3"
939*a96ef450SBaptiste Daroussin	test -d "$4/$2/$3/$2" &&    $1="[$]$1 $4/$2/$3/$2"
9404c8945a0SNathan Whitehorn}
9414c8945a0SNathan Whitehorn])dnl
9424c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
943f4f33ea0SBaptiste Daroussindnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
944f4f33ea0SBaptiste Daroussindnl --------------
945f4f33ea0SBaptiste Daroussindnl use this macro for appending text without introducing an extra blank at
946f4f33ea0SBaptiste Daroussindnl the beginning
947f4f33ea0SBaptiste Daroussindefine([CF_APPEND_TEXT],
948f4f33ea0SBaptiste Daroussin[
949f4f33ea0SBaptiste Daroussin	test -n "[$]$1" && $1="[$]$1 "
950f4f33ea0SBaptiste Daroussin	$1="[$]{$1}$2"
951f4f33ea0SBaptiste Daroussin])dnl
952f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
9534c8945a0SNathan Whitehorndnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
9544c8945a0SNathan Whitehorndnl --------------
9554c8945a0SNathan Whitehorndnl Allow user to disable a normally-on option.
9564c8945a0SNathan WhitehornAC_DEFUN([CF_ARG_DISABLE],
9574c8945a0SNathan Whitehorn[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
9584c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
959*a96ef450SBaptiste Daroussindnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
960*a96ef450SBaptiste Daroussindnl -------------
961*a96ef450SBaptiste Daroussindnl Allow user to enable a normally-off option.
962*a96ef450SBaptiste DaroussinAC_DEFUN([CF_ARG_ENABLE],
963*a96ef450SBaptiste Daroussin[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
964*a96ef450SBaptiste Daroussindnl ---------------------------------------------------------------------------
9654c8945a0SNathan Whitehorndnl CF_ARG_MSG_ENABLE version: 2 updated: 2000/07/29 19:32:03
9664c8945a0SNathan Whitehorndnl -----------------
9674c8945a0SNathan Whitehorndnl Verbose form of AC_ARG_ENABLE:
9684c8945a0SNathan Whitehorndnl
9694c8945a0SNathan Whitehorndnl Parameters:
9704c8945a0SNathan Whitehorndnl $1 = message
9714c8945a0SNathan Whitehorndnl $2 = option name
9724c8945a0SNathan Whitehorndnl $3 = help-string
9734c8945a0SNathan Whitehorndnl $4 = action to perform if option is enabled
9744c8945a0SNathan Whitehorndnl $5 = action if perform if option is disabled
9754c8945a0SNathan Whitehorndnl $6 = default option value (either 'yes' or 'no')
9764c8945a0SNathan WhitehornAC_DEFUN([CF_ARG_MSG_ENABLE],[
9774c8945a0SNathan WhitehornAC_MSG_CHECKING($1)
9784c8945a0SNathan WhitehornAC_ARG_ENABLE($2,[$3],,enableval=ifelse($6,,no,$6))
9794c8945a0SNathan WhitehornAC_MSG_RESULT($enableval)
9804c8945a0SNathan Whitehornif test "$enableval" != no ; then
9814c8945a0SNathan Whitehornifelse($4,,[	:],$4)
9824c8945a0SNathan Whitehornelse
9834c8945a0SNathan Whitehornifelse($5,,[	:],$5)
9844c8945a0SNathan Whitehornfi
9854c8945a0SNathan Whitehorn])dnl
9864c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
987f4f33ea0SBaptiste Daroussindnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
9884c8945a0SNathan Whitehorndnl -------------
9894c8945a0SNathan Whitehorndnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
9904c8945a0SNathan Whitehorndnl values.
9914c8945a0SNathan Whitehorndnl
9924c8945a0SNathan Whitehorndnl Parameters:
9934c8945a0SNathan Whitehorndnl $1 = option name
9944c8945a0SNathan Whitehorndnl $2 = help-string
9954c8945a0SNathan Whitehorndnl $3 = action to perform if option is not default
9964c8945a0SNathan Whitehorndnl $4 = action if perform if option is default
9974c8945a0SNathan Whitehorndnl $5 = default option value (either 'yes' or 'no')
9984c8945a0SNathan WhitehornAC_DEFUN([CF_ARG_OPTION],
9997a1c0d96SNathan Whitehorn[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
10004c8945a0SNathan Whitehorn	if test "$enableval" != "$5" ; then
10017a1c0d96SNathan Whitehornifelse([$3],,[    :]dnl
10027a1c0d96SNathan Whitehorn,[    $3]) ifelse([$4],,,[
10034c8945a0SNathan Whitehorn	else
10044c8945a0SNathan Whitehorn		$4])
10057a1c0d96SNathan Whitehorn	fi],[enableval=$5 ifelse([$4],,,[
10064c8945a0SNathan Whitehorn	$4
10074c8945a0SNathan Whitehorn])dnl
10084c8945a0SNathan Whitehorn])])dnl
10094c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
1010*a96ef450SBaptiste Daroussindnl CF_AR_FLAGS version: 9 updated: 2021/01/01 13:31:04
1011f4f33ea0SBaptiste Daroussindnl -----------
1012f4f33ea0SBaptiste Daroussindnl Check for suitable "ar" (archiver) options for updating an archive.
1013f4f33ea0SBaptiste Daroussindnl
1014f4f33ea0SBaptiste Daroussindnl In particular, handle some obsolete cases where the "-" might be omitted,
1015f4f33ea0SBaptiste Daroussindnl as well as a workaround for breakage of make's archive rules by the GNU
1016f4f33ea0SBaptiste Daroussindnl binutils "ar" program.
1017f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_AR_FLAGS],[
1018f4f33ea0SBaptiste DaroussinAC_REQUIRE([CF_PROG_AR])
1019f4f33ea0SBaptiste Daroussin
1020f4f33ea0SBaptiste DaroussinAC_CACHE_CHECK(for options to update archives, cf_cv_ar_flags,[
1021*a96ef450SBaptiste Daroussin	case "$cf_cv_system_name" in
1022*a96ef450SBaptiste Daroussin	(*-msvc*)
1023*a96ef450SBaptiste Daroussin		cf_cv_ar_flags=''
1024*a96ef450SBaptiste Daroussin		cat >mk_static_lib.sh <<-EOF
1025*a96ef450SBaptiste Daroussin		#!$SHELL
1026*a96ef450SBaptiste Daroussin		MSVC_BIN="[$]AR"
1027*a96ef450SBaptiste Daroussin		out="\[$]1"
1028*a96ef450SBaptiste Daroussin		shift
1029*a96ef450SBaptiste Daroussin		exec \[$]MSVC_BIN -out:"\[$]out" \[$]@
1030*a96ef450SBaptiste Daroussin		EOF
1031*a96ef450SBaptiste Daroussin		chmod +x mk_static_lib.sh
1032*a96ef450SBaptiste Daroussin		AR=`pwd`/mk_static_lib.sh
1033*a96ef450SBaptiste Daroussin		;;
1034*a96ef450SBaptiste Daroussin	(*)
1035f4f33ea0SBaptiste Daroussin		cf_cv_ar_flags=unknown
1036f4f33ea0SBaptiste Daroussin		for cf_ar_flags in -curvU -curv curv -crv crv -cqv cqv -rv rv
1037f4f33ea0SBaptiste Daroussin		do
1038f4f33ea0SBaptiste Daroussin
1039f4f33ea0SBaptiste Daroussin			# check if $ARFLAGS already contains this choice
1040f4f33ea0SBaptiste Daroussin			if test "x$ARFLAGS" != "x" ; then
1041f4f33ea0SBaptiste Daroussin				cf_check_ar_flags=`echo "x$ARFLAGS" | sed -e "s/$cf_ar_flags\$//" -e "s/$cf_ar_flags / /"`
1042f4f33ea0SBaptiste Daroussin				if test "x$ARFLAGS" != "$cf_check_ar_flags" ; then
1043f4f33ea0SBaptiste Daroussin					cf_cv_ar_flags=
1044f4f33ea0SBaptiste Daroussin					break
1045f4f33ea0SBaptiste Daroussin				fi
1046f4f33ea0SBaptiste Daroussin			fi
1047f4f33ea0SBaptiste Daroussin
1048*a96ef450SBaptiste Daroussin			rm -f "conftest.$ac_cv_objext"
1049f4f33ea0SBaptiste Daroussin			rm -f conftest.a
1050f4f33ea0SBaptiste Daroussin
1051*a96ef450SBaptiste Daroussin			cat >"conftest.$ac_ext" <<EOF
1052f4f33ea0SBaptiste Daroussin#line __oline__ "configure"
1053f4f33ea0SBaptiste Daroussinint	testdata[[3]] = { 123, 456, 789 };
1054f4f33ea0SBaptiste DaroussinEOF
1055f4f33ea0SBaptiste Daroussin			if AC_TRY_EVAL(ac_compile) ; then
1056f4f33ea0SBaptiste Daroussin				echo "$AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext" >&AC_FD_CC
1057*a96ef450SBaptiste Daroussin				$AR $ARFLAGS "$cf_ar_flags" conftest.a "conftest.$ac_cv_objext" 2>&AC_FD_CC 1>/dev/null
1058f4f33ea0SBaptiste Daroussin				if test -f conftest.a ; then
1059*a96ef450SBaptiste Daroussin					cf_cv_ar_flags="$cf_ar_flags"
1060f4f33ea0SBaptiste Daroussin					break
1061f4f33ea0SBaptiste Daroussin				fi
1062f4f33ea0SBaptiste Daroussin			else
1063f4f33ea0SBaptiste Daroussin				CF_VERBOSE(cannot compile test-program)
1064f4f33ea0SBaptiste Daroussin				break
1065f4f33ea0SBaptiste Daroussin			fi
1066f4f33ea0SBaptiste Daroussin		done
1067*a96ef450SBaptiste Daroussin		rm -f conftest.a "conftest.$ac_ext" "conftest.$ac_cv_objext"
1068*a96ef450SBaptiste Daroussin		;;
1069*a96ef450SBaptiste Daroussin	esac
1070f4f33ea0SBaptiste Daroussin])
1071f4f33ea0SBaptiste Daroussin
1072f4f33ea0SBaptiste Daroussinif test -n "$ARFLAGS" ; then
1073f4f33ea0SBaptiste Daroussin	if test -n "$cf_cv_ar_flags" ; then
1074f4f33ea0SBaptiste Daroussin		ARFLAGS="$ARFLAGS $cf_cv_ar_flags"
1075f4f33ea0SBaptiste Daroussin	fi
1076f4f33ea0SBaptiste Daroussinelse
1077f4f33ea0SBaptiste Daroussin	ARFLAGS=$cf_cv_ar_flags
1078f4f33ea0SBaptiste Daroussinfi
1079f4f33ea0SBaptiste Daroussin
1080f4f33ea0SBaptiste DaroussinAC_SUBST(ARFLAGS)
1081f4f33ea0SBaptiste Daroussin])
1082f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
1083*a96ef450SBaptiste Daroussindnl CF_BUNDLED_INTL version: 20 updated: 2021/01/02 09:31:20
10844c8945a0SNathan Whitehorndnl ---------------
10854c8945a0SNathan Whitehorndnl Top-level macro for configuring an application with a bundled copy of
10864c8945a0SNathan Whitehorndnl the intl and po directories for gettext.
10874c8945a0SNathan Whitehorndnl
10884c8945a0SNathan Whitehorndnl $1 specifies either Makefile or makefile, defaulting to the former.
10894c8945a0SNathan Whitehorndnl $2 if nonempty sets the option to --enable-nls rather than to --disable-nls
10904c8945a0SNathan Whitehorndnl
10914c8945a0SNathan Whitehorndnl Sets variables which can be used to substitute in makefiles:
10924c8945a0SNathan Whitehorndnl	GT_YES       - "#" comment unless building intl library, otherwise empty
10934c8945a0SNathan Whitehorndnl	GT_NO        - "#" comment if building intl library, otherwise empty
10944c8945a0SNathan Whitehorndnl	INTLDIR_MAKE - to make ./intl directory
10954c8945a0SNathan Whitehorndnl	MSG_DIR_MAKE - to make ./po directory
10964c8945a0SNathan Whitehorndnl	SUB_MAKEFILE - list of makefiles in ./intl, ./po directories
10977a1c0d96SNathan Whitehorndnl
10987a1c0d96SNathan Whitehorndnl Defines:
10994c8945a0SNathan Whitehorndnl	HAVE_LIBGETTEXT_H if we're using ./intl
11007a1c0d96SNathan Whitehorndnl	NLS_TEXTDOMAIN
11014c8945a0SNathan Whitehorndnl
11024c8945a0SNathan Whitehorndnl Environment:
11034c8945a0SNathan Whitehorndnl	ALL_LINGUAS if set, lists the root names of the ".po" files.
11044c8945a0SNathan Whitehorndnl	CONFIG_H assumed to be "config.h"
11057a1c0d96SNathan Whitehorndnl	PACKAGE must be set, used as default for textdomain
11064c8945a0SNathan Whitehorndnl	VERSION may be set, otherwise extract from "VERSION" file.
11074c8945a0SNathan Whitehorndnl
11084c8945a0SNathan WhitehornAC_DEFUN([CF_BUNDLED_INTL],[
11094c8945a0SNathan Whitehorncf_makefile=ifelse($1,,Makefile,$1)
11104c8945a0SNathan Whitehorn
11114c8945a0SNathan Whitehorndnl Set of available languages (based on source distribution).  Note that
11124c8945a0SNathan Whitehorndnl setting $LINGUAS overrides $ALL_LINGUAS.  Some environments set $LINGUAS
11134c8945a0SNathan Whitehorndnl rather than $LC_ALL
1114*a96ef450SBaptiste Daroussintest -z "$ALL_LINGUAS" && ALL_LINGUAS=`test -d "$srcdir/po" && cd "$srcdir/po" && echo *.po|sed -e 's/\.po//g' -e 's/*//'`
11154c8945a0SNathan Whitehorn
11164c8945a0SNathan Whitehorn# Allow override of "config.h" definition:
11177a1c0d96SNathan Whitehorn: ${CONFIG_H:=config.h}
11184c8945a0SNathan WhitehornAC_SUBST(CONFIG_H)
11194c8945a0SNathan Whitehorn
11207a1c0d96SNathan Whitehornif test -z "$PACKAGE" ; then
11217a1c0d96SNathan Whitehorn	AC_MSG_ERROR([[CF_BUNDLED_INTL] used without setting [PACKAGE] variable])
11227a1c0d96SNathan Whitehornfi
11237a1c0d96SNathan Whitehorn
11244c8945a0SNathan Whitehornif test -z "$VERSION" ; then
1125*a96ef450SBaptiste Daroussinif test -f "$srcdir/VERSION" ; then
1126*a96ef450SBaptiste Daroussin	VERSION=`sed -e '2,$d' "$srcdir/VERSION" |cut -f1`
11274c8945a0SNathan Whitehornelse
11284c8945a0SNathan Whitehorn	VERSION=unknown
11294c8945a0SNathan Whitehornfi
11304c8945a0SNathan Whitehornfi
11314c8945a0SNathan WhitehornAC_SUBST(VERSION)
11324c8945a0SNathan Whitehorn
11334c8945a0SNathan WhitehornAM_GNU_GETTEXT(,,,[$2])
11344c8945a0SNathan Whitehorn
11357a1c0d96SNathan Whitehornif test "$USE_NLS" = yes ; then
11367a1c0d96SNathan Whitehorn	AC_ARG_WITH(textdomain,
11377a1c0d96SNathan Whitehorn		[  --with-textdomain=PKG   NLS text-domain (default is package name)],
11387a1c0d96SNathan Whitehorn		[NLS_TEXTDOMAIN=$withval],
11397a1c0d96SNathan Whitehorn		[NLS_TEXTDOMAIN=$PACKAGE])
11402a3e3873SBaptiste Daroussin	AC_DEFINE_UNQUOTED(NLS_TEXTDOMAIN,"$NLS_TEXTDOMAIN",[Define to the nls textdomain value])
11417a1c0d96SNathan Whitehorn	AC_SUBST(NLS_TEXTDOMAIN)
11427a1c0d96SNathan Whitehornfi
11437a1c0d96SNathan Whitehorn
11444c8945a0SNathan WhitehornINTLDIR_MAKE=
11454c8945a0SNathan WhitehornMSG_DIR_MAKE=
11464c8945a0SNathan WhitehornSUB_MAKEFILE=
11474c8945a0SNathan Whitehorn
11484c8945a0SNathan Whitehorndnl this updates SUB_MAKEFILE and MSG_DIR_MAKE:
11494c8945a0SNathan WhitehornCF_OUR_MESSAGES($1)
11504c8945a0SNathan Whitehorn
11514c8945a0SNathan Whitehornif test "$USE_INCLUDED_LIBINTL" = yes ; then
11524c8945a0SNathan Whitehorn	if test "$nls_cv_force_use_gnu_gettext" = yes ; then
11534c8945a0SNathan Whitehorn		:
11544c8945a0SNathan Whitehorn	elif test "$nls_cv_use_gnu_gettext" = yes ; then
11554c8945a0SNathan Whitehorn		:
11564c8945a0SNathan Whitehorn	else
11574c8945a0SNathan Whitehorn		INTLDIR_MAKE="#"
11584c8945a0SNathan Whitehorn	fi
11594c8945a0SNathan Whitehorn	if test -z "$INTLDIR_MAKE"; then
11602a3e3873SBaptiste Daroussin		AC_DEFINE(HAVE_LIBGETTEXT_H,1,[Define to 1 if we have libgettext.h])
11614c8945a0SNathan Whitehorn		for cf_makefile in \
11624c8945a0SNathan Whitehorn			$srcdir/intl/Makefile.in \
11634c8945a0SNathan Whitehorn			$srcdir/intl/makefile.in
11644c8945a0SNathan Whitehorn		do
11654c8945a0SNathan Whitehorn			if test -f "$cf_makefile" ; then
11664c8945a0SNathan Whitehorn				SUB_MAKEFILE="$SUB_MAKEFILE `echo \"${cf_makefile}\"|sed -e 's,^'$srcdir/',,' -e 's/\.in$//'`:${cf_makefile}"
11674c8945a0SNathan Whitehorn				break
11684c8945a0SNathan Whitehorn			fi
11694c8945a0SNathan Whitehorn		done
11704c8945a0SNathan Whitehorn	fi
11714c8945a0SNathan Whitehornelse
11724c8945a0SNathan Whitehorn	INTLDIR_MAKE="#"
11734c8945a0SNathan Whitehorn	if test "$USE_NLS" = yes ; then
11744c8945a0SNathan Whitehorn		AC_CHECK_HEADERS(libintl.h)
11754c8945a0SNathan Whitehorn	fi
11764c8945a0SNathan Whitehornfi
11774c8945a0SNathan Whitehorn
11784c8945a0SNathan Whitehornif test -z "$INTLDIR_MAKE" ; then
1179f4f33ea0SBaptiste Daroussin	CF_APPEND_TEXT(CPPFLAGS,-I../intl)
11804c8945a0SNathan Whitehornfi
11814c8945a0SNathan Whitehorn
11824c8945a0SNathan Whitehorndnl FIXME:  we use this in lynx (the alternative is a spurious dependency upon
11834c8945a0SNathan Whitehorndnl GNU make)
11844c8945a0SNathan Whitehornif test "$BUILD_INCLUDED_LIBINTL" = yes ; then
11854c8945a0SNathan Whitehorn	GT_YES="#"
11864c8945a0SNathan Whitehorn	GT_NO=
11874c8945a0SNathan Whitehornelse
11884c8945a0SNathan Whitehorn	GT_YES=
11894c8945a0SNathan Whitehorn	GT_NO="#"
11904c8945a0SNathan Whitehornfi
11914c8945a0SNathan Whitehorn
11924c8945a0SNathan WhitehornAC_SUBST(INTLDIR_MAKE)
11934c8945a0SNathan WhitehornAC_SUBST(MSG_DIR_MAKE)
11944c8945a0SNathan WhitehornAC_SUBST(GT_YES)
11954c8945a0SNathan WhitehornAC_SUBST(GT_NO)
11964c8945a0SNathan Whitehorn
11974c8945a0SNathan Whitehorndnl FIXME:  the underlying AM_GNU_GETTEXT macro either needs some fixes or a
11984c8945a0SNathan Whitehorndnl little documentation.  It doesn't define anything so that we can ifdef our
11994c8945a0SNathan Whitehorndnl own code, except ENABLE_NLS, which is too vague to be of any use.
12004c8945a0SNathan Whitehorn
12014c8945a0SNathan Whitehornif test "$USE_INCLUDED_LIBINTL" = yes ; then
12024c8945a0SNathan Whitehorn	if test "$nls_cv_force_use_gnu_gettext" = yes ; then
12032a3e3873SBaptiste Daroussin		AC_DEFINE(HAVE_GETTEXT,1,[Define to 1 if we have gettext function])
12044c8945a0SNathan Whitehorn	elif test "$nls_cv_use_gnu_gettext" = yes ; then
12052a3e3873SBaptiste Daroussin		AC_DEFINE(HAVE_GETTEXT,1,[Define to 1 if we have gettext function])
12064c8945a0SNathan Whitehorn	fi
12074c8945a0SNathan Whitehorn	if test -n "$nls_cv_header_intl" ; then
12082a3e3873SBaptiste Daroussin		AC_DEFINE(HAVE_LIBINTL_H,1,[Define to 1 if we have header-file for libintl])
12094c8945a0SNathan Whitehorn	fi
12104c8945a0SNathan Whitehornfi
12114c8945a0SNathan Whitehorn])dnl
12124c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
1213*a96ef450SBaptiste Daroussindnl CF_CC_ENV_FLAGS version: 10 updated: 2020/12/31 18:40:20
12142a3e3873SBaptiste Daroussindnl ---------------
12152a3e3873SBaptiste Daroussindnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
1216f4f33ea0SBaptiste Daroussindnl into CC.  This will not help with broken scripts that wrap the compiler
1217f4f33ea0SBaptiste Daroussindnl with options, but eliminates a more common category of user confusion.
1218f4f33ea0SBaptiste Daroussindnl
1219f4f33ea0SBaptiste Daroussindnl In particular, it addresses the problem of being able to run the C
1220f4f33ea0SBaptiste Daroussindnl preprocessor in a consistent manner.
1221f4f33ea0SBaptiste Daroussindnl
1222f4f33ea0SBaptiste Daroussindnl Caveat: this also disallows blanks in the pathname for the compiler, but
1223f4f33ea0SBaptiste Daroussindnl the nuisance of having inconsistent settings for compiler and preprocessor
1224f4f33ea0SBaptiste Daroussindnl outweighs that limitation.
12252a3e3873SBaptiste DaroussinAC_DEFUN([CF_CC_ENV_FLAGS],
12262a3e3873SBaptiste Daroussin[
12272a3e3873SBaptiste Daroussin# This should have been defined by AC_PROG_CC
1228*a96ef450SBaptiste Daroussin: "${CC:=cc}"
1229*a96ef450SBaptiste Daroussin
1230*a96ef450SBaptiste DaroussinAC_MSG_CHECKING(\$CFLAGS variable)
1231*a96ef450SBaptiste Daroussincase "x$CFLAGS" in
1232*a96ef450SBaptiste Daroussin(*-[[IUD]]*)
1233*a96ef450SBaptiste Daroussin	AC_MSG_RESULT(broken)
1234*a96ef450SBaptiste Daroussin	AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
1235*a96ef450SBaptiste Daroussin	cf_flags="$CFLAGS"
1236*a96ef450SBaptiste Daroussin	CFLAGS=
1237*a96ef450SBaptiste Daroussin	for cf_arg in $cf_flags
1238*a96ef450SBaptiste Daroussin	do
1239*a96ef450SBaptiste Daroussin		CF_ADD_CFLAGS($cf_arg)
1240*a96ef450SBaptiste Daroussin	done
1241*a96ef450SBaptiste Daroussin	;;
1242*a96ef450SBaptiste Daroussin(*)
1243*a96ef450SBaptiste Daroussin	AC_MSG_RESULT(ok)
1244*a96ef450SBaptiste Daroussin	;;
1245*a96ef450SBaptiste Daroussinesac
12462a3e3873SBaptiste Daroussin
12472a3e3873SBaptiste DaroussinAC_MSG_CHECKING(\$CC variable)
1248f4f33ea0SBaptiste Daroussincase "$CC" in
1249f4f33ea0SBaptiste Daroussin(*[[\ \	]]-*)
12502a3e3873SBaptiste Daroussin	AC_MSG_RESULT(broken)
1251*a96ef450SBaptiste Daroussin	AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
12522a3e3873SBaptiste Daroussin	# humor him...
1253f4f33ea0SBaptiste Daroussin	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
1254f4f33ea0SBaptiste Daroussin	cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", [substr]([$]0,1+length(prog))); }'`
1255f4f33ea0SBaptiste Daroussin	CC="$cf_prog"
1256f4f33ea0SBaptiste Daroussin	for cf_arg in $cf_flags
1257f4f33ea0SBaptiste Daroussin	do
1258f4f33ea0SBaptiste Daroussin		case "x$cf_arg" in
1259f4f33ea0SBaptiste Daroussin		(x-[[IUDfgOW]]*)
1260f4f33ea0SBaptiste Daroussin			CF_ADD_CFLAGS($cf_arg)
12612a3e3873SBaptiste Daroussin			;;
1262f4f33ea0SBaptiste Daroussin		(*)
1263f4f33ea0SBaptiste Daroussin			CC="$CC $cf_arg"
1264f4f33ea0SBaptiste Daroussin			;;
1265f4f33ea0SBaptiste Daroussin		esac
1266f4f33ea0SBaptiste Daroussin	done
1267f4f33ea0SBaptiste Daroussin	CF_VERBOSE(resulting CC: '$CC')
1268f4f33ea0SBaptiste Daroussin	CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
1269f4f33ea0SBaptiste Daroussin	CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
1270f4f33ea0SBaptiste Daroussin	;;
1271f4f33ea0SBaptiste Daroussin(*)
12722a3e3873SBaptiste Daroussin	AC_MSG_RESULT(ok)
12732a3e3873SBaptiste Daroussin	;;
12742a3e3873SBaptiste Daroussinesac
12752a3e3873SBaptiste Daroussin])dnl
12762a3e3873SBaptiste Daroussindnl ---------------------------------------------------------------------------
1277*a96ef450SBaptiste Daroussindnl CF_CHECK_CACHE version: 13 updated: 2020/12/31 10:54:15
12784c8945a0SNathan Whitehorndnl --------------
12794c8945a0SNathan Whitehorndnl Check if we're accidentally using a cache from a different machine.
12804c8945a0SNathan Whitehorndnl Derive the system name, as a check for reusing the autoconf cache.
12814c8945a0SNathan Whitehorndnl
12824c8945a0SNathan Whitehorndnl If we've packaged config.guess and config.sub, run that (since it does a
12834c8945a0SNathan Whitehorndnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
12844c8945a0SNathan Whitehorndnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
12854c8945a0SNathan Whitehorndnl which is useful in cross-compiles.
12864c8945a0SNathan Whitehorndnl
12874c8945a0SNathan Whitehorndnl Note: we would use $ac_config_sub, but that is one of the places where
12884c8945a0SNathan Whitehorndnl autoconf 2.5x broke compatibility with autoconf 2.13
12894c8945a0SNathan WhitehornAC_DEFUN([CF_CHECK_CACHE],
12904c8945a0SNathan Whitehorn[
1291*a96ef450SBaptiste Daroussinif test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then
12924c8945a0SNathan Whitehorn	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
12934c8945a0SNathan Whitehorn	system_name="$host_os"
12944c8945a0SNathan Whitehornelse
12954c8945a0SNathan Whitehorn	system_name="`(uname -s -r) 2>/dev/null`"
12964c8945a0SNathan Whitehorn	if test -z "$system_name" ; then
12974c8945a0SNathan Whitehorn		system_name="`(hostname) 2>/dev/null`"
12984c8945a0SNathan Whitehorn	fi
12994c8945a0SNathan Whitehornfi
13002a3e3873SBaptiste Daroussintest -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
13014c8945a0SNathan WhitehornAC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
13024c8945a0SNathan Whitehorn
13034c8945a0SNathan Whitehorntest -z "$system_name" && system_name="$cf_cv_system_name"
13044c8945a0SNathan Whitehorntest -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
13054c8945a0SNathan Whitehorn
13064c8945a0SNathan Whitehornif test ".$system_name" != ".$cf_cv_system_name" ; then
13074c8945a0SNathan Whitehorn	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
13084c8945a0SNathan Whitehorn	AC_MSG_ERROR("Please remove config.cache and try again.")
13094c8945a0SNathan Whitehornfi
13104c8945a0SNathan Whitehorn])dnl
13114c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
1312*a96ef450SBaptiste Daroussindnl CF_CHECK_CFLAGS version: 4 updated: 2021/01/02 19:22:58
1313f4f33ea0SBaptiste Daroussindnl ---------------
1314f4f33ea0SBaptiste Daroussindnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
1315f4f33ea0SBaptiste Daroussindnl a build-configuration such as imake.  These have the pitfall that they
1316f4f33ea0SBaptiste Daroussindnl often contain compiler-specific options which we cannot use, mixed with
1317f4f33ea0SBaptiste Daroussindnl preprocessor options that we usually can.
1318f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_CHECK_CFLAGS],
1319f4f33ea0SBaptiste Daroussin[
1320f4f33ea0SBaptiste DaroussinCF_VERBOSE(checking additions to CFLAGS)
1321f4f33ea0SBaptiste Daroussincf_check_cflags="$CFLAGS"
1322f4f33ea0SBaptiste Daroussincf_check_cppflags="$CPPFLAGS"
1323f4f33ea0SBaptiste DaroussinCF_ADD_CFLAGS($1,yes)
1324f4f33ea0SBaptiste Daroussinif test "x$cf_check_cflags" != "x$CFLAGS" ; then
1325f4f33ea0SBaptiste DaroussinAC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
1326f4f33ea0SBaptiste Daroussin	[CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
1327f4f33ea0SBaptiste Daroussin	 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
1328f4f33ea0SBaptiste Daroussin		 CF_VERBOSE(but keeping change to \$CPPFLAGS)
1329f4f33ea0SBaptiste Daroussin	 fi
1330*a96ef450SBaptiste Daroussin	 CFLAGS="$cf_check_cflags"])
1331f4f33ea0SBaptiste Daroussinfi
1332f4f33ea0SBaptiste Daroussin])dnl
1333f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
1334febdb468SDevin Teskednl CF_CHECK_LIBTOOL_VERSION version: 1 updated: 2013/04/06 18:03:09
1335febdb468SDevin Teskednl ------------------------
1336febdb468SDevin Teskednl Show the version of libtool
1337febdb468SDevin Teskednl
1338febdb468SDevin Teskednl Save the version in a cache variable - this is not entirely a good thing,
1339febdb468SDevin Teskednl but the version string from libtool is very ugly, and for bug reports it
1340febdb468SDevin Teskednl might be useful to have the original string.
1341febdb468SDevin TeskeAC_DEFUN([CF_CHECK_LIBTOOL_VERSION],[
1342febdb468SDevin Teskeif test -n "$LIBTOOL" && test "$LIBTOOL" != none
1343febdb468SDevin Teskethen
1344febdb468SDevin Teske	AC_MSG_CHECKING(version of $LIBTOOL)
1345febdb468SDevin Teske	CF_LIBTOOL_VERSION
1346febdb468SDevin Teske	AC_MSG_RESULT($cf_cv_libtool_version)
1347febdb468SDevin Teske	if test -z "$cf_cv_libtool_version" ; then
1348febdb468SDevin Teske		AC_MSG_ERROR(This is not GNU libtool)
1349febdb468SDevin Teske	fi
1350febdb468SDevin Teskeelse
1351febdb468SDevin Teske	AC_MSG_ERROR(GNU libtool has not been found)
1352febdb468SDevin Teskefi
1353febdb468SDevin Teske])dnl
1354febdb468SDevin Teskednl ---------------------------------------------------------------------------
1355*a96ef450SBaptiste Daroussindnl CF_CLANG_COMPILER version: 8 updated: 2021/01/01 13:31:04
13562a3e3873SBaptiste Daroussindnl -----------------
13572a3e3873SBaptiste Daroussindnl Check if the given compiler is really clang.  clang's C driver defines
13582a3e3873SBaptiste Daroussindnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
13592a3e3873SBaptiste Daroussindnl not ignore some gcc options.
13602a3e3873SBaptiste Daroussindnl
13612a3e3873SBaptiste Daroussindnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
13622a3e3873SBaptiste Daroussindnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
13632a3e3873SBaptiste Daroussindnl the wrappers for gcc and g++ warnings.
13642a3e3873SBaptiste Daroussindnl
13652a3e3873SBaptiste Daroussindnl $1 = GCC (default) or GXX
1366f4f33ea0SBaptiste Daroussindnl $2 = CLANG_COMPILER (default)
13672a3e3873SBaptiste Daroussindnl $3 = CFLAGS (default) or CXXFLAGS
13682a3e3873SBaptiste DaroussinAC_DEFUN([CF_CLANG_COMPILER],[
13692a3e3873SBaptiste Daroussinifelse([$2],,CLANG_COMPILER,[$2])=no
13702a3e3873SBaptiste Daroussin
13712a3e3873SBaptiste Daroussinif test "$ifelse([$1],,[$1],GCC)" = yes ; then
13722a3e3873SBaptiste Daroussin	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
13732a3e3873SBaptiste Daroussin	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
13742a3e3873SBaptiste Daroussin	AC_TRY_COMPILE([],[
13752a3e3873SBaptiste Daroussin#ifdef __clang__
13762a3e3873SBaptiste Daroussin#else
13772a3e3873SBaptiste Daroussinmake an error
13782a3e3873SBaptiste Daroussin#endif
13792a3e3873SBaptiste Daroussin],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
13802a3e3873SBaptiste Daroussin],[])
13812a3e3873SBaptiste Daroussin	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
13822a3e3873SBaptiste Daroussin	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
13832a3e3873SBaptiste Daroussinfi
1384*a96ef450SBaptiste Daroussin
1385*a96ef450SBaptiste DaroussinCLANG_VERSION=none
1386*a96ef450SBaptiste Daroussin
1387*a96ef450SBaptiste Daroussinif test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then
1388*a96ef450SBaptiste Daroussin	case "$CC" in
1389*a96ef450SBaptiste Daroussin	(c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]])
1390*a96ef450SBaptiste Daroussin		AC_MSG_WARN(replacing broken compiler alias $CC)
1391*a96ef450SBaptiste Daroussin		CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`"
1392*a96ef450SBaptiste Daroussin		CC=clang
1393*a96ef450SBaptiste Daroussin		;;
1394*a96ef450SBaptiste Daroussin	esac
1395*a96ef450SBaptiste Daroussin
1396*a96ef450SBaptiste Daroussin	AC_MSG_CHECKING(version of $CC)
1397*a96ef450SBaptiste Daroussin	CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1398*a96ef450SBaptiste Daroussin	test -z "$CLANG_VERSION" && CLANG_VERSION=unknown
1399*a96ef450SBaptiste Daroussin	AC_MSG_RESULT($CLANG_VERSION)
1400*a96ef450SBaptiste Daroussin
1401*a96ef450SBaptiste Daroussin	for cf_clang_opt in \
1402*a96ef450SBaptiste Daroussin		-Qunused-arguments \
1403*a96ef450SBaptiste Daroussin		-Wno-error=implicit-function-declaration
1404*a96ef450SBaptiste Daroussin	do
1405*a96ef450SBaptiste Daroussin		AC_MSG_CHECKING(if option $cf_clang_opt works)
1406*a96ef450SBaptiste Daroussin		cf_save_CFLAGS="$CFLAGS"
1407*a96ef450SBaptiste Daroussin		CFLAGS="$CFLAGS $cf_clang_opt"
1408*a96ef450SBaptiste Daroussin		AC_TRY_LINK([
1409*a96ef450SBaptiste Daroussin			#include <stdio.h>],[
1410*a96ef450SBaptiste Daroussin			printf("hello!\\n");],[
1411*a96ef450SBaptiste Daroussin			cf_clang_optok=yes],[
1412*a96ef450SBaptiste Daroussin			cf_clang_optok=no])
1413*a96ef450SBaptiste Daroussin		AC_MSG_RESULT($cf_clang_optok)
1414*a96ef450SBaptiste Daroussin		CFLAGS="$cf_save_CFLAGS"
1415*a96ef450SBaptiste Daroussin		if test "$cf_clang_optok" = yes; then
1416*a96ef450SBaptiste Daroussin			CF_VERBOSE(adding option $cf_clang_opt)
1417*a96ef450SBaptiste Daroussin			CF_APPEND_TEXT(CFLAGS,$cf_clang_opt)
1418*a96ef450SBaptiste Daroussin		fi
1419*a96ef450SBaptiste Daroussin	done
1420*a96ef450SBaptiste Daroussinfi
14212a3e3873SBaptiste Daroussin])
14222a3e3873SBaptiste Daroussindnl ---------------------------------------------------------------------------
1423*a96ef450SBaptiste Daroussindnl CF_CONST_X_STRING version: 6 updated: 2021/01/01 13:31:04
1424*a96ef450SBaptiste Daroussindnl -----------------
1425*a96ef450SBaptiste Daroussindnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
1426*a96ef450SBaptiste Daroussindnl character-strings.
1427*a96ef450SBaptiste Daroussindnl
1428*a96ef450SBaptiste Daroussindnl It is ambiguous because the specification accommodated the pre-ANSI
1429*a96ef450SBaptiste Daroussindnl compilers bundled by more than one vendor in lieu of providing a standard C
1430*a96ef450SBaptiste Daroussindnl compiler other than by costly add-ons.  Because of this, the specification
1431*a96ef450SBaptiste Daroussindnl did not take into account the use of const for telling the compiler that
1432*a96ef450SBaptiste Daroussindnl string literals would be in readonly memory.
1433*a96ef450SBaptiste Daroussindnl
1434*a96ef450SBaptiste Daroussindnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
1435*a96ef450SBaptiste Daroussindnl let the compiler decide how to represent Xt's strings which were #define'd.
1436*a96ef450SBaptiste Daroussindnl That does not solve the problem of using the block of Xt's strings which
1437*a96ef450SBaptiste Daroussindnl are compiled into the library (and is less efficient than one might want).
1438*a96ef450SBaptiste Daroussindnl
1439*a96ef450SBaptiste Daroussindnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
1440*a96ef450SBaptiste Daroussindnl when compiling the library and compiling using the library, to tell the
1441*a96ef450SBaptiste Daroussindnl compiler that String is const.
1442*a96ef450SBaptiste DaroussinAC_DEFUN([CF_CONST_X_STRING],
1443*a96ef450SBaptiste Daroussin[
1444*a96ef450SBaptiste DaroussinAC_REQUIRE([AC_PATH_XTRA])
1445*a96ef450SBaptiste Daroussin
1446*a96ef450SBaptiste DaroussinCF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
1447*a96ef450SBaptiste Daroussin
1448*a96ef450SBaptiste DaroussinAC_TRY_COMPILE(
1449*a96ef450SBaptiste Daroussin[
1450*a96ef450SBaptiste Daroussin#include <stdlib.h>
1451*a96ef450SBaptiste Daroussin#include <X11/Intrinsic.h>
1452*a96ef450SBaptiste Daroussin],
1453*a96ef450SBaptiste Daroussin[String foo = malloc(1); (void)foo],[
1454*a96ef450SBaptiste Daroussin
1455*a96ef450SBaptiste DaroussinAC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
1456*a96ef450SBaptiste Daroussin	AC_TRY_COMPILE(
1457*a96ef450SBaptiste Daroussin		[
1458*a96ef450SBaptiste Daroussin#define _CONST_X_STRING	/* X11R7.8 (perhaps) */
1459*a96ef450SBaptiste Daroussin#undef  XTSTRINGDEFINES	/* X11R5 and later */
1460*a96ef450SBaptiste Daroussin#include <stdlib.h>
1461*a96ef450SBaptiste Daroussin#include <X11/Intrinsic.h>
1462*a96ef450SBaptiste Daroussin		],[String foo = malloc(1); *foo = 0],[
1463*a96ef450SBaptiste Daroussin			cf_cv_const_x_string=no
1464*a96ef450SBaptiste Daroussin		],[
1465*a96ef450SBaptiste Daroussin			cf_cv_const_x_string=yes
1466*a96ef450SBaptiste Daroussin		])
1467*a96ef450SBaptiste Daroussin])
1468*a96ef450SBaptiste Daroussin
1469*a96ef450SBaptiste DaroussinCF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
1470*a96ef450SBaptiste Daroussin
1471*a96ef450SBaptiste Daroussincase "$cf_cv_const_x_string" in
1472*a96ef450SBaptiste Daroussin(no)
1473*a96ef450SBaptiste Daroussin	CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
1474*a96ef450SBaptiste Daroussin	;;
1475*a96ef450SBaptiste Daroussin(*)
1476*a96ef450SBaptiste Daroussin	CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
1477*a96ef450SBaptiste Daroussin	;;
1478*a96ef450SBaptiste Daroussinesac
1479*a96ef450SBaptiste Daroussin
1480*a96ef450SBaptiste Daroussin])
1481*a96ef450SBaptiste Daroussin])dnl
1482*a96ef450SBaptiste Daroussindnl ---------------------------------------------------------------------------
1483*a96ef450SBaptiste Daroussindnl CF_CURSES_CHTYPE version: 11 updated: 2021/01/02 09:31:20
14844c8945a0SNathan Whitehorndnl ----------------
14854c8945a0SNathan Whitehorndnl Test if curses defines 'chtype' (usually a 'long' type for SysV curses).
14864c8945a0SNathan WhitehornAC_DEFUN([CF_CURSES_CHTYPE],
14874c8945a0SNathan Whitehorn[
14884c8945a0SNathan WhitehornAC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
14894c8945a0SNathan WhitehornAC_CACHE_CHECK(for chtype typedef,cf_cv_chtype_decl,[
14907a1c0d96SNathan Whitehorn	AC_TRY_COMPILE([#include <${cf_cv_ncurses_header:-curses.h}>],
1491*a96ef450SBaptiste Daroussin		[chtype foo; (void)foo],
14924c8945a0SNathan Whitehorn		[cf_cv_chtype_decl=yes],
14934c8945a0SNathan Whitehorn		[cf_cv_chtype_decl=no])])
1494*a96ef450SBaptiste Daroussinif test "$cf_cv_chtype_decl" = yes ; then
14952a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_TYPE_CHTYPE,1,[Define to 1 if chtype is declared])
14964c8945a0SNathan Whitehorn	AC_CACHE_CHECK(if chtype is scalar or struct,cf_cv_chtype_type,[
14977a1c0d96SNathan Whitehorn		AC_TRY_COMPILE([#include <${cf_cv_ncurses_header:-curses.h}>],
1498*a96ef450SBaptiste Daroussin			[static chtype foo; long x = foo; (void)x],
14994c8945a0SNathan Whitehorn			[cf_cv_chtype_type=scalar],
15004c8945a0SNathan Whitehorn			[cf_cv_chtype_type=struct])])
1501*a96ef450SBaptiste Daroussin	if test "$cf_cv_chtype_type" = scalar ; then
15022a3e3873SBaptiste Daroussin		AC_DEFINE(TYPE_CHTYPE_IS_SCALAR,1,[Define to 1 if chtype is a scaler/integer])
15034c8945a0SNathan Whitehorn	fi
15044c8945a0SNathan Whitehornfi
15054c8945a0SNathan Whitehorn])dnl
15064c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
15074c8945a0SNathan Whitehorndnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
15084c8945a0SNathan Whitehorndnl ----------------
15094c8945a0SNathan Whitehorndnl Tie together the configure-script macros for curses.  It may be ncurses,
15104c8945a0SNathan Whitehorndnl but unless asked, we do not make a special search for ncurses.  However,
15114c8945a0SNathan Whitehorndnl still check for the ncurses version number, for use in other macros.
15124c8945a0SNathan WhitehornAC_DEFUN([CF_CURSES_CONFIG],
15134c8945a0SNathan Whitehorn[
15144c8945a0SNathan WhitehornCF_CURSES_CPPFLAGS
15154c8945a0SNathan WhitehornCF_NCURSES_VERSION
15164c8945a0SNathan WhitehornCF_CURSES_LIBS
15174c8945a0SNathan Whitehorn])dnl
15184c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
1519*a96ef450SBaptiste Daroussindnl CF_CURSES_CPPFLAGS version: 14 updated: 2021/01/02 09:31:20
15204c8945a0SNathan Whitehorndnl ------------------
15214c8945a0SNathan Whitehorndnl Look for the curses headers.
15224c8945a0SNathan WhitehornAC_DEFUN([CF_CURSES_CPPFLAGS],[
15234c8945a0SNathan Whitehorn
15244c8945a0SNathan WhitehornAC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
15254c8945a0SNathan Whitehorncf_cv_curses_incdir=no
1526*a96ef450SBaptiste Daroussincase "$host_os" in
1527f4f33ea0SBaptiste Daroussin(hpux10.*)
1528682c9e0fSNathan Whitehorn	if test "x$cf_cv_screen" = "xcurses_colr"
1529682c9e0fSNathan Whitehorn	then
15304c8945a0SNathan Whitehorn		test -d /usr/include/curses_colr && \
15314c8945a0SNathan Whitehorn		cf_cv_curses_incdir="-I/usr/include/curses_colr"
1532682c9e0fSNathan Whitehorn	fi
15334c8945a0SNathan Whitehorn	;;
1534f4f33ea0SBaptiste Daroussin(sunos3*|sunos4*)
1535682c9e0fSNathan Whitehorn	if test "x$cf_cv_screen" = "xcurses_5lib"
1536682c9e0fSNathan Whitehorn	then
15374c8945a0SNathan Whitehorn		test -d /usr/5lib && \
15384c8945a0SNathan Whitehorn		test -d /usr/5include && \
15394c8945a0SNathan Whitehorn		cf_cv_curses_incdir="-I/usr/5include"
1540682c9e0fSNathan Whitehorn	fi
15414c8945a0SNathan Whitehorn	;;
15424c8945a0SNathan Whitehornesac
15434c8945a0SNathan Whitehorn])
1544f4f33ea0SBaptiste Daroussinif test "$cf_cv_curses_incdir" != no
1545f4f33ea0SBaptiste Daroussinthen
1546f4f33ea0SBaptiste Daroussin	CF_APPEND_TEXT(CPPFLAGS,$cf_cv_curses_incdir)
1547f4f33ea0SBaptiste Daroussinfi
15484c8945a0SNathan Whitehorn
15494c8945a0SNathan WhitehornCF_CURSES_HEADER
15504c8945a0SNathan WhitehornCF_TERM_HEADER
15514c8945a0SNathan Whitehorn])dnl
15524c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
1553*a96ef450SBaptiste Daroussindnl CF_CURSES_EXIT version: 1 updated: 2020/03/26 19:15:16
1554*a96ef450SBaptiste Daroussindnl --------------
1555*a96ef450SBaptiste Daroussindnl Check for ncurses memory-leak/debug feature.  Starting with ncurses 6.2,
1556*a96ef450SBaptiste Daroussindnl the curses_exit() function is always present, simplifying linkage changes
1557*a96ef450SBaptiste Daroussindnl when switching to/from a debug-library.
1558*a96ef450SBaptiste DaroussinAC_DEFUN([CF_CURSES_EXIT],
1559*a96ef450SBaptiste Daroussin[
1560*a96ef450SBaptiste DaroussinCF_CURSES_FUNCS(\
1561*a96ef450SBaptiste Daroussincurses_exit \
1562*a96ef450SBaptiste Daroussin_nc_free_and_exit \
1563*a96ef450SBaptiste Daroussin)
1564*a96ef450SBaptiste Daroussin])dnl
1565*a96ef450SBaptiste Daroussindnl ---------------------------------------------------------------------------
1566*a96ef450SBaptiste Daroussindnl CF_CURSES_FUNCS version: 20 updated: 2020/12/31 20:19:42
15674c8945a0SNathan Whitehorndnl ---------------
15684c8945a0SNathan Whitehorndnl Curses-functions are a little complicated, since a lot of them are macros.
15694c8945a0SNathan WhitehornAC_DEFUN([CF_CURSES_FUNCS],
15704c8945a0SNathan Whitehorn[
15714c8945a0SNathan WhitehornAC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
15724c8945a0SNathan WhitehornAC_REQUIRE([CF_XOPEN_CURSES])
15734c8945a0SNathan WhitehornAC_REQUIRE([CF_CURSES_TERM_H])
1574682c9e0fSNathan WhitehornAC_REQUIRE([CF_CURSES_UNCTRL_H])
15754c8945a0SNathan Whitehornfor cf_func in $1
15764c8945a0SNathan Whitehorndo
15774c8945a0SNathan Whitehorn	CF_UPPER(cf_tr_func,$cf_func)
15784c8945a0SNathan Whitehorn	AC_MSG_CHECKING(for ${cf_func})
15794c8945a0SNathan Whitehorn	CF_MSG_LOG(${cf_func})
15804c8945a0SNathan Whitehorn	AC_CACHE_VAL(cf_cv_func_$cf_func,[
15814c8945a0SNathan Whitehorn		eval cf_result='$ac_cv_func_'$cf_func
15824c8945a0SNathan Whitehorn		if test ".$cf_result" != ".no"; then
15834c8945a0SNathan Whitehorn			AC_TRY_LINK(CF__CURSES_HEAD,
15844c8945a0SNathan Whitehorn			[
15854c8945a0SNathan Whitehorn#ifndef ${cf_func}
15864c8945a0SNathan Whitehornlong foo = (long)(&${cf_func});
1587*a96ef450SBaptiste Daroussinfprintf(stderr, "testing linkage of $cf_func:%p\\n", (void *)foo);
1588f4f33ea0SBaptiste Daroussinif (foo + 1234L > 5678L)
1589f4f33ea0SBaptiste Daroussin	${cf_cv_main_return:-return}(foo != 0);
15904c8945a0SNathan Whitehorn#endif
15914c8945a0SNathan Whitehorn			],
15924c8945a0SNathan Whitehorn			[cf_result=yes],
15934c8945a0SNathan Whitehorn			[cf_result=no])
15944c8945a0SNathan Whitehorn		fi
1595*a96ef450SBaptiste Daroussin		eval 'cf_cv_func_'$cf_func'="$cf_result"'
15964c8945a0SNathan Whitehorn	])
15974c8945a0SNathan Whitehorn	# use the computed/retrieved cache-value:
15984c8945a0SNathan Whitehorn	eval 'cf_result=$cf_cv_func_'$cf_func
15994c8945a0SNathan Whitehorn	AC_MSG_RESULT($cf_result)
1600*a96ef450SBaptiste Daroussin	if test "$cf_result" != no; then
16014c8945a0SNathan Whitehorn		AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
16024c8945a0SNathan Whitehorn	fi
16034c8945a0SNathan Whitehorndone
16044c8945a0SNathan Whitehorn])dnl
16054c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
1606f4f33ea0SBaptiste Daroussindnl CF_CURSES_HEADER version: 5 updated: 2015/04/23 20:35:30
16074c8945a0SNathan Whitehorndnl ----------------
16084c8945a0SNathan Whitehorndnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
16094c8945a0SNathan Whitehorndnl variations of ncurses' installs.
16104c8945a0SNathan Whitehorndnl
16114c8945a0SNathan Whitehorndnl $1 = ncurses when looking for ncurses, or is empty
16124c8945a0SNathan WhitehornAC_DEFUN([CF_CURSES_HEADER],[
16134c8945a0SNathan WhitehornAC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
16144c8945a0SNathan Whitehorncf_cv_ncurses_header=none
1615f4f33ea0SBaptiste Daroussinfor cf_header in \
1616f4f33ea0SBaptiste Daroussin	ncurses.h ifelse($1,,,[$1/ncurses.h]) \
1617f4f33ea0SBaptiste Daroussin	curses.h ifelse($1,,,[$1/curses.h]) ifelse($1,,[ncurses/ncurses.h ncurses/curses.h])
16184c8945a0SNathan Whitehorndo
16194c8945a0SNathan WhitehornAC_TRY_COMPILE([#include <${cf_header}>],
16204c8945a0SNathan Whitehorn	[initscr(); tgoto("?", 0,0)],
16214c8945a0SNathan Whitehorn	[cf_cv_ncurses_header=$cf_header; break],[])
16224c8945a0SNathan Whitehorndone
16234c8945a0SNathan Whitehorn])
16244c8945a0SNathan Whitehorn
16254c8945a0SNathan Whitehornif test "$cf_cv_ncurses_header" = none ; then
16264c8945a0SNathan Whitehorn	AC_MSG_ERROR(No curses header-files found)
16274c8945a0SNathan Whitehornfi
16284c8945a0SNathan Whitehorn
16294c8945a0SNathan Whitehorn# cheat, to get the right #define's for HAVE_NCURSES_H, etc.
16304c8945a0SNathan WhitehornAC_CHECK_HEADERS($cf_cv_ncurses_header)
16314c8945a0SNathan Whitehorn])dnl
16324c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
1633*a96ef450SBaptiste Daroussindnl CF_CURSES_LIBS version: 44 updated: 2021/01/02 09:31:20
16344c8945a0SNathan Whitehorndnl --------------
16354c8945a0SNathan Whitehorndnl Look for the curses libraries.  Older curses implementations may require
16364c8945a0SNathan Whitehorndnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
16374c8945a0SNathan WhitehornAC_DEFUN([CF_CURSES_LIBS],[
16384c8945a0SNathan Whitehorn
16394c8945a0SNathan WhitehornAC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
16404c8945a0SNathan WhitehornAC_MSG_CHECKING(if we have identified curses libraries)
16417a1c0d96SNathan WhitehornAC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
16424c8945a0SNathan Whitehorn	[initscr(); tgoto("?", 0,0)],
16434c8945a0SNathan Whitehorn	cf_result=yes,
16444c8945a0SNathan Whitehorn	cf_result=no)
16454c8945a0SNathan WhitehornAC_MSG_RESULT($cf_result)
16464c8945a0SNathan Whitehorn
16474c8945a0SNathan Whitehornif test "$cf_result" = no ; then
1648*a96ef450SBaptiste Daroussincase "$host_os" in
1649f4f33ea0SBaptiste Daroussin(freebsd*)
16507a1c0d96SNathan Whitehorn	AC_CHECK_LIB(mytinfo,tgoto,[CF_ADD_LIBS(-lmytinfo)])
16514c8945a0SNathan Whitehorn	;;
1652f4f33ea0SBaptiste Daroussin(hpux10.*)
1653682c9e0fSNathan Whitehorn	# Looking at HPUX 10.20, the Hcurses library is the oldest (1997), cur_colr
1654682c9e0fSNathan Whitehorn	# next (1998), and xcurses "newer" (2000).  There is no header file for
1655682c9e0fSNathan Whitehorn	# Hcurses; the subdirectory curses_colr has the headers (curses.h and
1656682c9e0fSNathan Whitehorn	# term.h) for cur_colr
1657682c9e0fSNathan Whitehorn	if test "x$cf_cv_screen" = "xcurses_colr"
1658682c9e0fSNathan Whitehorn	then
16594c8945a0SNathan Whitehorn		AC_CHECK_LIB(cur_colr,initscr,[
16607a1c0d96SNathan Whitehorn			CF_ADD_LIBS(-lcur_colr)
16614c8945a0SNathan Whitehorn			ac_cv_func_initscr=yes
16624c8945a0SNathan Whitehorn			],[
16634c8945a0SNathan Whitehorn		AC_CHECK_LIB(Hcurses,initscr,[
16644c8945a0SNathan Whitehorn			# HP's header uses __HP_CURSES, but user claims _HP_CURSES.
16657a1c0d96SNathan Whitehorn			CF_ADD_LIBS(-lHcurses)
1666f4f33ea0SBaptiste Daroussin			CF_APPEND_TEXT(CPPFLAGS,-D__HP_CURSES -D_HP_CURSES)
16674c8945a0SNathan Whitehorn			ac_cv_func_initscr=yes
16684c8945a0SNathan Whitehorn			])])
1669682c9e0fSNathan Whitehorn	fi
16704c8945a0SNathan Whitehorn	;;
1671f4f33ea0SBaptiste Daroussin(linux*)
1672682c9e0fSNathan Whitehorn	case `arch 2>/dev/null` in
1673f4f33ea0SBaptiste Daroussin	(x86_64)
16747a1c0d96SNathan Whitehorn		if test -d /lib64
16757a1c0d96SNathan Whitehorn		then
16767a1c0d96SNathan Whitehorn			CF_ADD_LIBDIR(/lib64)
16777a1c0d96SNathan Whitehorn		else
16784c8945a0SNathan Whitehorn			CF_ADD_LIBDIR(/lib)
16797a1c0d96SNathan Whitehorn		fi
16807a1c0d96SNathan Whitehorn		;;
1681f4f33ea0SBaptiste Daroussin	(*)
16827a1c0d96SNathan Whitehorn		CF_ADD_LIBDIR(/lib)
16837a1c0d96SNathan Whitehorn		;;
16847a1c0d96SNathan Whitehorn	esac
16854c8945a0SNathan Whitehorn	;;
1686f4f33ea0SBaptiste Daroussin(sunos3*|sunos4*)
1687682c9e0fSNathan Whitehorn	if test "x$cf_cv_screen" = "xcurses_5lib"
1688682c9e0fSNathan Whitehorn	then
16894c8945a0SNathan Whitehorn		if test -d /usr/5lib ; then
16904c8945a0SNathan Whitehorn			CF_ADD_LIBDIR(/usr/5lib)
16917a1c0d96SNathan Whitehorn			CF_ADD_LIBS(-lcurses -ltermcap)
16924c8945a0SNathan Whitehorn		fi
1693682c9e0fSNathan Whitehorn	fi
16944c8945a0SNathan Whitehorn	ac_cv_func_initscr=yes
16954c8945a0SNathan Whitehorn	;;
16964c8945a0SNathan Whitehornesac
16974c8945a0SNathan Whitehorn
16984c8945a0SNathan Whitehornif test ".$ac_cv_func_initscr" != .yes ; then
16994c8945a0SNathan Whitehorn	cf_save_LIBS="$LIBS"
17004c8945a0SNathan Whitehorn
17017a1c0d96SNathan Whitehorn	if test ".${cf_cv_ncurses_version:-no}" != .no
17024c8945a0SNathan Whitehorn	then
17034c8945a0SNathan Whitehorn		cf_check_list="ncurses curses cursesX"
17044c8945a0SNathan Whitehorn	else
17054c8945a0SNathan Whitehorn		cf_check_list="cursesX curses ncurses"
17064c8945a0SNathan Whitehorn	fi
17074c8945a0SNathan Whitehorn
17084c8945a0SNathan Whitehorn	# Check for library containing tgoto.  Do this before curses library
17094c8945a0SNathan Whitehorn	# because it may be needed to link the test-case for initscr.
1710febdb468SDevin Teske	if test "x$cf_term_lib" = x
1711febdb468SDevin Teske	then
17124c8945a0SNathan Whitehorn		AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
17132a3e3873SBaptiste Daroussin			for cf_term_lib in $cf_check_list otermcap termcap tinfo termlib unknown
17144c8945a0SNathan Whitehorn			do
1715f4f33ea0SBaptiste Daroussin				AC_CHECK_LIB($cf_term_lib,tgoto,[
1716*a96ef450SBaptiste Daroussin					: "${cf_nculib_root:=$cf_term_lib}"
1717f4f33ea0SBaptiste Daroussin					break
1718f4f33ea0SBaptiste Daroussin				])
17194c8945a0SNathan Whitehorn			done
17204c8945a0SNathan Whitehorn		])
1721febdb468SDevin Teske	fi
17224c8945a0SNathan Whitehorn
17234c8945a0SNathan Whitehorn	# Check for library containing initscr
17244c8945a0SNathan Whitehorn	test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
1725febdb468SDevin Teske	if test "x$cf_curs_lib" = x
1726febdb468SDevin Teske	then
17274c8945a0SNathan Whitehorn		for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
17284c8945a0SNathan Whitehorn		do
17294c8945a0SNathan Whitehorn			LIBS="-l$cf_curs_lib $cf_save_LIBS"
1730f4f33ea0SBaptiste Daroussin			if test "$cf_term_lib" = unknown || test "$cf_term_lib" = "$cf_curs_lib" ; then
17314c8945a0SNathan Whitehorn				AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
17327a1c0d96SNathan Whitehorn				AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
17334c8945a0SNathan Whitehorn					[initscr()],
17344c8945a0SNathan Whitehorn					[cf_result=yes],
17354c8945a0SNathan Whitehorn					[cf_result=no])
17364c8945a0SNathan Whitehorn				AC_MSG_RESULT($cf_result)
1737*a96ef450SBaptiste Daroussin				test "$cf_result" = yes && break
17384c8945a0SNathan Whitehorn			elif test "$cf_curs_lib" = "$cf_term_lib" ; then
1739f4f33ea0SBaptiste Daroussin				cf_result=no
17404c8945a0SNathan Whitehorn			elif test "$cf_term_lib" != predefined ; then
17414c8945a0SNathan Whitehorn				AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
17427a1c0d96SNathan Whitehorn				AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
17434c8945a0SNathan Whitehorn					[initscr(); tgoto((char *)0, 0, 0);],
17444c8945a0SNathan Whitehorn					[cf_result=no],
17454c8945a0SNathan Whitehorn					[
17464c8945a0SNathan Whitehorn					LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
17477a1c0d96SNathan Whitehorn					AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
17484c8945a0SNathan Whitehorn						[initscr()],
17494c8945a0SNathan Whitehorn						[cf_result=yes],
17504c8945a0SNathan Whitehorn						[cf_result=error])
17514c8945a0SNathan Whitehorn					])
17524c8945a0SNathan Whitehorn				AC_MSG_RESULT($cf_result)
1753*a96ef450SBaptiste Daroussin				test "$cf_result" != error && break
17544c8945a0SNathan Whitehorn			fi
1755f4f33ea0SBaptiste Daroussin		done
1756f4f33ea0SBaptiste Daroussin	fi
1757*a96ef450SBaptiste Daroussin	test "$cf_curs_lib" = unknown && AC_MSG_ERROR(no curses library found)
17584c8945a0SNathan Whitehornfi
17594c8945a0SNathan Whitehornfi
17604c8945a0SNathan Whitehorn
17614c8945a0SNathan Whitehorn])dnl
17624c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
1763*a96ef450SBaptiste Daroussindnl CF_CURSES_TERM_H version: 15 updated: 2021/01/02 09:31:20
17644c8945a0SNathan Whitehorndnl ----------------
17654c8945a0SNathan Whitehorndnl SVr4 curses should have term.h as well (where it puts the definitions of
17664c8945a0SNathan Whitehorndnl the low-level interface).  This may not be true in old/broken implementations,
17674c8945a0SNathan Whitehorndnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
17684c8945a0SNathan Whitehorndnl running with Solaris 2.5.1).
17694c8945a0SNathan WhitehornAC_DEFUN([CF_CURSES_TERM_H],
17704c8945a0SNathan Whitehorn[
17714c8945a0SNathan WhitehornAC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
17724c8945a0SNathan Whitehorn
17734c8945a0SNathan WhitehornAC_CACHE_CHECK(for term.h, cf_cv_term_header,[
17744c8945a0SNathan Whitehorn
17754c8945a0SNathan Whitehorn# If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
17764c8945a0SNathan Whitehorn# for <term.h> if we do not find the variant.
1777682c9e0fSNathan Whitehorn
1778682c9e0fSNathan Whitehorncf_header_list="term.h ncurses/term.h ncursesw/term.h"
1779682c9e0fSNathan Whitehorn
1780*a96ef450SBaptiste Daroussincase "${cf_cv_ncurses_header:-curses.h}" in
1781f4f33ea0SBaptiste Daroussin(*/*)
1782*a96ef450SBaptiste Daroussin	cf_header_item=`echo "${cf_cv_ncurses_header:-curses.h}" | sed -e 's%\..*%%' -e 's%/.*%/%'`term.h
1783682c9e0fSNathan Whitehorn	cf_header_list="$cf_header_item $cf_header_list"
1784682c9e0fSNathan Whitehorn	;;
1785682c9e0fSNathan Whitehornesac
1786682c9e0fSNathan Whitehorn
1787682c9e0fSNathan Whitehornfor cf_header in $cf_header_list
17884c8945a0SNathan Whitehorndo
17894c8945a0SNathan Whitehorn	AC_TRY_COMPILE([
17907a1c0d96SNathan Whitehorn#include <${cf_cv_ncurses_header:-curses.h}>
17914c8945a0SNathan Whitehorn#include <${cf_header}>],
1792*a96ef450SBaptiste Daroussin	[WINDOW *x; (void)x],
17934c8945a0SNathan Whitehorn	[cf_cv_term_header=$cf_header
17944c8945a0SNathan Whitehorn	 break],
17954c8945a0SNathan Whitehorn	[cf_cv_term_header=no])
17964c8945a0SNathan Whitehorndone
17974c8945a0SNathan Whitehorn
1798*a96ef450SBaptiste Daroussincase "$cf_cv_term_header" in
1799f4f33ea0SBaptiste Daroussin(no)
18004c8945a0SNathan Whitehorn	# If curses is ncurses, some packagers still mess it up by trying to make
18014c8945a0SNathan Whitehorn	# us use GNU termcap.  This handles the most common case.
18024c8945a0SNathan Whitehorn	for cf_header in ncurses/term.h ncursesw/term.h
18034c8945a0SNathan Whitehorn	do
18044c8945a0SNathan Whitehorn		AC_TRY_COMPILE([
18057a1c0d96SNathan Whitehorn#include <${cf_cv_ncurses_header:-curses.h}>
18064c8945a0SNathan Whitehorn#ifdef NCURSES_VERSION
18074c8945a0SNathan Whitehorn#include <${cf_header}>
18084c8945a0SNathan Whitehorn#else
18094c8945a0SNathan Whitehornmake an error
18104c8945a0SNathan Whitehorn#endif],
1811*a96ef450SBaptiste Daroussin			[WINDOW *x; (void)x],
18124c8945a0SNathan Whitehorn			[cf_cv_term_header=$cf_header
18134c8945a0SNathan Whitehorn			 break],
18144c8945a0SNathan Whitehorn			[cf_cv_term_header=no])
18154c8945a0SNathan Whitehorn	done
18164c8945a0SNathan Whitehorn	;;
18174c8945a0SNathan Whitehornesac
18184c8945a0SNathan Whitehorn])
18194c8945a0SNathan Whitehorn
1820*a96ef450SBaptiste Daroussincase "$cf_cv_term_header" in
1821f4f33ea0SBaptiste Daroussin(term.h)
18222a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
18234c8945a0SNathan Whitehorn	;;
1824f4f33ea0SBaptiste Daroussin(ncurses/term.h)
18252a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
18264c8945a0SNathan Whitehorn	;;
1827f4f33ea0SBaptiste Daroussin(ncursesw/term.h)
18282a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
18294c8945a0SNathan Whitehorn	;;
18304c8945a0SNathan Whitehornesac
18314c8945a0SNathan Whitehorn])dnl
18324c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
1833*a96ef450SBaptiste Daroussindnl CF_CURSES_UNCTRL_H version: 8 updated: 2021/01/02 09:31:20
1834682c9e0fSNathan Whitehorndnl ------------------
1835682c9e0fSNathan Whitehorndnl Any X/Open curses implementation must have unctrl.h, but ncurses packages
1836682c9e0fSNathan Whitehorndnl may put it in a subdirectory (along with ncurses' other headers, of
1837682c9e0fSNathan Whitehorndnl course).  Packages which put the headers in inconsistent locations are
1838682c9e0fSNathan Whitehorndnl broken).
1839682c9e0fSNathan WhitehornAC_DEFUN([CF_CURSES_UNCTRL_H],
1840682c9e0fSNathan Whitehorn[
1841682c9e0fSNathan WhitehornAC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1842682c9e0fSNathan Whitehorn
1843682c9e0fSNathan WhitehornAC_CACHE_CHECK(for unctrl.h, cf_cv_unctrl_header,[
1844682c9e0fSNathan Whitehorn
1845682c9e0fSNathan Whitehorn# If we found <ncurses/curses.h>, look for <ncurses/unctrl.h>, but always look
1846682c9e0fSNathan Whitehorn# for <unctrl.h> if we do not find the variant.
1847682c9e0fSNathan Whitehorn
1848682c9e0fSNathan Whitehorncf_header_list="unctrl.h ncurses/unctrl.h ncursesw/unctrl.h"
1849682c9e0fSNathan Whitehorn
1850*a96ef450SBaptiste Daroussincase "${cf_cv_ncurses_header:-curses.h}" in
1851f4f33ea0SBaptiste Daroussin(*/*)
1852*a96ef450SBaptiste Daroussin	cf_header_item=`echo "${cf_cv_ncurses_header:-curses.h}" | sed -e 's%\..*%%' -e 's%/.*%/%'`unctrl.h
1853682c9e0fSNathan Whitehorn	cf_header_list="$cf_header_item $cf_header_list"
1854682c9e0fSNathan Whitehorn	;;
1855682c9e0fSNathan Whitehornesac
1856682c9e0fSNathan Whitehorn
1857682c9e0fSNathan Whitehornfor cf_header in $cf_header_list
1858682c9e0fSNathan Whitehorndo
1859682c9e0fSNathan Whitehorn	AC_TRY_COMPILE([
1860682c9e0fSNathan Whitehorn#include <${cf_cv_ncurses_header:-curses.h}>
1861682c9e0fSNathan Whitehorn#include <${cf_header}>],
1862*a96ef450SBaptiste Daroussin	[WINDOW *x; (void)x],
1863682c9e0fSNathan Whitehorn	[cf_cv_unctrl_header=$cf_header
1864682c9e0fSNathan Whitehorn	 break],
1865682c9e0fSNathan Whitehorn	[cf_cv_unctrl_header=no])
1866682c9e0fSNathan Whitehorndone
1867f4f33ea0SBaptiste Daroussin])
1868682c9e0fSNathan Whitehorn
1869*a96ef450SBaptiste Daroussincase "$cf_cv_unctrl_header" in
1870f4f33ea0SBaptiste Daroussin(no)
1871682c9e0fSNathan Whitehorn	AC_MSG_WARN(unctrl.h header not found)
1872682c9e0fSNathan Whitehorn	;;
1873682c9e0fSNathan Whitehornesac
1874682c9e0fSNathan Whitehorn
1875*a96ef450SBaptiste Daroussincase "$cf_cv_unctrl_header" in
1876f4f33ea0SBaptiste Daroussin(unctrl.h)
18772a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_UNCTRL_H,1,[Define to 1 if we have unctrl.h])
1878682c9e0fSNathan Whitehorn	;;
1879f4f33ea0SBaptiste Daroussin(ncurses/unctrl.h)
18802a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_NCURSES_UNCTRL_H,1,[Define to 1 if we have ncurses/unctrl.h])
1881682c9e0fSNathan Whitehorn	;;
1882f4f33ea0SBaptiste Daroussin(ncursesw/unctrl.h)
18832a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_NCURSESW_UNCTRL_H,1,[Define to 1 if we have ncursesw/unctrl.h])
1884682c9e0fSNathan Whitehorn	;;
1885682c9e0fSNathan Whitehornesac
1886682c9e0fSNathan Whitehorn])dnl
1887682c9e0fSNathan Whitehorndnl ---------------------------------------------------------------------------
1888*a96ef450SBaptiste Daroussindnl CF_CURSES_WACS_MAP version: 8 updated: 2021/01/04 19:45:09
18897a1c0d96SNathan Whitehorndnl ------------------
18907a1c0d96SNathan Whitehorndnl Check for likely values of wacs_map[].
18917a1c0d96SNathan WhitehornAC_DEFUN([CF_CURSES_WACS_MAP],
18927a1c0d96SNathan Whitehorn[
18937a1c0d96SNathan WhitehornAC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
18947a1c0d96SNathan Whitehorn	cf_cv_curses_wacs_map=unknown
18957a1c0d96SNathan Whitehorn	for name in wacs_map _wacs_map __wacs_map _nc_wacs _wacs_char
18967a1c0d96SNathan Whitehorn	do
18977a1c0d96SNathan Whitehorn	AC_TRY_LINK([
18987a1c0d96SNathan Whitehorn#ifndef _XOPEN_SOURCE_EXTENDED
18997a1c0d96SNathan Whitehorn#define _XOPEN_SOURCE_EXTENDED
19007a1c0d96SNathan Whitehorn#endif
19017a1c0d96SNathan Whitehorn#include <${cf_cv_ncurses_header:-curses.h}>],
1902*a96ef450SBaptiste Daroussin	[void *foo = &(${name}['k']); (void)foo],
19037a1c0d96SNathan Whitehorn	[cf_cv_curses_wacs_map=$name
19047a1c0d96SNathan Whitehorn	 break])
19057a1c0d96SNathan Whitehorn	done])
19067a1c0d96SNathan Whitehorn
19072a3e3873SBaptiste Daroussintest "$cf_cv_curses_wacs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_WACS_ARRAY,$cf_cv_curses_wacs_map,[Define to name of (n)curses wide-character array])
19087a1c0d96SNathan Whitehorn])dnl
19097a1c0d96SNathan Whitehorndnl ---------------------------------------------------------------------------
1910*a96ef450SBaptiste Daroussindnl CF_CURSES_WACS_SYMBOLS version: 4 updated: 2021/01/04 19:45:09
19117a1c0d96SNathan Whitehorndnl ----------------------
19127a1c0d96SNathan Whitehorndnl Do a check to see if the WACS_xxx constants are defined compatibly with
19137a1c0d96SNathan Whitehorndnl X/Open Curses.  In particular, NetBSD's implementation of the WACS_xxx
19147a1c0d96SNathan Whitehorndnl constants is broken since those constants do not point to cchar_t's.
19157a1c0d96SNathan WhitehornAC_DEFUN([CF_CURSES_WACS_SYMBOLS],
19167a1c0d96SNathan Whitehorn[
19177a1c0d96SNathan WhitehornAC_REQUIRE([CF_CURSES_WACS_MAP])
19187a1c0d96SNathan Whitehorn
19197a1c0d96SNathan WhitehornAC_CACHE_CHECK(for wide alternate character constants, cf_cv_curses_wacs_symbols,[
19207a1c0d96SNathan Whitehorncf_cv_curses_wacs_symbols=no
19217a1c0d96SNathan Whitehornif test "$cf_cv_curses_wacs_map" != unknown
19227a1c0d96SNathan Whitehornthen
19237a1c0d96SNathan Whitehorn	AC_TRY_LINK([
19247a1c0d96SNathan Whitehorn#ifndef _XOPEN_SOURCE_EXTENDED
19257a1c0d96SNathan Whitehorn#define _XOPEN_SOURCE_EXTENDED
19267a1c0d96SNathan Whitehorn#endif
19277a1c0d96SNathan Whitehorn#include <${cf_cv_ncurses_header:-curses.h}>],
19287a1c0d96SNathan Whitehorn	[cchar_t *foo = WACS_PLUS;
1929*a96ef450SBaptiste Daroussin	 ${cf_cv_curses_wacs_map}['k'] = *WACS_PLUS; (void)foo],
19307a1c0d96SNathan Whitehorn	[cf_cv_curses_wacs_symbols=yes])
19317a1c0d96SNathan Whitehornelse
19327a1c0d96SNathan Whitehorn	AC_TRY_LINK([
19337a1c0d96SNathan Whitehorn#ifndef _XOPEN_SOURCE_EXTENDED
19347a1c0d96SNathan Whitehorn#define _XOPEN_SOURCE_EXTENDED
19357a1c0d96SNathan Whitehorn#endif
19367a1c0d96SNathan Whitehorn#include <${cf_cv_ncurses_header:-curses.h}>],
1937*a96ef450SBaptiste Daroussin	[cchar_t *foo = WACS_PLUS; (void)foo],
19387a1c0d96SNathan Whitehorn	[cf_cv_curses_wacs_symbols=yes])
19397a1c0d96SNathan Whitehornfi
19407a1c0d96SNathan Whitehorn])
19417a1c0d96SNathan Whitehorn
19422a3e3873SBaptiste Daroussintest "$cf_cv_curses_wacs_symbols" != no && AC_DEFINE(CURSES_WACS_SYMBOLS,1,[Define to 1 if (n)curses supports wide-character WACS_ symbols])
19432a3e3873SBaptiste Daroussin])dnl
19442a3e3873SBaptiste Daroussindnl ---------------------------------------------------------------------------
1945*a96ef450SBaptiste Daroussindnl CF_CURSES_WGETPARENT version: 4 updated: 2020/03/19 20:23:48
19462a3e3873SBaptiste Daroussindnl --------------------
19472a3e3873SBaptiste Daroussindnl Check for curses support for directly determining the parent of a given
19482a3e3873SBaptiste Daroussindnl window.  Some implementations make this difficult, so we provide for
19492a3e3873SBaptiste Daroussindnl defining an application-specific function that gives this functionality.
19502a3e3873SBaptiste Daroussindnl
19512a3e3873SBaptiste Daroussindnl $1 = name of function to use if the feature is missing
19522a3e3873SBaptiste DaroussinAC_DEFUN([CF_CURSES_WGETPARENT],[
19532a3e3873SBaptiste DaroussinCF_CURSES_FUNCS(wgetparent)
19542a3e3873SBaptiste Daroussinif test "x$cf_cv_func_wgetparent" != xyes
19552a3e3873SBaptiste Daroussinthen
19562a3e3873SBaptiste Daroussin	AC_MSG_CHECKING(if WINDOW has _parent member)
19572a3e3873SBaptiste Daroussin	AC_TRY_COMPILE([#include <${cf_cv_ncurses_header:-curses.h}>],
1958*a96ef450SBaptiste Daroussin		[WINDOW *p = stdscr->_parent; (void)p],
19592a3e3873SBaptiste Daroussin		[cf_window__parent=yes],
19602a3e3873SBaptiste Daroussin		[cf_window__parent=no])
19612a3e3873SBaptiste Daroussin	AC_MSG_RESULT($cf_window__parent)
19622a3e3873SBaptiste Daroussin	if test "$cf_window__parent" = yes
19632a3e3873SBaptiste Daroussin	then
19642a3e3873SBaptiste Daroussin		AC_DEFINE(HAVE_WINDOW__PARENT,1,[Define to 1 if WINDOW struct has _parent member])
19652a3e3873SBaptiste Daroussin	fi
19662a3e3873SBaptiste Daroussinfi
19677a1c0d96SNathan Whitehorn])dnl
19687a1c0d96SNathan Whitehorndnl ---------------------------------------------------------------------------
1969*a96ef450SBaptiste Daroussindnl CF_DIRNAME version: 5 updated: 2020/12/31 20:19:42
19704c8945a0SNathan Whitehorndnl ----------
19714c8945a0SNathan Whitehorndnl "dirname" is not portable, so we fake it with a shell script.
1972*a96ef450SBaptiste DaroussinAC_DEFUN([CF_DIRNAME],[$1=`echo "$2" | sed -e 's%/[[^/]]*$%%'`])dnl
19734c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
1974f4f33ea0SBaptiste Daroussindnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
19754c8945a0SNathan Whitehorndnl ---------------
19764c8945a0SNathan Whitehorndnl You can always use "make -n" to see the actual options, but it's hard to
19774c8945a0SNathan Whitehorndnl pick out/analyze warning messages when the compile-line is long.
19784c8945a0SNathan Whitehorndnl
19794c8945a0SNathan Whitehorndnl Sets:
19804c8945a0SNathan Whitehorndnl	ECHO_LT - symbol to control if libtool is verbose
19814c8945a0SNathan Whitehorndnl	ECHO_LD - symbol to prefix "cc -o" lines
19824c8945a0SNathan Whitehorndnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
19834c8945a0SNathan Whitehorndnl	SHOW_CC - symbol to put before explicit "cc -c" lines
19844c8945a0SNathan Whitehorndnl	ECHO_CC - symbol to put before any "cc" line
19854c8945a0SNathan Whitehorndnl
19864c8945a0SNathan WhitehornAC_DEFUN([CF_DISABLE_ECHO],[
19874c8945a0SNathan WhitehornAC_MSG_CHECKING(if you want to see long compiling messages)
19884c8945a0SNathan WhitehornCF_ARG_DISABLE(echo,
19892a3e3873SBaptiste Daroussin	[  --disable-echo          do not display "compiling" commands],
19904c8945a0SNathan Whitehorn	[
19914c8945a0SNathan Whitehorn	ECHO_LT='--silent'
19924c8945a0SNathan Whitehorn	ECHO_LD='@echo linking [$]@;'
19934c8945a0SNathan Whitehorn	RULE_CC='@echo compiling [$]<'
19944c8945a0SNathan Whitehorn	SHOW_CC='@echo compiling [$]@'
19954c8945a0SNathan Whitehorn	ECHO_CC='@'
19964c8945a0SNathan Whitehorn],[
19974c8945a0SNathan Whitehorn	ECHO_LT=''
19984c8945a0SNathan Whitehorn	ECHO_LD=''
19994c8945a0SNathan Whitehorn	RULE_CC=''
20004c8945a0SNathan Whitehorn	SHOW_CC=''
20014c8945a0SNathan Whitehorn	ECHO_CC=''
20024c8945a0SNathan Whitehorn])
20034c8945a0SNathan WhitehornAC_MSG_RESULT($enableval)
20044c8945a0SNathan WhitehornAC_SUBST(ECHO_LT)
20054c8945a0SNathan WhitehornAC_SUBST(ECHO_LD)
20064c8945a0SNathan WhitehornAC_SUBST(RULE_CC)
20074c8945a0SNathan WhitehornAC_SUBST(SHOW_CC)
20084c8945a0SNathan WhitehornAC_SUBST(ECHO_CC)
20094c8945a0SNathan Whitehorn])dnl
20104c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
2011f4f33ea0SBaptiste Daroussindnl CF_DISABLE_LIBTOOL_VERSION version: 3 updated: 2015/04/17 21:13:04
20127a1c0d96SNathan Whitehorndnl --------------------------
20137a1c0d96SNathan Whitehorndnl Check if we should use the libtool 1.5 feature "-version-number" instead of
20147a1c0d96SNathan Whitehorndnl the older "-version-info" feature.  The newer feature allows us to use
20157a1c0d96SNathan Whitehorndnl version numbering on shared libraries which make them compatible with
20167a1c0d96SNathan Whitehorndnl various systems.
20177a1c0d96SNathan WhitehornAC_DEFUN([CF_DISABLE_LIBTOOL_VERSION],
20187a1c0d96SNathan Whitehorn[
20197a1c0d96SNathan WhitehornAC_MSG_CHECKING(if libtool -version-number should be used)
20207a1c0d96SNathan WhitehornCF_ARG_DISABLE(libtool-version,
20217a1c0d96SNathan Whitehorn	[  --disable-libtool-version  enable to use libtool's incompatible naming scheme],
20227a1c0d96SNathan Whitehorn	[cf_libtool_version=no],
20237a1c0d96SNathan Whitehorn	[cf_libtool_version=yes])
20247a1c0d96SNathan WhitehornAC_MSG_RESULT($cf_libtool_version)
20257a1c0d96SNathan Whitehorn
20267a1c0d96SNathan Whitehornif test "$cf_libtool_version" = yes ; then
20277a1c0d96SNathan Whitehorn	LIBTOOL_VERSION="-version-number"
20287a1c0d96SNathan Whitehornelse
20297a1c0d96SNathan Whitehorn	LIBTOOL_VERSION="-version-info"
2030f4f33ea0SBaptiste Daroussin	case "x$VERSION" in
2031f4f33ea0SBaptiste Daroussin	(x)
2032f4f33ea0SBaptiste Daroussin		AC_MSG_WARN(VERSION was not set)
2033f4f33ea0SBaptiste Daroussin		;;
2034f4f33ea0SBaptiste Daroussin	(x*.*.*)
2035f4f33ea0SBaptiste Daroussin		ABI_VERSION="$VERSION"
2036f4f33ea0SBaptiste Daroussin		CF_VERBOSE(ABI_VERSION: $ABI_VERSION)
2037f4f33ea0SBaptiste Daroussin		;;
2038f4f33ea0SBaptiste Daroussin	(x*:*:*)
2039f4f33ea0SBaptiste Daroussin		ABI_VERSION=`echo "$VERSION" | sed -e 's/:/./g'`
2040f4f33ea0SBaptiste Daroussin		CF_VERBOSE(ABI_VERSION: $ABI_VERSION)
2041f4f33ea0SBaptiste Daroussin		;;
2042f4f33ea0SBaptiste Daroussin	(*)
2043f4f33ea0SBaptiste Daroussin		AC_MSG_WARN(unexpected VERSION value: $VERSION)
2044f4f33ea0SBaptiste Daroussin		;;
2045f4f33ea0SBaptiste Daroussin	esac
20467a1c0d96SNathan Whitehornfi
20477a1c0d96SNathan Whitehorn
2048f4f33ea0SBaptiste DaroussinAC_SUBST(ABI_VERSION)
20497a1c0d96SNathan WhitehornAC_SUBST(LIBTOOL_VERSION)
20507a1c0d96SNathan Whitehorn])dnl
20517a1c0d96SNathan Whitehorndnl ---------------------------------------------------------------------------
2052*a96ef450SBaptiste Daroussindnl CF_DISABLE_RPATH_HACK version: 3 updated: 2021/01/05 20:14:44
20534c8945a0SNathan Whitehorndnl ---------------------
20544c8945a0SNathan Whitehorndnl The rpath-hack makes it simpler to build programs, particularly with the
20554c8945a0SNathan Whitehorndnl *BSD ports which may have essential libraries in unusual places.  But it
20564c8945a0SNathan Whitehorndnl can interfere with building an executable for the base system.  Use this
20574c8945a0SNathan Whitehorndnl option in that case.
20584c8945a0SNathan WhitehornAC_DEFUN([CF_DISABLE_RPATH_HACK],
20594c8945a0SNathan Whitehorn[
2060682c9e0fSNathan WhitehornAC_MSG_CHECKING(if rpath-hack should be disabled)
20614c8945a0SNathan WhitehornCF_ARG_DISABLE(rpath-hack,
20624c8945a0SNathan Whitehorn	[  --disable-rpath-hack    don't add rpath options for additional libraries],
2063*a96ef450SBaptiste Daroussin	[enable_rpath_hack=no],
2064*a96ef450SBaptiste Daroussin	[enable_rpath_hack=yes])
2065*a96ef450SBaptiste Daroussindnl TODO - drop cf_disable_rpath_hack
2066*a96ef450SBaptiste Daroussinif test "x$enable_rpath_hack" = xno; then cf_disable_rpath_hack=yes; else cf_disable_rpath_hack=no; fi
20674c8945a0SNathan WhitehornAC_MSG_RESULT($cf_disable_rpath_hack)
2068*a96ef450SBaptiste Daroussin
2069*a96ef450SBaptiste Daroussinif test "$enable_rpath_hack" = yes ; then
20704c8945a0SNathan Whitehorn	CF_RPATH_HACK
20714c8945a0SNathan Whitehornfi
20724c8945a0SNathan Whitehorn])
20734c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
2074febdb468SDevin Teskednl CF_ENABLE_RPATH version: 2 updated: 2010/03/27 18:39:42
2075febdb468SDevin Teskednl ---------------
2076febdb468SDevin Teskednl Check if the rpath option should be used, setting cache variable
2077febdb468SDevin Teskednl cf_cv_enable_rpath if so.
2078febdb468SDevin TeskeAC_DEFUN([CF_ENABLE_RPATH],
2079febdb468SDevin Teske[
2080febdb468SDevin TeskeAC_MSG_CHECKING(if rpath option should be used)
2081febdb468SDevin TeskeAC_ARG_ENABLE(rpath,
2082febdb468SDevin Teske[  --enable-rpath          use rpath option when generating shared libraries],
2083febdb468SDevin Teske[cf_cv_enable_rpath=$enableval],
2084febdb468SDevin Teske[cf_cv_enable_rpath=no])
2085febdb468SDevin TeskeAC_MSG_RESULT($cf_cv_enable_rpath)
2086febdb468SDevin Teske])dnl
2087febdb468SDevin Teskednl ---------------------------------------------------------------------------
2088*a96ef450SBaptiste Daroussindnl CF_ENABLE_WARNINGS version: 9 updated: 2021/01/05 19:40:50
2089*a96ef450SBaptiste Daroussindnl ------------------
2090*a96ef450SBaptiste Daroussindnl Configure-option to enable gcc warnings
2091*a96ef450SBaptiste Daroussindnl
2092*a96ef450SBaptiste Daroussindnl $1 = extra options to add, if supported
2093*a96ef450SBaptiste Daroussindnl $2 = option for checking attributes.  By default, this is done when
2094*a96ef450SBaptiste Daroussindnl      warnings are enabled.  For other values:
2095*a96ef450SBaptiste Daroussindnl      yes: always do this, e.g., to use in generated library-headers
2096*a96ef450SBaptiste Daroussindnl      no: never do this
2097*a96ef450SBaptiste DaroussinAC_DEFUN([CF_ENABLE_WARNINGS],[
2098*a96ef450SBaptiste Daroussinif test "$GCC" = yes || test "$GXX" = yes
2099*a96ef450SBaptiste Daroussinthen
2100*a96ef450SBaptiste DaroussinCF_FIX_WARNINGS(CFLAGS)
2101*a96ef450SBaptiste DaroussinCF_FIX_WARNINGS(CPPFLAGS)
2102*a96ef450SBaptiste DaroussinCF_FIX_WARNINGS(LDFLAGS)
2103*a96ef450SBaptiste DaroussinAC_MSG_CHECKING(if you want to turn on gcc warnings)
2104*a96ef450SBaptiste DaroussinCF_ARG_ENABLE(warnings,
2105*a96ef450SBaptiste Daroussin	[  --enable-warnings       test: turn on gcc compiler warnings],
2106*a96ef450SBaptiste Daroussin	[enable_warnings=yes],
2107*a96ef450SBaptiste Daroussin	[enable_warnings=no])
2108*a96ef450SBaptiste DaroussinAC_MSG_RESULT($enable_warnings)
2109*a96ef450SBaptiste Daroussinif test "$enable_warnings" = "yes"
2110*a96ef450SBaptiste Daroussinthen
2111*a96ef450SBaptiste Daroussin	ifelse($2,,[CF_GCC_ATTRIBUTES])
2112*a96ef450SBaptiste Daroussin	CF_GCC_WARNINGS($1)
2113*a96ef450SBaptiste Daroussinfi
2114*a96ef450SBaptiste Daroussinifelse($2,yes,[CF_GCC_ATTRIBUTES])
2115*a96ef450SBaptiste Daroussinfi
2116*a96ef450SBaptiste Daroussin])dnl
2117*a96ef450SBaptiste Daroussindnl ---------------------------------------------------------------------------
2118*a96ef450SBaptiste Daroussindnl CF_FIND_LIBRARY version: 11 updated: 2021/01/02 09:31:20
21194c8945a0SNathan Whitehorndnl ---------------
21204c8945a0SNathan Whitehorndnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
21214c8945a0SNathan Whitehorndnl prefer a standard location, and use -L options only if we do not find the
21224c8945a0SNathan Whitehorndnl library in the standard library location(s).
21234c8945a0SNathan Whitehorndnl	$1 = library name
21244c8945a0SNathan Whitehorndnl	$2 = library class, usually the same as library name
21254c8945a0SNathan Whitehorndnl	$3 = includes
21264c8945a0SNathan Whitehorndnl	$4 = code fragment to compile/link
21274c8945a0SNathan Whitehorndnl	$5 = corresponding function-name
21284c8945a0SNathan Whitehorndnl	$6 = flag, nonnull if failure should not cause an error-exit
21294c8945a0SNathan Whitehorndnl
21304c8945a0SNathan Whitehorndnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
21314c8945a0SNathan Whitehorndnl to use a -L option.
21324c8945a0SNathan WhitehornAC_DEFUN([CF_FIND_LIBRARY],
21334c8945a0SNathan Whitehorn[
2134*a96ef450SBaptiste Daroussin	eval 'cf_cv_have_lib_'"$1"'=no'
21354c8945a0SNathan Whitehorn	cf_libdir=""
21364c8945a0SNathan Whitehorn	AC_CHECK_FUNC($5,
2137*a96ef450SBaptiste Daroussin		eval 'cf_cv_have_lib_'"$1"'=yes',[
21384c8945a0SNathan Whitehorn		cf_save_LIBS="$LIBS"
21394c8945a0SNathan Whitehorn		AC_MSG_CHECKING(for $5 in -l$1)
21404c8945a0SNathan Whitehorn		LIBS="-l$1 $LIBS"
21414c8945a0SNathan Whitehorn		AC_TRY_LINK([$3],[$4],
21424c8945a0SNathan Whitehorn			[AC_MSG_RESULT(yes)
2143*a96ef450SBaptiste Daroussin			 eval 'cf_cv_have_lib_'"$1"'=yes'
21444c8945a0SNathan Whitehorn			],
21454c8945a0SNathan Whitehorn			[AC_MSG_RESULT(no)
21464c8945a0SNathan Whitehorn			CF_LIBRARY_PATH(cf_search,$2)
21474c8945a0SNathan Whitehorn			for cf_libdir in $cf_search
21484c8945a0SNathan Whitehorn			do
21494c8945a0SNathan Whitehorn				AC_MSG_CHECKING(for -l$1 in $cf_libdir)
21504c8945a0SNathan Whitehorn				LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
21514c8945a0SNathan Whitehorn				AC_TRY_LINK([$3],[$4],
21524c8945a0SNathan Whitehorn					[AC_MSG_RESULT(yes)
2153*a96ef450SBaptiste Daroussin			 		 eval 'cf_cv_have_lib_'"$1"'=yes'
21544c8945a0SNathan Whitehorn					 break],
21554c8945a0SNathan Whitehorn					[AC_MSG_RESULT(no)
21564c8945a0SNathan Whitehorn					 LIBS="$cf_save_LIBS"])
21574c8945a0SNathan Whitehorn			done
21584c8945a0SNathan Whitehorn			])
21594c8945a0SNathan Whitehorn		])
2160*a96ef450SBaptiste Daroussineval 'cf_found_library="[$]cf_cv_have_lib_'"$1"\"
21614c8945a0SNathan Whitehornifelse($6,,[
2162*a96ef450SBaptiste Daroussinif test "$cf_found_library" = no ; then
21634c8945a0SNathan Whitehorn	AC_MSG_ERROR(Cannot link $1 library)
21644c8945a0SNathan Whitehornfi
21654c8945a0SNathan Whitehorn])
21664c8945a0SNathan Whitehorn])dnl
21674c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
2168*a96ef450SBaptiste Daroussindnl CF_FIND_LINKAGE version: 22 updated: 2020/12/31 20:19:42
21694c8945a0SNathan Whitehorndnl ---------------
21704c8945a0SNathan Whitehorndnl Find a library (specifically the linkage used in the code fragment),
21714c8945a0SNathan Whitehorndnl searching for it if it is not already in the library path.
21724c8945a0SNathan Whitehorndnl See also CF_ADD_SEARCHPATH.
21734c8945a0SNathan Whitehorndnl
21744c8945a0SNathan Whitehorndnl Parameters (4-on are optional):
21754c8945a0SNathan Whitehorndnl     $1 = headers for library entrypoint
21764c8945a0SNathan Whitehorndnl     $2 = code fragment for library entrypoint
21774c8945a0SNathan Whitehorndnl     $3 = the library name without the "-l" option or ".so" suffix.
21784c8945a0SNathan Whitehorndnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
21794c8945a0SNathan Whitehorndnl     $5 = action to perform if not successful
21804c8945a0SNathan Whitehorndnl     $6 = module name, if not the same as the library name
21814c8945a0SNathan Whitehorndnl     $7 = extra libraries
21824c8945a0SNathan Whitehorndnl
21834c8945a0SNathan Whitehorndnl Sets these variables:
21844c8945a0SNathan Whitehorndnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
21854c8945a0SNathan Whitehorndnl     $cf_cv_header_path_$3 - include-directory if needed
21864c8945a0SNathan Whitehorndnl     $cf_cv_library_path_$3 - library-directory if needed
21874c8945a0SNathan Whitehorndnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
21884c8945a0SNathan WhitehornAC_DEFUN([CF_FIND_LINKAGE],[
21894c8945a0SNathan Whitehorn
21904c8945a0SNathan Whitehorn# If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
21914c8945a0SNathan Whitehorn# will be set on completion of the AC_TRY_LINK below.
21924c8945a0SNathan Whitehorncf_cv_header_path_$3=
21934c8945a0SNathan Whitehorncf_cv_library_path_$3=
21944c8945a0SNathan Whitehorn
21954c8945a0SNathan WhitehornCF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
21964c8945a0SNathan Whitehorn
21977a1c0d96SNathan Whitehorncf_save_LIBS="$LIBS"
21987a1c0d96SNathan Whitehorn
21994c8945a0SNathan WhitehornAC_TRY_LINK([$1],[$2],[
22004c8945a0SNathan Whitehorn	cf_cv_find_linkage_$3=yes
22017a1c0d96SNathan Whitehorn	cf_cv_header_path_$3=/usr/include
22027a1c0d96SNathan Whitehorn	cf_cv_library_path_$3=/usr/lib
22034c8945a0SNathan Whitehorn],[
22044c8945a0SNathan Whitehorn
22054c8945a0SNathan WhitehornLIBS="-l$3 $7 $cf_save_LIBS"
22064c8945a0SNathan Whitehorn
22074c8945a0SNathan WhitehornAC_TRY_LINK([$1],[$2],[
22084c8945a0SNathan Whitehorn	cf_cv_find_linkage_$3=yes
22097a1c0d96SNathan Whitehorn	cf_cv_header_path_$3=/usr/include
22107a1c0d96SNathan Whitehorn	cf_cv_library_path_$3=/usr/lib
22114c8945a0SNathan Whitehorn	cf_cv_library_file_$3="-l$3"
22124c8945a0SNathan Whitehorn],[
22134c8945a0SNathan Whitehorn	cf_cv_find_linkage_$3=no
22144c8945a0SNathan Whitehorn	LIBS="$cf_save_LIBS"
22154c8945a0SNathan Whitehorn
22164c8945a0SNathan Whitehorn	CF_VERBOSE(find linkage for $3 library)
22174c8945a0SNathan Whitehorn	CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
22184c8945a0SNathan Whitehorn
22194c8945a0SNathan Whitehorn	cf_save_CPPFLAGS="$CPPFLAGS"
22204c8945a0SNathan Whitehorn	cf_test_CPPFLAGS="$CPPFLAGS"
22214c8945a0SNathan Whitehorn
22224c8945a0SNathan Whitehorn	CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
22234c8945a0SNathan Whitehorn	for cf_cv_header_path_$3 in $cf_search
22244c8945a0SNathan Whitehorn	do
2225*a96ef450SBaptiste Daroussin		if test -d "$cf_cv_header_path_$3" ; then
22264c8945a0SNathan Whitehorn			CF_VERBOSE(... testing $cf_cv_header_path_$3)
2227f4f33ea0SBaptiste Daroussin			CPPFLAGS="$cf_save_CPPFLAGS"
2228f4f33ea0SBaptiste Daroussin			CF_APPEND_TEXT(CPPFLAGS,-I$cf_cv_header_path_$3)
22294c8945a0SNathan Whitehorn			AC_TRY_COMPILE([$1],[$2],[
22304c8945a0SNathan Whitehorn				CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
22314c8945a0SNathan Whitehorn				cf_cv_find_linkage_$3=maybe
22324c8945a0SNathan Whitehorn				cf_test_CPPFLAGS="$CPPFLAGS"
22334c8945a0SNathan Whitehorn				break],[
22344c8945a0SNathan Whitehorn				CPPFLAGS="$cf_save_CPPFLAGS"
22354c8945a0SNathan Whitehorn				])
22364c8945a0SNathan Whitehorn		fi
22374c8945a0SNathan Whitehorn	done
22384c8945a0SNathan Whitehorn
22394c8945a0SNathan Whitehorn	if test "$cf_cv_find_linkage_$3" = maybe ; then
22404c8945a0SNathan Whitehorn
22414c8945a0SNathan Whitehorn		CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
22424c8945a0SNathan Whitehorn
22434c8945a0SNathan Whitehorn		cf_save_LIBS="$LIBS"
22444c8945a0SNathan Whitehorn		cf_save_LDFLAGS="$LDFLAGS"
22454c8945a0SNathan Whitehorn
22464c8945a0SNathan Whitehorn		ifelse([$6],,,[
22474c8945a0SNathan Whitehorn		CPPFLAGS="$cf_test_CPPFLAGS"
22484c8945a0SNathan Whitehorn		LIBS="-l$3 $7 $cf_save_LIBS"
22494c8945a0SNathan Whitehorn		AC_TRY_LINK([$1],[$2],[
22504c8945a0SNathan Whitehorn			CF_VERBOSE(... found $3 library in system)
22514c8945a0SNathan Whitehorn			cf_cv_find_linkage_$3=yes])
22524c8945a0SNathan Whitehorn			CPPFLAGS="$cf_save_CPPFLAGS"
22534c8945a0SNathan Whitehorn			LIBS="$cf_save_LIBS"
22544c8945a0SNathan Whitehorn			])
22554c8945a0SNathan Whitehorn
22564c8945a0SNathan Whitehorn		if test "$cf_cv_find_linkage_$3" != yes ; then
22574c8945a0SNathan Whitehorn			CF_LIBRARY_PATH(cf_search,$3)
22584c8945a0SNathan Whitehorn			for cf_cv_library_path_$3 in $cf_search
22594c8945a0SNathan Whitehorn			do
2260*a96ef450SBaptiste Daroussin				if test -d "$cf_cv_library_path_$3" ; then
22614c8945a0SNathan Whitehorn					CF_VERBOSE(... testing $cf_cv_library_path_$3)
22624c8945a0SNathan Whitehorn					CPPFLAGS="$cf_test_CPPFLAGS"
22634c8945a0SNathan Whitehorn					LIBS="-l$3 $7 $cf_save_LIBS"
22644c8945a0SNathan Whitehorn					LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
22654c8945a0SNathan Whitehorn					AC_TRY_LINK([$1],[$2],[
22664c8945a0SNathan Whitehorn					CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
22674c8945a0SNathan Whitehorn					cf_cv_find_linkage_$3=yes
22684c8945a0SNathan Whitehorn					cf_cv_library_file_$3="-l$3"
22694c8945a0SNathan Whitehorn					break],[
22704c8945a0SNathan Whitehorn					CPPFLAGS="$cf_save_CPPFLAGS"
22714c8945a0SNathan Whitehorn					LIBS="$cf_save_LIBS"
22724c8945a0SNathan Whitehorn					LDFLAGS="$cf_save_LDFLAGS"
22734c8945a0SNathan Whitehorn					])
22744c8945a0SNathan Whitehorn				fi
22754c8945a0SNathan Whitehorn			done
22764c8945a0SNathan Whitehorn			CPPFLAGS="$cf_save_CPPFLAGS"
22774c8945a0SNathan Whitehorn			LDFLAGS="$cf_save_LDFLAGS"
22784c8945a0SNathan Whitehorn		fi
22794c8945a0SNathan Whitehorn
22804c8945a0SNathan Whitehorn	else
22814c8945a0SNathan Whitehorn		cf_cv_find_linkage_$3=no
22824c8945a0SNathan Whitehorn	fi
22834c8945a0SNathan Whitehorn	],$7)
22844c8945a0SNathan Whitehorn])
22854c8945a0SNathan Whitehorn
22867a1c0d96SNathan WhitehornLIBS="$cf_save_LIBS"
22877a1c0d96SNathan Whitehorn
22884c8945a0SNathan Whitehornif test "$cf_cv_find_linkage_$3" = yes ; then
22894c8945a0SNathan Whitehornifelse([$4],,[
22904c8945a0SNathan Whitehorn	CF_ADD_INCDIR($cf_cv_header_path_$3)
22914c8945a0SNathan Whitehorn	CF_ADD_LIBDIR($cf_cv_library_path_$3)
22927a1c0d96SNathan Whitehorn	CF_ADD_LIB($3)
22934c8945a0SNathan Whitehorn],[$4])
22944c8945a0SNathan Whitehornelse
22954c8945a0SNathan Whitehornifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
22964c8945a0SNathan Whitehornfi
22974c8945a0SNathan Whitehorn])dnl
22984c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
2299*a96ef450SBaptiste Daroussindnl CF_FIX_WARNINGS version: 3 updated: 2020/12/31 18:40:20
2300*a96ef450SBaptiste Daroussindnl ---------------
2301*a96ef450SBaptiste Daroussindnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc.  Any of gcc's
2302*a96ef450SBaptiste Daroussindnl "-Werror" flags can interfere with configure-checks.  Those go into
2303*a96ef450SBaptiste Daroussindnl EXTRA_CFLAGS.
2304*a96ef450SBaptiste Daroussindnl
2305*a96ef450SBaptiste Daroussindnl $1 = variable name to repair
2306*a96ef450SBaptiste Daroussindefine([CF_FIX_WARNINGS],[
2307*a96ef450SBaptiste Daroussinif test "$GCC" = yes || test "$GXX" = yes
2308*a96ef450SBaptiste Daroussinthen
2309*a96ef450SBaptiste Daroussin	case [$]$1 in
2310*a96ef450SBaptiste Daroussin	(*-Werror=*)
2311*a96ef450SBaptiste Daroussin		CF_VERBOSE(repairing $1: [$]$1)
2312*a96ef450SBaptiste Daroussin		cf_temp_flags=
2313*a96ef450SBaptiste Daroussin		for cf_temp_scan in [$]$1
2314*a96ef450SBaptiste Daroussin		do
2315*a96ef450SBaptiste Daroussin			case "x$cf_temp_scan" in
2316*a96ef450SBaptiste Daroussin			(x-Werror=*)
2317*a96ef450SBaptiste Daroussin				CF_APPEND_TEXT(EXTRA_CFLAGS,$cf_temp_scan)
2318*a96ef450SBaptiste Daroussin				;;
2319*a96ef450SBaptiste Daroussin			(*)
2320*a96ef450SBaptiste Daroussin				CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
2321*a96ef450SBaptiste Daroussin				;;
2322*a96ef450SBaptiste Daroussin			esac
2323*a96ef450SBaptiste Daroussin		done
2324*a96ef450SBaptiste Daroussin		$1="$cf_temp_flags"
2325*a96ef450SBaptiste Daroussin		CF_VERBOSE(... fixed [$]$1)
2326*a96ef450SBaptiste Daroussin		CF_VERBOSE(... extra $EXTRA_CFLAGS)
2327*a96ef450SBaptiste Daroussin		;;
2328*a96ef450SBaptiste Daroussin	esac
2329*a96ef450SBaptiste Daroussinfi
2330*a96ef450SBaptiste DaroussinAC_SUBST(EXTRA_CFLAGS)
2331*a96ef450SBaptiste Daroussin])dnl
2332*a96ef450SBaptiste Daroussindnl ---------------------------------------------------------------------------
2333febdb468SDevin Teskednl CF_FORGET_TOOL version: 1 updated: 2013/04/06 18:03:09
2334febdb468SDevin Teskednl --------------
2335febdb468SDevin Teskednl Forget that we saw the given tool.
2336febdb468SDevin TeskeAC_DEFUN([CF_FORGET_TOOL],[
2337febdb468SDevin Teskeunset ac_cv_prog_ac_ct_$1
2338febdb468SDevin Teskeunset ac_ct_$1
2339febdb468SDevin Teskeunset $1
2340febdb468SDevin Teske])dnl
2341febdb468SDevin Teskednl ---------------------------------------------------------------------------
2342*a96ef450SBaptiste Daroussindnl CF_FUNC_WAIT version: 4 updated: 2021/01/02 09:31:20
23434c8945a0SNathan Whitehorndnl ------------
23444c8945a0SNathan Whitehorndnl Test for the presence of <sys/wait.h>, 'union wait', arg-type of 'wait()'
23454c8945a0SNathan Whitehorndnl and/or 'waitpid()'.
23464c8945a0SNathan Whitehorndnl
23474c8945a0SNathan Whitehorndnl Note that we cannot simply grep for 'union wait' in the wait.h file,
23484c8945a0SNathan Whitehorndnl because some Posix systems turn this on only when a BSD variable is
23494c8945a0SNathan Whitehorndnl defined.
23504c8945a0SNathan Whitehorndnl
23514c8945a0SNathan Whitehorndnl I don't use AC_HEADER_SYS_WAIT, because it defines HAVE_SYS_WAIT_H, which
23524c8945a0SNathan Whitehorndnl would conflict with an attempt to test that header directly.
23534c8945a0SNathan Whitehorndnl
23544c8945a0SNathan WhitehornAC_DEFUN([CF_FUNC_WAIT],
23554c8945a0SNathan Whitehorn[
23564c8945a0SNathan WhitehornAC_REQUIRE([CF_UNION_WAIT])
2357*a96ef450SBaptiste Daroussinif test "$cf_cv_type_unionwait" = yes; then
23584c8945a0SNathan Whitehorn
23594c8945a0SNathan Whitehorn	AC_MSG_CHECKING(if union wait can be used as wait-arg)
23604c8945a0SNathan Whitehorn	AC_CACHE_VAL(cf_cv_arg_union_wait,[
23614c8945a0SNathan Whitehorn		AC_TRY_COMPILE($cf_wait_headers,
23624c8945a0SNathan Whitehorn 			[union wait x; wait(&x)],
23634c8945a0SNathan Whitehorn			[cf_cv_arg_union_wait=yes],
23644c8945a0SNathan Whitehorn			[cf_cv_arg_union_wait=no])
23654c8945a0SNathan Whitehorn		])
23664c8945a0SNathan Whitehorn	AC_MSG_RESULT($cf_cv_arg_union_wait)
2367*a96ef450SBaptiste Daroussin	test "$cf_cv_arg_union_wait" = yes && AC_DEFINE(WAIT_USES_UNION,1,[Define to 1 if wait() uses a union parameter])
23684c8945a0SNathan Whitehorn
23694c8945a0SNathan Whitehorn	AC_MSG_CHECKING(if union wait can be used as waitpid-arg)
23704c8945a0SNathan Whitehorn	AC_CACHE_VAL(cf_cv_arg_union_waitpid,[
23714c8945a0SNathan Whitehorn		AC_TRY_COMPILE($cf_wait_headers,
23724c8945a0SNathan Whitehorn 			[union wait x; waitpid(0, &x, 0)],
23734c8945a0SNathan Whitehorn			[cf_cv_arg_union_waitpid=yes],
23744c8945a0SNathan Whitehorn			[cf_cv_arg_union_waitpid=no])
23754c8945a0SNathan Whitehorn		])
23764c8945a0SNathan Whitehorn	AC_MSG_RESULT($cf_cv_arg_union_waitpid)
2377*a96ef450SBaptiste Daroussin	test "$cf_cv_arg_union_waitpid" = yes && AC_DEFINE(WAITPID_USES_UNION,1,[Define to 1 if waitpid() uses a union parameter])
23784c8945a0SNathan Whitehorn
23794c8945a0SNathan Whitehornfi
23804c8945a0SNathan Whitehorn])dnl
23814c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
2382*a96ef450SBaptiste Daroussindnl CF_GCC_ATTRIBUTES version: 23 updated: 2021/01/03 18:30:50
23834c8945a0SNathan Whitehorndnl -----------------
23844c8945a0SNathan Whitehorndnl Test for availability of useful gcc __attribute__ directives to quiet
23854c8945a0SNathan Whitehorndnl compiler warnings.  Though useful, not all are supported -- and contrary
23864c8945a0SNathan Whitehorndnl to documentation, unrecognized directives cause older compilers to barf.
23874c8945a0SNathan WhitehornAC_DEFUN([CF_GCC_ATTRIBUTES],
2388*a96ef450SBaptiste Daroussin[AC_REQUIRE([AC_PROG_FGREP])dnl
2389*a96ef450SBaptiste Daroussin
2390*a96ef450SBaptiste Daroussinif test "$GCC" = yes || test "$GXX" = yes
23914c8945a0SNathan Whitehornthen
23924c8945a0SNathan Whitehorncat > conftest.i <<EOF
23934c8945a0SNathan Whitehorn#ifndef GCC_PRINTF
23944c8945a0SNathan Whitehorn#define GCC_PRINTF 0
23954c8945a0SNathan Whitehorn#endif
23964c8945a0SNathan Whitehorn#ifndef GCC_SCANF
23974c8945a0SNathan Whitehorn#define GCC_SCANF 0
23984c8945a0SNathan Whitehorn#endif
23994c8945a0SNathan Whitehorn#ifndef GCC_NORETURN
24004c8945a0SNathan Whitehorn#define GCC_NORETURN /* nothing */
24014c8945a0SNathan Whitehorn#endif
24024c8945a0SNathan Whitehorn#ifndef GCC_UNUSED
24034c8945a0SNathan Whitehorn#define GCC_UNUSED /* nothing */
24044c8945a0SNathan Whitehorn#endif
24054c8945a0SNathan WhitehornEOF
24064c8945a0SNathan Whitehornif test "$GCC" = yes
24074c8945a0SNathan Whitehornthen
24084c8945a0SNathan Whitehorn	AC_CHECKING([for $CC __attribute__ directives])
2409*a96ef450SBaptiste Daroussincat > "conftest.$ac_ext" <<EOF
24107a1c0d96SNathan Whitehorn#line __oline__ "${as_me:-configure}"
24114c8945a0SNathan Whitehorn#include "confdefs.h"
24124c8945a0SNathan Whitehorn#include "conftest.h"
24134c8945a0SNathan Whitehorn#include "conftest.i"
24144c8945a0SNathan Whitehorn#if	GCC_PRINTF
24154c8945a0SNathan Whitehorn#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
24164c8945a0SNathan Whitehorn#else
24174c8945a0SNathan Whitehorn#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
24184c8945a0SNathan Whitehorn#endif
24194c8945a0SNathan Whitehorn#if	GCC_SCANF
24204c8945a0SNathan Whitehorn#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
24214c8945a0SNathan Whitehorn#else
24224c8945a0SNathan Whitehorn#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
24234c8945a0SNathan Whitehorn#endif
24244c8945a0SNathan Whitehornextern void wow(char *,...) GCC_SCANFLIKE(1,2);
24254c8945a0SNathan Whitehornextern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
24264c8945a0SNathan Whitehornextern void foo(void) GCC_NORETURN;
2427*a96ef450SBaptiste Daroussinint main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
24284c8945a0SNathan WhitehornEOF
24294c8945a0SNathan Whitehorn	cf_printf_attribute=no
24304c8945a0SNathan Whitehorn	cf_scanf_attribute=no
24314c8945a0SNathan Whitehorn	for cf_attribute in scanf printf unused noreturn
24324c8945a0SNathan Whitehorn	do
24334c8945a0SNathan Whitehorn		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
24344c8945a0SNathan Whitehorn		cf_directive="__attribute__(($cf_attribute))"
24354c8945a0SNathan Whitehorn		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
24364c8945a0SNathan Whitehorn
2437*a96ef450SBaptiste Daroussin		case "$cf_attribute" in
2438f4f33ea0SBaptiste Daroussin		(printf)
24394c8945a0SNathan Whitehorn			cf_printf_attribute=yes
24404c8945a0SNathan Whitehorn			cat >conftest.h <<EOF
24414c8945a0SNathan Whitehorn#define GCC_$cf_ATTRIBUTE 1
24424c8945a0SNathan WhitehornEOF
24434c8945a0SNathan Whitehorn			;;
2444f4f33ea0SBaptiste Daroussin		(scanf)
24454c8945a0SNathan Whitehorn			cf_scanf_attribute=yes
24464c8945a0SNathan Whitehorn			cat >conftest.h <<EOF
24474c8945a0SNathan Whitehorn#define GCC_$cf_ATTRIBUTE 1
24484c8945a0SNathan WhitehornEOF
24494c8945a0SNathan Whitehorn			;;
2450f4f33ea0SBaptiste Daroussin		(*)
24514c8945a0SNathan Whitehorn			cat >conftest.h <<EOF
24524c8945a0SNathan Whitehorn#define GCC_$cf_ATTRIBUTE $cf_directive
24534c8945a0SNathan WhitehornEOF
24544c8945a0SNathan Whitehorn			;;
24554c8945a0SNathan Whitehorn		esac
24564c8945a0SNathan Whitehorn
24574c8945a0SNathan Whitehorn		if AC_TRY_EVAL(ac_compile); then
24584c8945a0SNathan Whitehorn			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
24594c8945a0SNathan Whitehorn			cat conftest.h >>confdefs.h
2460*a96ef450SBaptiste Daroussin			case "$cf_attribute" in
2461f4f33ea0SBaptiste Daroussin			(noreturn)
24622a3e3873SBaptiste Daroussin				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
24632a3e3873SBaptiste Daroussin				;;
2464f4f33ea0SBaptiste Daroussin			(printf)
24652a3e3873SBaptiste Daroussin				cf_value='/* nothing */'
24662a3e3873SBaptiste Daroussin				if test "$cf_printf_attribute" != no ; then
24672a3e3873SBaptiste Daroussin					cf_value='__attribute__((format(printf,fmt,var)))'
24682a3e3873SBaptiste Daroussin					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
24694c8945a0SNathan Whitehorn				fi
24702a3e3873SBaptiste Daroussin				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
24714c8945a0SNathan Whitehorn				;;
2472f4f33ea0SBaptiste Daroussin			(scanf)
24732a3e3873SBaptiste Daroussin				cf_value='/* nothing */'
24742a3e3873SBaptiste Daroussin				if test "$cf_scanf_attribute" != no ; then
24752a3e3873SBaptiste Daroussin					cf_value='__attribute__((format(scanf,fmt,var)))'
24762a3e3873SBaptiste Daroussin					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
24774c8945a0SNathan Whitehorn				fi
24782a3e3873SBaptiste Daroussin				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
24792a3e3873SBaptiste Daroussin				;;
2480f4f33ea0SBaptiste Daroussin			(unused)
24812a3e3873SBaptiste Daroussin				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
24824c8945a0SNathan Whitehorn				;;
24834c8945a0SNathan Whitehorn			esac
24844c8945a0SNathan Whitehorn		fi
24854c8945a0SNathan Whitehorn	done
24864c8945a0SNathan Whitehornelse
2487*a96ef450SBaptiste Daroussin	${FGREP-fgrep} define conftest.i >>confdefs.h
24884c8945a0SNathan Whitehornfi
2489*a96ef450SBaptiste Daroussinrm -rf ./conftest*
24904c8945a0SNathan Whitehornfi
24914c8945a0SNathan Whitehorn])dnl
24924c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
2493*a96ef450SBaptiste Daroussindnl CF_GCC_VERSION version: 8 updated: 2019/09/07 13:38:36
24944c8945a0SNathan Whitehorndnl --------------
2495*a96ef450SBaptiste Daroussindnl Find version of gcc, and (because icc/clang pretend to be gcc without being
2496*a96ef450SBaptiste Daroussindnl compatible), attempt to determine if icc/clang is actually used.
24974c8945a0SNathan WhitehornAC_DEFUN([CF_GCC_VERSION],[
24984c8945a0SNathan WhitehornAC_REQUIRE([AC_PROG_CC])
24994c8945a0SNathan WhitehornGCC_VERSION=none
25004c8945a0SNathan Whitehornif test "$GCC" = yes ; then
25014c8945a0SNathan Whitehorn	AC_MSG_CHECKING(version of $CC)
25022a3e3873SBaptiste Daroussin	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
25034c8945a0SNathan Whitehorn	test -z "$GCC_VERSION" && GCC_VERSION=unknown
25044c8945a0SNathan Whitehorn	AC_MSG_RESULT($GCC_VERSION)
25054c8945a0SNathan Whitehornfi
2506*a96ef450SBaptiste DaroussinCF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
2507*a96ef450SBaptiste DaroussinCF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
25084c8945a0SNathan Whitehorn])dnl
25094c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
2510*a96ef450SBaptiste Daroussindnl CF_GCC_WARNINGS version: 41 updated: 2021/01/01 16:53:59
25114c8945a0SNathan Whitehorndnl ---------------
25124c8945a0SNathan Whitehorndnl Check if the compiler supports useful warning options.  There's a few that
25134c8945a0SNathan Whitehorndnl we don't use, simply because they're too noisy:
25144c8945a0SNathan Whitehorndnl
25154c8945a0SNathan Whitehorndnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
2516*a96ef450SBaptiste Daroussindnl	-Winline (usually not worthwhile)
25174c8945a0SNathan Whitehorndnl	-Wredundant-decls (system headers make this too noisy)
25184c8945a0SNathan Whitehorndnl	-Wtraditional (combines too many unrelated messages, only a few useful)
25194c8945a0SNathan Whitehorndnl	-Wwrite-strings (too noisy, but should review occasionally).  This
25204c8945a0SNathan Whitehorndnl		is enabled for ncurses using "--enable-const".
25214c8945a0SNathan Whitehorndnl	-pedantic
25224c8945a0SNathan Whitehorndnl
25234c8945a0SNathan Whitehorndnl Parameter:
25244c8945a0SNathan Whitehorndnl	$1 is an optional list of gcc warning flags that a particular
25254c8945a0SNathan Whitehorndnl		application might want to use, e.g., "no-unused" for
25264c8945a0SNathan Whitehorndnl		-Wno-unused
25274c8945a0SNathan Whitehorndnl Special:
25284c8945a0SNathan Whitehorndnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
25294c8945a0SNathan Whitehorndnl
25304c8945a0SNathan WhitehornAC_DEFUN([CF_GCC_WARNINGS],
25314c8945a0SNathan Whitehorn[
25324c8945a0SNathan WhitehornAC_REQUIRE([CF_GCC_VERSION])
2533*a96ef450SBaptiste Daroussinif test "x$have_x" = xyes; then CF_CONST_X_STRING fi
2534*a96ef450SBaptiste Daroussincat > "conftest.$ac_ext" <<EOF
25357a1c0d96SNathan Whitehorn#line __oline__ "${as_me:-configure}"
25364c8945a0SNathan Whitehornint main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
25374c8945a0SNathan WhitehornEOF
25384c8945a0SNathan Whitehornif test "$INTEL_COMPILER" = yes
25394c8945a0SNathan Whitehornthen
25404c8945a0SNathan Whitehorn# The "-wdXXX" options suppress warnings:
25414c8945a0SNathan Whitehorn# remark #1419: external declaration in primary source file
25424c8945a0SNathan Whitehorn# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
25434c8945a0SNathan Whitehorn# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
25444c8945a0SNathan Whitehorn# remark #193: zero used for undefined preprocessing identifier
25454c8945a0SNathan Whitehorn# remark #593: variable "curs_sb_left_arrow" was set but never used
25464c8945a0SNathan Whitehorn# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
25474c8945a0SNathan Whitehorn# remark #869: parameter "tw" was never referenced
25484c8945a0SNathan Whitehorn# remark #981: operands are evaluated in unspecified order
25494c8945a0SNathan Whitehorn# warning #279: controlling expression is constant
25504c8945a0SNathan Whitehorn
25514c8945a0SNathan Whitehorn	AC_CHECKING([for $CC warning options])
25524c8945a0SNathan Whitehorn	cf_save_CFLAGS="$CFLAGS"
2553*a96ef450SBaptiste Daroussin	EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
25544c8945a0SNathan Whitehorn	for cf_opt in \
25554c8945a0SNathan Whitehorn		wd1419 \
25564c8945a0SNathan Whitehorn		wd1683 \
25574c8945a0SNathan Whitehorn		wd1684 \
25584c8945a0SNathan Whitehorn		wd193 \
25594c8945a0SNathan Whitehorn		wd593 \
25604c8945a0SNathan Whitehorn		wd279 \
25614c8945a0SNathan Whitehorn		wd810 \
25624c8945a0SNathan Whitehorn		wd869 \
25634c8945a0SNathan Whitehorn		wd981
25644c8945a0SNathan Whitehorn	do
25654c8945a0SNathan Whitehorn		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
25664c8945a0SNathan Whitehorn		if AC_TRY_EVAL(ac_compile); then
25674c8945a0SNathan Whitehorn			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
25684c8945a0SNathan Whitehorn			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
25694c8945a0SNathan Whitehorn		fi
25704c8945a0SNathan Whitehorn	done
25714c8945a0SNathan Whitehorn	CFLAGS="$cf_save_CFLAGS"
2572*a96ef450SBaptiste Daroussinelif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
25734c8945a0SNathan Whitehornthen
25744c8945a0SNathan Whitehorn	AC_CHECKING([for $CC warning options])
25754c8945a0SNathan Whitehorn	cf_save_CFLAGS="$CFLAGS"
25764c8945a0SNathan Whitehorn	cf_warn_CONST=""
25774c8945a0SNathan Whitehorn	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
2578f4f33ea0SBaptiste Daroussin	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
2579f4f33ea0SBaptiste Daroussin	test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
25804c8945a0SNathan Whitehorn	for cf_opt in W Wall \
25814c8945a0SNathan Whitehorn		Wbad-function-cast \
25824c8945a0SNathan Whitehorn		Wcast-align \
25834c8945a0SNathan Whitehorn		Wcast-qual \
2584f4f33ea0SBaptiste Daroussin		Wdeclaration-after-statement \
2585f4f33ea0SBaptiste Daroussin		Wextra \
25864c8945a0SNathan Whitehorn		Winline \
25874c8945a0SNathan Whitehorn		Wmissing-declarations \
25884c8945a0SNathan Whitehorn		Wmissing-prototypes \
25894c8945a0SNathan Whitehorn		Wnested-externs \
25904c8945a0SNathan Whitehorn		Wpointer-arith \
25914c8945a0SNathan Whitehorn		Wshadow \
25924c8945a0SNathan Whitehorn		Wstrict-prototypes \
2593*a96ef450SBaptiste Daroussin		Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
25944c8945a0SNathan Whitehorn	do
25954c8945a0SNathan Whitehorn		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
25964c8945a0SNathan Whitehorn		if AC_TRY_EVAL(ac_compile); then
25974c8945a0SNathan Whitehorn			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
2598*a96ef450SBaptiste Daroussin			case "$cf_opt" in
2599f4f33ea0SBaptiste Daroussin			(Winline)
2600*a96ef450SBaptiste Daroussin				case "$GCC_VERSION" in
2601f4f33ea0SBaptiste Daroussin				([[34]].*)
26024c8945a0SNathan Whitehorn					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
26034c8945a0SNathan Whitehorn					continue;;
26044c8945a0SNathan Whitehorn				esac
26054c8945a0SNathan Whitehorn				;;
2606f4f33ea0SBaptiste Daroussin			(Wpointer-arith)
2607*a96ef450SBaptiste Daroussin				case "$GCC_VERSION" in
2608f4f33ea0SBaptiste Daroussin				([[12]].*)
26092a3e3873SBaptiste Daroussin					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
26102a3e3873SBaptiste Daroussin					continue;;
26112a3e3873SBaptiste Daroussin				esac
26122a3e3873SBaptiste Daroussin				;;
26134c8945a0SNathan Whitehorn			esac
26144c8945a0SNathan Whitehorn			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
26154c8945a0SNathan Whitehorn		fi
26164c8945a0SNathan Whitehorn	done
26174c8945a0SNathan Whitehorn	CFLAGS="$cf_save_CFLAGS"
26184c8945a0SNathan Whitehornfi
2619*a96ef450SBaptiste Daroussinrm -rf ./conftest*
26204c8945a0SNathan Whitehorn
26214c8945a0SNathan WhitehornAC_SUBST(EXTRA_CFLAGS)
26224c8945a0SNathan Whitehorn])dnl
26234c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
2624*a96ef450SBaptiste Daroussindnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
26254c8945a0SNathan Whitehorndnl -------------
26264c8945a0SNathan Whitehorndnl Check if we must define _GNU_SOURCE to get a reasonable value for
26274c8945a0SNathan Whitehorndnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
26284c8945a0SNathan Whitehorndnl (or misfeature) of glibc2, which breaks portability of many applications,
26294c8945a0SNathan Whitehorndnl since it is interwoven with GNU extensions.
26304c8945a0SNathan Whitehorndnl
26314c8945a0SNathan Whitehorndnl Well, yes we could work around it...
2632f4f33ea0SBaptiste Daroussindnl
2633f4f33ea0SBaptiste Daroussindnl Parameters:
2634f4f33ea0SBaptiste Daroussindnl	$1 is the nominal value for _XOPEN_SOURCE
26354c8945a0SNathan WhitehornAC_DEFUN([CF_GNU_SOURCE],
26364c8945a0SNathan Whitehorn[
2637f4f33ea0SBaptiste Daroussincf_gnu_xopen_source=ifelse($1,,500,$1)
2638f4f33ea0SBaptiste Daroussin
2639f4f33ea0SBaptiste DaroussinAC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
2640f4f33ea0SBaptiste DaroussinAC_TRY_COMPILE([#include <sys/types.h>],[
2641f4f33ea0SBaptiste Daroussin	#if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
2642f4f33ea0SBaptiste Daroussin		return 0;
2643*a96ef450SBaptiste Daroussin	#elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
2644*a96ef450SBaptiste Daroussin		return 0;
2645f4f33ea0SBaptiste Daroussin	#else
2646f4f33ea0SBaptiste Daroussin	#	error not GNU C library
2647f4f33ea0SBaptiste Daroussin	#endif],
2648f4f33ea0SBaptiste Daroussin	[cf_cv_gnu_library=yes],
2649f4f33ea0SBaptiste Daroussin	[cf_cv_gnu_library=no])
2650f4f33ea0SBaptiste Daroussin])
2651f4f33ea0SBaptiste Daroussin
2652f4f33ea0SBaptiste Daroussinif test x$cf_cv_gnu_library = xyes; then
2653f4f33ea0SBaptiste Daroussin
2654f4f33ea0SBaptiste Daroussin	# With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
2655*a96ef450SBaptiste Daroussin	# was changed to help a little.  newlib incorporated the change about 4
2656*a96ef450SBaptiste Daroussin	# years later.
2657f4f33ea0SBaptiste Daroussin	AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
2658f4f33ea0SBaptiste Daroussin		cf_save="$CPPFLAGS"
2659f4f33ea0SBaptiste Daroussin		CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
2660f4f33ea0SBaptiste Daroussin		AC_TRY_COMPILE([#include <sys/types.h>],[
2661f4f33ea0SBaptiste Daroussin			#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
2662f4f33ea0SBaptiste Daroussin				return 0;
2663*a96ef450SBaptiste Daroussin			#elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
2664*a96ef450SBaptiste Daroussin				return 0;
2665f4f33ea0SBaptiste Daroussin			#else
2666f4f33ea0SBaptiste Daroussin			#	error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
2667f4f33ea0SBaptiste Daroussin			#endif],
2668f4f33ea0SBaptiste Daroussin			[cf_cv_gnu_library_219=yes],
2669f4f33ea0SBaptiste Daroussin			[cf_cv_gnu_library_219=no])
2670f4f33ea0SBaptiste Daroussin		CPPFLAGS="$cf_save"
2671f4f33ea0SBaptiste Daroussin	])
2672f4f33ea0SBaptiste Daroussin
2673f4f33ea0SBaptiste Daroussin	if test "x$cf_cv_gnu_library_219" = xyes; then
2674f4f33ea0SBaptiste Daroussin		cf_save="$CPPFLAGS"
2675f4f33ea0SBaptiste Daroussin		AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
2676f4f33ea0SBaptiste Daroussin			CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
2677f4f33ea0SBaptiste Daroussin			AC_TRY_COMPILE([
2678f4f33ea0SBaptiste Daroussin				#include <limits.h>
2679f4f33ea0SBaptiste Daroussin				#include <sys/types.h>
2680f4f33ea0SBaptiste Daroussin				],[
2681f4f33ea0SBaptiste Daroussin				#if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
2682f4f33ea0SBaptiste Daroussin					return 0;
2683f4f33ea0SBaptiste Daroussin				#else
2684f4f33ea0SBaptiste Daroussin				#	error GNU C library is too old
2685f4f33ea0SBaptiste Daroussin				#endif],
2686f4f33ea0SBaptiste Daroussin				[cf_cv_gnu_dftsrc_219=yes],
2687f4f33ea0SBaptiste Daroussin				[cf_cv_gnu_dftsrc_219=no])
2688f4f33ea0SBaptiste Daroussin			])
2689f4f33ea0SBaptiste Daroussin		test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
2690f4f33ea0SBaptiste Daroussin	else
2691f4f33ea0SBaptiste Daroussin		cf_cv_gnu_dftsrc_219=maybe
2692f4f33ea0SBaptiste Daroussin	fi
2693f4f33ea0SBaptiste Daroussin
2694f4f33ea0SBaptiste Daroussin	if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
2695f4f33ea0SBaptiste Daroussin
26964c8945a0SNathan Whitehorn		AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
26974c8945a0SNathan Whitehorn		AC_TRY_COMPILE([#include <sys/types.h>],[
26984c8945a0SNathan Whitehorn			#ifndef _XOPEN_SOURCE
2699f4f33ea0SBaptiste Daroussin			#error	expected _XOPEN_SOURCE to be defined
27004c8945a0SNathan Whitehorn			#endif],
27014c8945a0SNathan Whitehorn			[cf_cv_gnu_source=no],
27024c8945a0SNathan Whitehorn			[cf_save="$CPPFLAGS"
2703f4f33ea0SBaptiste Daroussin			 CF_ADD_CFLAGS(-D_GNU_SOURCE)
27044c8945a0SNathan Whitehorn			 AC_TRY_COMPILE([#include <sys/types.h>],[
27054c8945a0SNathan Whitehorn				#ifdef _XOPEN_SOURCE
2706f4f33ea0SBaptiste Daroussin				#error	expected _XOPEN_SOURCE to be undefined
27074c8945a0SNathan Whitehorn				#endif],
27084c8945a0SNathan Whitehorn				[cf_cv_gnu_source=no],
27094c8945a0SNathan Whitehorn				[cf_cv_gnu_source=yes])
27104c8945a0SNathan Whitehorn			CPPFLAGS="$cf_save"
27114c8945a0SNathan Whitehorn			])
27124c8945a0SNathan Whitehorn		])
2713f4f33ea0SBaptiste Daroussin
2714f4f33ea0SBaptiste Daroussin		if test "$cf_cv_gnu_source" = yes
2715f4f33ea0SBaptiste Daroussin		then
2716f4f33ea0SBaptiste Daroussin		AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
2717f4f33ea0SBaptiste Daroussin			CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
2718f4f33ea0SBaptiste Daroussin			AC_TRY_COMPILE([#include <sys/types.h>],[
2719f4f33ea0SBaptiste Daroussin				#ifdef _DEFAULT_SOURCE
2720f4f33ea0SBaptiste Daroussin				#error	expected _DEFAULT_SOURCE to be undefined
2721f4f33ea0SBaptiste Daroussin				#endif],
2722f4f33ea0SBaptiste Daroussin				[cf_cv_default_source=no],
2723f4f33ea0SBaptiste Daroussin				[cf_cv_default_source=yes])
2724f4f33ea0SBaptiste Daroussin			])
2725f4f33ea0SBaptiste Daroussin			if test "$cf_cv_default_source" = yes
2726f4f33ea0SBaptiste Daroussin			then
2727f4f33ea0SBaptiste Daroussin				CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
2728f4f33ea0SBaptiste Daroussin			fi
2729f4f33ea0SBaptiste Daroussin		fi
2730f4f33ea0SBaptiste Daroussin	fi
2731f4f33ea0SBaptiste Daroussin
2732f4f33ea0SBaptiste Daroussinfi
27334c8945a0SNathan Whitehorn])dnl
27344c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
27354c8945a0SNathan Whitehorndnl CF_HEADERS_SH version: 1 updated: 2007/07/04 15:37:05
27364c8945a0SNathan Whitehorndnl -------------
27374c8945a0SNathan Whitehorndnl Setup variables needed to construct headers-sh
27384c8945a0SNathan WhitehornAC_DEFUN([CF_HEADERS_SH],[
27394c8945a0SNathan WhitehornPACKAGE_PREFIX=$1
27404c8945a0SNathan WhitehornPACKAGE_CONFIG=$2
27414c8945a0SNathan WhitehornAC_SUBST(PACKAGE_PREFIX)
27424c8945a0SNathan WhitehornAC_SUBST(PACKAGE_CONFIG)
27434c8945a0SNathan WhitehornEXTRA_OUTPUT="$EXTRA_OUTPUT headers-sh:$srcdir/headers-sh.in"
27444c8945a0SNathan Whitehorn])
27454c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
2746*a96ef450SBaptiste Daroussindnl CF_HEADER_PATH version: 15 updated: 2021/01/01 13:31:04
27474c8945a0SNathan Whitehorndnl --------------
27484c8945a0SNathan Whitehorndnl Construct a search-list of directories for a nonstandard header-file
27494c8945a0SNathan Whitehorndnl
27504c8945a0SNathan Whitehorndnl Parameters
27514c8945a0SNathan Whitehorndnl	$1 = the variable to return as result
27524c8945a0SNathan Whitehorndnl	$2 = the package name
27534c8945a0SNathan WhitehornAC_DEFUN([CF_HEADER_PATH],
27544c8945a0SNathan Whitehorn[
27554c8945a0SNathan Whitehorn$1=
27564c8945a0SNathan Whitehorn
27574c8945a0SNathan Whitehorn# collect the current set of include-directories from compiler flags
27584c8945a0SNathan Whitehorncf_header_path_list=""
27594c8945a0SNathan Whitehornif test -n "${CFLAGS}${CPPFLAGS}" ; then
27604c8945a0SNathan Whitehorn	for cf_header_path in $CPPFLAGS $CFLAGS
27614c8945a0SNathan Whitehorn	do
2762*a96ef450SBaptiste Daroussin		case "$cf_header_path" in
2763f4f33ea0SBaptiste Daroussin		(-I*)
27644c8945a0SNathan Whitehorn			cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
27657a1c0d96SNathan Whitehorn			CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
27667a1c0d96SNathan Whitehorn			cf_header_path_list="$cf_header_path_list [$]$1"
27674c8945a0SNathan Whitehorn			;;
27684c8945a0SNathan Whitehorn		esac
27694c8945a0SNathan Whitehorn	done
27704c8945a0SNathan Whitehornfi
27714c8945a0SNathan Whitehorn
27724c8945a0SNathan Whitehorn# add the variations for the package we are looking for
27734c8945a0SNathan WhitehornCF_SUBDIR_PATH($1,$2,include)
27744c8945a0SNathan Whitehorn
27754c8945a0SNathan Whitehorntest "$includedir" != NONE && \
27764c8945a0SNathan Whitehorntest "$includedir" != "/usr/include" && \
27774c8945a0SNathan Whitehorntest -d "$includedir" && {
2778*a96ef450SBaptiste Daroussin	test -d "$includedir" &&    $1="[$]$1 $includedir"
2779*a96ef450SBaptiste Daroussin	test -d "$includedir/$2" && $1="[$]$1 $includedir/$2"
27804c8945a0SNathan Whitehorn}
27814c8945a0SNathan Whitehorn
27824c8945a0SNathan Whitehorntest "$oldincludedir" != NONE && \
27834c8945a0SNathan Whitehorntest "$oldincludedir" != "/usr/include" && \
27844c8945a0SNathan Whitehorntest -d "$oldincludedir" && {
2785*a96ef450SBaptiste Daroussin	test -d "$oldincludedir"    && $1="[$]$1 $oldincludedir"
2786*a96ef450SBaptiste Daroussin	test -d "$oldincludedir/$2" && $1="[$]$1 $oldincludedir/$2"
27874c8945a0SNathan Whitehorn}
27884c8945a0SNathan Whitehorn
27894c8945a0SNathan Whitehorn$1="[$]$1 $cf_header_path_list"
27904c8945a0SNathan Whitehorn])dnl
27914c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
2792*a96ef450SBaptiste Daroussindnl CF_INTEL_COMPILER version: 8 updated: 2021/01/01 16:53:59
27934c8945a0SNathan Whitehorndnl -----------------
27944c8945a0SNathan Whitehorndnl Check if the given compiler is really the Intel compiler for Linux.  It
27954c8945a0SNathan Whitehorndnl tries to imitate gcc, but does not return an error when it finds a mismatch
27964c8945a0SNathan Whitehorndnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
27974c8945a0SNathan Whitehorndnl
27984c8945a0SNathan Whitehorndnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
27994c8945a0SNathan Whitehorndnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
28004c8945a0SNathan Whitehorndnl the wrappers for gcc and g++ warnings.
28014c8945a0SNathan Whitehorndnl
28024c8945a0SNathan Whitehorndnl $1 = GCC (default) or GXX
28034c8945a0SNathan Whitehorndnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
28044c8945a0SNathan Whitehorndnl $3 = CFLAGS (default) or CXXFLAGS
28054c8945a0SNathan WhitehornAC_DEFUN([CF_INTEL_COMPILER],[
2806febdb468SDevin TeskeAC_REQUIRE([AC_CANONICAL_HOST])
28077a1c0d96SNathan Whitehornifelse([$2],,INTEL_COMPILER,[$2])=no
28084c8945a0SNathan Whitehorn
28097a1c0d96SNathan Whitehornif test "$ifelse([$1],,[$1],GCC)" = yes ; then
2810*a96ef450SBaptiste Daroussin	case "$host_os" in
2811f4f33ea0SBaptiste Daroussin	(linux*|gnu*)
28127a1c0d96SNathan Whitehorn		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
28137a1c0d96SNathan Whitehorn		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
28147a1c0d96SNathan Whitehorn		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
28154c8945a0SNathan Whitehorn		AC_TRY_COMPILE([],[
28164c8945a0SNathan Whitehorn#ifdef __INTEL_COMPILER
28174c8945a0SNathan Whitehorn#else
28184c8945a0SNathan Whitehornmake an error
28194c8945a0SNathan Whitehorn#endif
28207a1c0d96SNathan Whitehorn],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
2821f4f33ea0SBaptiste Daroussincf_save_CFLAGS="$cf_save_CFLAGS -we147"
28224c8945a0SNathan Whitehorn],[])
28237a1c0d96SNathan Whitehorn		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
28247a1c0d96SNathan Whitehorn		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
28254c8945a0SNathan Whitehorn		;;
28264c8945a0SNathan Whitehorn	esac
28274c8945a0SNathan Whitehornfi
28284c8945a0SNathan Whitehorn])dnl
28294c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
2830*a96ef450SBaptiste Daroussindnl CF_LARGEFILE version: 12 updated: 2020/03/19 20:23:48
28314c8945a0SNathan Whitehorndnl ------------
28324c8945a0SNathan Whitehorndnl Add checks for large file support.
28334c8945a0SNathan WhitehornAC_DEFUN([CF_LARGEFILE],[
28344c8945a0SNathan Whitehornifdef([AC_FUNC_FSEEKO],[
28354c8945a0SNathan Whitehorn	AC_SYS_LARGEFILE
28364c8945a0SNathan Whitehorn	if test "$enable_largefile" != no ; then
28374c8945a0SNathan Whitehorn	AC_FUNC_FSEEKO
28384c8945a0SNathan Whitehorn
28394c8945a0SNathan Whitehorn	# Normally we would collect these definitions in the config.h,
28404c8945a0SNathan Whitehorn	# but (like _XOPEN_SOURCE), some environments rely on having these
28414c8945a0SNathan Whitehorn	# defined before any of the system headers are included.  Another
28424c8945a0SNathan Whitehorn	# case comes up with C++, e.g., on AIX the compiler compiles the
28434c8945a0SNathan Whitehorn	# header files by themselves before looking at the body files it is
28444c8945a0SNathan Whitehorn	# told to compile.  For ncurses, those header files do not include
28454c8945a0SNathan Whitehorn	# the config.h
2846f4f33ea0SBaptiste Daroussin	if test "$ac_cv_sys_large_files" != no
2847f4f33ea0SBaptiste Daroussin	then
2848f4f33ea0SBaptiste Daroussin		CF_APPEND_TEXT(CPPFLAGS,-D_LARGE_FILES)
2849f4f33ea0SBaptiste Daroussin	fi
2850f4f33ea0SBaptiste Daroussin	if test "$ac_cv_sys_largefile_source" != no
2851f4f33ea0SBaptiste Daroussin	then
2852f4f33ea0SBaptiste Daroussin		CF_APPEND_TEXT(CPPFLAGS,-D_LARGEFILE_SOURCE)
2853f4f33ea0SBaptiste Daroussin	fi
2854f4f33ea0SBaptiste Daroussin	if test "$ac_cv_sys_file_offset_bits" != no
2855f4f33ea0SBaptiste Daroussin	then
2856f4f33ea0SBaptiste Daroussin		CF_APPEND_TEXT(CPPFLAGS,-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits)
2857f4f33ea0SBaptiste Daroussin	fi
28584c8945a0SNathan Whitehorn
28594c8945a0SNathan Whitehorn	AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
28604c8945a0SNathan Whitehorn		AC_TRY_COMPILE([
2861f4f33ea0SBaptiste Daroussin#pragma GCC diagnostic error "-Wincompatible-pointer-types"
28624c8945a0SNathan Whitehorn#include <sys/types.h>
28634c8945a0SNathan Whitehorn#include <dirent.h>
28644c8945a0SNathan Whitehorn		],[
28654c8945a0SNathan Whitehorn		/* if transitional largefile support is setup, this is true */
28664c8945a0SNathan Whitehorn		extern struct dirent64 * readdir(DIR *);
28674c8945a0SNathan Whitehorn		struct dirent64 *x = readdir((DIR *)0);
28684c8945a0SNathan Whitehorn		struct dirent *y = readdir((DIR *)0);
28694c8945a0SNathan Whitehorn		int z = x - y;
2870*a96ef450SBaptiste Daroussin		(void)z;
28714c8945a0SNathan Whitehorn		],
28724c8945a0SNathan Whitehorn		[cf_cv_struct_dirent64=yes],
28734c8945a0SNathan Whitehorn		[cf_cv_struct_dirent64=no])
28744c8945a0SNathan Whitehorn	])
28752a3e3873SBaptiste Daroussin	test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Define to 1 if we have struct dirent64])
28764c8945a0SNathan Whitehorn	fi
28774c8945a0SNathan Whitehorn])
28784c8945a0SNathan Whitehorn])
28794c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
2880*a96ef450SBaptiste Daroussindnl CF_LD_RPATH_OPT version: 9 updated: 2021/01/01 13:31:04
28814c8945a0SNathan Whitehorndnl ---------------
28824c8945a0SNathan Whitehorndnl For the given system and compiler, find the compiler flags to pass to the
28834c8945a0SNathan Whitehorndnl loader to use the "rpath" feature.
28844c8945a0SNathan WhitehornAC_DEFUN([CF_LD_RPATH_OPT],
28854c8945a0SNathan Whitehorn[
28864c8945a0SNathan WhitehornAC_REQUIRE([CF_CHECK_CACHE])
28874c8945a0SNathan Whitehorn
28884c8945a0SNathan WhitehornLD_RPATH_OPT=
2889*a96ef450SBaptiste Daroussinif test "x$cf_cv_enable_rpath" != xno
2890*a96ef450SBaptiste Daroussinthen
28914c8945a0SNathan Whitehorn	AC_MSG_CHECKING(for an rpath option)
2892*a96ef450SBaptiste Daroussin	case "$cf_cv_system_name" in
2893f4f33ea0SBaptiste Daroussin	(irix*)
28944c8945a0SNathan Whitehorn		if test "$GCC" = yes; then
28954c8945a0SNathan Whitehorn			LD_RPATH_OPT="-Wl,-rpath,"
28964c8945a0SNathan Whitehorn		else
28974c8945a0SNathan Whitehorn			LD_RPATH_OPT="-rpath "
28984c8945a0SNathan Whitehorn		fi
28994c8945a0SNathan Whitehorn		;;
2900f4f33ea0SBaptiste Daroussin	(linux*|gnu*|k*bsd*-gnu|freebsd*)
29014c8945a0SNathan Whitehorn		LD_RPATH_OPT="-Wl,-rpath,"
29024c8945a0SNathan Whitehorn		;;
2903f4f33ea0SBaptiste Daroussin	(openbsd[[2-9]].*|mirbsd*)
29044c8945a0SNathan Whitehorn		LD_RPATH_OPT="-Wl,-rpath,"
29054c8945a0SNathan Whitehorn		;;
2906f4f33ea0SBaptiste Daroussin	(dragonfly*)
29074c8945a0SNathan Whitehorn		LD_RPATH_OPT="-rpath "
29084c8945a0SNathan Whitehorn		;;
2909f4f33ea0SBaptiste Daroussin	(netbsd*)
29104c8945a0SNathan Whitehorn		LD_RPATH_OPT="-Wl,-rpath,"
29114c8945a0SNathan Whitehorn		;;
2912f4f33ea0SBaptiste Daroussin	(osf*|mls+*)
29134c8945a0SNathan Whitehorn		LD_RPATH_OPT="-rpath "
29144c8945a0SNathan Whitehorn		;;
2915f4f33ea0SBaptiste Daroussin	(solaris2*)
29164c8945a0SNathan Whitehorn		LD_RPATH_OPT="-R"
29174c8945a0SNathan Whitehorn		;;
2918f4f33ea0SBaptiste Daroussin	(*)
29194c8945a0SNathan Whitehorn		;;
29204c8945a0SNathan Whitehorn	esac
29214c8945a0SNathan Whitehorn	AC_MSG_RESULT($LD_RPATH_OPT)
29224c8945a0SNathan Whitehorn
2923f4f33ea0SBaptiste Daroussin	case "x$LD_RPATH_OPT" in
2924f4f33ea0SBaptiste Daroussin	(x-R*)
29254c8945a0SNathan Whitehorn		AC_MSG_CHECKING(if we need a space after rpath option)
29264c8945a0SNathan Whitehorn		cf_save_LIBS="$LIBS"
29277a1c0d96SNathan Whitehorn		CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
29284c8945a0SNathan Whitehorn		AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
29294c8945a0SNathan Whitehorn		LIBS="$cf_save_LIBS"
29304c8945a0SNathan Whitehorn		AC_MSG_RESULT($cf_rpath_space)
29314c8945a0SNathan Whitehorn		test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
29324c8945a0SNathan Whitehorn		;;
29334c8945a0SNathan Whitehorn	esac
2934*a96ef450SBaptiste Daroussinfi
29354c8945a0SNathan Whitehorn])dnl
29364c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
2937*a96ef450SBaptiste Daroussindnl CF_LD_SEARCHPATH version: 2 updated: 2019/09/26 20:34:14
2938*a96ef450SBaptiste Daroussindnl ----------------
2939*a96ef450SBaptiste Daroussindnl Try to obtain the linker's search-path, for use in scripts.
2940*a96ef450SBaptiste Daroussindnl
2941*a96ef450SBaptiste Daroussindnl Ignore LD_LIBRARY_PATH, etc.
2942*a96ef450SBaptiste DaroussinAC_DEFUN([CF_LD_SEARCHPATH],[
2943*a96ef450SBaptiste DaroussinAC_CACHE_CHECK(for linker search path,cf_cv_ld_searchpath,[
2944*a96ef450SBaptiste Daroussin
2945*a96ef450SBaptiste Daroussinif test "$cross_compiling" != yes ; then
2946*a96ef450SBaptiste Daroussin
2947*a96ef450SBaptiste Daroussin# GNU binutils' ld does not involve permissions which may stop ldconfig.
2948*a96ef450SBaptiste Daroussincf_pathlist=`ld --verbose 2>/dev/null | grep SEARCH_DIR | sed -e 's,SEARCH_DIR[[("=]][[("=]]*,,g' -e 's/"[[)]];//gp' | sort -u`
2949*a96ef450SBaptiste Daroussin
2950*a96ef450SBaptiste Daroussin# The -NX options tell newer versions of Linux ldconfig to not attempt to
2951*a96ef450SBaptiste Daroussin# update the cache, which makes it run faster.
2952*a96ef450SBaptiste Daroussintest -z "$cf_pathlist" && \
2953*a96ef450SBaptiste Daroussin	cf_pathlist=`ldconfig -NX -v 2>/dev/null | sed -e '/^[[ 	]]/d' -e 's/:$//' | sort -u`
2954*a96ef450SBaptiste Daroussin
2955*a96ef450SBaptiste Daroussintest -z "$cf_pathlist" &&
2956*a96ef450SBaptiste Daroussin	cf_pathlist=`ldconfig -v 2>/dev/null | sed -n -e '/^[[ 	]]/d' -e 's/:$//p' | sort -u`
2957*a96ef450SBaptiste Daroussin
2958*a96ef450SBaptiste Daroussin# This works with OpenBSD 6.5, which lists only filenames
2959*a96ef450SBaptiste Daroussintest -z "$cf_pathlist" &&
2960*a96ef450SBaptiste Daroussin	cf_pathlist=`ldconfig -v 2>/dev/null | sed -n -e 's,^Adding \(.*\)/.*[$],\1,p' | sort -u`
2961*a96ef450SBaptiste Daroussin
2962*a96ef450SBaptiste Daroussinif test -z "$cf_pathlist"
2963*a96ef450SBaptiste Daroussinthen
2964*a96ef450SBaptiste Daroussin	# dyld default path with MacOS
2965*a96ef450SBaptiste Daroussin	if test -f /usr/bin/otool && test "x`uname -s`" = xDarwin
2966*a96ef450SBaptiste Daroussin	then
2967*a96ef450SBaptiste Daroussin		# do this to bypass check
2968*a96ef450SBaptiste Daroussin		cf_cv_ld_searchpath='$HOME/lib'
2969*a96ef450SBaptiste Daroussin		cf_pathlist="/usr/local/lib /lib /usr/lib"
2970*a96ef450SBaptiste Daroussin	fi
2971*a96ef450SBaptiste Daroussinfi
2972*a96ef450SBaptiste Daroussin
2973*a96ef450SBaptiste Daroussinif test -z "$cf_pathlist"
2974*a96ef450SBaptiste Daroussinthen
2975*a96ef450SBaptiste Daroussin	# Solaris is hardcoded
2976*a96ef450SBaptiste Daroussin	if test -d /opt/SUNWspro/lib
2977*a96ef450SBaptiste Daroussin	then
2978*a96ef450SBaptiste Daroussin		cf_pathlist="/opt/SUNWspro/lib /usr/ccs/lib /usr/lib"
2979*a96ef450SBaptiste Daroussin	elif test -d /usr/ccs/lib
2980*a96ef450SBaptiste Daroussin	then
2981*a96ef450SBaptiste Daroussin		cf_pathlist="/usr/ccs/lib /usr/lib"
2982*a96ef450SBaptiste Daroussin	fi
2983*a96ef450SBaptiste Daroussinfi
2984*a96ef450SBaptiste Daroussin
2985*a96ef450SBaptiste Daroussinfi
2986*a96ef450SBaptiste Daroussin
2987*a96ef450SBaptiste Daroussin# If nothing else, assume it is conventional
2988*a96ef450SBaptiste Daroussintest -z "$cf_pathlist" && cf_pathlist="/usr/lib /lib"
2989*a96ef450SBaptiste Daroussin
2990*a96ef450SBaptiste Daroussin# Finally, check that this is only directories
2991*a96ef450SBaptiste Daroussinfor cf_path in [$]0 $cf_pathlist
2992*a96ef450SBaptiste Daroussindo
2993*a96ef450SBaptiste Daroussin	if test -d "$cf_path"; then
2994*a96ef450SBaptiste Daroussin		test -n "$cf_cv_ld_searchpath" && cf_cv_ld_searchpath="${cf_cv_ld_searchpath} "
2995*a96ef450SBaptiste Daroussin		cf_cv_ld_searchpath="${cf_cv_ld_searchpath}${cf_path}"
2996*a96ef450SBaptiste Daroussin	fi
2997*a96ef450SBaptiste Daroussindone
2998*a96ef450SBaptiste Daroussin
2999*a96ef450SBaptiste Daroussin# Ensure that it is nonempty
3000*a96ef450SBaptiste Daroussintest -z "$cf_cv_ld_searchpath" && cf_cv_ld_searchpath=/usr/lib
3001*a96ef450SBaptiste Daroussin])
3002*a96ef450SBaptiste Daroussin
3003*a96ef450SBaptiste DaroussinLD_SEARCHPATH=`echo "$cf_cv_ld_searchpath"|sed -e 's/ /|/g'`
3004*a96ef450SBaptiste DaroussinAC_SUBST(LD_SEARCHPATH)
3005*a96ef450SBaptiste Daroussin])dnl
3006*a96ef450SBaptiste Daroussindnl ---------------------------------------------------------------------------
3007*a96ef450SBaptiste Daroussindnl CF_LIBRARY_PATH version: 11 updated: 2021/01/01 13:31:04
30084c8945a0SNathan Whitehorndnl ---------------
30094c8945a0SNathan Whitehorndnl Construct a search-list of directories for a nonstandard library-file
30104c8945a0SNathan Whitehorndnl
30114c8945a0SNathan Whitehorndnl Parameters
30124c8945a0SNathan Whitehorndnl	$1 = the variable to return as result
30134c8945a0SNathan Whitehorndnl	$2 = the package name
30144c8945a0SNathan WhitehornAC_DEFUN([CF_LIBRARY_PATH],
30154c8945a0SNathan Whitehorn[
30164c8945a0SNathan Whitehorn$1=
30174c8945a0SNathan Whitehorncf_library_path_list=""
30184c8945a0SNathan Whitehornif test -n "${LDFLAGS}${LIBS}" ; then
30194c8945a0SNathan Whitehorn	for cf_library_path in $LDFLAGS $LIBS
30204c8945a0SNathan Whitehorn	do
3021*a96ef450SBaptiste Daroussin		case "$cf_library_path" in
3022f4f33ea0SBaptiste Daroussin		(-L*)
30234c8945a0SNathan Whitehorn			cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
30244c8945a0SNathan Whitehorn			CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
30254c8945a0SNathan Whitehorn			cf_library_path_list="$cf_library_path_list [$]$1"
30264c8945a0SNathan Whitehorn			;;
30274c8945a0SNathan Whitehorn		esac
30284c8945a0SNathan Whitehorn	done
30294c8945a0SNathan Whitehornfi
30304c8945a0SNathan Whitehorn
30314c8945a0SNathan WhitehornCF_SUBDIR_PATH($1,$2,lib)
30324c8945a0SNathan Whitehorn
30334c8945a0SNathan Whitehorn$1="$cf_library_path_list [$]$1"
30344c8945a0SNathan Whitehorn])dnl
30354c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3036febdb468SDevin Teskednl CF_LIBTOOL_VERSION version: 1 updated: 2013/04/06 18:03:09
3037febdb468SDevin Teskednl ------------------
3038febdb468SDevin TeskeAC_DEFUN([CF_LIBTOOL_VERSION],[
3039febdb468SDevin Teskeif test -n "$LIBTOOL" && test "$LIBTOOL" != none
3040febdb468SDevin Teskethen
3041febdb468SDevin Teske	cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '/^$/d' |sed -e '2,$d' -e 's/([[^)]]*)//g' -e 's/^[[^1-9]]*//' -e 's/[[^0-9.]].*//'`
3042febdb468SDevin Teskeelse
3043febdb468SDevin Teske	cf_cv_libtool_version=
3044febdb468SDevin Teskefi
3045febdb468SDevin Tesketest -z "$cf_cv_libtool_version" && unset cf_cv_libtool_version
3046febdb468SDevin Teske])dnl
3047febdb468SDevin Teskednl ---------------------------------------------------------------------------
3048*a96ef450SBaptiste Daroussindnl CF_LIB_PREFIX version: 14 updated: 2021/01/01 13:31:04
30494c8945a0SNathan Whitehorndnl -------------
30504c8945a0SNathan Whitehorndnl Compute the library-prefix for the given host system
30514c8945a0SNathan Whitehorndnl $1 = variable to set
30522a3e3873SBaptiste Daroussindefine([CF_LIB_PREFIX],
30534c8945a0SNathan Whitehorn[
3054*a96ef450SBaptiste Daroussin	case "$cf_cv_system_name" in
3055f4f33ea0SBaptiste Daroussin	(OS/2*|os2*)
3056f4f33ea0SBaptiste Daroussin		if test "$DFT_LWR_MODEL" = libtool; then
3057f4f33ea0SBaptiste Daroussin			LIB_PREFIX='lib'
3058f4f33ea0SBaptiste Daroussin		else
30594c8945a0SNathan Whitehorn			LIB_PREFIX=''
3060f4f33ea0SBaptiste Daroussin		fi
30614c8945a0SNathan Whitehorn		;;
3062*a96ef450SBaptiste Daroussin	(*-msvc*)
3063*a96ef450SBaptiste Daroussin		LIB_PREFIX=''
3064*a96ef450SBaptiste Daroussin		;;
3065f4f33ea0SBaptiste Daroussin	(*)	LIB_PREFIX='lib'
30664c8945a0SNathan Whitehorn		;;
30674c8945a0SNathan Whitehorn	esac
30684c8945a0SNathan Whitehornifelse($1,,,[$1=$LIB_PREFIX])
30694c8945a0SNathan Whitehorn	AC_SUBST(LIB_PREFIX)
30704c8945a0SNathan Whitehorn])dnl
30714c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3072*a96ef450SBaptiste Daroussindnl CF_LIB_SUFFIX version: 28 updated: 2021/01/01 16:53:59
3073febdb468SDevin Teskednl -------------
3074febdb468SDevin Teskednl Compute the library file-suffix from the given model name
3075febdb468SDevin Teskednl $1 = model name
3076febdb468SDevin Teskednl $2 = variable to set (the nominal library suffix)
3077febdb468SDevin Teskednl $3 = dependency variable to set (actual filename)
3078febdb468SDevin Teskednl The variable $LIB_SUFFIX, if set, prepends the variable to set.
3079febdb468SDevin TeskeAC_DEFUN([CF_LIB_SUFFIX],
3080febdb468SDevin Teske[
3081f4f33ea0SBaptiste Daroussin	case X$1 in
3082f4f33ea0SBaptiste Daroussin	(Xlibtool)
3083febdb468SDevin Teske		$2='.la'
3084febdb468SDevin Teske		$3=[$]$2
3085febdb468SDevin Teske		;;
3086f4f33ea0SBaptiste Daroussin	(Xdebug)
3087*a96ef450SBaptiste Daroussin		case "$cf_cv_system_name" in
3088*a96ef450SBaptiste Daroussin		(*-msvc*)
3089*a96ef450SBaptiste Daroussin			$2='_g.lib'
3090*a96ef450SBaptiste Daroussin			;;
3091*a96ef450SBaptiste Daroussin		(*)
3092febdb468SDevin Teske			$2='_g.a'
3093*a96ef450SBaptiste Daroussin			;;
3094*a96ef450SBaptiste Daroussin		esac
3095febdb468SDevin Teske		$3=[$]$2
3096febdb468SDevin Teske		;;
3097f4f33ea0SBaptiste Daroussin	(Xprofile)
3098*a96ef450SBaptiste Daroussin		case "$cf_cv_system_name" in
3099*a96ef450SBaptiste Daroussin		(*-msvc*)
3100*a96ef450SBaptiste Daroussin			$2='_p.lib'
3101*a96ef450SBaptiste Daroussin			;;
3102*a96ef450SBaptiste Daroussin		(*)
3103febdb468SDevin Teske			$2='_p.a'
3104*a96ef450SBaptiste Daroussin			;;
3105*a96ef450SBaptiste Daroussin		esac
3106febdb468SDevin Teske		$3=[$]$2
3107febdb468SDevin Teske		;;
3108f4f33ea0SBaptiste Daroussin	(Xshared)
3109*a96ef450SBaptiste Daroussin		case "$cf_cv_system_name" in
3110f4f33ea0SBaptiste Daroussin		(aix[[5-7]]*)
3111febdb468SDevin Teske			$2='.so'
3112febdb468SDevin Teske			$3=[$]$2
3113febdb468SDevin Teske			;;
3114*a96ef450SBaptiste Daroussin		(*-msvc*)
3115*a96ef450SBaptiste Daroussin			$2='.dll'
3116*a96ef450SBaptiste Daroussin			$3='.dll.lib'
3117*a96ef450SBaptiste Daroussin			;;
3118f4f33ea0SBaptiste Daroussin		(cygwin*|msys*|mingw*)
3119f4f33ea0SBaptiste Daroussin			$2='.dll'
3120f4f33ea0SBaptiste Daroussin			$3='.dll.a'
3121f4f33ea0SBaptiste Daroussin			;;
3122f4f33ea0SBaptiste Daroussin		(darwin*)
3123f4f33ea0SBaptiste Daroussin			$2='.dylib'
3124f4f33ea0SBaptiste Daroussin			$3=[$]$2
3125f4f33ea0SBaptiste Daroussin			;;
3126f4f33ea0SBaptiste Daroussin		(hpux*)
3127*a96ef450SBaptiste Daroussin			case "$target" in
3128f4f33ea0SBaptiste Daroussin			(ia64*)
3129f4f33ea0SBaptiste Daroussin				$2='.so'
3130f4f33ea0SBaptiste Daroussin				$3=[$]$2
3131f4f33ea0SBaptiste Daroussin				;;
3132f4f33ea0SBaptiste Daroussin			(*)
3133febdb468SDevin Teske				$2='.sl'
3134febdb468SDevin Teske				$3=[$]$2
3135febdb468SDevin Teske				;;
3136febdb468SDevin Teske			esac
3137febdb468SDevin Teske			;;
3138f4f33ea0SBaptiste Daroussin		(*)
3139febdb468SDevin Teske			$2='.so'
3140febdb468SDevin Teske			$3=[$]$2
3141febdb468SDevin Teske			;;
3142febdb468SDevin Teske		esac
3143febdb468SDevin Teske		;;
3144f4f33ea0SBaptiste Daroussin	(*)
3145*a96ef450SBaptiste Daroussin		case "$target" in
3146*a96ef450SBaptiste Daroussin		(*-msvc*)
3147*a96ef450SBaptiste Daroussin			$2='.lib'
3148*a96ef450SBaptiste Daroussin			;;
3149*a96ef450SBaptiste Daroussin		(*)
3150febdb468SDevin Teske			$2='.a'
3151*a96ef450SBaptiste Daroussin			;;
3152*a96ef450SBaptiste Daroussin		esac
3153febdb468SDevin Teske		$3=[$]$2
3154febdb468SDevin Teske		;;
3155febdb468SDevin Teske	esac
3156f4f33ea0SBaptiste Daroussin	if test -n "${LIB_SUFFIX}${EXTRA_SUFFIX}"
3157f4f33ea0SBaptiste Daroussin	then
3158f4f33ea0SBaptiste Daroussin		$2="${LIB_SUFFIX}${EXTRA_SUFFIX}[$]{$2}"
3159f4f33ea0SBaptiste Daroussin		$3="${LIB_SUFFIX}${EXTRA_SUFFIX}[$]{$3}"
3160f4f33ea0SBaptiste Daroussin	fi
3161febdb468SDevin Teske])dnl
3162febdb468SDevin Teskednl ---------------------------------------------------------------------------
3163*a96ef450SBaptiste Daroussindnl CF_MAKEFLAGS version: 20 updated: 2021/01/03 19:29:49
31644c8945a0SNathan Whitehorndnl ------------
31654c8945a0SNathan Whitehorndnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
31664c8945a0SNathan Whitehorndnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
31674c8945a0SNathan Whitehorndnl (GNU 'make' does both, something POSIX 'make', which happens to make the
31684c8945a0SNathan Whitehorndnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
31694c8945a0SNathan WhitehornAC_DEFUN([CF_MAKEFLAGS],
3170*a96ef450SBaptiste Daroussin[AC_REQUIRE([AC_PROG_FGREP])dnl
3171*a96ef450SBaptiste Daroussin
31724c8945a0SNathan WhitehornAC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
31734c8945a0SNathan Whitehorn	cf_cv_makeflags=''
31744c8945a0SNathan Whitehorn	for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
31754c8945a0SNathan Whitehorn	do
31764c8945a0SNathan Whitehorn		cat >cf_makeflags.tmp <<CF_EOF
3177f4f33ea0SBaptiste DaroussinSHELL = $SHELL
31784c8945a0SNathan Whitehornall :
31794c8945a0SNathan Whitehorn	@ echo '.$cf_option'
31804c8945a0SNathan WhitehornCF_EOF
3181*a96ef450SBaptiste Daroussin		cf_result=`${MAKE:-make} -k -f cf_makeflags.tmp 2>/dev/null | ${FGREP-fgrep} -v "ing directory" | sed -e 's,[[ 	]]*$,,'`
31824c8945a0SNathan Whitehorn		case "$cf_result" in
3183f4f33ea0SBaptiste Daroussin		(.*k|.*kw)
3184*a96ef450SBaptiste Daroussin			cf_result="`${MAKE:-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`"
31854c8945a0SNathan Whitehorn			case "$cf_result" in
3186f4f33ea0SBaptiste Daroussin			(.*CC=*)	cf_cv_makeflags=
31874c8945a0SNathan Whitehorn				;;
3188f4f33ea0SBaptiste Daroussin			(*)	cf_cv_makeflags=$cf_option
31894c8945a0SNathan Whitehorn				;;
31904c8945a0SNathan Whitehorn			esac
31914c8945a0SNathan Whitehorn			break
31924c8945a0SNathan Whitehorn			;;
3193f4f33ea0SBaptiste Daroussin		(.-)
3194f4f33ea0SBaptiste Daroussin			;;
3195f4f33ea0SBaptiste Daroussin		(*)
3196f4f33ea0SBaptiste Daroussin			CF_MSG_LOG(given option \"$cf_option\", no match \"$cf_result\")
31974c8945a0SNathan Whitehorn			;;
31984c8945a0SNathan Whitehorn		esac
31994c8945a0SNathan Whitehorn	done
32004c8945a0SNathan Whitehorn	rm -f cf_makeflags.tmp
32014c8945a0SNathan Whitehorn])
32024c8945a0SNathan Whitehorn
32034c8945a0SNathan WhitehornAC_SUBST(cf_cv_makeflags)
32044c8945a0SNathan Whitehorn])dnl
32054c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
32067a1c0d96SNathan Whitehorndnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
32074c8945a0SNathan Whitehorndnl ------------
32084c8945a0SNathan Whitehorndnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
32094c8945a0SNathan Whitehorndnl a monocase filesystem.
32104c8945a0SNathan WhitehornAC_DEFUN([CF_MAKE_TAGS],[
32114c8945a0SNathan WhitehornAC_REQUIRE([CF_MIXEDCASE_FILENAMES])
32124c8945a0SNathan Whitehorn
32134c8945a0SNathan WhitehornAC_CHECK_PROGS(CTAGS, exctags ctags)
32144c8945a0SNathan WhitehornAC_CHECK_PROGS(ETAGS, exetags etags)
32154c8945a0SNathan Whitehorn
32167a1c0d96SNathan WhitehornAC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
32174c8945a0SNathan Whitehorn
32184c8945a0SNathan Whitehornif test "$cf_cv_mixedcase" = yes ; then
32197a1c0d96SNathan Whitehorn	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
32204c8945a0SNathan Whitehornelse
32214c8945a0SNathan Whitehorn	MAKE_UPPER_TAGS=no
32224c8945a0SNathan Whitehornfi
32234c8945a0SNathan Whitehorn
32244c8945a0SNathan Whitehornif test "$MAKE_UPPER_TAGS" = yes ; then
32254c8945a0SNathan Whitehorn	MAKE_UPPER_TAGS=
32264c8945a0SNathan Whitehornelse
32274c8945a0SNathan Whitehorn	MAKE_UPPER_TAGS="#"
32284c8945a0SNathan Whitehornfi
32294c8945a0SNathan Whitehorn
32304c8945a0SNathan Whitehornif test "$MAKE_LOWER_TAGS" = yes ; then
32314c8945a0SNathan Whitehorn	MAKE_LOWER_TAGS=
32324c8945a0SNathan Whitehornelse
32334c8945a0SNathan Whitehorn	MAKE_LOWER_TAGS="#"
32344c8945a0SNathan Whitehornfi
32354c8945a0SNathan Whitehorn
32364c8945a0SNathan WhitehornAC_SUBST(CTAGS)
32374c8945a0SNathan WhitehornAC_SUBST(ETAGS)
32384c8945a0SNathan Whitehorn
32394c8945a0SNathan WhitehornAC_SUBST(MAKE_UPPER_TAGS)
32404c8945a0SNathan WhitehornAC_SUBST(MAKE_LOWER_TAGS)
32414c8945a0SNathan Whitehorn])dnl
32424c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3243*a96ef450SBaptiste Daroussindnl CF_MATH_LIB version: 10 updated: 2020/12/31 18:40:20
32444c8945a0SNathan Whitehorndnl -----------
32454c8945a0SNathan Whitehorndnl Checks for libraries.  At least one UNIX system, Apple Macintosh
32464c8945a0SNathan Whitehorndnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
32474c8945a0SNathan Whitehorndnl AC_CHECK_LIB(m,sin), because that fails for C++.
32484c8945a0SNathan WhitehornAC_DEFUN([CF_MATH_LIB],
32494c8945a0SNathan Whitehorn[
32504c8945a0SNathan WhitehornAC_CACHE_CHECK(if -lm needed for math functions,
32514c8945a0SNathan Whitehorn	cf_cv_need_libm,[
32524c8945a0SNathan Whitehorn	AC_TRY_LINK([
32534c8945a0SNathan Whitehorn	#include <stdio.h>
3254f4f33ea0SBaptiste Daroussin	#include <stdlib.h>
32554c8945a0SNathan Whitehorn	#include <math.h>
32564c8945a0SNathan Whitehorn	],
3257*a96ef450SBaptiste Daroussin	[double x = rand(); printf("result = %g\\n", ]ifelse([$2],,sin(x),$2)[)],
32584c8945a0SNathan Whitehorn	[cf_cv_need_libm=no],
32594c8945a0SNathan Whitehorn	[cf_cv_need_libm=yes])])
32604c8945a0SNathan Whitehornif test "$cf_cv_need_libm" = yes
32614c8945a0SNathan Whitehornthen
32624c8945a0SNathan Whitehornifelse($1,,[
32637a1c0d96SNathan Whitehorn	CF_ADD_LIB(m)
32644c8945a0SNathan Whitehorn],[$1=-lm])
32654c8945a0SNathan Whitehornfi
32664c8945a0SNathan Whitehorn])
32674c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3268*a96ef450SBaptiste Daroussindnl CF_MBSTATE_T version: 5 updated: 2020/03/19 20:23:48
32694c8945a0SNathan Whitehorndnl ------------
32704c8945a0SNathan Whitehorndnl Check if mbstate_t is declared, and if so, which header file.
32714c8945a0SNathan Whitehorndnl This (including wchar.h) is needed on Tru64 5.0 to declare mbstate_t,
32724c8945a0SNathan Whitehorndnl as well as include stdio.h to work around a misuse of varargs in wchar.h
32734c8945a0SNathan WhitehornAC_DEFUN([CF_MBSTATE_T],
32744c8945a0SNathan Whitehorn[
32754c8945a0SNathan WhitehornAC_CACHE_CHECK(if we must include wchar.h to declare mbstate_t,cf_cv_mbstate_t,[
32764c8945a0SNathan WhitehornAC_TRY_COMPILE([
32774c8945a0SNathan Whitehorn#include <stdlib.h>
32784c8945a0SNathan Whitehorn#include <stdio.h>
32794c8945a0SNathan Whitehorn#ifdef HAVE_LIBUTF8_H
32804c8945a0SNathan Whitehorn#include <libutf8.h>
32814c8945a0SNathan Whitehorn#endif],
3282*a96ef450SBaptiste Daroussin	[mbstate_t state; (void)state],
32834c8945a0SNathan Whitehorn	[cf_cv_mbstate_t=no],
32844c8945a0SNathan Whitehorn	[AC_TRY_COMPILE([
32854c8945a0SNathan Whitehorn#include <stdlib.h>
32864c8945a0SNathan Whitehorn#include <stdio.h>
32874c8945a0SNathan Whitehorn#include <wchar.h>
32884c8945a0SNathan Whitehorn#ifdef HAVE_LIBUTF8_H
32894c8945a0SNathan Whitehorn#include <libutf8.h>
32904c8945a0SNathan Whitehorn#endif],
3291*a96ef450SBaptiste Daroussin	[mbstate_t value; (void)value],
32924c8945a0SNathan Whitehorn	[cf_cv_mbstate_t=yes],
32934c8945a0SNathan Whitehorn	[cf_cv_mbstate_t=unknown])])])
32944c8945a0SNathan Whitehorn
32954c8945a0SNathan Whitehornif test "$cf_cv_mbstate_t" = yes ; then
32962a3e3873SBaptiste Daroussin	AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
32974c8945a0SNathan Whitehornfi
32984c8945a0SNathan Whitehorn
32994c8945a0SNathan Whitehornif test "$cf_cv_mbstate_t" != unknown ; then
33002a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_MBSTATE_T,1,[Define to 1 if mbstate_t is declared])
33014c8945a0SNathan Whitehornfi
33024c8945a0SNathan Whitehorn])dnl
33034c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3304*a96ef450SBaptiste Daroussindnl CF_MERGE_EXTRA_CFLAGS version: 2 updated: 2021/01/02 09:31:20
3305*a96ef450SBaptiste Daroussindnl ---------------------
3306*a96ef450SBaptiste Daroussindnl CF_FIX_WARNINGS moves problematic flags into EXTRA_CFLAGS, but some scripts
3307*a96ef450SBaptiste Daroussindnl may depend on being able to override that variable at build-time.  Move it
3308*a96ef450SBaptiste Daroussindnl all back.
3309*a96ef450SBaptiste Daroussindefine([CF_MERGE_EXTRA_CFLAGS],[
3310*a96ef450SBaptiste Daroussinif test "$GCC" = yes || test "$GXX" = yes
3311*a96ef450SBaptiste Daroussinthen
3312*a96ef450SBaptiste Daroussin	CF_APPEND_TEXT(CFLAGS,$EXTRA_CFLAGS)
3313*a96ef450SBaptiste Daroussin	EXTRA_CFLAGS=
3314*a96ef450SBaptiste Daroussinfi
3315*a96ef450SBaptiste Daroussin])
3316*a96ef450SBaptiste Daroussindnl ---------------------------------------------------------------------------
3317*a96ef450SBaptiste Daroussindnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59
33184c8945a0SNathan Whitehorndnl ----------------------
33194c8945a0SNathan Whitehorndnl Check if the file-system supports mixed-case filenames.  If we're able to
33204c8945a0SNathan Whitehorndnl create a lowercase name and see it as uppercase, it doesn't support that.
33214c8945a0SNathan WhitehornAC_DEFUN([CF_MIXEDCASE_FILENAMES],
33224c8945a0SNathan Whitehorn[
33234c8945a0SNathan WhitehornAC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
33244c8945a0SNathan Whitehornif test "$cross_compiling" = yes ; then
3325*a96ef450SBaptiste Daroussin	case "$target_alias" in
3326*a96ef450SBaptiste Daroussin	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*)
33274c8945a0SNathan Whitehorn		cf_cv_mixedcase=no
33284c8945a0SNathan Whitehorn		;;
3329f4f33ea0SBaptiste Daroussin	(*)
33304c8945a0SNathan Whitehorn		cf_cv_mixedcase=yes
33314c8945a0SNathan Whitehorn		;;
33324c8945a0SNathan Whitehorn	esac
33334c8945a0SNathan Whitehornelse
33344c8945a0SNathan Whitehorn	rm -f conftest CONFTEST
33354c8945a0SNathan Whitehorn	echo test >conftest
33364c8945a0SNathan Whitehorn	if test -f CONFTEST ; then
33374c8945a0SNathan Whitehorn		cf_cv_mixedcase=no
33384c8945a0SNathan Whitehorn	else
33394c8945a0SNathan Whitehorn		cf_cv_mixedcase=yes
33404c8945a0SNathan Whitehorn	fi
33414c8945a0SNathan Whitehorn	rm -f conftest CONFTEST
33424c8945a0SNathan Whitehornfi
33434c8945a0SNathan Whitehorn])
33442a3e3873SBaptiste Daroussintest "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
33454c8945a0SNathan Whitehorn])dnl
33464c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
33477a1c0d96SNathan Whitehorndnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
33484c8945a0SNathan Whitehorndnl ----------
33494c8945a0SNathan Whitehorndnl Write a debug message to config.log, along with the line number in the
33504c8945a0SNathan Whitehorndnl configure script.
33514c8945a0SNathan WhitehornAC_DEFUN([CF_MSG_LOG],[
33527a1c0d96SNathan Whitehornecho "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
33534c8945a0SNathan Whitehorn])dnl
33544c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3355*a96ef450SBaptiste Daroussindnl CF_NCURSES_CC_CHECK version: 5 updated: 2020/12/31 20:19:42
33564c8945a0SNathan Whitehorndnl -------------------
33574c8945a0SNathan Whitehorndnl Check if we can compile with ncurses' header file
33584c8945a0SNathan Whitehorndnl $1 is the cache variable to set
33594c8945a0SNathan Whitehorndnl $2 is the header-file to include
33604c8945a0SNathan Whitehorndnl $3 is the root name (ncurses or ncursesw)
33614c8945a0SNathan WhitehornAC_DEFUN([CF_NCURSES_CC_CHECK],[
33624c8945a0SNathan Whitehorn	AC_TRY_COMPILE([
33634c8945a0SNathan Whitehorn]ifelse($3,ncursesw,[
33644c8945a0SNathan Whitehorn#define _XOPEN_SOURCE_EXTENDED
33654c8945a0SNathan Whitehorn#undef  HAVE_LIBUTF8_H	/* in case we used CF_UTF8_LIB */
33664c8945a0SNathan Whitehorn#define HAVE_LIBUTF8_H	/* to force ncurses' header file to use cchar_t */
33674c8945a0SNathan Whitehorn])[
33684c8945a0SNathan Whitehorn#include <$2>],[
33694c8945a0SNathan Whitehorn#ifdef NCURSES_VERSION
33704c8945a0SNathan Whitehorn]ifelse($3,ncursesw,[
33714c8945a0SNathan Whitehorn#ifndef WACS_BSSB
33724c8945a0SNathan Whitehorn	make an error
33734c8945a0SNathan Whitehorn#endif
33744c8945a0SNathan Whitehorn])[
3375*a96ef450SBaptiste Daroussinprintf("%s\\n", NCURSES_VERSION);
33764c8945a0SNathan Whitehorn#else
33774c8945a0SNathan Whitehorn#ifdef __NCURSES_H
3378*a96ef450SBaptiste Daroussinprintf("old\\n");
33794c8945a0SNathan Whitehorn#else
33804c8945a0SNathan Whitehorn	make an error
33814c8945a0SNathan Whitehorn#endif
33824c8945a0SNathan Whitehorn#endif
33834c8945a0SNathan Whitehorn	]
33844c8945a0SNathan Whitehorn	,[$1=$2]
33854c8945a0SNathan Whitehorn	,[$1=no])
33864c8945a0SNathan Whitehorn])dnl
33874c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3388*a96ef450SBaptiste Daroussindnl CF_NCURSES_CONFIG version: 26 updated: 2021/01/03 08:05:37
33894c8945a0SNathan Whitehorndnl -----------------
3390f4f33ea0SBaptiste Daroussindnl Tie together the configure-script macros for ncurses, preferring these in
3391f4f33ea0SBaptiste Daroussindnl order:
3392f4f33ea0SBaptiste Daroussindnl a) ".pc" files for pkg-config, using $NCURSES_CONFIG_PKG
3393f4f33ea0SBaptiste Daroussindnl b) the "-config" script from ncurses, using $NCURSES_CONFIG
3394f4f33ea0SBaptiste Daroussindnl c) just plain libraries
33954c8945a0SNathan Whitehorndnl
33964c8945a0SNathan Whitehorndnl $1 is the root library name (default: "ncurses")
3397f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_NCURSES_CONFIG],[
3398f4f33ea0SBaptiste DaroussinAC_REQUIRE([CF_PKG_CONFIG])
33994c8945a0SNathan Whitehorncf_ncuconfig_root=ifelse($1,,ncurses,$1)
3400f4f33ea0SBaptiste Daroussincf_have_ncuconfig=no
34014c8945a0SNathan Whitehorn
3402f4f33ea0SBaptiste Daroussinif test "x${PKG_CONFIG:=none}" != xnone; then
3403f4f33ea0SBaptiste Daroussin	AC_MSG_CHECKING(pkg-config for $cf_ncuconfig_root)
3404f4f33ea0SBaptiste Daroussin	if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
3405f4f33ea0SBaptiste Daroussin		AC_MSG_RESULT(yes)
3406f4f33ea0SBaptiste Daroussin
3407f4f33ea0SBaptiste Daroussin		AC_MSG_CHECKING(if the $cf_ncuconfig_root package files work)
3408f4f33ea0SBaptiste Daroussin		cf_have_ncuconfig=unknown
3409f4f33ea0SBaptiste Daroussin
3410*a96ef450SBaptiste Daroussin		cf_save_CFLAGS="$CFLAGS"
3411f4f33ea0SBaptiste Daroussin		cf_save_CPPFLAGS="$CPPFLAGS"
3412f4f33ea0SBaptiste Daroussin		cf_save_LIBS="$LIBS"
3413f4f33ea0SBaptiste Daroussin
3414*a96ef450SBaptiste Daroussin		cf_pkg_cflags="`$PKG_CONFIG --cflags $cf_ncuconfig_root`"
3415*a96ef450SBaptiste Daroussin		cf_pkg_libs="`$PKG_CONFIG --libs $cf_ncuconfig_root`"
3416*a96ef450SBaptiste Daroussin
3417*a96ef450SBaptiste Daroussin		# while -W for passing linker flags is prevalent, it is not "standard".
3418*a96ef450SBaptiste Daroussin		# At least one wrapper for c89/c99 (in Apple's xcode) has its own
3419*a96ef450SBaptiste Daroussin		# incompatible _and_ non-standard -W option which gives an error.  Work
3420*a96ef450SBaptiste Daroussin		# around that pitfall.
3421*a96ef450SBaptiste Daroussin		case "x${CC}@@${cf_pkg_libs}@${cf_pkg_cflags}" in
3422*a96ef450SBaptiste Daroussin		(x*c[[89]]9@@*-W*)
3423*a96ef450SBaptiste Daroussin			CF_ADD_CFLAGS($cf_pkg_cflags)
3424*a96ef450SBaptiste Daroussin			CF_ADD_LIBS($cf_pkg_libs)
3425f4f33ea0SBaptiste Daroussin
3426f4f33ea0SBaptiste Daroussin			AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
3427*a96ef450SBaptiste Daroussin				[initscr(); mousemask(0,0); tigetstr((char *)0);],
3428*a96ef450SBaptiste Daroussin				[AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
3429*a96ef450SBaptiste Daroussin					int main(void)
3430*a96ef450SBaptiste Daroussin					{ char *xx = curses_version(); return (xx == 0); }],
3431*a96ef450SBaptiste Daroussin					[cf_test_ncuconfig=yes],
3432*a96ef450SBaptiste Daroussin					[cf_test_ncuconfig=no],
3433*a96ef450SBaptiste Daroussin					[cf_test_ncuconfig=maybe])],
3434*a96ef450SBaptiste Daroussin				[cf_test_ncuconfig=no])
3435*a96ef450SBaptiste Daroussin
3436*a96ef450SBaptiste Daroussin			CFLAGS="$cf_save_CFLAGS"
3437*a96ef450SBaptiste Daroussin			CPPFLAGS="$cf_save_CPPFLAGS"
3438*a96ef450SBaptiste Daroussin			LIBS="$cf_save_LIBS"
3439*a96ef450SBaptiste Daroussin
3440*a96ef450SBaptiste Daroussin			if test "x$cf_test_ncuconfig" != xyes; then
3441*a96ef450SBaptiste Daroussin				cf_temp=`echo "x$cf_pkg_cflags" | sed -e s/^x// -e 's/-W[[^ 	]]*//g'`
3442*a96ef450SBaptiste Daroussin				cf_pkg_cflags="$cf_temp"
3443*a96ef450SBaptiste Daroussin				cf_temp=`echo "x$cf_pkg_libs" | sed -e s/^x// -e 's/-W[[^ 	]]*//g'`
3444*a96ef450SBaptiste Daroussin				cf_pkg_libs="$cf_temp"
3445*a96ef450SBaptiste Daroussin			fi
3446*a96ef450SBaptiste Daroussin			;;
3447*a96ef450SBaptiste Daroussin		esac
3448*a96ef450SBaptiste Daroussin
3449*a96ef450SBaptiste Daroussin		CF_ADD_CFLAGS($cf_pkg_cflags)
3450*a96ef450SBaptiste Daroussin		CF_ADD_LIBS($cf_pkg_libs)
3451*a96ef450SBaptiste Daroussin
3452*a96ef450SBaptiste Daroussin		AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
3453*a96ef450SBaptiste Daroussin			[initscr(); mousemask(0,0); tigetstr((char *)0);],
3454f4f33ea0SBaptiste Daroussin			[AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
3455f4f33ea0SBaptiste Daroussin				int main(void)
3456f4f33ea0SBaptiste Daroussin				{ char *xx = curses_version(); return (xx == 0); }],
3457f4f33ea0SBaptiste Daroussin				[cf_have_ncuconfig=yes],
3458f4f33ea0SBaptiste Daroussin				[cf_have_ncuconfig=no],
3459f4f33ea0SBaptiste Daroussin				[cf_have_ncuconfig=maybe])],
3460f4f33ea0SBaptiste Daroussin			[cf_have_ncuconfig=no])
3461f4f33ea0SBaptiste Daroussin		AC_MSG_RESULT($cf_have_ncuconfig)
3462f4f33ea0SBaptiste Daroussin		test "$cf_have_ncuconfig" = maybe && cf_have_ncuconfig=yes
3463f4f33ea0SBaptiste Daroussin		if test "$cf_have_ncuconfig" != "yes"
3464f4f33ea0SBaptiste Daroussin		then
3465f4f33ea0SBaptiste Daroussin			CPPFLAGS="$cf_save_CPPFLAGS"
3466f4f33ea0SBaptiste Daroussin			LIBS="$cf_save_LIBS"
3467f4f33ea0SBaptiste Daroussin			NCURSES_CONFIG_PKG=none
3468f4f33ea0SBaptiste Daroussin		else
3469f4f33ea0SBaptiste Daroussin			AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
3470f4f33ea0SBaptiste Daroussin			NCURSES_CONFIG_PKG=$cf_ncuconfig_root
3471f4f33ea0SBaptiste Daroussin			CF_TERM_HEADER
3472f4f33ea0SBaptiste Daroussin		fi
3473f4f33ea0SBaptiste Daroussin
3474f4f33ea0SBaptiste Daroussin	else
3475f4f33ea0SBaptiste Daroussin		AC_MSG_RESULT(no)
3476f4f33ea0SBaptiste Daroussin		NCURSES_CONFIG_PKG=none
3477f4f33ea0SBaptiste Daroussin	fi
3478f4f33ea0SBaptiste Daroussinelse
3479f4f33ea0SBaptiste Daroussin	NCURSES_CONFIG_PKG=none
3480f4f33ea0SBaptiste Daroussinfi
3481f4f33ea0SBaptiste Daroussin
3482f4f33ea0SBaptiste Daroussinif test "x$cf_have_ncuconfig" = "xno"; then
3483f4f33ea0SBaptiste Daroussin	cf_ncurses_config="${cf_ncuconfig_root}${NCURSES_CONFIG_SUFFIX}-config"; echo "Looking for ${cf_ncurses_config}"
34842a3e3873SBaptiste Daroussin
34852a3e3873SBaptiste Daroussin	CF_ACVERSION_CHECK(2.52,
3486f4f33ea0SBaptiste Daroussin		[AC_CHECK_TOOLS(NCURSES_CONFIG, ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)],
3487f4f33ea0SBaptiste Daroussin		[AC_PATH_PROGS(NCURSES_CONFIG,  ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)])
34884c8945a0SNathan Whitehorn
34894c8945a0SNathan Whitehorn	if test "$NCURSES_CONFIG" != none ; then
34904c8945a0SNathan Whitehorn
3491f4f33ea0SBaptiste Daroussin		CF_ADD_CFLAGS(`$NCURSES_CONFIG --cflags`)
34927a1c0d96SNathan Whitehorn		CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
34934c8945a0SNathan Whitehorn
34944c8945a0SNathan Whitehorn		# even with config script, some packages use no-override for curses.h
34954c8945a0SNathan Whitehorn		CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
34964c8945a0SNathan Whitehorn
34974c8945a0SNathan Whitehorn		dnl like CF_NCURSES_CPPFLAGS
34982a3e3873SBaptiste Daroussin		AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
34994c8945a0SNathan Whitehorn
35004c8945a0SNathan Whitehorn		dnl like CF_NCURSES_LIBS
35014c8945a0SNathan Whitehorn		CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
35024c8945a0SNathan Whitehorn		AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
35034c8945a0SNathan Whitehorn
35044c8945a0SNathan Whitehorn		dnl like CF_NCURSES_VERSION
3505*a96ef450SBaptiste Daroussin		cf_cv_ncurses_version="`$NCURSES_CONFIG --version`"
35064c8945a0SNathan Whitehorn
35074c8945a0SNathan Whitehorn	else
35084c8945a0SNathan Whitehorn
35094c8945a0SNathan Whitehorn		CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
35104c8945a0SNathan Whitehorn		CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
35114c8945a0SNathan Whitehorn
35124c8945a0SNathan Whitehorn	fi
3513f4f33ea0SBaptiste Daroussinelse
3514f4f33ea0SBaptiste Daroussin	NCURSES_CONFIG=none
3515f4f33ea0SBaptiste Daroussinfi
35164c8945a0SNathan Whitehorn])dnl
35174c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3518*a96ef450SBaptiste Daroussindnl CF_NCURSES_CPPFLAGS version: 22 updated: 2021/01/02 09:31:20
35194c8945a0SNathan Whitehorndnl -------------------
35204c8945a0SNathan Whitehorndnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
35214c8945a0SNathan Whitehorndnl the CPPFLAGS variable so we can include its header.
35224c8945a0SNathan Whitehorndnl
35234c8945a0SNathan Whitehorndnl The header files may be installed as either curses.h, or ncurses.h (would
35244c8945a0SNathan Whitehorndnl be obsolete, except that some packagers prefer this name to distinguish it
35254c8945a0SNathan Whitehorndnl from a "native" curses implementation).  If not installed for overwrite,
35264c8945a0SNathan Whitehorndnl the curses.h file would be in an ncurses subdirectory (e.g.,
35274c8945a0SNathan Whitehorndnl /usr/include/ncurses), but someone may have installed overwriting the
35284c8945a0SNathan Whitehorndnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
35294c8945a0SNathan Whitehorndnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
35304c8945a0SNathan Whitehorndnl the header.
35314c8945a0SNathan Whitehorndnl
35324c8945a0SNathan Whitehorndnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
35334c8945a0SNathan Whitehorndnl is already in the include-path, don't even bother with this, since we cannot
35344c8945a0SNathan Whitehorndnl easily determine which file it is.  In this case, it has to be <curses.h>.
35354c8945a0SNathan Whitehorndnl
35364c8945a0SNathan Whitehorndnl The optional parameter gives the root name of the library, in case it is
35374c8945a0SNathan Whitehorndnl not installed as the default curses library.  That is how the
35384c8945a0SNathan Whitehorndnl wide-character version of ncurses is installed.
35394c8945a0SNathan WhitehornAC_DEFUN([CF_NCURSES_CPPFLAGS],
35404c8945a0SNathan Whitehorn[AC_REQUIRE([CF_WITH_CURSES_DIR])
35414c8945a0SNathan Whitehorn
35424c8945a0SNathan WhitehornAC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
35434c8945a0SNathan Whitehorncf_ncuhdr_root=ifelse($1,,ncurses,$1)
35444c8945a0SNathan Whitehorn
35454c8945a0SNathan Whitehorntest -n "$cf_cv_curses_dir" && \
35464c8945a0SNathan Whitehorntest "$cf_cv_curses_dir" != "no" && { \
35477a1c0d96SNathan Whitehorn  CF_ADD_INCDIR($cf_cv_curses_dir/include/$cf_ncuhdr_root)
35484c8945a0SNathan Whitehorn}
35494c8945a0SNathan Whitehorn
35504c8945a0SNathan WhitehornAC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
35514c8945a0SNathan Whitehorn	cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
3552*a96ef450SBaptiste Daroussin	{ test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw; } && cf_header_list="$cf_header_list curses.h ncurses.h"
35534c8945a0SNathan Whitehorn	for cf_header in $cf_header_list
35544c8945a0SNathan Whitehorn	do
35554c8945a0SNathan Whitehorn		CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
35564c8945a0SNathan Whitehorn		test "$cf_cv_ncurses_h" != no && break
35574c8945a0SNathan Whitehorn	done
35584c8945a0SNathan Whitehorn])
35594c8945a0SNathan Whitehorn
35604c8945a0SNathan WhitehornCF_NCURSES_HEADER
35614c8945a0SNathan WhitehornCF_TERM_HEADER
35624c8945a0SNathan Whitehorn
35634c8945a0SNathan Whitehorn# some applications need this, but should check for NCURSES_VERSION
35642a3e3873SBaptiste DaroussinAC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
35654c8945a0SNathan Whitehorn
35664c8945a0SNathan WhitehornCF_NCURSES_VERSION
35674c8945a0SNathan Whitehorn])dnl
35684c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3569*a96ef450SBaptiste Daroussindnl CF_NCURSES_HEADER version: 7 updated: 2021/01/04 19:33:05
35704c8945a0SNathan Whitehorndnl -----------------
35714c8945a0SNathan Whitehorndnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
35724c8945a0SNathan Whitehorndnl variations of ncurses' installs.
35734c8945a0SNathan Whitehorndnl
35744c8945a0SNathan Whitehorndnl See also CF_CURSES_HEADER, which sets the same cache variable.
35754c8945a0SNathan WhitehornAC_DEFUN([CF_NCURSES_HEADER],[
35764c8945a0SNathan Whitehorn
35774c8945a0SNathan Whitehornif test "$cf_cv_ncurses_h" != no ; then
35784c8945a0SNathan Whitehorn	cf_cv_ncurses_header=$cf_cv_ncurses_h
35794c8945a0SNathan Whitehornelse
35804c8945a0SNathan Whitehorn
35814c8945a0SNathan WhitehornAC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
35824c8945a0SNathan Whitehorn	test -n "$verbose" && echo
35834c8945a0SNathan Whitehorn	CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
3584*a96ef450SBaptiste Daroussin	test -n "$verbose" && echo "search path $cf_search"
35854c8945a0SNathan Whitehorn	cf_save2_CPPFLAGS="$CPPFLAGS"
35864c8945a0SNathan Whitehorn	for cf_incdir in $cf_search
35874c8945a0SNathan Whitehorn	do
35884c8945a0SNathan Whitehorn		CF_ADD_INCDIR($cf_incdir)
35894c8945a0SNathan Whitehorn		for cf_header in \
35904c8945a0SNathan Whitehorn			ncurses.h \
35914c8945a0SNathan Whitehorn			curses.h
35924c8945a0SNathan Whitehorn		do
35934c8945a0SNathan Whitehorn			CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
35944c8945a0SNathan Whitehorn			if test "$cf_cv_ncurses_h2" != no ; then
35954c8945a0SNathan Whitehorn				cf_cv_ncurses_h2=$cf_incdir/$cf_header
3596*a96ef450SBaptiste Daroussin				test -n "$verbose" && echo $ECHO_N "	... found $ECHO_C" 1>&AC_FD_MSG
35974c8945a0SNathan Whitehorn				break
35984c8945a0SNathan Whitehorn			fi
35994c8945a0SNathan Whitehorn			test -n "$verbose" && echo "	... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
36004c8945a0SNathan Whitehorn		done
36014c8945a0SNathan Whitehorn		CPPFLAGS="$cf_save2_CPPFLAGS"
36024c8945a0SNathan Whitehorn		test "$cf_cv_ncurses_h2" != no && break
36034c8945a0SNathan Whitehorn	done
36044c8945a0SNathan Whitehorn	test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
36054c8945a0SNathan Whitehorn	])
36064c8945a0SNathan Whitehorn
36074c8945a0SNathan Whitehorn	CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
3608*a96ef450SBaptiste Daroussin	cf_cv_ncurses_header="`basename "$cf_cv_ncurses_h2"`"
3609*a96ef450SBaptiste Daroussin	if test "`basename "$cf_1st_incdir"`" = "$cf_ncuhdr_root" ; then
3610*a96ef450SBaptiste Daroussin		cf_cv_ncurses_header="$cf_ncuhdr_root/$cf_cv_ncurses_header"
36114c8945a0SNathan Whitehorn	fi
36124c8945a0SNathan Whitehorn	CF_ADD_INCDIR($cf_1st_incdir)
36134c8945a0SNathan Whitehorn
36144c8945a0SNathan Whitehornfi
36154c8945a0SNathan Whitehorn
36164c8945a0SNathan Whitehorn# Set definitions to allow ifdef'ing for ncurses.h
36174c8945a0SNathan Whitehorn
3618*a96ef450SBaptiste Daroussincase "$cf_cv_ncurses_header" in
3619f4f33ea0SBaptiste Daroussin(*ncurses.h)
36202a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_NCURSES_H,1,[Define to 1 if we have ncurses.h])
36214c8945a0SNathan Whitehorn	;;
36224c8945a0SNathan Whitehornesac
36234c8945a0SNathan Whitehorn
3624*a96ef450SBaptiste Daroussincase "$cf_cv_ncurses_header" in
3625f4f33ea0SBaptiste Daroussin(ncurses/curses.h|ncurses/ncurses.h)
36262a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Define to 1 if we have ncurses/ncurses.h])
36274c8945a0SNathan Whitehorn	;;
3628f4f33ea0SBaptiste Daroussin(ncursesw/curses.h|ncursesw/ncurses.h)
36292a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_NCURSESW_NCURSES_H,1,[Define to 1 if we have ncursesw/ncurses.h])
36304c8945a0SNathan Whitehorn	;;
36314c8945a0SNathan Whitehornesac
36324c8945a0SNathan Whitehorn
36334c8945a0SNathan Whitehorn])dnl
36344c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3635*a96ef450SBaptiste Daroussindnl CF_NCURSES_LIBS version: 20 updated: 2021/01/03 08:05:37
36364c8945a0SNathan Whitehorndnl ---------------
36374c8945a0SNathan Whitehorndnl Look for the ncurses library.  This is a little complicated on Linux,
36384c8945a0SNathan Whitehorndnl because it may be linked with the gpm (general purpose mouse) library.
36394c8945a0SNathan Whitehorndnl Some distributions have gpm linked with (bsd) curses, which makes it
36404c8945a0SNathan Whitehorndnl unusable with ncurses.  However, we don't want to link with gpm unless
36414c8945a0SNathan Whitehorndnl ncurses has a dependency, since gpm is normally set up as a shared library,
36424c8945a0SNathan Whitehorndnl and the linker will record a dependency.
36434c8945a0SNathan Whitehorndnl
36444c8945a0SNathan Whitehorndnl The optional parameter gives the root name of the library, in case it is
36454c8945a0SNathan Whitehorndnl not installed as the default curses library.  That is how the
36464c8945a0SNathan Whitehorndnl wide-character version of ncurses is installed.
36474c8945a0SNathan WhitehornAC_DEFUN([CF_NCURSES_LIBS],
36484c8945a0SNathan Whitehorn[AC_REQUIRE([CF_NCURSES_CPPFLAGS])
36494c8945a0SNathan Whitehorn
36504c8945a0SNathan Whitehorncf_nculib_root=ifelse($1,,ncurses,$1)
36514c8945a0SNathan Whitehorn	# This works, except for the special case where we find gpm, but
36524c8945a0SNathan Whitehorn	# ncurses is in a nonstandard location via $LIBS, and we really want
36534c8945a0SNathan Whitehorn	# to link gpm.
36544c8945a0SNathan Whitehorncf_ncurses_LIBS=""
36554c8945a0SNathan Whitehorncf_ncurses_SAVE="$LIBS"
36564c8945a0SNathan WhitehornAC_CHECK_LIB(gpm,Gpm_Open,
36574c8945a0SNathan Whitehorn	[AC_CHECK_LIB(gpm,initscr,
36584c8945a0SNathan Whitehorn		[LIBS="$cf_ncurses_SAVE"],
36594c8945a0SNathan Whitehorn		[cf_ncurses_LIBS="-lgpm"])])
36604c8945a0SNathan Whitehorn
3661*a96ef450SBaptiste Daroussincase "$host_os" in
3662f4f33ea0SBaptiste Daroussin(freebsd*)
36634c8945a0SNathan Whitehorn	# This is only necessary if you are linking against an obsolete
36644c8945a0SNathan Whitehorn	# version of ncurses (but it should do no harm, since it's static).
36654c8945a0SNathan Whitehorn	if test "$cf_nculib_root" = ncurses ; then
36664c8945a0SNathan Whitehorn		AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
36674c8945a0SNathan Whitehorn	fi
36684c8945a0SNathan Whitehorn	;;
36694c8945a0SNathan Whitehornesac
36704c8945a0SNathan Whitehorn
36717a1c0d96SNathan WhitehornCF_ADD_LIBS($cf_ncurses_LIBS)
36724c8945a0SNathan Whitehorn
3673*a96ef450SBaptiste Daroussinif test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no"
36744c8945a0SNathan Whitehornthen
36757a1c0d96SNathan Whitehorn	CF_ADD_LIBS(-l$cf_nculib_root)
36764c8945a0SNathan Whitehornelse
36774c8945a0SNathan Whitehorn	CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
36787a1c0d96SNathan Whitehorn		[#include <${cf_cv_ncurses_header:-curses.h}>],
36794c8945a0SNathan Whitehorn		[initscr()],
36804c8945a0SNathan Whitehorn		initscr)
36814c8945a0SNathan Whitehornfi
36824c8945a0SNathan Whitehorn
36834c8945a0SNathan Whitehornif test -n "$cf_ncurses_LIBS" ; then
36844c8945a0SNathan Whitehorn	AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
36854c8945a0SNathan Whitehorn	cf_ncurses_SAVE="$LIBS"
36864c8945a0SNathan Whitehorn	for p in $cf_ncurses_LIBS ; do
3687*a96ef450SBaptiste Daroussin		q=`echo "$LIBS" | sed -e "s%$p %%" -e "s%$p$%%"`
36884c8945a0SNathan Whitehorn		if test "$q" != "$LIBS" ; then
36894c8945a0SNathan Whitehorn			LIBS="$q"
36904c8945a0SNathan Whitehorn		fi
36914c8945a0SNathan Whitehorn	done
36927a1c0d96SNathan Whitehorn	AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
3693*a96ef450SBaptiste Daroussin		[initscr(); mousemask(0,0); tigetstr((char *)0);],
36944c8945a0SNathan Whitehorn		[AC_MSG_RESULT(yes)],
36954c8945a0SNathan Whitehorn		[AC_MSG_RESULT(no)
36964c8945a0SNathan Whitehorn		 LIBS="$cf_ncurses_SAVE"])
36974c8945a0SNathan Whitehornfi
36984c8945a0SNathan Whitehorn
36994c8945a0SNathan WhitehornCF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
37004c8945a0SNathan WhitehornAC_DEFINE_UNQUOTED($cf_nculib_ROOT)
37014c8945a0SNathan Whitehorn])dnl
37024c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3703f4f33ea0SBaptiste Daroussindnl CF_NCURSES_PTHREADS version: 2 updated: 2016/04/22 05:07:41
3704f4f33ea0SBaptiste Daroussindnl -------------------
3705f4f33ea0SBaptiste Daroussindnl Use this followup check to ensure that we link with pthreads if ncurses
3706f4f33ea0SBaptiste Daroussindnl uses it.
3707f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_NCURSES_PTHREADS],[
3708f4f33ea0SBaptiste Daroussin: ${cf_nculib_root:=ifelse($1,,ncurses,$1)}
3709f4f33ea0SBaptiste DaroussinAC_CHECK_LIB($cf_nculib_root,_nc_init_pthreads,
3710f4f33ea0SBaptiste Daroussin	cf_cv_ncurses_pthreads=yes,
3711f4f33ea0SBaptiste Daroussin	cf_cv_ncurses_pthreads=no)
3712f4f33ea0SBaptiste Daroussinif test "$cf_cv_ncurses_pthreads" = yes
3713f4f33ea0SBaptiste Daroussinthen
3714f4f33ea0SBaptiste Daroussin	CF_ADD_LIBS(-lpthread)
3715f4f33ea0SBaptiste Daroussinfi
3716f4f33ea0SBaptiste Daroussin])dnl
3717f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
3718*a96ef450SBaptiste Daroussindnl CF_NCURSES_VERSION version: 16 updated: 2020/12/31 20:19:42
37194c8945a0SNathan Whitehorndnl ------------------
37204c8945a0SNathan Whitehorndnl Check for the version of ncurses, to aid in reporting bugs, etc.
37214c8945a0SNathan Whitehorndnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
37224c8945a0SNathan Whitehorndnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
37234c8945a0SNathan WhitehornAC_DEFUN([CF_NCURSES_VERSION],
37244c8945a0SNathan Whitehorn[
37254c8945a0SNathan WhitehornAC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
37264c8945a0SNathan WhitehornAC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
37274c8945a0SNathan Whitehorn	cf_cv_ncurses_version=no
37284c8945a0SNathan Whitehorn	cf_tempfile=out$$
3729*a96ef450SBaptiste Daroussin	rm -f "$cf_tempfile"
37304c8945a0SNathan Whitehorn	AC_TRY_RUN([
37317a1c0d96SNathan Whitehorn#include <${cf_cv_ncurses_header:-curses.h}>
37324c8945a0SNathan Whitehorn#include <stdio.h>
3733f4f33ea0SBaptiste Daroussinint main(void)
37344c8945a0SNathan Whitehorn{
37354c8945a0SNathan Whitehorn	FILE *fp = fopen("$cf_tempfile", "w");
37364c8945a0SNathan Whitehorn#ifdef NCURSES_VERSION
37374c8945a0SNathan Whitehorn# ifdef NCURSES_VERSION_PATCH
3738*a96ef450SBaptiste Daroussin	fprintf(fp, "%s.%d\\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
37394c8945a0SNathan Whitehorn# else
3740*a96ef450SBaptiste Daroussin	fprintf(fp, "%s\\n", NCURSES_VERSION);
37414c8945a0SNathan Whitehorn# endif
37424c8945a0SNathan Whitehorn#else
37434c8945a0SNathan Whitehorn# ifdef __NCURSES_H
3744*a96ef450SBaptiste Daroussin	fprintf(fp, "old\\n");
37454c8945a0SNathan Whitehorn# else
37464c8945a0SNathan Whitehorn	make an error
37474c8945a0SNathan Whitehorn# endif
37484c8945a0SNathan Whitehorn#endif
37497a1c0d96SNathan Whitehorn	${cf_cv_main_return:-return}(0);
37504c8945a0SNathan Whitehorn}],[
37514c8945a0SNathan Whitehorn	cf_cv_ncurses_version=`cat $cf_tempfile`],,[
37524c8945a0SNathan Whitehorn
37534c8945a0SNathan Whitehorn	# This will not work if the preprocessor splits the line after the
37544c8945a0SNathan Whitehorn	# Autoconf token.  The 'unproto' program does that.
3755*a96ef450SBaptiste Daroussin	cat > "conftest.$ac_ext" <<EOF
37567a1c0d96SNathan Whitehorn#include <${cf_cv_ncurses_header:-curses.h}>
37574c8945a0SNathan Whitehorn#undef Autoconf
37584c8945a0SNathan Whitehorn#ifdef NCURSES_VERSION
37594c8945a0SNathan WhitehornAutoconf NCURSES_VERSION
37604c8945a0SNathan Whitehorn#else
37614c8945a0SNathan Whitehorn#ifdef __NCURSES_H
37624c8945a0SNathan WhitehornAutoconf "old"
37634c8945a0SNathan Whitehorn#endif
37644c8945a0SNathan Whitehorn;
37654c8945a0SNathan Whitehorn#endif
37664c8945a0SNathan WhitehornEOF
37674c8945a0SNathan Whitehorn	cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
37684c8945a0SNathan Whitehorn	AC_TRY_EVAL(cf_try)
37694c8945a0SNathan Whitehorn	if test -f conftest.out ; then
3770*a96ef450SBaptiste Daroussin		cf_out=`sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%' conftest.out`
37714c8945a0SNathan Whitehorn		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
37724c8945a0SNathan Whitehorn		rm -f conftest.out
37734c8945a0SNathan Whitehorn	fi
37744c8945a0SNathan Whitehorn])
3775*a96ef450SBaptiste Daroussin	rm -f "$cf_tempfile"
37764c8945a0SNathan Whitehorn])
37772a3e3873SBaptiste Daroussintest "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
37784c8945a0SNathan Whitehorn])dnl
37794c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3780*a96ef450SBaptiste Daroussindnl CF_NL_LANGINFO_1STDAY version: 3 updated: 2020/03/19 20:23:48
3781f4f33ea0SBaptiste Daroussindnl ---------------------
3782f4f33ea0SBaptiste Daroussindnl glibc locale support has runtime extensions which might be implemented in
3783f4f33ea0SBaptiste Daroussindnl other systems.
3784f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_NL_LANGINFO_1STDAY],[
3785f4f33ea0SBaptiste DaroussinAC_CACHE_CHECK(if runtime has nl_langinfo support for first weekday,
3786f4f33ea0SBaptiste Daroussin	cf_nl_langinfo_1stday,[
3787f4f33ea0SBaptiste Daroussin	AC_TRY_COMPILE([
3788f4f33ea0SBaptiste Daroussin#include <langinfo.h>
3789f4f33ea0SBaptiste Daroussin#include <locale.h>
3790f4f33ea0SBaptiste Daroussin],[
3791f4f33ea0SBaptiste Daroussin	int first_weekday = nl_langinfo (_NL_TIME_FIRST_WEEKDAY)[0];
3792f4f33ea0SBaptiste Daroussin	long week_1stday_l = (long) nl_langinfo (_NL_TIME_WEEK_1STDAY);
3793*a96ef450SBaptiste Daroussin	(void) first_weekday;
3794*a96ef450SBaptiste Daroussin	(void) week_1stday_l;
3795f4f33ea0SBaptiste Daroussin],[cf_nl_langinfo_1stday=yes
3796f4f33ea0SBaptiste Daroussin],[cf_nl_langinfo_1stday=no
3797f4f33ea0SBaptiste Daroussin])
3798f4f33ea0SBaptiste Daroussin])
3799*a96ef450SBaptiste Daroussintest "x$cf_nl_langinfo_1stday" = xyes && AC_DEFINE(HAVE_NL_LANGINFO_1STDAY,1,[Define to 1 if runtime has nl_langinfo support for first weekday])
3800f4f33ea0SBaptiste Daroussin])dnl
3801f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
3802*a96ef450SBaptiste Daroussindnl CF_NO_LEAKS_OPTION version: 8 updated: 2021/01/05 20:05:09
38034c8945a0SNathan Whitehorndnl ------------------
38044c8945a0SNathan Whitehorndnl see CF_WITH_NO_LEAKS
38054c8945a0SNathan WhitehornAC_DEFUN([CF_NO_LEAKS_OPTION],[
38064c8945a0SNathan WhitehornAC_MSG_CHECKING(if you want to use $1 for testing)
38074c8945a0SNathan WhitehornAC_ARG_WITH($1,
38084c8945a0SNathan Whitehorn	[$2],
38092a3e3873SBaptiste Daroussin	[AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
38104c8945a0SNathan Whitehorn	 $4
38114c8945a0SNathan Whitehorn])
3812*a96ef450SBaptiste Daroussin	: "${with_cflags:=-g}"
3813*a96ef450SBaptiste Daroussin	: "${enable_leaks:=no}"
38144c8945a0SNathan Whitehorn	 with_$1=yes],
38154c8945a0SNathan Whitehorn	[with_$1=])
38164c8945a0SNathan WhitehornAC_MSG_RESULT(${with_$1:-no})
38174c8945a0SNathan Whitehorn
3818*a96ef450SBaptiste Daroussincase ".$with_cflags" in
3819f4f33ea0SBaptiste Daroussin(.*-g*)
3820f4f33ea0SBaptiste Daroussin	case .$CFLAGS in
3821f4f33ea0SBaptiste Daroussin	(.*-g*)
38224c8945a0SNathan Whitehorn		;;
3823f4f33ea0SBaptiste Daroussin	(*)
38244c8945a0SNathan Whitehorn		CF_ADD_CFLAGS([-g])
38254c8945a0SNathan Whitehorn		;;
38264c8945a0SNathan Whitehorn	esac
38274c8945a0SNathan Whitehorn	;;
38284c8945a0SNathan Whitehornesac
38294c8945a0SNathan Whitehorn])dnl
38304c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3831f4f33ea0SBaptiste Daroussindnl CF_NUMBER_SYNTAX version: 2 updated: 2015/04/17 21:13:04
3832febdb468SDevin Teskednl ----------------
3833febdb468SDevin Teskednl Check if the given variable is a number.  If not, report an error.
3834febdb468SDevin Teskednl $1 is the variable
3835febdb468SDevin Teskednl $2 is the message
3836febdb468SDevin TeskeAC_DEFUN([CF_NUMBER_SYNTAX],[
3837febdb468SDevin Teskeif test -n "$1" ; then
3838f4f33ea0SBaptiste Daroussin  case $1 in
3839f4f33ea0SBaptiste Daroussin  ([[0-9]]*)
3840febdb468SDevin Teske 	;;
3841f4f33ea0SBaptiste Daroussin  (*)
3842febdb468SDevin Teske	AC_MSG_ERROR($2 is not a number: $1)
3843febdb468SDevin Teske 	;;
3844febdb468SDevin Teske  esac
3845febdb468SDevin Teskeelse
3846febdb468SDevin Teske  AC_MSG_ERROR($2 value is empty)
3847febdb468SDevin Teskefi
3848febdb468SDevin Teske])dnl
3849febdb468SDevin Teskednl ---------------------------------------------------------------------------
3850*a96ef450SBaptiste Daroussindnl CF_OUR_MESSAGES version: 8 updated: 2021/01/02 09:31:20
38514c8945a0SNathan Whitehorndnl ---------------
38524c8945a0SNathan Whitehorndnl Check if we use the messages included with this program
38534c8945a0SNathan Whitehorndnl
38544c8945a0SNathan Whitehorndnl $1 specifies either Makefile or makefile, defaulting to the former.
38554c8945a0SNathan Whitehorndnl
38564c8945a0SNathan Whitehorndnl Sets variables which can be used to substitute in makefiles:
38574c8945a0SNathan Whitehorndnl	MSG_DIR_MAKE - to make ./po directory
38584c8945a0SNathan Whitehorndnl	SUB_MAKEFILE - makefile in ./po directory (see CF_BUNDLED_INTL)
38594c8945a0SNathan Whitehorndnl
38604c8945a0SNathan WhitehornAC_DEFUN([CF_OUR_MESSAGES],
38614c8945a0SNathan Whitehorn[
38624c8945a0SNathan Whitehorncf_makefile=ifelse($1,,Makefile,$1)
38634c8945a0SNathan Whitehorn
38644c8945a0SNathan Whitehornuse_our_messages=no
38654c8945a0SNathan Whitehornif test "$USE_NLS" = yes ; then
3866*a96ef450SBaptiste Daroussinif test -d "$srcdir/po" ; then
38674c8945a0SNathan WhitehornAC_MSG_CHECKING(if we should use included message-library)
38684c8945a0SNathan Whitehorn	AC_ARG_ENABLE(included-msgs,
38694c8945a0SNathan Whitehorn	[  --disable-included-msgs use included messages, for i18n support],
38704c8945a0SNathan Whitehorn	[use_our_messages=$enableval],
38714c8945a0SNathan Whitehorn	[use_our_messages=yes])
38724c8945a0SNathan Whitehornfi
38734c8945a0SNathan WhitehornAC_MSG_RESULT($use_our_messages)
38744c8945a0SNathan Whitehornfi
38754c8945a0SNathan Whitehorn
38764c8945a0SNathan WhitehornMSG_DIR_MAKE="#"
38774c8945a0SNathan Whitehornif test "$use_our_messages" = yes
38784c8945a0SNathan Whitehornthen
38794c8945a0SNathan Whitehorn	SUB_MAKEFILE="$SUB_MAKEFILE po/$cf_makefile.in:$srcdir/po/$cf_makefile.inn"
38804c8945a0SNathan Whitehorn	MSG_DIR_MAKE=
38814c8945a0SNathan Whitehornfi
38824c8945a0SNathan Whitehorn
38834c8945a0SNathan WhitehornAC_SUBST(MSG_DIR_MAKE)
38844c8945a0SNathan WhitehornAC_SUBST(SUB_MAKEFILE)
38854c8945a0SNathan Whitehorn])dnl
38864c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3887*a96ef450SBaptiste Daroussindnl CF_PATHSEP version: 8 updated: 2021/01/01 13:31:04
38884c8945a0SNathan Whitehorndnl ----------
38892a3e3873SBaptiste Daroussindnl Provide a value for the $PATH and similar separator (or amend the value
38902a3e3873SBaptiste Daroussindnl as provided in autoconf 2.5x).
38914c8945a0SNathan WhitehornAC_DEFUN([CF_PATHSEP],
38924c8945a0SNathan Whitehorn[
38932a3e3873SBaptiste Daroussin	AC_MSG_CHECKING(for PATH separator)
3894*a96ef450SBaptiste Daroussin	case "$cf_cv_system_name" in
3895f4f33ea0SBaptiste Daroussin	(os2*)	PATH_SEPARATOR=';'  ;;
3896f4f33ea0SBaptiste Daroussin	(*)	${PATH_SEPARATOR:=':'}  ;;
38974c8945a0SNathan Whitehorn	esac
38987a1c0d96SNathan Whitehornifelse([$1],,,[$1=$PATH_SEPARATOR])
38994c8945a0SNathan Whitehorn	AC_SUBST(PATH_SEPARATOR)
39002a3e3873SBaptiste Daroussin	AC_MSG_RESULT($PATH_SEPARATOR)
39014c8945a0SNathan Whitehorn])dnl
39024c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3903*a96ef450SBaptiste Daroussindnl CF_PATH_SYNTAX version: 18 updated: 2020/12/31 18:40:20
39044c8945a0SNathan Whitehorndnl --------------
39054c8945a0SNathan Whitehorndnl Check the argument to see that it looks like a pathname.  Rewrite it if it
39064c8945a0SNathan Whitehorndnl begins with one of the prefix/exec_prefix variables, and then again if the
39074c8945a0SNathan Whitehorndnl result begins with 'NONE'.  This is necessary to work around autoconf's
39084c8945a0SNathan Whitehorndnl delayed evaluation of those symbols.
39094c8945a0SNathan WhitehornAC_DEFUN([CF_PATH_SYNTAX],[
39104c8945a0SNathan Whitehornif test "x$prefix" != xNONE; then
39114c8945a0SNathan Whitehorn	cf_path_syntax="$prefix"
39124c8945a0SNathan Whitehornelse
39134c8945a0SNathan Whitehorn	cf_path_syntax="$ac_default_prefix"
39144c8945a0SNathan Whitehornfi
39154c8945a0SNathan Whitehorn
3916f4f33ea0SBaptiste Daroussincase ".[$]$1" in
3917f4f33ea0SBaptiste Daroussin(.\[$]\(*\)*|.\'*\'*)
39184c8945a0SNathan Whitehorn	;;
3919f4f33ea0SBaptiste Daroussin(..|./*|.\\*)
39204c8945a0SNathan Whitehorn	;;
3921f4f33ea0SBaptiste Daroussin(.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
39224c8945a0SNathan Whitehorn	;;
3923*a96ef450SBaptiste Daroussin(.\[$]\{*prefix\}*|.\[$]\{*dir\}*)
39244c8945a0SNathan Whitehorn	eval $1="[$]$1"
3925f4f33ea0SBaptiste Daroussin	case ".[$]$1" in
3926f4f33ea0SBaptiste Daroussin	(.NONE/*)
3927*a96ef450SBaptiste Daroussin		$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
39284c8945a0SNathan Whitehorn		;;
39294c8945a0SNathan Whitehorn	esac
3930f4f33ea0SBaptiste Daroussin	;;
3931f4f33ea0SBaptiste Daroussin(.no|.NONE/*)
3932*a96ef450SBaptiste Daroussin	$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
39334c8945a0SNathan Whitehorn	;;
3934f4f33ea0SBaptiste Daroussin(*)
39357a1c0d96SNathan Whitehorn	ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
39364c8945a0SNathan Whitehorn	;;
39374c8945a0SNathan Whitehornesac
39384c8945a0SNathan Whitehorn])dnl
39394c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
3940*a96ef450SBaptiste Daroussindnl CF_PDCURSES_X11 version: 15 updated: 2021/01/02 09:31:20
3941f4f33ea0SBaptiste Daroussindnl ---------------
3942f4f33ea0SBaptiste Daroussindnl Configure for PDCurses' X11 library
3943f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_PDCURSES_X11],[
3944f4f33ea0SBaptiste DaroussinAC_REQUIRE([CF_X_ATHENA])
3945f4f33ea0SBaptiste Daroussin
3946f4f33ea0SBaptiste DaroussinCF_ACVERSION_CHECK(2.52,
3947f4f33ea0SBaptiste Daroussin	[AC_CHECK_TOOLS(XCURSES_CONFIG, xcurses-config, none)],
3948f4f33ea0SBaptiste Daroussin	[AC_PATH_PROGS(XCURSES_CONFIG, xcurses-config, none)])
3949f4f33ea0SBaptiste Daroussin
3950f4f33ea0SBaptiste Daroussinif test "$XCURSES_CONFIG" != none ; then
3951f4f33ea0SBaptiste Daroussin
3952f4f33ea0SBaptiste DaroussinCF_ADD_CFLAGS(`$XCURSES_CONFIG --cflags`)
3953f4f33ea0SBaptiste DaroussinCF_ADD_LIBS(`$XCURSES_CONFIG --libs`)
3954f4f33ea0SBaptiste Daroussin
3955f4f33ea0SBaptiste Daroussincf_cv_lib_XCurses=yes
3956f4f33ea0SBaptiste Daroussin
3957f4f33ea0SBaptiste Daroussinelse
3958f4f33ea0SBaptiste Daroussin
3959f4f33ea0SBaptiste DaroussinLDFLAGS="$LDFLAGS $X_LIBS"
3960f4f33ea0SBaptiste DaroussinCF_CHECK_CFLAGS($X_CFLAGS)
3961f4f33ea0SBaptiste DaroussinAC_CHECK_LIB(X11,XOpenDisplay,
3962f4f33ea0SBaptiste Daroussin	[CF_ADD_LIBS(-lX11)],,
3963f4f33ea0SBaptiste Daroussin	[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
3964f4f33ea0SBaptiste DaroussinAC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
3965f4f33ea0SBaptiste DaroussinCF_ADD_LIBS(-lXCurses)
3966f4f33ea0SBaptiste DaroussinAC_TRY_LINK([
3967f4f33ea0SBaptiste Daroussin#include <xcurses.h>
3968f4f33ea0SBaptiste Daroussinchar *XCursesProgramName = "test";
3969f4f33ea0SBaptiste Daroussin],[XCursesExit();],
3970f4f33ea0SBaptiste Daroussin[cf_cv_lib_XCurses=yes],
3971f4f33ea0SBaptiste Daroussin[cf_cv_lib_XCurses=no])
3972f4f33ea0SBaptiste Daroussin])
3973f4f33ea0SBaptiste Daroussin
3974f4f33ea0SBaptiste Daroussinfi
3975f4f33ea0SBaptiste Daroussin
3976*a96ef450SBaptiste Daroussinif test "$cf_cv_lib_XCurses" = yes ; then
3977f4f33ea0SBaptiste Daroussin	AC_DEFINE(UNIX,1,[Define to 1 if using PDCurses on Unix])
3978f4f33ea0SBaptiste Daroussin	AC_DEFINE(XCURSES,1,[Define to 1 if using PDCurses on Unix])
3979f4f33ea0SBaptiste Daroussin	AC_CHECK_HEADER(xcurses.h, AC_DEFINE(HAVE_XCURSES,1,[Define to 1 if using PDCurses on Unix]))
3980f4f33ea0SBaptiste Daroussinelse
3981f4f33ea0SBaptiste Daroussin	AC_MSG_ERROR(Cannot link with XCurses)
3982f4f33ea0SBaptiste Daroussinfi
3983f4f33ea0SBaptiste Daroussin])dnl
3984f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
3985*a96ef450SBaptiste Daroussindnl CF_PKG_CONFIG version: 11 updated: 2021/01/01 13:31:04
3986febdb468SDevin Teskednl -------------
3987febdb468SDevin Teskednl Check for the package-config program, unless disabled by command-line.
3988febdb468SDevin TeskeAC_DEFUN([CF_PKG_CONFIG],
3989febdb468SDevin Teske[
3990febdb468SDevin TeskeAC_MSG_CHECKING(if you want to use pkg-config)
3991febdb468SDevin TeskeAC_ARG_WITH(pkg-config,
3992febdb468SDevin Teske	[  --with-pkg-config{=path} enable/disable use of pkg-config],
3993febdb468SDevin Teske	[cf_pkg_config=$withval],
3994febdb468SDevin Teske	[cf_pkg_config=yes])
3995febdb468SDevin TeskeAC_MSG_RESULT($cf_pkg_config)
3996febdb468SDevin Teske
3997*a96ef450SBaptiste Daroussincase "$cf_pkg_config" in
3998f4f33ea0SBaptiste Daroussin(no)
3999febdb468SDevin Teske	PKG_CONFIG=none
4000febdb468SDevin Teske	;;
4001f4f33ea0SBaptiste Daroussin(yes)
4002febdb468SDevin Teske	CF_ACVERSION_CHECK(2.52,
4003febdb468SDevin Teske		[AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
4004febdb468SDevin Teske		[AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
4005febdb468SDevin Teske	;;
4006f4f33ea0SBaptiste Daroussin(*)
4007febdb468SDevin Teske	PKG_CONFIG=$withval
4008febdb468SDevin Teske	;;
4009febdb468SDevin Teskeesac
4010febdb468SDevin Teske
4011febdb468SDevin Tesketest -z "$PKG_CONFIG" && PKG_CONFIG=none
4012febdb468SDevin Teskeif test "$PKG_CONFIG" != none ; then
4013febdb468SDevin Teske	CF_PATH_SYNTAX(PKG_CONFIG)
4014f4f33ea0SBaptiste Daroussinelif test "x$cf_pkg_config" != xno ; then
4015f4f33ea0SBaptiste Daroussin	AC_MSG_WARN(pkg-config is not installed)
4016febdb468SDevin Teskefi
4017febdb468SDevin Teske
4018febdb468SDevin TeskeAC_SUBST(PKG_CONFIG)
4019febdb468SDevin Teske])dnl
4020febdb468SDevin Teskednl ---------------------------------------------------------------------------
4021*a96ef450SBaptiste Daroussindnl CF_POSIX_C_SOURCE version: 11 updated: 2018/12/31 20:46:17
40224c8945a0SNathan Whitehorndnl -----------------
40234c8945a0SNathan Whitehorndnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
40244c8945a0SNathan Whitehorndnl
40254c8945a0SNathan Whitehorndnl	POSIX.1-1990				_POSIX_SOURCE
40264c8945a0SNathan Whitehorndnl	POSIX.1-1990 and			_POSIX_SOURCE and
40274c8945a0SNathan Whitehorndnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
40284c8945a0SNathan Whitehorndnl		Bindings Option
40294c8945a0SNathan Whitehorndnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
40304c8945a0SNathan Whitehorndnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
40314c8945a0SNathan Whitehorndnl	X/Open 2000				_POSIX_C_SOURCE=200112L
40324c8945a0SNathan Whitehorndnl
40334c8945a0SNathan Whitehorndnl Parameters:
40344c8945a0SNathan Whitehorndnl	$1 is the nominal value for _POSIX_C_SOURCE
40354c8945a0SNathan WhitehornAC_DEFUN([CF_POSIX_C_SOURCE],
4036*a96ef450SBaptiste Daroussin[AC_REQUIRE([CF_POSIX_VISIBLE])dnl
4037*a96ef450SBaptiste Daroussin
4038*a96ef450SBaptiste Daroussinif test "$cf_cv_posix_visible" = no; then
4039*a96ef450SBaptiste Daroussin
40407a1c0d96SNathan Whitehorncf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
40414c8945a0SNathan Whitehorn
40424c8945a0SNathan Whitehorncf_save_CFLAGS="$CFLAGS"
40434c8945a0SNathan Whitehorncf_save_CPPFLAGS="$CPPFLAGS"
40444c8945a0SNathan Whitehorn
40454c8945a0SNathan WhitehornCF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
40464c8945a0SNathan WhitehornCF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
40474c8945a0SNathan Whitehorn
40484c8945a0SNathan WhitehornAC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
40494c8945a0SNathan Whitehorn	CF_MSG_LOG(if the symbol is already defined go no further)
40504c8945a0SNathan Whitehorn	AC_TRY_COMPILE([#include <sys/types.h>],[
40514c8945a0SNathan Whitehorn#ifndef _POSIX_C_SOURCE
40524c8945a0SNathan Whitehornmake an error
40534c8945a0SNathan Whitehorn#endif],
40544c8945a0SNathan Whitehorn	[cf_cv_posix_c_source=no],
40554c8945a0SNathan Whitehorn	[cf_want_posix_source=no
4056f4f33ea0SBaptiste Daroussin	 case .$cf_POSIX_C_SOURCE in
4057f4f33ea0SBaptiste Daroussin	 (.[[12]]??*)
40584c8945a0SNathan Whitehorn		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
40594c8945a0SNathan Whitehorn		;;
4060f4f33ea0SBaptiste Daroussin	 (.2)
40614c8945a0SNathan Whitehorn		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
40624c8945a0SNathan Whitehorn		cf_want_posix_source=yes
40634c8945a0SNathan Whitehorn		;;
4064f4f33ea0SBaptiste Daroussin	 (.*)
40654c8945a0SNathan Whitehorn		cf_want_posix_source=yes
40664c8945a0SNathan Whitehorn		;;
40674c8945a0SNathan Whitehorn	 esac
40684c8945a0SNathan Whitehorn	 if test "$cf_want_posix_source" = yes ; then
40694c8945a0SNathan Whitehorn		AC_TRY_COMPILE([#include <sys/types.h>],[
40704c8945a0SNathan Whitehorn#ifdef _POSIX_SOURCE
40714c8945a0SNathan Whitehornmake an error
40724c8945a0SNathan Whitehorn#endif],[],
40734c8945a0SNathan Whitehorn		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
40744c8945a0SNathan Whitehorn	 fi
40754c8945a0SNathan Whitehorn	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
40764c8945a0SNathan Whitehorn	 CFLAGS="$cf_trim_CFLAGS"
4077f4f33ea0SBaptiste Daroussin	 CPPFLAGS="$cf_trim_CPPFLAGS"
4078f4f33ea0SBaptiste Daroussin	 CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
40794c8945a0SNathan Whitehorn	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
40804c8945a0SNathan Whitehorn	 AC_TRY_COMPILE([#include <sys/types.h>],[
40814c8945a0SNathan Whitehorn#ifndef _POSIX_C_SOURCE
40824c8945a0SNathan Whitehornmake an error
40834c8945a0SNathan Whitehorn#endif],,
40844c8945a0SNathan Whitehorn	 [cf_cv_posix_c_source=no])
40854c8945a0SNathan Whitehorn	 CFLAGS="$cf_save_CFLAGS"
40864c8945a0SNathan Whitehorn	 CPPFLAGS="$cf_save_CPPFLAGS"
40874c8945a0SNathan Whitehorn	])
40884c8945a0SNathan Whitehorn])
40894c8945a0SNathan Whitehorn
40904c8945a0SNathan Whitehornif test "$cf_cv_posix_c_source" != no ; then
40914c8945a0SNathan Whitehorn	CFLAGS="$cf_trim_CFLAGS"
40924c8945a0SNathan Whitehorn	CPPFLAGS="$cf_trim_CPPFLAGS"
40934c8945a0SNathan Whitehorn	CF_ADD_CFLAGS($cf_cv_posix_c_source)
40944c8945a0SNathan Whitehornfi
40954c8945a0SNathan Whitehorn
4096*a96ef450SBaptiste Daroussinfi # cf_cv_posix_visible
4097*a96ef450SBaptiste Daroussin
4098*a96ef450SBaptiste Daroussin])dnl
4099*a96ef450SBaptiste Daroussindnl ---------------------------------------------------------------------------
4100*a96ef450SBaptiste Daroussindnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
4101*a96ef450SBaptiste Daroussindnl ----------------
4102*a96ef450SBaptiste Daroussindnl POSIX documents test-macros which an application may set before any system
4103*a96ef450SBaptiste Daroussindnl headers are included to make features available.
4104*a96ef450SBaptiste Daroussindnl
4105*a96ef450SBaptiste Daroussindnl Some BSD platforms (originally FreeBSD, but copied by a few others)
4106*a96ef450SBaptiste Daroussindnl diverged from POSIX in 2002 by setting symbols which make all of the most
4107*a96ef450SBaptiste Daroussindnl recent features visible in the system header files unless the application
4108*a96ef450SBaptiste Daroussindnl overrides the corresponding test-macros.  Doing that introduces portability
4109*a96ef450SBaptiste Daroussindnl problems.
4110*a96ef450SBaptiste Daroussindnl
4111*a96ef450SBaptiste Daroussindnl This macro makes a special check for the symbols used for this, to avoid a
4112*a96ef450SBaptiste Daroussindnl conflicting definition.
4113*a96ef450SBaptiste DaroussinAC_DEFUN([CF_POSIX_VISIBLE],
4114*a96ef450SBaptiste Daroussin[
4115*a96ef450SBaptiste DaroussinAC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
4116*a96ef450SBaptiste DaroussinAC_TRY_COMPILE([#include <stdio.h>],[
4117*a96ef450SBaptiste Daroussin#if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
4118*a96ef450SBaptiste Daroussin	&& defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
4119*a96ef450SBaptiste Daroussin	&& defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
4120*a96ef450SBaptiste Daroussin	&& defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
4121*a96ef450SBaptiste Daroussin#error conflicting symbols found
4122*a96ef450SBaptiste Daroussin#endif
4123*a96ef450SBaptiste Daroussin],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
4124*a96ef450SBaptiste Daroussin])
41254c8945a0SNathan Whitehorn])dnl
41264c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
4127f4f33ea0SBaptiste Daroussindnl CF_PROG_AR version: 1 updated: 2009/01/01 20:15:22
4128f4f33ea0SBaptiste Daroussindnl ----------
4129f4f33ea0SBaptiste Daroussindnl Check for archiver "ar".
4130f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_PROG_AR],[
4131f4f33ea0SBaptiste DaroussinAC_CHECK_TOOL(AR, ar, ar)
4132f4f33ea0SBaptiste Daroussin])
4133f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
4134*a96ef450SBaptiste Daroussindnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
41352a3e3873SBaptiste Daroussindnl ----------
41362a3e3873SBaptiste Daroussindnl standard check for CC, plus followup sanity checks
41372a3e3873SBaptiste Daroussindnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
41382a3e3873SBaptiste DaroussinAC_DEFUN([CF_PROG_CC],[
4139*a96ef450SBaptiste DaroussinCF_ACVERSION_CHECK(2.53,
4140*a96ef450SBaptiste Daroussin	[AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
4141*a96ef450SBaptiste Daroussin	 AC_REQUIRE([AC_PROG_CC])],
4142*a96ef450SBaptiste Daroussin	[])
41432a3e3873SBaptiste Daroussinifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
41442a3e3873SBaptiste DaroussinCF_GCC_VERSION
41452a3e3873SBaptiste DaroussinCF_ACVERSION_CHECK(2.52,
41462a3e3873SBaptiste Daroussin	[AC_PROG_CC_STDC],
41472a3e3873SBaptiste Daroussin	[CF_ANSI_CC_REQD])
41482a3e3873SBaptiste DaroussinCF_CC_ENV_FLAGS
41494c8945a0SNathan Whitehorn])dnl
41504c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
4151*a96ef450SBaptiste Daroussindnl CF_PROG_EXT version: 15 updated: 2021/01/02 09:31:20
41524c8945a0SNathan Whitehorndnl -----------
41534c8945a0SNathan Whitehorndnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
41544c8945a0SNathan WhitehornAC_DEFUN([CF_PROG_EXT],
41554c8945a0SNathan Whitehorn[
41564c8945a0SNathan WhitehornAC_REQUIRE([CF_CHECK_CACHE])
4157*a96ef450SBaptiste Daroussincase "$cf_cv_system_name" in
4158f4f33ea0SBaptiste Daroussin(os2*)
41594c8945a0SNathan Whitehorn	CFLAGS="$CFLAGS -Zmt"
4160f4f33ea0SBaptiste Daroussin	CF_APPEND_TEXT(CPPFLAGS,-D__ST_MT_ERRNO__)
41614c8945a0SNathan Whitehorn	CXXFLAGS="$CXXFLAGS -Zmt"
41624c8945a0SNathan Whitehorn	# autoconf's macro sets -Zexe and suffix both, which conflict:w
41634c8945a0SNathan Whitehorn	LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
41644c8945a0SNathan Whitehorn	ac_cv_exeext=.exe
41654c8945a0SNathan Whitehorn	;;
41664c8945a0SNathan Whitehornesac
41674c8945a0SNathan Whitehorn
41684c8945a0SNathan WhitehornAC_EXEEXT
41694c8945a0SNathan WhitehornAC_OBJEXT
41704c8945a0SNathan Whitehorn
41714c8945a0SNathan WhitehornPROG_EXT="$EXEEXT"
41724c8945a0SNathan WhitehornAC_SUBST(PROG_EXT)
41732a3e3873SBaptiste Daroussintest -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT",[Define to the program extension (normally blank)])
41742a3e3873SBaptiste Daroussin])dnl
41752a3e3873SBaptiste Daroussindnl ---------------------------------------------------------------------------
4176f4f33ea0SBaptiste Daroussindnl CF_PROG_GROFF version: 3 updated: 2018/01/07 13:16:19
4177f4f33ea0SBaptiste Daroussindnl -------------
4178f4f33ea0SBaptiste Daroussindnl Check if groff is available, for cases (such as html output) where nroff
4179f4f33ea0SBaptiste Daroussindnl is not enough.
4180f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_PROG_GROFF],[
4181f4f33ea0SBaptiste DaroussinAC_PATH_PROG(GROFF_PATH,groff,no)
4182f4f33ea0SBaptiste DaroussinAC_PATH_PROGS(NROFF_PATH,nroff mandoc,no)
4183f4f33ea0SBaptiste DaroussinAC_PATH_PROG(TBL_PATH,tbl,cat)
4184f4f33ea0SBaptiste Daroussinif test "x$GROFF_PATH" = xno
4185f4f33ea0SBaptiste Daroussinthen
4186f4f33ea0SBaptiste Daroussin	NROFF_NOTE=
4187f4f33ea0SBaptiste Daroussin	GROFF_NOTE="#"
4188f4f33ea0SBaptiste Daroussinelse
4189f4f33ea0SBaptiste Daroussin	NROFF_NOTE="#"
4190f4f33ea0SBaptiste Daroussin	GROFF_NOTE=
4191f4f33ea0SBaptiste Daroussinfi
4192f4f33ea0SBaptiste DaroussinAC_SUBST(GROFF_NOTE)
4193f4f33ea0SBaptiste DaroussinAC_SUBST(NROFF_NOTE)
4194f4f33ea0SBaptiste Daroussin])dnl
4195f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
4196*a96ef450SBaptiste Daroussindnl CF_PROG_LINT version: 4 updated: 2019/11/20 18:55:37
41972a3e3873SBaptiste Daroussindnl ------------
41982a3e3873SBaptiste DaroussinAC_DEFUN([CF_PROG_LINT],
41992a3e3873SBaptiste Daroussin[
4200f4f33ea0SBaptiste DaroussinAC_CHECK_PROGS(LINT, lint cppcheck splint)
4201*a96ef450SBaptiste Daroussincase "x$LINT" in
4202*a96ef450SBaptiste Daroussin(xcppcheck|x*/cppcheck)
4203*a96ef450SBaptiste Daroussin	test -z "$LINT_OPTS" && LINT_OPTS="--enable=all"
4204*a96ef450SBaptiste Daroussin	;;
4205*a96ef450SBaptiste Daroussinesac
42062a3e3873SBaptiste DaroussinAC_SUBST(LINT_OPTS)
42074c8945a0SNathan Whitehorn])dnl
42084c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
4209febdb468SDevin Teskednl CF_PROG_LN_S version: 2 updated: 2010/08/14 18:25:37
4210febdb468SDevin Teskednl ------------
4211febdb468SDevin Teskednl Combine checks for "ln -s" and "ln -sf", updating $LN_S to include "-f"
4212febdb468SDevin Teskednl option if it is supported.
4213febdb468SDevin TeskeAC_DEFUN([CF_PROG_LN_S],[
4214febdb468SDevin TeskeAC_PROG_LN_S
4215febdb468SDevin TeskeAC_MSG_CHECKING(if $LN_S -f options work)
4216febdb468SDevin Teske
4217febdb468SDevin Teskerm -f conf$$.src conf$$dst
4218febdb468SDevin Teskeecho >conf$$.dst
4219febdb468SDevin Teskeecho first >conf$$.src
4220febdb468SDevin Teskeif $LN_S -f conf$$.src conf$$.dst 2>/dev/null; then
4221febdb468SDevin Teske	cf_prog_ln_sf=yes
4222febdb468SDevin Teskeelse
4223febdb468SDevin Teske	cf_prog_ln_sf=no
4224febdb468SDevin Teskefi
4225febdb468SDevin Teskerm -f conf$$.dst conf$$src
4226febdb468SDevin TeskeAC_MSG_RESULT($cf_prog_ln_sf)
4227febdb468SDevin Teske
4228febdb468SDevin Tesketest "$cf_prog_ln_sf" = yes && LN_S="$LN_S -f"
4229febdb468SDevin Teske])dnl
4230febdb468SDevin Teskednl ---------------------------------------------------------------------------
42314c8945a0SNathan Whitehorndnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
42324c8945a0SNathan Whitehorndnl ----------------
42334c8945a0SNathan Whitehorndnl Remove all -U and -D options that refer to the given symbol from a list
42344c8945a0SNathan Whitehorndnl of C compiler options.  This works around the problem that not all
42354c8945a0SNathan Whitehorndnl compilers process -U and -D options from left-to-right, so a -U option
42364c8945a0SNathan Whitehorndnl cannot be used to cancel the effect of a preceding -D option.
42374c8945a0SNathan Whitehorndnl
42384c8945a0SNathan Whitehorndnl $1 = target (which could be the same as the source variable)
42394c8945a0SNathan Whitehorndnl $2 = source (including '$')
42404c8945a0SNathan Whitehorndnl $3 = symbol to remove
42414c8945a0SNathan Whitehorndefine([CF_REMOVE_DEFINE],
42424c8945a0SNathan Whitehorn[
42434c8945a0SNathan Whitehorn$1=`echo "$2" | \
42444c8945a0SNathan Whitehorn	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
42454c8945a0SNathan Whitehorn		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
42464c8945a0SNathan Whitehorn])dnl
42474c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
4248*a96ef450SBaptiste Daroussindnl CF_RESTORE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:47:45
4249*a96ef450SBaptiste Daroussindnl ---------------------
4250*a96ef450SBaptiste Daroussindnl Restore flags saved in CF_SAVE_XTRA_FLAGS
4251*a96ef450SBaptiste Daroussindnl $1 = name of current macro
4252*a96ef450SBaptiste Daroussindefine([CF_RESTORE_XTRA_FLAGS],
4253*a96ef450SBaptiste Daroussin[
4254*a96ef450SBaptiste DaroussinLIBS="$cf_save_LIBS_$1"
4255*a96ef450SBaptiste DaroussinCFLAGS="$cf_save_CFLAGS_$1"
4256*a96ef450SBaptiste DaroussinCPPFLAGS="$cf_save_CPPFLAGS_$1"
4257*a96ef450SBaptiste Daroussin])dnl
4258*a96ef450SBaptiste Daroussindnl ---------------------------------------------------------------------------
4259*a96ef450SBaptiste Daroussindnl CF_RPATH_HACK version: 13 updated: 2021/01/03 18:30:50
42604c8945a0SNathan Whitehorndnl -------------
42614c8945a0SNathan WhitehornAC_DEFUN([CF_RPATH_HACK],
4262*a96ef450SBaptiste Daroussin[AC_REQUIRE([AC_PROG_FGREP])dnl
4263*a96ef450SBaptiste DaroussinAC_REQUIRE([CF_LD_RPATH_OPT])dnl
4264*a96ef450SBaptiste Daroussin
42654c8945a0SNathan WhitehornAC_MSG_CHECKING(for updated LDFLAGS)
42664c8945a0SNathan Whitehornif test -n "$LD_RPATH_OPT" ; then
42674c8945a0SNathan Whitehorn	AC_MSG_RESULT(maybe)
42684c8945a0SNathan Whitehorn
42694c8945a0SNathan Whitehorn	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
42704c8945a0SNathan Whitehorn	cf_rpath_list="/usr/lib /lib"
42714c8945a0SNathan Whitehorn	if test "$cf_ldd_prog" != no
42724c8945a0SNathan Whitehorn	then
4273682c9e0fSNathan Whitehorn		cf_rpath_oops=
4274682c9e0fSNathan Whitehorn
42754c8945a0SNathan WhitehornAC_TRY_LINK([#include <stdio.h>],
42764c8945a0SNathan Whitehorn		[printf("Hello");],
4277*a96ef450SBaptiste Daroussin		[cf_rpath_oops=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
4278*a96ef450SBaptiste Daroussin		 cf_rpath_list=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
4279682c9e0fSNathan Whitehorn
4280682c9e0fSNathan Whitehorn		# If we passed the link-test, but get a "not found" on a given library,
4281682c9e0fSNathan Whitehorn		# this could be due to inept reconfiguration of gcc to make it only
4282682c9e0fSNathan Whitehorn		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
4283682c9e0fSNathan Whitehorn		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
4284682c9e0fSNathan Whitehorn		# /usr/local libraries.
4285682c9e0fSNathan Whitehorn		if test -n "$cf_rpath_oops"
4286682c9e0fSNathan Whitehorn		then
4287682c9e0fSNathan Whitehorn			for cf_rpath_src in $cf_rpath_oops
4288682c9e0fSNathan Whitehorn			do
4289682c9e0fSNathan Whitehorn				for cf_rpath_dir in \
4290682c9e0fSNathan Whitehorn					/usr/local \
4291682c9e0fSNathan Whitehorn					/usr/pkg \
4292682c9e0fSNathan Whitehorn					/opt/sfw
4293682c9e0fSNathan Whitehorn				do
4294*a96ef450SBaptiste Daroussin					if test -f "$cf_rpath_dir/lib/$cf_rpath_src"
4295682c9e0fSNathan Whitehorn					then
4296682c9e0fSNathan Whitehorn						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
4297682c9e0fSNathan Whitehorn						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
4298682c9e0fSNathan Whitehorn						break
4299682c9e0fSNathan Whitehorn					fi
4300682c9e0fSNathan Whitehorn				done
4301682c9e0fSNathan Whitehorn			done
4302682c9e0fSNathan Whitehorn		fi
43034c8945a0SNathan Whitehorn	fi
43044c8945a0SNathan Whitehorn
43054c8945a0SNathan Whitehorn	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
43064c8945a0SNathan Whitehorn
43074c8945a0SNathan Whitehorn	CF_RPATH_HACK_2(LDFLAGS)
43084c8945a0SNathan Whitehorn	CF_RPATH_HACK_2(LIBS)
43094c8945a0SNathan Whitehorn
43104c8945a0SNathan Whitehorn	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
4311febdb468SDevin Teskeelse
4312febdb468SDevin Teske	AC_MSG_RESULT(no)
43134c8945a0SNathan Whitehornfi
43144c8945a0SNathan WhitehornAC_SUBST(EXTRA_LDFLAGS)
43154c8945a0SNathan Whitehorn])dnl
43164c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
4317*a96ef450SBaptiste Daroussindnl CF_RPATH_HACK_2 version: 8 updated: 2021/01/01 13:31:04
43184c8945a0SNathan Whitehorndnl ---------------
43194c8945a0SNathan Whitehorndnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
43204c8945a0SNathan Whitehorndnl EXTRA_LDFLAGS for each -L option found.
43214c8945a0SNathan Whitehorndnl
43224c8945a0SNathan Whitehorndnl $cf_rpath_list contains a list of directories to ignore.
43234c8945a0SNathan Whitehorndnl
43244c8945a0SNathan Whitehorndnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
43254c8945a0SNathan Whitehorndnl      but LIBS often has misplaced -L options.
43264c8945a0SNathan WhitehornAC_DEFUN([CF_RPATH_HACK_2],
43274c8945a0SNathan Whitehorn[
43284c8945a0SNathan WhitehornCF_VERBOSE(...checking $1 [$]$1)
43294c8945a0SNathan Whitehorn
43304c8945a0SNathan Whitehorncf_rpath_dst=
43314c8945a0SNathan Whitehornfor cf_rpath_src in [$]$1
43324c8945a0SNathan Whitehorndo
4333*a96ef450SBaptiste Daroussin	case "$cf_rpath_src" in
4334f4f33ea0SBaptiste Daroussin	(-L*)
43354c8945a0SNathan Whitehorn
43364c8945a0SNathan Whitehorn		# check if this refers to a directory which we will ignore
43374c8945a0SNathan Whitehorn		cf_rpath_skip=no
43384c8945a0SNathan Whitehorn		if test -n "$cf_rpath_list"
43394c8945a0SNathan Whitehorn		then
43404c8945a0SNathan Whitehorn			for cf_rpath_item in $cf_rpath_list
43414c8945a0SNathan Whitehorn			do
43424c8945a0SNathan Whitehorn				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
43434c8945a0SNathan Whitehorn				then
43444c8945a0SNathan Whitehorn					cf_rpath_skip=yes
43454c8945a0SNathan Whitehorn					break
43464c8945a0SNathan Whitehorn				fi
43474c8945a0SNathan Whitehorn			done
43484c8945a0SNathan Whitehorn		fi
43494c8945a0SNathan Whitehorn
43504c8945a0SNathan Whitehorn		if test "$cf_rpath_skip" = no
43514c8945a0SNathan Whitehorn		then
43524c8945a0SNathan Whitehorn			# transform the option
43534c8945a0SNathan Whitehorn			if test "$LD_RPATH_OPT" = "-R " ; then
43544c8945a0SNathan Whitehorn				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
43554c8945a0SNathan Whitehorn			else
43564c8945a0SNathan Whitehorn				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
43574c8945a0SNathan Whitehorn			fi
43584c8945a0SNathan Whitehorn
43594c8945a0SNathan Whitehorn			# if we have not already added this, add it now
43604c8945a0SNathan Whitehorn			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
43614c8945a0SNathan Whitehorn			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
43624c8945a0SNathan Whitehorn			then
43634c8945a0SNathan Whitehorn				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
43644c8945a0SNathan Whitehorn				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
43654c8945a0SNathan Whitehorn			fi
43664c8945a0SNathan Whitehorn		fi
43674c8945a0SNathan Whitehorn		;;
43684c8945a0SNathan Whitehorn	esac
43694c8945a0SNathan Whitehorn	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
43704c8945a0SNathan Whitehorndone
43714c8945a0SNathan Whitehorn$1=$cf_rpath_dst
43724c8945a0SNathan Whitehorn
43734c8945a0SNathan WhitehornCF_VERBOSE(...checked $1 [$]$1)
43744c8945a0SNathan WhitehornAC_SUBST(EXTRA_LDFLAGS)
43754c8945a0SNathan Whitehorn])dnl
43764c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
4377*a96ef450SBaptiste Daroussindnl CF_SAVE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:46:44
4378*a96ef450SBaptiste Daroussindnl ------------------
4379*a96ef450SBaptiste Daroussindnl Use this macro to save CFLAGS/CPPFLAGS/LIBS before checks against X headers
4380*a96ef450SBaptiste Daroussindnl and libraries which do not update those variables.
4381*a96ef450SBaptiste Daroussindnl
4382*a96ef450SBaptiste Daroussindnl $1 = name of current macro
4383*a96ef450SBaptiste Daroussindefine([CF_SAVE_XTRA_FLAGS],
4384*a96ef450SBaptiste Daroussin[
4385*a96ef450SBaptiste Daroussincf_save_LIBS_$1="$LIBS"
4386*a96ef450SBaptiste Daroussincf_save_CFLAGS_$1="$CFLAGS"
4387*a96ef450SBaptiste Daroussincf_save_CPPFLAGS_$1="$CPPFLAGS"
4388*a96ef450SBaptiste DaroussinLIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
4389*a96ef450SBaptiste Daroussinfor cf_X_CFLAGS in $X_CFLAGS
4390*a96ef450SBaptiste Daroussindo
4391*a96ef450SBaptiste Daroussin	case "x$cf_X_CFLAGS" in
4392*a96ef450SBaptiste Daroussin	x-[[IUD]]*)
4393*a96ef450SBaptiste Daroussin		CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS"
4394*a96ef450SBaptiste Daroussin		;;
4395*a96ef450SBaptiste Daroussin	*)
4396*a96ef450SBaptiste Daroussin		CFLAGS="$CFLAGS $cf_X_CFLAGS"
4397*a96ef450SBaptiste Daroussin		;;
4398*a96ef450SBaptiste Daroussin	esac
4399*a96ef450SBaptiste Daroussindone
4400*a96ef450SBaptiste Daroussin])dnl
4401*a96ef450SBaptiste Daroussindnl ---------------------------------------------------------------------------
4402*a96ef450SBaptiste Daroussindnl CF_SHARED_OPTS version: 105 updated: 2021/01/02 17:09:14
4403febdb468SDevin Teskednl --------------
4404febdb468SDevin Teskednl --------------
4405febdb468SDevin Teskednl Attempt to determine the appropriate CC/LD options for creating a shared
4406febdb468SDevin Teskednl library.
4407febdb468SDevin Teskednl
4408febdb468SDevin Teskednl Notes:
4409febdb468SDevin Teskednl a) ${LOCAL_LDFLAGS} is used to link executables that will run within
4410febdb468SDevin Teskednl the build-tree, i.e., by making use of the libraries that are compiled in
4411febdb468SDevin Teskednl $rel_builddir/lib We avoid compiling-in a $rel_builddir/lib path for the
4412febdb468SDevin Teskednl shared library since that can lead to unexpected results at runtime.
4413febdb468SDevin Teskednl b) ${LOCAL_LDFLAGS2} has the same intention but assumes that the shared
4414febdb468SDevin Teskednl libraries are compiled in ../../lib
4415febdb468SDevin Teskednl
4416febdb468SDevin Teskednl The variable 'cf_cv_do_symlinks' is used to control whether we configure
4417febdb468SDevin Teskednl to install symbolic links to the rel/abi versions of shared libraries.
4418febdb468SDevin Teskednl
4419febdb468SDevin Teskednl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
4420febdb468SDevin Teskednl version when making symbolic links.
4421febdb468SDevin Teskednl
4422febdb468SDevin Teskednl The variable 'cf_cv_shlib_version_infix' controls whether shared library
4423febdb468SDevin Teskednl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
4424febdb468SDevin Teskednl (ex: libncurses.so.<ver>).
4425febdb468SDevin Teskednl
4426febdb468SDevin Teskednl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
4427febdb468SDevin TeskeAC_DEFUN([CF_SHARED_OPTS],
4428febdb468SDevin Teske[
4429febdb468SDevin Teske	AC_REQUIRE([CF_LD_RPATH_OPT])
4430*a96ef450SBaptiste Daroussin
4431febdb468SDevin Teske	RM_SHARED_OPTS=
4432febdb468SDevin Teske	LOCAL_LDFLAGS=
4433febdb468SDevin Teske	LOCAL_LDFLAGS2=
4434febdb468SDevin Teske	LD_SHARED_OPTS=
4435febdb468SDevin Teske	INSTALL_LIB="-m 644"
4436febdb468SDevin Teske	: ${rel_builddir:=.}
4437febdb468SDevin Teske
4438f4f33ea0SBaptiste Daroussin	shlibdir=$libdir
4439f4f33ea0SBaptiste Daroussin	AC_SUBST(shlibdir)
4440f4f33ea0SBaptiste Daroussin
4441f4f33ea0SBaptiste Daroussin	MAKE_DLLS="#"
4442f4f33ea0SBaptiste Daroussin	AC_SUBST(MAKE_DLLS)
4443f4f33ea0SBaptiste Daroussin
4444febdb468SDevin Teske	cf_cv_do_symlinks=no
4445febdb468SDevin Teske	cf_ld_rpath_opt=
4446febdb468SDevin Teske	test "$cf_cv_enable_rpath" = yes && cf_ld_rpath_opt="$LD_RPATH_OPT"
4447febdb468SDevin Teske
4448febdb468SDevin Teske	AC_MSG_CHECKING(if release/abi version should be used for shared libs)
4449febdb468SDevin Teske	AC_ARG_WITH(shlib-version,
4450febdb468SDevin Teske	[  --with-shlib-version=X  Specify rel or abi version for shared libs],
4451febdb468SDevin Teske	[test -z "$withval" && withval=auto
4452*a96ef450SBaptiste Daroussin	case "$withval" in
4453f4f33ea0SBaptiste Daroussin	(yes)
4454febdb468SDevin Teske		cf_cv_shlib_version=auto
4455febdb468SDevin Teske		;;
4456f4f33ea0SBaptiste Daroussin	(rel|abi|auto)
4457febdb468SDevin Teske		cf_cv_shlib_version=$withval
4458febdb468SDevin Teske		;;
4459f4f33ea0SBaptiste Daroussin	(*)
4460f4f33ea0SBaptiste Daroussin		AC_MSG_RESULT($withval)
4461f4f33ea0SBaptiste Daroussin		AC_MSG_ERROR([option value must be one of: rel, abi, or auto])
4462febdb468SDevin Teske		;;
4463febdb468SDevin Teske	esac
4464febdb468SDevin Teske	],[cf_cv_shlib_version=auto])
4465febdb468SDevin Teske	AC_MSG_RESULT($cf_cv_shlib_version)
4466febdb468SDevin Teske
4467febdb468SDevin Teske	cf_cv_rm_so_locs=no
4468febdb468SDevin Teske	cf_try_cflags=
4469febdb468SDevin Teske
4470febdb468SDevin Teske	# Some less-capable ports of gcc support only -fpic
4471febdb468SDevin Teske	CC_SHARED_OPTS=
4472f4f33ea0SBaptiste Daroussin
4473f4f33ea0SBaptiste Daroussin	cf_try_fPIC=no
4474febdb468SDevin Teske	if test "$GCC" = yes
4475febdb468SDevin Teske	then
4476f4f33ea0SBaptiste Daroussin		cf_try_fPIC=yes
4477f4f33ea0SBaptiste Daroussin	else
4478*a96ef450SBaptiste Daroussin		case "$cf_cv_system_name" in
4479f4f33ea0SBaptiste Daroussin		(*linux*)	# e.g., PGI compiler
4480f4f33ea0SBaptiste Daroussin			cf_try_fPIC=yes
4481f4f33ea0SBaptiste Daroussin			;;
4482f4f33ea0SBaptiste Daroussin		esac
4483f4f33ea0SBaptiste Daroussin	fi
4484f4f33ea0SBaptiste Daroussin
4485f4f33ea0SBaptiste Daroussin	if test "$cf_try_fPIC" = yes
4486f4f33ea0SBaptiste Daroussin	then
4487febdb468SDevin Teske		AC_MSG_CHECKING(which $CC option to use)
4488febdb468SDevin Teske		cf_save_CFLAGS="$CFLAGS"
4489febdb468SDevin Teske		for CC_SHARED_OPTS in -fPIC -fpic ''
4490febdb468SDevin Teske		do
4491febdb468SDevin Teske			CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
4492febdb468SDevin Teske			AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
4493febdb468SDevin Teske		done
4494febdb468SDevin Teske		AC_MSG_RESULT($CC_SHARED_OPTS)
4495febdb468SDevin Teske		CFLAGS="$cf_save_CFLAGS"
4496febdb468SDevin Teske	fi
4497febdb468SDevin Teske
4498febdb468SDevin Teske	cf_cv_shlib_version_infix=no
4499febdb468SDevin Teske
4500*a96ef450SBaptiste Daroussin	case "$cf_cv_system_name" in
4501f4f33ea0SBaptiste Daroussin	(aix4.[3-9]*|aix[[5-7]]*)
4502febdb468SDevin Teske		if test "$GCC" = yes; then
4503f4f33ea0SBaptiste Daroussin			CC_SHARED_OPTS='-Wl,-brtl'
4504f4f33ea0SBaptiste Daroussin			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-brtl -Wl,-blibpath:${RPATH_LIST}:/usr/lib -o [$]@'
4505febdb468SDevin Teske		else
4506f4f33ea0SBaptiste Daroussin			CC_SHARED_OPTS='-brtl'
4507f4f33ea0SBaptiste Daroussin			# as well as '-qpic=large -G' or perhaps "-bM:SRE -bnoentry -bexpall"
4508f4f33ea0SBaptiste Daroussin			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -G -Wl,-brtl -Wl,-blibpath:${RPATH_LIST}:/usr/lib -o [$]@'
4509febdb468SDevin Teske		fi
4510febdb468SDevin Teske		;;
4511f4f33ea0SBaptiste Daroussin	(beos*)
4512f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
4513febdb468SDevin Teske		;;
4514f4f33ea0SBaptiste Daroussin	(cygwin*)
4515febdb468SDevin Teske		CC_SHARED_OPTS=
4516f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
4517febdb468SDevin Teske		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
4518febdb468SDevin Teske		cf_cv_shlib_version=cygdll
4519febdb468SDevin Teske		cf_cv_shlib_version_infix=cygdll
4520f4f33ea0SBaptiste Daroussin		shlibdir=$bindir
4521f4f33ea0SBaptiste Daroussin		MAKE_DLLS=
4522febdb468SDevin Teske		cat >mk_shared_lib.sh <<-CF_EOF
4523f4f33ea0SBaptiste Daroussin		#!$SHELL
4524febdb468SDevin Teske		SHARED_LIB=\[$]1
4525febdb468SDevin Teske		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/cyg/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
4526febdb468SDevin Teske		shift
4527febdb468SDevin Teske		cat <<-EOF
4528febdb468SDevin Teske		Linking shared library
4529febdb468SDevin Teske		** SHARED_LIB \[$]SHARED_LIB
4530febdb468SDevin Teske		** IMPORT_LIB \[$]IMPORT_LIB
4531febdb468SDevin TeskeEOF
4532f4f33ea0SBaptiste Daroussin		exec \[$]* ${LDFLAGS} -shared -Wl,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
4533febdb468SDevin TeskeCF_EOF
4534febdb468SDevin Teske		chmod +x mk_shared_lib.sh
4535febdb468SDevin Teske		;;
4536f4f33ea0SBaptiste Daroussin	(msys*)
4537febdb468SDevin Teske		CC_SHARED_OPTS=
4538f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
4539febdb468SDevin Teske		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
4540febdb468SDevin Teske		cf_cv_shlib_version=msysdll
4541febdb468SDevin Teske		cf_cv_shlib_version_infix=msysdll
4542f4f33ea0SBaptiste Daroussin		shlibdir=$bindir
4543f4f33ea0SBaptiste Daroussin		MAKE_DLLS=
4544febdb468SDevin Teske		cat >mk_shared_lib.sh <<-CF_EOF
4545f4f33ea0SBaptiste Daroussin		#!$SHELL
4546febdb468SDevin Teske		SHARED_LIB=\[$]1
4547febdb468SDevin Teske		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/msys-/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
4548febdb468SDevin Teske		shift
4549febdb468SDevin Teske		cat <<-EOF
4550febdb468SDevin Teske		Linking shared library
4551febdb468SDevin Teske		** SHARED_LIB \[$]SHARED_LIB
4552febdb468SDevin Teske		** IMPORT_LIB \[$]IMPORT_LIB
4553febdb468SDevin TeskeEOF
4554f4f33ea0SBaptiste Daroussin		exec \[$]* ${LDFLAGS} -shared -Wl,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
4555febdb468SDevin TeskeCF_EOF
4556febdb468SDevin Teske		chmod +x mk_shared_lib.sh
4557febdb468SDevin Teske		;;
4558f4f33ea0SBaptiste Daroussin	(darwin*)
4559febdb468SDevin Teske		cf_try_cflags="no-cpp-precomp"
4560febdb468SDevin Teske		CC_SHARED_OPTS="-dynamic"
4561f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $[@]` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $[@]'
4562febdb468SDevin Teske		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
4563febdb468SDevin Teske		cf_cv_shlib_version_infix=yes
4564febdb468SDevin Teske		AC_CACHE_CHECK([if ld -search_paths_first works], cf_cv_ldflags_search_paths_first, [
4565febdb468SDevin Teske			cf_save_LDFLAGS=$LDFLAGS
4566febdb468SDevin Teske			LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
4567febdb468SDevin Teske			AC_TRY_LINK(, [int i;], cf_cv_ldflags_search_paths_first=yes, cf_cv_ldflags_search_paths_first=no)
4568febdb468SDevin Teske				LDFLAGS=$cf_save_LDFLAGS])
4569*a96ef450SBaptiste Daroussin		if test "$cf_cv_ldflags_search_paths_first" = yes; then
4570febdb468SDevin Teske			LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
4571febdb468SDevin Teske		fi
4572febdb468SDevin Teske		;;
4573f4f33ea0SBaptiste Daroussin	(hpux[[7-8]]*)
4574febdb468SDevin Teske		# HP-UX 8.07 ld lacks "+b" option used for libdir search-list
4575febdb468SDevin Teske		if test "$GCC" != yes; then
4576febdb468SDevin Teske			CC_SHARED_OPTS='+Z'
4577febdb468SDevin Teske		fi
4578f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB='${LD} ${LDFLAGS} -b -o $[@]'
4579febdb468SDevin Teske		INSTALL_LIB="-m 555"
4580febdb468SDevin Teske		;;
4581f4f33ea0SBaptiste Daroussin	(hpux*)
4582febdb468SDevin Teske		# (tested with gcc 2.7.2 -- I don't have c89)
4583febdb468SDevin Teske		if test "$GCC" = yes; then
4584febdb468SDevin Teske			LD_SHARED_OPTS='-Xlinker +b -Xlinker ${libdir}'
4585febdb468SDevin Teske		else
4586febdb468SDevin Teske			CC_SHARED_OPTS='+Z'
4587febdb468SDevin Teske			LD_SHARED_OPTS='-Wl,+b,${libdir}'
4588febdb468SDevin Teske		fi
4589f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB='${LD} ${LDFLAGS} +b ${libdir} -b -o $[@]'
4590febdb468SDevin Teske		# HP-UX shared libraries must be executable, and should be
4591febdb468SDevin Teske		# readonly to exploit a quirk in the memory manager.
4592febdb468SDevin Teske		INSTALL_LIB="-m 555"
4593febdb468SDevin Teske		;;
4594f4f33ea0SBaptiste Daroussin	(interix*)
4595febdb468SDevin Teske		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
4596febdb468SDevin Teske		if test "$cf_cv_shlib_version" = rel; then
4597f4f33ea0SBaptiste Daroussin			cf_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
4598febdb468SDevin Teske		else
4599f4f33ea0SBaptiste Daroussin			cf_shared_soname='`basename $[@]`'
4600febdb468SDevin Teske		fi
4601febdb468SDevin Teske		CC_SHARED_OPTS=
4602f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-rpath,${RPATH_LIST} -Wl,-h,'$cf_shared_soname' -o $[@]'
4603febdb468SDevin Teske		;;
4604f4f33ea0SBaptiste Daroussin	(irix*)
4605febdb468SDevin Teske		if test "$cf_cv_enable_rpath" = yes ; then
4606febdb468SDevin Teske			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
4607febdb468SDevin Teske		fi
4608febdb468SDevin Teske		# tested with IRIX 5.2 and 'cc'.
4609febdb468SDevin Teske		if test "$GCC" != yes; then
4610febdb468SDevin Teske			CC_SHARED_OPTS='-KPIC'
4611f4f33ea0SBaptiste Daroussin			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
4612febdb468SDevin Teske		else
4613f4f33ea0SBaptiste Daroussin			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,`basename $[@]` -o $[@]'
4614febdb468SDevin Teske		fi
4615febdb468SDevin Teske		cf_cv_rm_so_locs=yes
4616febdb468SDevin Teske		;;
4617f4f33ea0SBaptiste Daroussin	(linux*|gnu*|k*bsd*-gnu)
4618*a96ef450SBaptiste Daroussin		if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
4619febdb468SDevin Teske			LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
4620febdb468SDevin Teske			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4621febdb468SDevin Teske		fi
4622febdb468SDevin Teske		if test "$cf_cv_enable_rpath" = yes ; then
4623febdb468SDevin Teske			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
4624febdb468SDevin Teske		fi
4625febdb468SDevin Teske		CF_SHARED_SONAME
4626f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
4627febdb468SDevin Teske		;;
4628*a96ef450SBaptiste Daroussin	(mingw*msvc*)
4629*a96ef450SBaptiste Daroussin		cf_cv_shlib_version=msvcdll
4630*a96ef450SBaptiste Daroussin		cf_cv_shlib_version_infix=msvcdll
4631*a96ef450SBaptiste Daroussin		shlibdir=$bindir
4632*a96ef450SBaptiste Daroussin		MAKE_DLLS=
4633*a96ef450SBaptiste Daroussin		if test "$DFT_LWR_MODEL" = "shared" ; then
4634*a96ef450SBaptiste Daroussin			LOCAL_LDFLAGS="-link -dll"
4635*a96ef450SBaptiste Daroussin			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4636*a96ef450SBaptiste Daroussin			EXTRA_LDFLAGS="-link -dll $EXTRA_LDFLAGS"
4637*a96ef450SBaptiste Daroussin		fi
4638*a96ef450SBaptiste Daroussin		CC_SHARED_OPTS=
4639*a96ef450SBaptiste Daroussin		MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ ${LD} [$]{CFLAGS}'
4640*a96ef450SBaptiste Daroussin		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.lib"
4641*a96ef450SBaptiste Daroussin		cat >mk_shared_lib.sh <<-CF_EOF
4642*a96ef450SBaptiste Daroussin		#!$SHELL
4643*a96ef450SBaptiste Daroussin		SHARED_LIB=\[$]1
4644*a96ef450SBaptiste Daroussin		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/[[0-9]]*\.dll[$]/.dll.lib/'\`
4645*a96ef450SBaptiste Daroussin		shift
4646*a96ef450SBaptiste Daroussin		my_ld=\[$]1
4647*a96ef450SBaptiste Daroussin		shift
4648*a96ef450SBaptiste Daroussin		cat <<-EOF
4649*a96ef450SBaptiste Daroussin		Linking shared library
4650*a96ef450SBaptiste Daroussin		** SHARED LIB \$SHARED_LIB
4651*a96ef450SBaptiste Daroussin		** IMPORT_LIB \$IMPORT_LIB
4652*a96ef450SBaptiste DaroussinEOF
4653*a96ef450SBaptiste Daroussin		args=\$(echo \[$]* | sed -E "s#-l(\w*)#\1.dll.lib#g" | sed -E "s#-L(\w*)#-LIBPATH:\1#g")
4654*a96ef450SBaptiste Daroussin		exec \$my_ld -DLL -IMPLIB:"\${IMPORT_LIB}" -OUT:"\${SHARED_LIB}" ${LDFLAGS} \$args
4655*a96ef450SBaptiste Daroussin		mv "\${IMPORT_LIB}" "\${IMPORT_LIB}"
4656*a96ef450SBaptiste DaroussinCF_EOF
4657*a96ef450SBaptiste Daroussin		chmod +x mk_shared_lib.sh
4658*a96ef450SBaptiste Daroussin		cat >mk_prog.sh <<-CF_EOF
4659*a96ef450SBaptiste Daroussin		#!$SHELL
4660*a96ef450SBaptiste Daroussin		shift
4661*a96ef450SBaptiste Daroussin		# Ignore first argument (compiler) and use LD (link.exe) unconditionally
4662*a96ef450SBaptiste Daroussin		LD="[$]LD"
4663*a96ef450SBaptiste Daroussin		clopts=()
4664*a96ef450SBaptiste Daroussin		ldopts=("/subsystem:console")
4665*a96ef450SBaptiste Daroussin		libs=()
4666*a96ef450SBaptiste Daroussin		isdll=0
4667*a96ef450SBaptiste Daroussin		while test \[$]# -gt 0; do
4668*a96ef450SBaptiste Daroussin			case "\[$]1" in
4669*a96ef450SBaptiste Daroussin				-link)
4670*a96ef450SBaptiste Daroussin					# ignore -link argument
4671*a96ef450SBaptiste Daroussin					;;
4672*a96ef450SBaptiste Daroussin				-M[[TD]] | -M[[TD]]d)
4673*a96ef450SBaptiste Daroussin					# ignore runtime-library option
4674*a96ef450SBaptiste Daroussin					;;
4675*a96ef450SBaptiste Daroussin				-dll)
4676*a96ef450SBaptiste Daroussin					isdll=1
4677*a96ef450SBaptiste Daroussin					;;
4678*a96ef450SBaptiste Daroussin				-W* | -w*)
4679*a96ef450SBaptiste Daroussin					# ignore warnings
4680*a96ef450SBaptiste Daroussin					;;
4681*a96ef450SBaptiste Daroussin				-D*)
4682*a96ef450SBaptiste Daroussin					clopts+=("\[$]1")
4683*a96ef450SBaptiste Daroussin					;;
4684*a96ef450SBaptiste Daroussin				-I*)
4685*a96ef450SBaptiste Daroussin					clopts+=("\[$]1")
4686*a96ef450SBaptiste Daroussin					;;
4687*a96ef450SBaptiste Daroussin				-l*)
4688*a96ef450SBaptiste Daroussin					libs+=("\`echo \"\[$]1\" | sed \"s/^-l//\"\`")
4689*a96ef450SBaptiste Daroussin					;;
4690*a96ef450SBaptiste Daroussin				-L*)
4691*a96ef450SBaptiste Daroussin					ldopts+=("\`echo \"\[$]1\" | sed \"s/^-L/-LIBPATH:/\"\`")
4692*a96ef450SBaptiste Daroussin					;;
4693*a96ef450SBaptiste Daroussin				*.obj | *.o)
4694*a96ef450SBaptiste Daroussin					ldopts+=("\[$]1")
4695*a96ef450SBaptiste Daroussin					;;
4696*a96ef450SBaptiste Daroussin				-Wl,*)
4697*a96ef450SBaptiste Daroussin					for linkarg in \`echo '\[$]1' | sed -e 's/-Wl,//' -e 's/,/ /'\`; do
4698*a96ef450SBaptiste Daroussin						ldopts+=("\[$]{linkarg}")
4699*a96ef450SBaptiste Daroussin					done
4700*a96ef450SBaptiste Daroussin					;;
4701*a96ef450SBaptiste Daroussin				*.lib)
4702*a96ef450SBaptiste Daroussin					ldopts+=("\[$]1")
4703*a96ef450SBaptiste Daroussin					;;
4704*a96ef450SBaptiste Daroussin				-o)
4705*a96ef450SBaptiste Daroussin					shift
4706*a96ef450SBaptiste Daroussin					ldopts+=("-out:\[$]1")
4707*a96ef450SBaptiste Daroussin					;;
4708*a96ef450SBaptiste Daroussin				*)
4709*a96ef450SBaptiste Daroussin					clopts+=("\[$]1")
4710*a96ef450SBaptiste Daroussin					ldopts+=("\[$]1")
4711*a96ef450SBaptiste Daroussin					;;
4712*a96ef450SBaptiste Daroussin			esac
4713*a96ef450SBaptiste Daroussin			shift
4714*a96ef450SBaptiste Daroussin		done
4715*a96ef450SBaptiste Daroussin		if [[ "\$isdll" -ne 0 ]]; then
4716*a96ef450SBaptiste Daroussin			for lib in \[$]{libs[[*]]}; do
4717*a96ef450SBaptiste Daroussin				ldopts+=("\[$]lib.dll.lib")
4718*a96ef450SBaptiste Daroussin			done
4719*a96ef450SBaptiste Daroussin		else
4720*a96ef450SBaptiste Daroussin			for lib in \[$]{libs[[*]]}; do
4721*a96ef450SBaptiste Daroussin				ldopts+=("\[$]lib.lib")
4722*a96ef450SBaptiste Daroussin			done
4723*a96ef450SBaptiste Daroussin		fi
4724*a96ef450SBaptiste Daroussin		cat <<-EOF
4725*a96ef450SBaptiste Daroussin		Creating program
4726*a96ef450SBaptiste Daroussin		** ld options:   "\[$]{ldopts[[@]]}"
4727*a96ef450SBaptiste DaroussinEOF
4728*a96ef450SBaptiste Daroussin		exec \[$]LD \[$]{ldopts[[@]]}
4729*a96ef450SBaptiste DaroussinCF_EOF
4730*a96ef450SBaptiste Daroussin		chmod +x mk_prog.sh
4731*a96ef450SBaptiste Daroussin		LINK_PROGS="$SHELL ${rel_builddir}/mk_prog.sh"
4732*a96ef450SBaptiste Daroussin		LINK_TESTS="$SHELL ${rel_builddir}/mk_prog.sh"
4733*a96ef450SBaptiste Daroussin		;;
4734f4f33ea0SBaptiste Daroussin	(mingw*)
4735febdb468SDevin Teske		cf_cv_shlib_version=mingw
4736febdb468SDevin Teske		cf_cv_shlib_version_infix=mingw
4737f4f33ea0SBaptiste Daroussin		shlibdir=$bindir
4738f4f33ea0SBaptiste Daroussin		MAKE_DLLS=
4739febdb468SDevin Teske		if test "$DFT_LWR_MODEL" = "shared" ; then
4740febdb468SDevin Teske			LOCAL_LDFLAGS="-Wl,--enable-auto-import"
4741febdb468SDevin Teske			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4742febdb468SDevin Teske			EXTRA_LDFLAGS="-Wl,--enable-auto-import $EXTRA_LDFLAGS"
4743febdb468SDevin Teske		fi
4744febdb468SDevin Teske		CC_SHARED_OPTS=
4745f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
4746febdb468SDevin Teske		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
4747febdb468SDevin Teske		cat >mk_shared_lib.sh <<-CF_EOF
4748f4f33ea0SBaptiste Daroussin		#!$SHELL
4749febdb468SDevin Teske		SHARED_LIB=\[$]1
4750febdb468SDevin Teske		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
4751febdb468SDevin Teske		shift
4752febdb468SDevin Teske		cat <<-EOF
4753febdb468SDevin Teske		Linking shared library
4754febdb468SDevin Teske		** SHARED_LIB \[$]SHARED_LIB
4755febdb468SDevin Teske		** IMPORT_LIB \[$]IMPORT_LIB
4756febdb468SDevin TeskeEOF
4757f4f33ea0SBaptiste Daroussin		exec \[$]* ${LDFLAGS} -shared -Wl,--enable-auto-import,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
4758febdb468SDevin TeskeCF_EOF
4759febdb468SDevin Teske		chmod +x mk_shared_lib.sh
4760febdb468SDevin Teske		;;
4761f4f33ea0SBaptiste Daroussin	(openbsd[[2-9]].*|mirbsd*)
4762*a96ef450SBaptiste Daroussin		if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
4763febdb468SDevin Teske			LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
4764febdb468SDevin Teske			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4765febdb468SDevin Teske		fi
4766febdb468SDevin Teske		if test "$cf_cv_enable_rpath" = yes ; then
4767febdb468SDevin Teske			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
4768febdb468SDevin Teske		fi
4769febdb468SDevin Teske		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4770febdb468SDevin Teske		CF_SHARED_SONAME
4771f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-Bshareable,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
4772febdb468SDevin Teske		;;
4773*a96ef450SBaptiste Daroussin	(nskJ*)
4774*a96ef450SBaptiste Daroussin		CC_SHARED_OPTS=
4775*a96ef450SBaptiste Daroussin		MK_SHARED_LIB='${LD} -Wshared -Weld=-export_all -o $[@]'
4776*a96ef450SBaptiste Daroussin		;;
4777*a96ef450SBaptiste Daroussin	(nskL*)
4778*a96ef450SBaptiste Daroussin		CC_SHARED_OPTS=
4779*a96ef450SBaptiste Daroussin		MK_SHARED_LIB='${LD} -Wshared -Wxld=-export_all -o $[@]'
4780*a96ef450SBaptiste Daroussin		;;
4781f4f33ea0SBaptiste Daroussin	(nto-qnx*|openbsd*|freebsd[[12]].*)
4782febdb468SDevin Teske		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4783f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB='${LD} ${LDFLAGS} -Bshareable -o $[@]'
4784febdb468SDevin Teske		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
4785febdb468SDevin Teske		;;
4786f4f33ea0SBaptiste Daroussin	(dragonfly*|freebsd*)
4787febdb468SDevin Teske		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4788febdb468SDevin Teske		if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
4789febdb468SDevin Teske			LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
4790febdb468SDevin Teske			LOCAL_LDFLAGS2="${cf_ld_rpath_opt}\${RPATH_LIST} $LOCAL_LDFLAGS"
4791febdb468SDevin Teske			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
4792febdb468SDevin Teske		fi
4793febdb468SDevin Teske		CF_SHARED_SONAME
4794f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
4795febdb468SDevin Teske		;;
4796f4f33ea0SBaptiste Daroussin	(netbsd*)
4797febdb468SDevin Teske		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4798febdb468SDevin Teske		if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
4799febdb468SDevin Teske			LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
4800febdb468SDevin Teske			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4801febdb468SDevin Teske			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
4802febdb468SDevin Teske			if test "$cf_cv_shlib_version" = auto; then
4803febdb468SDevin Teske			if test -f /usr/libexec/ld.elf_so; then
4804febdb468SDevin Teske				cf_cv_shlib_version=abi
4805febdb468SDevin Teske			else
4806febdb468SDevin Teske				cf_cv_shlib_version=rel
4807febdb468SDevin Teske			fi
4808febdb468SDevin Teske			fi
4809febdb468SDevin Teske			CF_SHARED_SONAME
4810f4f33ea0SBaptiste Daroussin			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname' -o $[@]'
4811febdb468SDevin Teske		else
4812*a96ef450SBaptiste Daroussin			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -o $[@]'
4813febdb468SDevin Teske		fi
4814febdb468SDevin Teske		;;
4815f4f33ea0SBaptiste Daroussin	(osf*|mls+*)
4816febdb468SDevin Teske		# tested with OSF/1 V3.2 and 'cc'
4817febdb468SDevin Teske		# tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
4818febdb468SDevin Teske		# link with shared libs).
4819f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB='${LD} ${LDFLAGS} -set_version ${REL_VERSION}:${ABI_VERSION} -expect_unresolved "*" -shared -soname `basename $[@]`'
4820*a96ef450SBaptiste Daroussin		case "$host_os" in
4821f4f33ea0SBaptiste Daroussin		(osf4*)
4822febdb468SDevin Teske			MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
4823febdb468SDevin Teske			;;
4824febdb468SDevin Teske		esac
4825febdb468SDevin Teske		MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
4826*a96ef450SBaptiste Daroussin		if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
4827febdb468SDevin Teske			LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
4828febdb468SDevin Teske			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4829febdb468SDevin Teske		fi
4830febdb468SDevin Teske		cf_cv_rm_so_locs=yes
4831febdb468SDevin Teske		;;
4832f4f33ea0SBaptiste Daroussin	(sco3.2v5*)  # also uw2* and UW7: hops 13-Apr-98
4833febdb468SDevin Teske		# tested with osr5.0.5
4834febdb468SDevin Teske		if test "$GCC" != yes; then
4835febdb468SDevin Teske			CC_SHARED_OPTS='-belf -KPIC'
4836febdb468SDevin Teske		fi
4837f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB='${LD} ${LDFLAGS} -dy -G -h `basename $[@] .${REL_VERSION}`.${ABI_VERSION} -o [$]@'
4838febdb468SDevin Teske		if test "$cf_cv_enable_rpath" = yes ; then
4839febdb468SDevin Teske			# only way is to set LD_RUN_PATH but no switch for it
4840febdb468SDevin Teske			RUN_PATH=$libdir
4841febdb468SDevin Teske		fi
4842febdb468SDevin Teske		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
4843febdb468SDevin Teske		LINK_PROGS='LD_RUN_PATH=${libdir}'
4844febdb468SDevin Teske		LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
4845febdb468SDevin Teske		;;
4846f4f33ea0SBaptiste Daroussin	(sunos4*)
4847febdb468SDevin Teske		# tested with SunOS 4.1.1 and gcc 2.7.0
4848febdb468SDevin Teske		if test "$GCC" != yes; then
4849febdb468SDevin Teske			CC_SHARED_OPTS='-KPIC'
4850febdb468SDevin Teske		fi
4851f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB='${LD} ${LDFLAGS} -assert pure-text -o $[@]'
4852febdb468SDevin Teske		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
4853febdb468SDevin Teske		;;
4854f4f33ea0SBaptiste Daroussin	(solaris2*)
4855febdb468SDevin Teske		# tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
4856febdb468SDevin Teske		# tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
4857febdb468SDevin Teske		if test "$DFT_LWR_MODEL" = "shared" ; then
4858febdb468SDevin Teske			LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}"
4859febdb468SDevin Teske			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4860febdb468SDevin Teske		fi
4861febdb468SDevin Teske		if test "$cf_cv_enable_rpath" = yes ; then
4862febdb468SDevin Teske			EXTRA_LDFLAGS="-R \${libdir} $EXTRA_LDFLAGS"
4863febdb468SDevin Teske		fi
4864febdb468SDevin Teske		CF_SHARED_SONAME
4865febdb468SDevin Teske		if test "$GCC" != yes; then
4866febdb468SDevin Teske			cf_save_CFLAGS="$CFLAGS"
4867febdb468SDevin Teske			for cf_shared_opts in -xcode=pic32 -xcode=pic13 -KPIC -Kpic -O
4868febdb468SDevin Teske			do
4869febdb468SDevin Teske				CFLAGS="$cf_shared_opts $cf_save_CFLAGS"
4870*a96ef450SBaptiste Daroussin				AC_TRY_COMPILE([#include <stdio.h>],[printf("Hello\\n");],[break])
4871febdb468SDevin Teske			done
4872febdb468SDevin Teske			CFLAGS="$cf_save_CFLAGS"
4873febdb468SDevin Teske			CC_SHARED_OPTS=$cf_shared_opts
4874f4f33ea0SBaptiste Daroussin			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dy -G -h '$cf_cv_shared_soname' -o $[@]'
4875febdb468SDevin Teske		else
4876f4f33ea0SBaptiste Daroussin			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -dy -G -h '$cf_cv_shared_soname' -o $[@]'
4877febdb468SDevin Teske		fi
4878febdb468SDevin Teske		;;
4879f4f33ea0SBaptiste Daroussin	(sysv5uw7*|unix_sv*)
4880febdb468SDevin Teske		# tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
4881febdb468SDevin Teske		if test "$GCC" != yes; then
4882febdb468SDevin Teske			CC_SHARED_OPTS='-KPIC'
4883febdb468SDevin Teske		fi
4884f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB='${LD} ${LDFLAGS} -d y -G -o [$]@'
4885febdb468SDevin Teske		;;
4886f4f33ea0SBaptiste Daroussin	(*)
4887febdb468SDevin Teske		CC_SHARED_OPTS='unknown'
4888febdb468SDevin Teske		MK_SHARED_LIB='echo unknown'
4889febdb468SDevin Teske		;;
4890febdb468SDevin Teske	esac
4891febdb468SDevin Teske
4892febdb468SDevin Teske	# This works if the last tokens in $MK_SHARED_LIB are the -o target.
4893f4f33ea0SBaptiste Daroussin	case "$cf_cv_shlib_version" in
4894f4f33ea0SBaptiste Daroussin	(rel|abi)
4895f4f33ea0SBaptiste Daroussin		case "$MK_SHARED_LIB" in
4896f4f33ea0SBaptiste Daroussin		(*'-o $[@]')
4897febdb468SDevin Teske			test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
4898febdb468SDevin Teske			;;
4899f4f33ea0SBaptiste Daroussin		(*)
4900febdb468SDevin Teske			AC_MSG_WARN(ignored --with-shlib-version)
4901febdb468SDevin Teske			;;
4902febdb468SDevin Teske		esac
4903febdb468SDevin Teske		;;
4904febdb468SDevin Teske	esac
4905febdb468SDevin Teske
4906febdb468SDevin Teske	if test -n "$cf_try_cflags"
4907febdb468SDevin Teske	then
4908febdb468SDevin Teskecat > conftest.$ac_ext <<EOF
4909febdb468SDevin Teske#line __oline__ "${as_me:-configure}"
4910febdb468SDevin Teske#include <stdio.h>
4911febdb468SDevin Teskeint main(int argc, char *argv[[]])
4912febdb468SDevin Teske{
4913*a96ef450SBaptiste Daroussin	printf("hello\\n");
4914febdb468SDevin Teske	return (argv[[argc-1]] == 0) ;
4915febdb468SDevin Teske}
4916febdb468SDevin TeskeEOF
4917febdb468SDevin Teske		cf_save_CFLAGS="$CFLAGS"
4918febdb468SDevin Teske		for cf_opt in $cf_try_cflags
4919febdb468SDevin Teske		do
4920febdb468SDevin Teske			CFLAGS="$cf_save_CFLAGS -$cf_opt"
4921febdb468SDevin Teske			AC_MSG_CHECKING(if CFLAGS option -$cf_opt works)
4922febdb468SDevin Teske			if AC_TRY_EVAL(ac_compile); then
4923febdb468SDevin Teske				AC_MSG_RESULT(yes)
4924febdb468SDevin Teske				cf_save_CFLAGS="$CFLAGS"
4925febdb468SDevin Teske			else
4926febdb468SDevin Teske				AC_MSG_RESULT(no)
4927febdb468SDevin Teske			fi
4928febdb468SDevin Teske		done
4929febdb468SDevin Teske		CFLAGS="$cf_save_CFLAGS"
4930febdb468SDevin Teske	fi
4931febdb468SDevin Teske
4932febdb468SDevin Teske
4933febdb468SDevin Teske	# RPATH_LIST is a colon-separated list of directories
4934febdb468SDevin Teske	test -n "$cf_ld_rpath_opt" && MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\${RPATH_LIST}"
4935febdb468SDevin Teske	test -z "$RPATH_LIST" && RPATH_LIST="\${libdir}"
4936febdb468SDevin Teske
4937*a96ef450SBaptiste Daroussin	test "$cf_cv_rm_so_locs" = yes && RM_SHARED_OPTS="$RM_SHARED_OPTS so_locations"
4938febdb468SDevin Teske
4939febdb468SDevin Teske	CF_VERBOSE(CC_SHARED_OPTS: $CC_SHARED_OPTS)
4940febdb468SDevin Teske	CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
4941febdb468SDevin Teske
4942febdb468SDevin Teske	AC_SUBST(CC_SHARED_OPTS)
4943febdb468SDevin Teske	AC_SUBST(LD_RPATH_OPT)
4944febdb468SDevin Teske	AC_SUBST(LD_SHARED_OPTS)
4945febdb468SDevin Teske	AC_SUBST(MK_SHARED_LIB)
4946febdb468SDevin Teske	AC_SUBST(RM_SHARED_OPTS)
4947febdb468SDevin Teske
4948febdb468SDevin Teske	AC_SUBST(LINK_PROGS)
4949febdb468SDevin Teske	AC_SUBST(LINK_TESTS)
4950febdb468SDevin Teske
4951febdb468SDevin Teske	AC_SUBST(EXTRA_LDFLAGS)
4952febdb468SDevin Teske	AC_SUBST(LOCAL_LDFLAGS)
4953febdb468SDevin Teske	AC_SUBST(LOCAL_LDFLAGS2)
4954febdb468SDevin Teske
4955febdb468SDevin Teske	AC_SUBST(INSTALL_LIB)
4956febdb468SDevin Teske	AC_SUBST(RPATH_LIST)
4957febdb468SDevin Teske])dnl
4958febdb468SDevin Teskednl ---------------------------------------------------------------------------
4959febdb468SDevin Teskednl CF_SHARED_SONAME version: 3 updated: 2008/09/08 18:34:43
4960febdb468SDevin Teskednl ----------------
4961febdb468SDevin Teskednl utility macro for CF_SHARED_OPTS, constructs "$cf_cv_shared_soname" for
4962febdb468SDevin Teskednl substitution into MK_SHARED_LIB string for the "-soname" (or similar)
4963febdb468SDevin Teskednl option.
4964febdb468SDevin Teskednl
4965febdb468SDevin Teskednl $1 is the default that should be used for "$cf_cv_shlib_version".
4966febdb468SDevin Teskednl If missing, use "rel".
4967febdb468SDevin Teskedefine([CF_SHARED_SONAME],
4968febdb468SDevin Teske[
4969febdb468SDevin Teske	test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=ifelse($1,,rel,$1)
4970febdb468SDevin Teske	if test "$cf_cv_shlib_version" = rel; then
4971febdb468SDevin Teske		cf_cv_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
4972febdb468SDevin Teske	else
4973febdb468SDevin Teske		cf_cv_shared_soname='`basename $[@]`'
4974febdb468SDevin Teske	fi
4975febdb468SDevin Teske])
4976febdb468SDevin Teskednl ---------------------------------------------------------------------------
4977*a96ef450SBaptiste Daroussindnl CF_SIZECHANGE version: 17 updated: 2021/01/01 13:31:04
4978f4f33ea0SBaptiste Daroussindnl -------------
4979f4f33ea0SBaptiste Daroussindnl Check for definitions & structures needed for window size-changing
4980f4f33ea0SBaptiste Daroussindnl
4981f4f33ea0SBaptiste Daroussindnl https://stackoverflow.com/questions/18878141/difference-between-structures-ttysize-and-winsize/50769952#50769952
4982f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_SIZECHANGE],
4983f4f33ea0SBaptiste Daroussin[
4984f4f33ea0SBaptiste DaroussinAC_REQUIRE([CF_STRUCT_TERMIOS])
4985f4f33ea0SBaptiste DaroussinAC_CACHE_CHECK(declaration of size-change, cf_cv_sizechange,[
4986f4f33ea0SBaptiste Daroussin	cf_cv_sizechange=unknown
4987f4f33ea0SBaptiste Daroussin	cf_save_CPPFLAGS="$CPPFLAGS"
4988f4f33ea0SBaptiste Daroussin
4989f4f33ea0SBaptiste Daroussinfor cf_opts in "" "NEED_PTEM_H"
4990f4f33ea0SBaptiste Daroussindo
4991f4f33ea0SBaptiste Daroussin
4992f4f33ea0SBaptiste Daroussin	CPPFLAGS="$cf_save_CPPFLAGS"
4993f4f33ea0SBaptiste Daroussin	if test -n "$cf_opts"
4994f4f33ea0SBaptiste Daroussin	then
4995f4f33ea0SBaptiste Daroussin		CF_APPEND_TEXT(CPPFLAGS,-D$cf_opts)
4996f4f33ea0SBaptiste Daroussin	fi
4997f4f33ea0SBaptiste Daroussin	AC_TRY_COMPILE([#include <sys/types.h>
4998f4f33ea0SBaptiste Daroussin#ifdef HAVE_TERMIOS_H
4999f4f33ea0SBaptiste Daroussin#include <termios.h>
5000f4f33ea0SBaptiste Daroussin#else
5001f4f33ea0SBaptiste Daroussin#ifdef HAVE_TERMIO_H
5002f4f33ea0SBaptiste Daroussin#include <termio.h>
5003f4f33ea0SBaptiste Daroussin#endif
5004f4f33ea0SBaptiste Daroussin#endif
5005f4f33ea0SBaptiste Daroussin
5006f4f33ea0SBaptiste Daroussin#ifdef NEED_PTEM_H
5007f4f33ea0SBaptiste Daroussin/* This is a workaround for SCO:  they neglected to define struct winsize in
5008f4f33ea0SBaptiste Daroussin * termios.h -- it's only in termio.h and ptem.h
5009f4f33ea0SBaptiste Daroussin */
5010f4f33ea0SBaptiste Daroussin#include <sys/stream.h>
5011f4f33ea0SBaptiste Daroussin#include <sys/ptem.h>
5012f4f33ea0SBaptiste Daroussin#endif
5013f4f33ea0SBaptiste Daroussin
5014f4f33ea0SBaptiste Daroussin#ifdef HAVE_SYS_IOCTL_H
5015f4f33ea0SBaptiste Daroussin#include <sys/ioctl.h>
5016f4f33ea0SBaptiste Daroussin#endif
5017f4f33ea0SBaptiste Daroussin],[
5018f4f33ea0SBaptiste Daroussin#ifdef TIOCGSIZE
5019f4f33ea0SBaptiste Daroussin	struct ttysize win;	/* SunOS 3.0... */
5020*a96ef450SBaptiste Daroussin	int y = win.ts_lines = 2;
5021*a96ef450SBaptiste Daroussin	int x = win.ts_cols = 1;
5022*a96ef450SBaptiste Daroussin	(void)y;
5023*a96ef450SBaptiste Daroussin	(void)x;
5024f4f33ea0SBaptiste Daroussin#else
5025f4f33ea0SBaptiste Daroussin#ifdef TIOCGWINSZ
5026f4f33ea0SBaptiste Daroussin	struct winsize win;	/* everything else */
5027*a96ef450SBaptiste Daroussin	int y = win.ws_row = 2;
5028*a96ef450SBaptiste Daroussin	int x = win.ws_col = 1;
5029*a96ef450SBaptiste Daroussin	(void)y;
5030*a96ef450SBaptiste Daroussin	(void)x;
5031f4f33ea0SBaptiste Daroussin#else
5032f4f33ea0SBaptiste Daroussin	no TIOCGSIZE or TIOCGWINSZ
5033f4f33ea0SBaptiste Daroussin#endif /* TIOCGWINSZ */
5034f4f33ea0SBaptiste Daroussin#endif /* TIOCGSIZE */
5035f4f33ea0SBaptiste Daroussin	],
5036f4f33ea0SBaptiste Daroussin	[cf_cv_sizechange=yes],
5037f4f33ea0SBaptiste Daroussin	[cf_cv_sizechange=no])
5038f4f33ea0SBaptiste Daroussin
5039f4f33ea0SBaptiste Daroussin	CPPFLAGS="$cf_save_CPPFLAGS"
5040f4f33ea0SBaptiste Daroussin	if test "$cf_cv_sizechange" = yes ; then
5041f4f33ea0SBaptiste Daroussin		echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
5042f4f33ea0SBaptiste Daroussin		test -n "$cf_opts" && cf_cv_sizechange="$cf_opts"
5043f4f33ea0SBaptiste Daroussin		break
5044f4f33ea0SBaptiste Daroussin	fi
5045f4f33ea0SBaptiste Daroussindone
5046f4f33ea0SBaptiste Daroussin])
5047f4f33ea0SBaptiste Daroussinif test "$cf_cv_sizechange" != no ; then
5048f4f33ea0SBaptiste Daroussin	AC_DEFINE(HAVE_SIZECHANGE,1,[Define to 1 if sizechange declarations are provided])
5049*a96ef450SBaptiste Daroussin	case "$cf_cv_sizechange" in
5050f4f33ea0SBaptiste Daroussin	(NEED*)
5051f4f33ea0SBaptiste Daroussin		AC_DEFINE_UNQUOTED($cf_cv_sizechange )
5052f4f33ea0SBaptiste Daroussin		;;
5053f4f33ea0SBaptiste Daroussin	esac
5054f4f33ea0SBaptiste Daroussinfi
5055f4f33ea0SBaptiste Daroussin])dnl
5056f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
5057*a96ef450SBaptiste Daroussindnl CF_STRUCT_TERMIOS version: 11 updated: 2020/03/19 20:46:13
5058f4f33ea0SBaptiste Daroussindnl -----------------
5059f4f33ea0SBaptiste Daroussindnl Some machines require _POSIX_SOURCE to completely define struct termios.
5060f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_STRUCT_TERMIOS],[
5061f4f33ea0SBaptiste DaroussinAC_REQUIRE([CF_XOPEN_SOURCE])
5062f4f33ea0SBaptiste Daroussin
5063f4f33ea0SBaptiste DaroussinAC_CHECK_HEADERS( \
5064f4f33ea0SBaptiste Daroussintermio.h \
5065f4f33ea0SBaptiste Daroussintermios.h \
5066f4f33ea0SBaptiste Daroussinunistd.h \
5067f4f33ea0SBaptiste Daroussinsys/ioctl.h \
5068f4f33ea0SBaptiste Daroussinsys/termio.h \
5069f4f33ea0SBaptiste Daroussin)
5070f4f33ea0SBaptiste Daroussin
5071f4f33ea0SBaptiste Daroussinif test "$ac_cv_header_termios_h" = yes ; then
5072f4f33ea0SBaptiste Daroussin	case "$CFLAGS $CPPFLAGS" in
5073f4f33ea0SBaptiste Daroussin	(*-D_POSIX_SOURCE*)
5074f4f33ea0SBaptiste Daroussin		termios_bad=dunno ;;
5075f4f33ea0SBaptiste Daroussin	(*)	termios_bad=maybe ;;
5076f4f33ea0SBaptiste Daroussin	esac
5077f4f33ea0SBaptiste Daroussin	if test "$termios_bad" = maybe ; then
5078f4f33ea0SBaptiste Daroussin	AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
5079f4f33ea0SBaptiste Daroussin	AC_TRY_COMPILE([#include <termios.h>],
5080*a96ef450SBaptiste Daroussin		[struct termios foo; int x = foo.c_iflag = 1; (void)x],
5081f4f33ea0SBaptiste Daroussin		termios_bad=no, [
5082f4f33ea0SBaptiste Daroussin		AC_TRY_COMPILE([
5083f4f33ea0SBaptiste Daroussin#define _POSIX_SOURCE
5084f4f33ea0SBaptiste Daroussin#include <termios.h>],
5085*a96ef450SBaptiste Daroussin			[struct termios foo; int x = foo.c_iflag = 2; (void)x],
5086f4f33ea0SBaptiste Daroussin			termios_bad=unknown,
5087f4f33ea0SBaptiste Daroussin			termios_bad=yes AC_DEFINE(_POSIX_SOURCE,1,[Define to 1 if we must define _POSIX_SOURCE]))
5088f4f33ea0SBaptiste Daroussin			])
5089f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT($termios_bad)
5090f4f33ea0SBaptiste Daroussin	fi
5091f4f33ea0SBaptiste Daroussinfi
5092f4f33ea0SBaptiste Daroussin])dnl
5093f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
5094f4f33ea0SBaptiste Daroussindnl CF_SUBDIR_PATH version: 7 updated: 2014/12/04 04:33:06
50954c8945a0SNathan Whitehorndnl --------------
50964c8945a0SNathan Whitehorndnl Construct a search-list for a nonstandard header/lib-file
50974c8945a0SNathan Whitehorndnl	$1 = the variable to return as result
50984c8945a0SNathan Whitehorndnl	$2 = the package name
50994c8945a0SNathan Whitehorndnl	$3 = the subdirectory, e.g., bin, include or lib
51004c8945a0SNathan WhitehornAC_DEFUN([CF_SUBDIR_PATH],
51014c8945a0SNathan Whitehorn[
51024c8945a0SNathan Whitehorn$1=
51034c8945a0SNathan Whitehorn
51044c8945a0SNathan WhitehornCF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
5105f4f33ea0SBaptiste Daroussin
5106f4f33ea0SBaptiste Daroussinfor cf_subdir_prefix in \
5107f4f33ea0SBaptiste Daroussin	/usr \
5108f4f33ea0SBaptiste Daroussin	/usr/local \
5109f4f33ea0SBaptiste Daroussin	/usr/pkg \
5110f4f33ea0SBaptiste Daroussin	/opt \
5111f4f33ea0SBaptiste Daroussin	/opt/local \
5112f4f33ea0SBaptiste Daroussin	[$]HOME
5113f4f33ea0SBaptiste Daroussindo
5114f4f33ea0SBaptiste Daroussin	CF_ADD_SUBDIR_PATH($1,$2,$3,$cf_subdir_prefix,$prefix)
5115f4f33ea0SBaptiste Daroussindone
51164c8945a0SNathan Whitehorn])dnl
51174c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
5118*a96ef450SBaptiste Daroussindnl CF_TERM_HEADER version: 6 updated: 2021/01/02 09:31:20
51194c8945a0SNathan Whitehorndnl --------------
51204c8945a0SNathan Whitehorndnl Look for term.h, which is part of X/Open curses.  It defines the interface
51214c8945a0SNathan Whitehorndnl to terminfo database.  Usually it is in the same include-path as curses.h,
51224c8945a0SNathan Whitehorndnl but some packagers change this, breaking various applications.
51234c8945a0SNathan WhitehornAC_DEFUN([CF_TERM_HEADER],[
51244c8945a0SNathan WhitehornAC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
5125*a96ef450SBaptiste Daroussincase "${cf_cv_ncurses_header}" in
5126f4f33ea0SBaptiste Daroussin(*/ncurses.h|*/ncursesw.h)
51274c8945a0SNathan Whitehorn	cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
51284c8945a0SNathan Whitehorn	;;
5129f4f33ea0SBaptiste Daroussin(*)
51304c8945a0SNathan Whitehorn	cf_term_header=term.h
51314c8945a0SNathan Whitehorn	;;
51324c8945a0SNathan Whitehornesac
51334c8945a0SNathan Whitehorn
51344c8945a0SNathan Whitehornfor cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
51354c8945a0SNathan Whitehorndo
51364c8945a0SNathan WhitehornAC_TRY_COMPILE([#include <stdio.h>
51377a1c0d96SNathan Whitehorn#include <${cf_cv_ncurses_header:-curses.h}>
51384c8945a0SNathan Whitehorn#include <$cf_test>
5139*a96ef450SBaptiste Daroussin],[int x = auto_left_margin; (void)x],[
51404c8945a0SNathan Whitehorn	cf_cv_term_header="$cf_test"],[
51414c8945a0SNathan Whitehorn	cf_cv_term_header=unknown
51424c8945a0SNathan Whitehorn	])
51434c8945a0SNathan Whitehorn	test "$cf_cv_term_header" != unknown && break
51444c8945a0SNathan Whitehorndone
51454c8945a0SNathan Whitehorn])
51464c8945a0SNathan Whitehorn
51474c8945a0SNathan Whitehorn# Set definitions to allow ifdef'ing to accommodate subdirectories
51484c8945a0SNathan Whitehorn
5149*a96ef450SBaptiste Daroussincase "$cf_cv_term_header" in
5150f4f33ea0SBaptiste Daroussin(*term.h)
51512a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
51524c8945a0SNathan Whitehorn	;;
51534c8945a0SNathan Whitehornesac
51544c8945a0SNathan Whitehorn
5155*a96ef450SBaptiste Daroussincase "$cf_cv_term_header" in
5156f4f33ea0SBaptiste Daroussin(ncurses/term.h)
51572a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
51584c8945a0SNathan Whitehorn	;;
5159f4f33ea0SBaptiste Daroussin(ncursesw/term.h)
51602a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
51614c8945a0SNathan Whitehorn	;;
51624c8945a0SNathan Whitehornesac
51634c8945a0SNathan Whitehorn])dnl
51644c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
5165f4f33ea0SBaptiste Daroussindnl CF_TRIM_X_LIBS version: 3 updated: 2015/04/12 15:39:00
5166f4f33ea0SBaptiste Daroussindnl --------------
5167f4f33ea0SBaptiste Daroussindnl Trim extra base X libraries added as a workaround for inconsistent library
5168f4f33ea0SBaptiste Daroussindnl dependencies returned by "new" pkg-config files.
5169f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_TRIM_X_LIBS],[
5170f4f33ea0SBaptiste Daroussin	for cf_trim_lib in Xmu Xt X11
5171f4f33ea0SBaptiste Daroussin	do
5172f4f33ea0SBaptiste Daroussin		case "$LIBS" in
5173f4f33ea0SBaptiste Daroussin		(*-l$cf_trim_lib\ *-l$cf_trim_lib*)
5174f4f33ea0SBaptiste Daroussin			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
5175f4f33ea0SBaptiste Daroussin			CF_VERBOSE(..trimmed $LIBS)
5176f4f33ea0SBaptiste Daroussin			;;
5177f4f33ea0SBaptiste Daroussin		esac
5178f4f33ea0SBaptiste Daroussin	done
5179f4f33ea0SBaptiste Daroussin])
5180f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
5181*a96ef450SBaptiste Daroussindnl CF_TRY_PKG_CONFIG version: 6 updated: 2020/12/31 10:54:15
5182f4f33ea0SBaptiste Daroussindnl -----------------
5183f4f33ea0SBaptiste Daroussindnl This is a simple wrapper to use for pkg-config, for libraries which may be
5184f4f33ea0SBaptiste Daroussindnl available in that form.
5185f4f33ea0SBaptiste Daroussindnl
5186*a96ef450SBaptiste Daroussindnl $1 = package name, which may be a shell variable
5187f4f33ea0SBaptiste Daroussindnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
5188f4f33ea0SBaptiste Daroussindnl $3 = logic to use if pkg-config does not have the package
5189f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_TRY_PKG_CONFIG],[
5190f4f33ea0SBaptiste DaroussinAC_REQUIRE([CF_PKG_CONFIG])
5191f4f33ea0SBaptiste Daroussin
5192*a96ef450SBaptiste Daroussinif test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "$1"; then
5193f4f33ea0SBaptiste Daroussin	CF_VERBOSE(found package $1)
5194*a96ef450SBaptiste Daroussin	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "$1" 2>/dev/null`"
5195*a96ef450SBaptiste Daroussin	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "$1" 2>/dev/null`"
5196f4f33ea0SBaptiste Daroussin	CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
5197f4f33ea0SBaptiste Daroussin	CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
5198f4f33ea0SBaptiste Daroussin	CF_ADD_CFLAGS($cf_pkgconfig_incs)
5199f4f33ea0SBaptiste Daroussin	CF_ADD_LIBS($cf_pkgconfig_libs)
5200f4f33ea0SBaptiste Daroussin	ifelse([$2],,:,[$2])
5201f4f33ea0SBaptiste Daroussinelse
5202f4f33ea0SBaptiste Daroussin	cf_pkgconfig_incs=
5203f4f33ea0SBaptiste Daroussin	cf_pkgconfig_libs=
5204f4f33ea0SBaptiste Daroussin	ifelse([$3],,:,[$3])
5205f4f33ea0SBaptiste Daroussinfi
5206f4f33ea0SBaptiste Daroussin])
5207f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
5208f4f33ea0SBaptiste Daroussindnl CF_TRY_XOPEN_SOURCE version: 2 updated: 2018/06/20 20:23:13
52092a3e3873SBaptiste Daroussindnl -------------------
52102a3e3873SBaptiste Daroussindnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
52112a3e3873SBaptiste Daroussindnl can define it successfully.
52122a3e3873SBaptiste DaroussinAC_DEFUN([CF_TRY_XOPEN_SOURCE],[
52132a3e3873SBaptiste DaroussinAC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
52142a3e3873SBaptiste Daroussin	AC_TRY_COMPILE([
52152a3e3873SBaptiste Daroussin#include <stdlib.h>
52162a3e3873SBaptiste Daroussin#include <string.h>
52172a3e3873SBaptiste Daroussin#include <sys/types.h>
52182a3e3873SBaptiste Daroussin],[
52192a3e3873SBaptiste Daroussin#ifndef _XOPEN_SOURCE
52202a3e3873SBaptiste Daroussinmake an error
52212a3e3873SBaptiste Daroussin#endif],
52222a3e3873SBaptiste Daroussin	[cf_cv_xopen_source=no],
52232a3e3873SBaptiste Daroussin	[cf_save="$CPPFLAGS"
5224f4f33ea0SBaptiste Daroussin	 CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
52252a3e3873SBaptiste Daroussin	 AC_TRY_COMPILE([
52262a3e3873SBaptiste Daroussin#include <stdlib.h>
52272a3e3873SBaptiste Daroussin#include <string.h>
52282a3e3873SBaptiste Daroussin#include <sys/types.h>
52292a3e3873SBaptiste Daroussin],[
52302a3e3873SBaptiste Daroussin#ifdef _XOPEN_SOURCE
52312a3e3873SBaptiste Daroussinmake an error
52322a3e3873SBaptiste Daroussin#endif],
52332a3e3873SBaptiste Daroussin	[cf_cv_xopen_source=no],
52342a3e3873SBaptiste Daroussin	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
52352a3e3873SBaptiste Daroussin	CPPFLAGS="$cf_save"
52362a3e3873SBaptiste Daroussin	])
52372a3e3873SBaptiste Daroussin])
52382a3e3873SBaptiste Daroussin
52392a3e3873SBaptiste Daroussinif test "$cf_cv_xopen_source" != no ; then
52402a3e3873SBaptiste Daroussin	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
52412a3e3873SBaptiste Daroussin	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
52422a3e3873SBaptiste Daroussin	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
52432a3e3873SBaptiste Daroussin	CF_ADD_CFLAGS($cf_temp_xopen_source)
52442a3e3873SBaptiste Daroussinfi
52452a3e3873SBaptiste Daroussin])
52462a3e3873SBaptiste Daroussindnl ---------------------------------------------------------------------------
5247*a96ef450SBaptiste Daroussindnl CF_UNION_WAIT version: 8 updated: 2021/01/02 09:31:20
52484c8945a0SNathan Whitehorndnl -------------
52494c8945a0SNathan Whitehorndnl Check to see if the BSD-style union wait is declared.  Some platforms may
52504c8945a0SNathan Whitehorndnl use this, though it is deprecated in favor of the 'int' type in Posix.
52514c8945a0SNathan Whitehorndnl Some vendors provide a bogus implementation that declares union wait, but
52524c8945a0SNathan Whitehorndnl uses the 'int' type instead; we try to spot these by checking for the
52534c8945a0SNathan Whitehorndnl associated macros.
52544c8945a0SNathan Whitehorndnl
52554c8945a0SNathan Whitehorndnl Ahem.  Some implementers cast the status value to an int*, as an attempt to
52564c8945a0SNathan Whitehorndnl use the macros for either union wait or int.  So we do a check compile to
52574c8945a0SNathan Whitehorndnl see if the macros are defined and apply to an int.
52584c8945a0SNathan Whitehorndnl
52594c8945a0SNathan Whitehorndnl Sets: $cf_cv_type_unionwait
52604c8945a0SNathan Whitehorndnl Defines: HAVE_TYPE_UNIONWAIT
52614c8945a0SNathan WhitehornAC_DEFUN([CF_UNION_WAIT],
52624c8945a0SNathan Whitehorn[
52634c8945a0SNathan WhitehornAC_REQUIRE([CF_WAIT_HEADERS])
52644c8945a0SNathan WhitehornAC_MSG_CHECKING([for union wait])
52654c8945a0SNathan WhitehornAC_CACHE_VAL(cf_cv_type_unionwait,[
52664c8945a0SNathan Whitehorn	AC_TRY_LINK($cf_wait_headers,
52674c8945a0SNathan Whitehorn	[int x;
52684c8945a0SNathan Whitehorn	 int y = WEXITSTATUS(x);
52694c8945a0SNathan Whitehorn	 int z = WTERMSIG(x);
52704c8945a0SNathan Whitehorn	 wait(&x);
5271*a96ef450SBaptiste Daroussin	 (void)x;
5272*a96ef450SBaptiste Daroussin	 (void)y;
5273*a96ef450SBaptiste Daroussin	 (void)z;
52744c8945a0SNathan Whitehorn	],
52754c8945a0SNathan Whitehorn	[cf_cv_type_unionwait=no
52764c8945a0SNathan Whitehorn	 echo compiles ok w/o union wait 1>&AC_FD_CC
52774c8945a0SNathan Whitehorn	],[
52784c8945a0SNathan Whitehorn	AC_TRY_LINK($cf_wait_headers,
52794c8945a0SNathan Whitehorn	[union wait x;
52804c8945a0SNathan Whitehorn#ifdef WEXITSTATUS
52814c8945a0SNathan Whitehorn	 int y = WEXITSTATUS(x);
52824c8945a0SNathan Whitehorn#endif
52834c8945a0SNathan Whitehorn#ifdef WTERMSIG
52844c8945a0SNathan Whitehorn	 int z = WTERMSIG(x);
52854c8945a0SNathan Whitehorn#endif
52864c8945a0SNathan Whitehorn	 wait(&x);
5287*a96ef450SBaptiste Daroussin	 (void)x;
5288*a96ef450SBaptiste Daroussin#ifdef WEXITSTATUS
5289*a96ef450SBaptiste Daroussin	 (void)y;
5290*a96ef450SBaptiste Daroussin#endif
5291*a96ef450SBaptiste Daroussin#ifdef WTERMSIG
5292*a96ef450SBaptiste Daroussin	 (void)z;
5293*a96ef450SBaptiste Daroussin#endif
52944c8945a0SNathan Whitehorn	],
52954c8945a0SNathan Whitehorn	[cf_cv_type_unionwait=yes
52964c8945a0SNathan Whitehorn	 echo compiles ok with union wait and possibly macros too 1>&AC_FD_CC
52974c8945a0SNathan Whitehorn	],
52984c8945a0SNathan Whitehorn	[cf_cv_type_unionwait=no])])])
52994c8945a0SNathan WhitehornAC_MSG_RESULT($cf_cv_type_unionwait)
5300*a96ef450SBaptiste Daroussintest "$cf_cv_type_unionwait" = yes && AC_DEFINE(HAVE_TYPE_UNIONWAIT,1,[Define to 1 if type unionwait is declared])
53014c8945a0SNathan Whitehorn])dnl
53024c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
53034c8945a0SNathan Whitehorndnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
53044c8945a0SNathan Whitehorndnl --------
53054c8945a0SNathan Whitehorndnl Make an uppercase version of a variable
53064c8945a0SNathan Whitehorndnl $1=uppercase($2)
53074c8945a0SNathan WhitehornAC_DEFUN([CF_UPPER],
53084c8945a0SNathan Whitehorn[
53094c8945a0SNathan Whitehorn$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
53104c8945a0SNathan Whitehorn])dnl
53114c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
53122a3e3873SBaptiste Daroussindnl CF_UTF8_LIB version: 8 updated: 2012/10/06 08:57:51
53134c8945a0SNathan Whitehorndnl -----------
53144c8945a0SNathan Whitehorndnl Check for multibyte support, and if not found, utf8 compatibility library
53154c8945a0SNathan WhitehornAC_DEFUN([CF_UTF8_LIB],
53164c8945a0SNathan Whitehorn[
53174c8945a0SNathan WhitehornAC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
53184c8945a0SNathan Whitehorn	cf_save_LIBS="$LIBS"
53194c8945a0SNathan Whitehorn	AC_TRY_LINK([
53204c8945a0SNathan Whitehorn#include <stdlib.h>],[putwc(0,0);],
53214c8945a0SNathan Whitehorn	[cf_cv_utf8_lib=yes],
53224c8945a0SNathan Whitehorn	[CF_FIND_LINKAGE([
53234c8945a0SNathan Whitehorn#include <libutf8.h>],[putwc(0,0);],utf8,
53244c8945a0SNathan Whitehorn		[cf_cv_utf8_lib=add-on],
53254c8945a0SNathan Whitehorn		[cf_cv_utf8_lib=no])
53264c8945a0SNathan Whitehorn])])
53274c8945a0SNathan Whitehorn
53284c8945a0SNathan Whitehorn# HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
53294c8945a0SNathan Whitehorn# ncurses/ncursesw:
53304c8945a0SNathan Whitehornif test "$cf_cv_utf8_lib" = "add-on" ; then
53312a3e3873SBaptiste Daroussin	AC_DEFINE(HAVE_LIBUTF8_H,1,[Define to 1 if we should include libutf8.h])
53324c8945a0SNathan Whitehorn	CF_ADD_INCDIR($cf_cv_header_path_utf8)
53334c8945a0SNathan Whitehorn	CF_ADD_LIBDIR($cf_cv_library_path_utf8)
53347a1c0d96SNathan Whitehorn	CF_ADD_LIBS($cf_cv_library_file_utf8)
53354c8945a0SNathan Whitehornfi
53364c8945a0SNathan Whitehorn])dnl
53374c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
53384c8945a0SNathan Whitehorndnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
53394c8945a0SNathan Whitehorndnl ----------
53404c8945a0SNathan Whitehorndnl Use AC_VERBOSE w/o the warnings
53414c8945a0SNathan WhitehornAC_DEFUN([CF_VERBOSE],
53424c8945a0SNathan Whitehorn[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
53434c8945a0SNathan WhitehornCF_MSG_LOG([$1])
53444c8945a0SNathan Whitehorn])dnl
53454c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
5346*a96ef450SBaptiste Daroussindnl CF_VERSION_INFO version: 8 updated: 2021/01/01 13:31:04
53474c8945a0SNathan Whitehorndnl ---------------
53484c8945a0SNathan Whitehorndnl Define several useful symbols derived from the VERSION file.  A separate
53494c8945a0SNathan Whitehorndnl file is preferred to embedding the version numbers in various scripts.
53504c8945a0SNathan Whitehorndnl (automake is a textbook-example of why the latter is a bad idea, but there
53514c8945a0SNathan Whitehorndnl are others).
53524c8945a0SNathan Whitehorndnl
53534c8945a0SNathan Whitehorndnl The file contents are:
53544c8945a0SNathan Whitehorndnl	libtool-version	release-version	patch-version
53554c8945a0SNathan Whitehorndnl or
53564c8945a0SNathan Whitehorndnl	release-version
53574c8945a0SNathan Whitehorndnl where
53584c8945a0SNathan Whitehorndnl	libtool-version (see ?) consists of 3 integers separated by '.'
53594c8945a0SNathan Whitehorndnl	release-version consists of a major version and minor version
53604c8945a0SNathan Whitehorndnl		separated by '.', optionally followed by a patch-version
53614c8945a0SNathan Whitehorndnl		separated by '-'.  The minor version need not be an
53624c8945a0SNathan Whitehorndnl		integer (but it is preferred).
53634c8945a0SNathan Whitehorndnl	patch-version is an integer in the form yyyymmdd, so ifdef's and
53644c8945a0SNathan Whitehorndnl		scripts can easily compare versions.
53654c8945a0SNathan Whitehorndnl
53664c8945a0SNathan Whitehorndnl If libtool is used, the first form is required, since CF_WITH_LIBTOOL
53674c8945a0SNathan Whitehorndnl simply extracts the first field using 'cut -f1'.
53687a1c0d96SNathan Whitehorndnl
53697a1c0d96SNathan Whitehorndnl Optional parameters:
53707a1c0d96SNathan Whitehorndnl $1 = internal name for package
53717a1c0d96SNathan Whitehorndnl $2 = external name for package
53724c8945a0SNathan WhitehornAC_DEFUN([CF_VERSION_INFO],
53734c8945a0SNathan Whitehorn[
5374*a96ef450SBaptiste Daroussinif test -f "$srcdir/VERSION" ; then
53754c8945a0SNathan Whitehorn	AC_MSG_CHECKING(for package version)
53764c8945a0SNathan Whitehorn
53774c8945a0SNathan Whitehorn	# if there are not enough fields, cut returns the last one...
5378*a96ef450SBaptiste Daroussin	cf_field1=`sed -e '2,$d' "$srcdir/VERSION" |cut -f1`
5379*a96ef450SBaptiste Daroussin	cf_field2=`sed -e '2,$d' "$srcdir/VERSION" |cut -f2`
5380*a96ef450SBaptiste Daroussin	cf_field3=`sed -e '2,$d' "$srcdir/VERSION" |cut -f3`
53814c8945a0SNathan Whitehorn
53824c8945a0SNathan Whitehorn	# this is how CF_BUNDLED_INTL uses $VERSION:
53834c8945a0SNathan Whitehorn	VERSION="$cf_field1"
53844c8945a0SNathan Whitehorn
53854c8945a0SNathan Whitehorn	VERSION_MAJOR=`echo "$cf_field2" | sed -e 's/\..*//'`
53864c8945a0SNathan Whitehorn	test -z "$VERSION_MAJOR" && AC_MSG_ERROR(missing major-version)
53874c8945a0SNathan Whitehorn
53884c8945a0SNathan Whitehorn	VERSION_MINOR=`echo "$cf_field2" | sed -e 's/^[[^.]]*\.//' -e 's/-.*//'`
53894c8945a0SNathan Whitehorn	test -z "$VERSION_MINOR" && AC_MSG_ERROR(missing minor-version)
53904c8945a0SNathan Whitehorn
53914c8945a0SNathan Whitehorn	AC_MSG_RESULT(${VERSION_MAJOR}.${VERSION_MINOR})
53924c8945a0SNathan Whitehorn
53934c8945a0SNathan Whitehorn	AC_MSG_CHECKING(for package patch date)
53944c8945a0SNathan Whitehorn	VERSION_PATCH=`echo "$cf_field3" | sed -e 's/^[[^-]]*-//'`
53954c8945a0SNathan Whitehorn	case .$VERSION_PATCH in
5396f4f33ea0SBaptiste Daroussin	(.)
53974c8945a0SNathan Whitehorn		AC_MSG_ERROR(missing patch-date $VERSION_PATCH)
53984c8945a0SNathan Whitehorn		;;
5399f4f33ea0SBaptiste Daroussin	(.[[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]])
54004c8945a0SNathan Whitehorn		;;
5401f4f33ea0SBaptiste Daroussin	(*)
54024c8945a0SNathan Whitehorn		AC_MSG_ERROR(illegal patch-date $VERSION_PATCH)
54034c8945a0SNathan Whitehorn		;;
54044c8945a0SNathan Whitehorn	esac
54054c8945a0SNathan Whitehorn	AC_MSG_RESULT($VERSION_PATCH)
54064c8945a0SNathan Whitehornelse
54074c8945a0SNathan Whitehorn	AC_MSG_ERROR(did not find $srcdir/VERSION)
54084c8945a0SNathan Whitehornfi
54094c8945a0SNathan Whitehorn
54104c8945a0SNathan Whitehorn# show the actual data that we have for versions:
5411febdb468SDevin TeskeCF_VERBOSE(ABI VERSION $VERSION)
54124c8945a0SNathan WhitehornCF_VERBOSE(VERSION_MAJOR $VERSION_MAJOR)
54134c8945a0SNathan WhitehornCF_VERBOSE(VERSION_MINOR $VERSION_MINOR)
54144c8945a0SNathan WhitehornCF_VERBOSE(VERSION_PATCH $VERSION_PATCH)
54154c8945a0SNathan Whitehorn
54164c8945a0SNathan WhitehornAC_SUBST(VERSION)
54174c8945a0SNathan WhitehornAC_SUBST(VERSION_MAJOR)
54184c8945a0SNathan WhitehornAC_SUBST(VERSION_MINOR)
54194c8945a0SNathan WhitehornAC_SUBST(VERSION_PATCH)
54204c8945a0SNathan Whitehorn
54214c8945a0SNathan Whitehorndnl if a package name is given, define its corresponding version info.  We
54224c8945a0SNathan Whitehorndnl need the package name to ensure that the defined symbols are unique.
54234c8945a0SNathan Whitehornifelse($1,,,[
54247a1c0d96SNathan Whitehorn	cf_PACKAGE=$1
54257a1c0d96SNathan Whitehorn	PACKAGE=ifelse($2,,$1,$2)
54262a3e3873SBaptiste Daroussin	AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE",[Define to the package-name])
54274c8945a0SNathan Whitehorn	AC_SUBST(PACKAGE)
54287a1c0d96SNathan Whitehorn	CF_UPPER(cf_PACKAGE,$cf_PACKAGE)
54294c8945a0SNathan Whitehorn	AC_DEFINE_UNQUOTED(${cf_PACKAGE}_VERSION,"${VERSION_MAJOR}.${VERSION_MINOR}")
54304c8945a0SNathan Whitehorn	AC_DEFINE_UNQUOTED(${cf_PACKAGE}_PATCHDATE,${VERSION_PATCH})
54314c8945a0SNathan Whitehorn])
54324c8945a0SNathan Whitehorn])dnl
54334c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
5434*a96ef450SBaptiste Daroussindnl CF_WAIT_HEADERS version: 3 updated: 2021/01/02 09:31:20
54354c8945a0SNathan Whitehorndnl ---------------
54364c8945a0SNathan Whitehorndnl Build up an expression $cf_wait_headers with the header files needed to
54374c8945a0SNathan Whitehorndnl compile against the prototypes for 'wait()', 'waitpid()', etc.  Assume it's
54384c8945a0SNathan Whitehorndnl Posix, which uses <sys/types.h> and <sys/wait.h>, but allow SVr4 variation
54394c8945a0SNathan Whitehorndnl with <wait.h>.
54404c8945a0SNathan WhitehornAC_DEFUN([CF_WAIT_HEADERS],
54414c8945a0SNathan Whitehorn[
54424c8945a0SNathan WhitehornAC_HAVE_HEADERS(sys/wait.h)
54434c8945a0SNathan Whitehorncf_wait_headers="#include <sys/types.h>
54444c8945a0SNathan Whitehorn"
5445*a96ef450SBaptiste Daroussinif test "$ac_cv_header_sys_wait_h" = yes; then
54464c8945a0SNathan Whitehorncf_wait_headers="$cf_wait_headers
54474c8945a0SNathan Whitehorn#include <sys/wait.h>
54484c8945a0SNathan Whitehorn"
54494c8945a0SNathan Whitehornelse
54504c8945a0SNathan WhitehornAC_HAVE_HEADERS(wait.h)
54514c8945a0SNathan WhitehornAC_HAVE_HEADERS(waitstatus.h)
5452*a96ef450SBaptiste Daroussinif test "$ac_cv_header_wait_h" = yes; then
54534c8945a0SNathan Whitehorncf_wait_headers="$cf_wait_headers
54544c8945a0SNathan Whitehorn#include <wait.h>
54554c8945a0SNathan Whitehorn"
54564c8945a0SNathan Whitehornfi
5457*a96ef450SBaptiste Daroussinif test "$ac_cv_header_waitstatus_h" = yes; then
54584c8945a0SNathan Whitehorncf_wait_headers="$cf_wait_headers
54594c8945a0SNathan Whitehorn#include <waitstatus.h>
54604c8945a0SNathan Whitehorn"
54614c8945a0SNathan Whitehornfi
54624c8945a0SNathan Whitehornfi
54634c8945a0SNathan Whitehorn])dnl
54644c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
5465*a96ef450SBaptiste Daroussindnl CF_WIDEC_CURSES version: 6 updated: 2020/03/19 20:23:48
5466f4f33ea0SBaptiste Daroussindnl ---------------
5467f4f33ea0SBaptiste Daroussindnl Check for curses implementations that can handle wide-characters
5468f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_WIDEC_CURSES],
5469f4f33ea0SBaptiste Daroussin[
5470f4f33ea0SBaptiste DaroussinAC_CACHE_CHECK(if curses supports wide characters,cf_cv_widec_curses,[
5471f4f33ea0SBaptiste DaroussinAC_TRY_LINK([
5472f4f33ea0SBaptiste Daroussin#include <stdlib.h>
5473f4f33ea0SBaptiste Daroussin#include <${cf_cv_ncurses_header:-curses.h}>],[
5474f4f33ea0SBaptiste Daroussin    wchar_t temp[2];
5475f4f33ea0SBaptiste Daroussin    wchar_t wch = 'A';
5476f4f33ea0SBaptiste Daroussin    temp[0] = wch;
5477f4f33ea0SBaptiste Daroussin    waddnwstr(stdscr, temp, 1);
5478f4f33ea0SBaptiste Daroussin],
5479f4f33ea0SBaptiste Daroussin[cf_cv_widec_curses=yes],
5480f4f33ea0SBaptiste Daroussin[cf_cv_widec_curses=no])
5481f4f33ea0SBaptiste Daroussin])
5482f4f33ea0SBaptiste Daroussin
5483f4f33ea0SBaptiste Daroussinif test "$cf_cv_widec_curses" = yes ; then
5484f4f33ea0SBaptiste Daroussin	AC_DEFINE(WIDEC_CURSES,1,[Define to 1 if curses supports wide characters])
5485f4f33ea0SBaptiste Daroussin
5486f4f33ea0SBaptiste Daroussin	# This is needed on Tru64 5.0 to declare mbstate_t
5487f4f33ea0SBaptiste Daroussin	AC_CACHE_CHECK(if we must include wchar.h to declare mbstate_t,cf_cv_widec_mbstate,[
5488f4f33ea0SBaptiste Daroussin	AC_TRY_COMPILE([
5489f4f33ea0SBaptiste Daroussin#include <stdlib.h>
5490f4f33ea0SBaptiste Daroussin#include <${cf_cv_ncurses_header:-curses.h}>],
5491*a96ef450SBaptiste Daroussin[mbstate_t state; (void)state],
5492f4f33ea0SBaptiste Daroussin[cf_cv_widec_mbstate=no],
5493f4f33ea0SBaptiste Daroussin[AC_TRY_COMPILE([
5494f4f33ea0SBaptiste Daroussin#include <stdlib.h>
5495f4f33ea0SBaptiste Daroussin#include <wchar.h>
5496f4f33ea0SBaptiste Daroussin#include <${cf_cv_ncurses_header:-curses.h}>],
5497*a96ef450SBaptiste Daroussin[mbstate_t state; (void)state],
5498f4f33ea0SBaptiste Daroussin[cf_cv_widec_mbstate=yes],
5499f4f33ea0SBaptiste Daroussin[cf_cv_widec_mbstate=unknown])])])
5500f4f33ea0SBaptiste Daroussin
5501f4f33ea0SBaptiste Daroussinif test "$cf_cv_widec_mbstate" = yes ; then
5502f4f33ea0SBaptiste Daroussin	AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
5503f4f33ea0SBaptiste Daroussinfi
5504f4f33ea0SBaptiste Daroussin
5505f4f33ea0SBaptiste Daroussinif test "$cf_cv_widec_mbstate" != unknown ; then
5506f4f33ea0SBaptiste Daroussin	AC_DEFINE(HAVE_MBSTATE_T,1,[Define to 1 if we have mbstate_t type])
5507f4f33ea0SBaptiste Daroussinfi
5508f4f33ea0SBaptiste Daroussin
5509f4f33ea0SBaptiste Daroussinfi
5510f4f33ea0SBaptiste Daroussin])dnl
5511f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
5512*a96ef450SBaptiste Daroussindnl CF_WITH_ABI_VERSION version: 4 updated: 2021/01/01 13:31:04
5513febdb468SDevin Teskednl -------------------
5514febdb468SDevin Teskednl Allow library's ABI to be overridden.  Generally this happens when a
5515febdb468SDevin Teskednl packager has incremented the ABI past that used in the original package,
5516febdb468SDevin Teskednl and wishes to keep doing this.
5517febdb468SDevin Teskednl
5518febdb468SDevin Teskednl $1 is the package name, if any, to derive a corresponding {package}_ABI
5519febdb468SDevin Teskednl symbol.
5520febdb468SDevin TeskeAC_DEFUN([CF_WITH_ABI_VERSION],[
5521febdb468SDevin Tesketest -z "$cf_cv_abi_version" && cf_cv_abi_version=0
5522febdb468SDevin TeskeAC_ARG_WITH(abi-version,
5523f4f33ea0SBaptiste Daroussin[  --with-abi-version=XXX  override derived ABI version],[
5524f4f33ea0SBaptiste Daroussin	if test "x$cf_cv_abi_version" != "x$withval"
5525f4f33ea0SBaptiste Daroussin	then
5526f4f33ea0SBaptiste Daroussin		AC_MSG_WARN(overriding ABI version $cf_cv_abi_version to $withval)
5527*a96ef450SBaptiste Daroussin		case "$cf_cv_rel_version" in
5528f4f33ea0SBaptiste Daroussin		(5.*)
5529f4f33ea0SBaptiste Daroussin			cf_cv_rel_version=$withval.0
5530f4f33ea0SBaptiste Daroussin			;;
5531f4f33ea0SBaptiste Daroussin		(6.*)
5532f4f33ea0SBaptiste Daroussin			cf_cv_rel_version=$withval.9	# FIXME: should be 10 as of 6.0 release
5533f4f33ea0SBaptiste Daroussin			;;
5534f4f33ea0SBaptiste Daroussin		esac
5535f4f33ea0SBaptiste Daroussin	fi
5536febdb468SDevin Teske	cf_cv_abi_version=$withval])
5537febdb468SDevin Teske	CF_NUMBER_SYNTAX($cf_cv_abi_version,ABI version)
5538febdb468SDevin Teskeifelse($1,,,[
5539febdb468SDevin Teske$1_ABI=$cf_cv_abi_version
5540febdb468SDevin Teske])
5541febdb468SDevin Teske])dnl
5542febdb468SDevin Teskednl ---------------------------------------------------------------------------
5543*a96ef450SBaptiste Daroussindnl CF_WITH_CURSES_DIR version: 4 updated: 2021/01/02 19:22:58
55444c8945a0SNathan Whitehorndnl ------------------
55454c8945a0SNathan Whitehorndnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
55464c8945a0SNathan Whitehorndnl libraries.
55474c8945a0SNathan WhitehornAC_DEFUN([CF_WITH_CURSES_DIR],[
55487a1c0d96SNathan Whitehorn
55497a1c0d96SNathan WhitehornAC_MSG_CHECKING(for specific curses-directory)
55504c8945a0SNathan WhitehornAC_ARG_WITH(curses-dir,
55514c8945a0SNathan Whitehorn	[  --with-curses-dir=DIR   directory in which (n)curses is installed],
55527a1c0d96SNathan Whitehorn	[cf_cv_curses_dir=$withval],
55534c8945a0SNathan Whitehorn	[cf_cv_curses_dir=no])
55547a1c0d96SNathan WhitehornAC_MSG_RESULT($cf_cv_curses_dir)
55557a1c0d96SNathan Whitehorn
5556*a96ef450SBaptiste Daroussinif test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no"
55577a1c0d96SNathan Whitehornthen
55587a1c0d96SNathan Whitehorn	CF_PATH_SYNTAX(withval)
55597a1c0d96SNathan Whitehorn	if test -d "$cf_cv_curses_dir"
55607a1c0d96SNathan Whitehorn	then
55617a1c0d96SNathan Whitehorn		CF_ADD_INCDIR($cf_cv_curses_dir/include)
55627a1c0d96SNathan Whitehorn		CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
55637a1c0d96SNathan Whitehorn	fi
55647a1c0d96SNathan Whitehornfi
55654c8945a0SNathan Whitehorn])dnl
55664c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
55677a1c0d96SNathan Whitehorndnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
55684c8945a0SNathan Whitehorndnl ----------------
55694c8945a0SNathan Whitehorndnl Configure-option for dbmalloc.  The optional parameter is used to override
55704c8945a0SNathan Whitehorndnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
55714c8945a0SNathan WhitehornAC_DEFUN([CF_WITH_DBMALLOC],[
55724c8945a0SNathan WhitehornCF_NO_LEAKS_OPTION(dbmalloc,
55734c8945a0SNathan Whitehorn	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
55744c8945a0SNathan Whitehorn	[USE_DBMALLOC])
55754c8945a0SNathan Whitehorn
55764c8945a0SNathan Whitehornif test "$with_dbmalloc" = yes ; then
55774c8945a0SNathan Whitehorn	AC_CHECK_HEADER(dbmalloc.h,
55787a1c0d96SNathan Whitehorn		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
55794c8945a0SNathan Whitehornfi
55804c8945a0SNathan Whitehorn])dnl
55814c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
55827a1c0d96SNathan Whitehorndnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
55834c8945a0SNathan Whitehorndnl ---------------
55844c8945a0SNathan Whitehorndnl Configure-option for dmalloc.  The optional parameter is used to override
55854c8945a0SNathan Whitehorndnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
55864c8945a0SNathan WhitehornAC_DEFUN([CF_WITH_DMALLOC],[
55874c8945a0SNathan WhitehornCF_NO_LEAKS_OPTION(dmalloc,
55884c8945a0SNathan Whitehorn	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
55894c8945a0SNathan Whitehorn	[USE_DMALLOC])
55904c8945a0SNathan Whitehorn
55914c8945a0SNathan Whitehornif test "$with_dmalloc" = yes ; then
55924c8945a0SNathan Whitehorn	AC_CHECK_HEADER(dmalloc.h,
55937a1c0d96SNathan Whitehorn		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
55944c8945a0SNathan Whitehornfi
55954c8945a0SNathan Whitehorn])dnl
55964c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
5597f4f33ea0SBaptiste Daroussindnl CF_WITH_EXPORT_SYMS version: 3 updated: 2014/12/20 19:16:08
5598f4f33ea0SBaptiste Daroussindnl -------------------
5599f4f33ea0SBaptiste Daroussindnl Use this with libtool to specify the list of symbols that may be exported.
5600f4f33ea0SBaptiste Daroussindnl The input file contains one symbol per line; comments work with "#".
5601f4f33ea0SBaptiste Daroussindnl
5602f4f33ea0SBaptiste Daroussindnl $1 = basename of the ".sym" file (default $PACKAGE)
5603f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_WITH_EXPORT_SYMS],
5604f4f33ea0SBaptiste Daroussin[
5605f4f33ea0SBaptiste DaroussinAC_MSG_CHECKING(if exported-symbols file should be used)
5606f4f33ea0SBaptiste DaroussinAC_ARG_WITH(export-syms,
5607f4f33ea0SBaptiste Daroussin	[  --with-export-syms=XXX  limit exported symbols using libtool],
5608f4f33ea0SBaptiste Daroussin	[with_export_syms=$withval],
5609f4f33ea0SBaptiste Daroussin	[with_export_syms=no])
5610f4f33ea0SBaptiste Daroussinif test "x$with_export_syms" = xyes
5611f4f33ea0SBaptiste Daroussinthen
5612f4f33ea0SBaptiste Daroussin	with_export_syms='${top_srcdir}/package/ifelse($1,,${PACKAGE},[$1]).sym'
5613f4f33ea0SBaptiste Daroussin	AC_SUBST(PACKAGE)
5614f4f33ea0SBaptiste Daroussinfi
5615f4f33ea0SBaptiste DaroussinAC_MSG_RESULT($with_export_syms)
5616f4f33ea0SBaptiste Daroussinif test "x$with_export_syms" != xno
5617f4f33ea0SBaptiste Daroussinthen
5618f4f33ea0SBaptiste Daroussin	EXPORT_SYMS="-export-symbols $with_export_syms"
5619f4f33ea0SBaptiste Daroussin	AC_SUBST(EXPORT_SYMS)
5620f4f33ea0SBaptiste Daroussinfi
5621f4f33ea0SBaptiste Daroussin])dnl
5622f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
5623f4f33ea0SBaptiste Daroussindnl CF_WITH_INSTALL_PREFIX version: 4 updated: 2010/10/23 15:52:32
5624f4f33ea0SBaptiste Daroussindnl ----------------------
5625f4f33ea0SBaptiste Daroussindnl Configure-script option to give a default value for the poorly-chosen name
5626f4f33ea0SBaptiste Daroussindnl $(DESTDIR).
5627f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_WITH_INSTALL_PREFIX],
5628f4f33ea0SBaptiste Daroussin[
5629f4f33ea0SBaptiste DaroussinAC_MSG_CHECKING(for install-prefix)
5630f4f33ea0SBaptiste DaroussinAC_ARG_WITH(install-prefix,
5631f4f33ea0SBaptiste Daroussin	[  --with-install-prefix=XXX sets DESTDIR, useful for packaging],
5632f4f33ea0SBaptiste Daroussin	[cf_opt_with_install_prefix=$withval],
5633f4f33ea0SBaptiste Daroussin	[cf_opt_with_install_prefix=${DESTDIR:-no}])
5634f4f33ea0SBaptiste DaroussinAC_MSG_RESULT($cf_opt_with_install_prefix)
5635f4f33ea0SBaptiste Daroussinif test "$cf_opt_with_install_prefix" != no ; then
5636f4f33ea0SBaptiste Daroussin	CF_PATH_SYNTAX(cf_opt_with_install_prefix)
5637f4f33ea0SBaptiste Daroussin	DESTDIR=$cf_opt_with_install_prefix
5638f4f33ea0SBaptiste Daroussinfi
5639f4f33ea0SBaptiste DaroussinAC_SUBST(DESTDIR)
5640f4f33ea0SBaptiste Daroussin])dnl
5641f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
5642*a96ef450SBaptiste Daroussindnl CF_WITH_LIBTOOL version: 36 updated: 2021/01/01 13:31:04
56434c8945a0SNathan Whitehorndnl ---------------
56444c8945a0SNathan Whitehorndnl Provide a configure option to incorporate libtool.  Define several useful
56454c8945a0SNathan Whitehorndnl symbols for the makefile rules.
56464c8945a0SNathan Whitehorndnl
56474c8945a0SNathan Whitehorndnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
56484c8945a0SNathan Whitehorndnl macros from libtool.m4 which is in the aclocal directory of automake.
56494c8945a0SNathan Whitehorndnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
56504c8945a0SNathan Whitehorndnl But that still does not work properly since the macro is expanded outside
56514c8945a0SNathan Whitehorndnl the CF_WITH_LIBTOOL macro:
56524c8945a0SNathan Whitehorndnl
56534c8945a0SNathan Whitehorndnl	#!/bin/sh
56544c8945a0SNathan Whitehorndnl	ACLOCAL=`aclocal --print-ac-dir`
56554c8945a0SNathan Whitehorndnl	if test -z "$ACLOCAL" ; then
56564c8945a0SNathan Whitehorndnl		echo cannot find aclocal directory
56574c8945a0SNathan Whitehorndnl		exit 1
56584c8945a0SNathan Whitehorndnl	elif test ! -f $ACLOCAL/libtool.m4 ; then
56594c8945a0SNathan Whitehorndnl		echo cannot find libtool.m4 file
56604c8945a0SNathan Whitehorndnl		exit 1
56614c8945a0SNathan Whitehorndnl	fi
56624c8945a0SNathan Whitehorndnl
56634c8945a0SNathan Whitehorndnl	LOCAL=aclocal.m4
56644c8945a0SNathan Whitehorndnl	ORIG=aclocal.m4.orig
56654c8945a0SNathan Whitehorndnl
5666f4f33ea0SBaptiste Daroussindnl	trap "mv $ORIG $LOCAL" 0 1 2 3 15
56674c8945a0SNathan Whitehorndnl	rm -f $ORIG
56684c8945a0SNathan Whitehorndnl	mv $LOCAL $ORIG
56694c8945a0SNathan Whitehorndnl
56704c8945a0SNathan Whitehorndnl	# sed the LIBTOOL= assignment to omit the current directory?
56717a1c0d96SNathan Whitehorndnl	sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL:-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
56724c8945a0SNathan Whitehorndnl	cat $ORIG >>$LOCAL
56734c8945a0SNathan Whitehorndnl
56744c8945a0SNathan Whitehorndnl	autoconf-257 $*
56754c8945a0SNathan Whitehorndnl
56764c8945a0SNathan WhitehornAC_DEFUN([CF_WITH_LIBTOOL],
56774c8945a0SNathan Whitehorn[
56787a1c0d96SNathan WhitehornAC_REQUIRE([CF_DISABLE_LIBTOOL_VERSION])
56794c8945a0SNathan Whitehornifdef([AC_PROG_LIBTOOL],,[
56804c8945a0SNathan WhitehornLIBTOOL=
56814c8945a0SNathan Whitehorn])
56824c8945a0SNathan Whitehorn# common library maintenance symbols that are convenient for libtool scripts:
56834c8945a0SNathan WhitehornLIB_CREATE='${AR} -cr'
56844c8945a0SNathan WhitehornLIB_OBJECT='${OBJECTS}'
56854c8945a0SNathan WhitehornLIB_SUFFIX=.a
56864c8945a0SNathan WhitehornLIB_PREP="$RANLIB"
56874c8945a0SNathan Whitehorn
56884c8945a0SNathan Whitehorn# symbols used to prop libtool up to enable it to determine what it should be
56894c8945a0SNathan Whitehorn# doing:
56904c8945a0SNathan WhitehornLIB_CLEAN=
56914c8945a0SNathan WhitehornLIB_COMPILE=
56924c8945a0SNathan WhitehornLIB_LINK='${CC}'
56934c8945a0SNathan WhitehornLIB_INSTALL=
56944c8945a0SNathan WhitehornLIB_UNINSTALL=
56954c8945a0SNathan Whitehorn
56964c8945a0SNathan WhitehornAC_MSG_CHECKING(if you want to build libraries with libtool)
56974c8945a0SNathan WhitehornAC_ARG_WITH(libtool,
56984c8945a0SNathan Whitehorn	[  --with-libtool          generate libraries with libtool],
56994c8945a0SNathan Whitehorn	[with_libtool=$withval],
57004c8945a0SNathan Whitehorn	[with_libtool=no])
57014c8945a0SNathan WhitehornAC_MSG_RESULT($with_libtool)
57024c8945a0SNathan Whitehornif test "$with_libtool" != "no"; then
57034c8945a0SNathan Whitehornifdef([AC_PROG_LIBTOOL],[
57044c8945a0SNathan Whitehorn	# missing_content_AC_PROG_LIBTOOL{{
57054c8945a0SNathan Whitehorn	AC_PROG_LIBTOOL
57064c8945a0SNathan Whitehorn	# missing_content_AC_PROG_LIBTOOL}}
57074c8945a0SNathan Whitehorn],[
57084c8945a0SNathan Whitehorn	if test "$with_libtool" != "yes" ; then
57094c8945a0SNathan Whitehorn		CF_PATH_SYNTAX(with_libtool)
57104c8945a0SNathan Whitehorn		LIBTOOL=$with_libtool
57114c8945a0SNathan Whitehorn	else
5712febdb468SDevin Teske		AC_CHECK_TOOLS(LIBTOOL,[libtool glibtool],none)
5713febdb468SDevin Teske		CF_LIBTOOL_VERSION
5714febdb468SDevin Teske		if test -z "$cf_cv_libtool_version" && test "$LIBTOOL" = libtool
5715febdb468SDevin Teske		then
5716febdb468SDevin Teske			CF_FORGET_TOOL(LIBTOOL)
5717febdb468SDevin Teske			AC_CHECK_TOOLS(LIBTOOL,[glibtool],none)
5718febdb468SDevin Teske			CF_LIBTOOL_VERSION
5719febdb468SDevin Teske		fi
57204c8945a0SNathan Whitehorn	fi
57214c8945a0SNathan Whitehorn	if test -z "$LIBTOOL" ; then
57224c8945a0SNathan Whitehorn		AC_MSG_ERROR(Cannot find libtool)
57234c8945a0SNathan Whitehorn	fi
57244c8945a0SNathan Whitehorn])dnl
5725f4f33ea0SBaptiste Daroussin	LIB_CREATE='${LIBTOOL} --mode=link ${CC} -rpath ${libdir} ${LIBTOOL_VERSION} `cut -f1 ${top_srcdir}/VERSION` ${LIBTOOL_OPTS} ${LT_UNDEF} $(LIBS) -o'
57264c8945a0SNathan Whitehorn	LIB_OBJECT='${OBJECTS:.o=.lo}'
57274c8945a0SNathan Whitehorn	LIB_SUFFIX=.la
57284c8945a0SNathan Whitehorn	LIB_CLEAN='${LIBTOOL} --mode=clean'
57294c8945a0SNathan Whitehorn	LIB_COMPILE='${LIBTOOL} --mode=compile'
57304c8945a0SNathan Whitehorn	LIB_LINK='${LIBTOOL} --mode=link ${CC} ${LIBTOOL_OPTS}'
57314c8945a0SNathan Whitehorn	LIB_INSTALL='${LIBTOOL} --mode=install'
57324c8945a0SNathan Whitehorn	LIB_UNINSTALL='${LIBTOOL} --mode=uninstall'
57334c8945a0SNathan Whitehorn	LIB_PREP=:
57344c8945a0SNathan Whitehorn
5735febdb468SDevin Teske	CF_CHECK_LIBTOOL_VERSION
57364c8945a0SNathan Whitehorn
57374c8945a0SNathan Whitehorn	# special hack to add -no-undefined (which libtool should do for itself)
57384c8945a0SNathan Whitehorn	LT_UNDEF=
5739f4f33ea0SBaptiste Daroussin	case "$cf_cv_system_name" in
5740f4f33ea0SBaptiste Daroussin	(cygwin*|msys*|mingw32*|os2*|uwin*|aix[[4-7]])
57414c8945a0SNathan Whitehorn		LT_UNDEF=-no-undefined
57424c8945a0SNathan Whitehorn		;;
57434c8945a0SNathan Whitehorn	esac
57444c8945a0SNathan Whitehorn	AC_SUBST([LT_UNDEF])
57454c8945a0SNathan Whitehorn
57464c8945a0SNathan Whitehorn	# special hack to add --tag option for C++ compiler
5747*a96ef450SBaptiste Daroussin	case "$cf_cv_libtool_version" in
5748f4f33ea0SBaptiste Daroussin	(1.[[5-9]]*|[[2-9]].[[0-9.a-z]]*)
57494c8945a0SNathan Whitehorn		LIBTOOL_CXX="$LIBTOOL --tag=CXX"
57504c8945a0SNathan Whitehorn		LIBTOOL="$LIBTOOL --tag=CC"
57514c8945a0SNathan Whitehorn		;;
5752f4f33ea0SBaptiste Daroussin	(*)
57534c8945a0SNathan Whitehorn		LIBTOOL_CXX="$LIBTOOL"
57544c8945a0SNathan Whitehorn		;;
57554c8945a0SNathan Whitehorn	esac
57564c8945a0SNathan Whitehornelse
57574c8945a0SNathan Whitehorn	LIBTOOL=""
57584c8945a0SNathan Whitehorn	LIBTOOL_CXX=""
57594c8945a0SNathan Whitehornfi
57604c8945a0SNathan Whitehorn
57614c8945a0SNathan Whitehorntest -z "$LIBTOOL" && ECHO_LT=
57624c8945a0SNathan Whitehorn
57634c8945a0SNathan WhitehornAC_SUBST(LIBTOOL)
57644c8945a0SNathan WhitehornAC_SUBST(LIBTOOL_CXX)
57654c8945a0SNathan WhitehornAC_SUBST(LIBTOOL_OPTS)
57664c8945a0SNathan Whitehorn
57674c8945a0SNathan WhitehornAC_SUBST(LIB_CREATE)
57684c8945a0SNathan WhitehornAC_SUBST(LIB_OBJECT)
57694c8945a0SNathan WhitehornAC_SUBST(LIB_SUFFIX)
57704c8945a0SNathan WhitehornAC_SUBST(LIB_PREP)
57714c8945a0SNathan Whitehorn
57724c8945a0SNathan WhitehornAC_SUBST(LIB_CLEAN)
57734c8945a0SNathan WhitehornAC_SUBST(LIB_COMPILE)
57744c8945a0SNathan WhitehornAC_SUBST(LIB_LINK)
57754c8945a0SNathan WhitehornAC_SUBST(LIB_INSTALL)
57764c8945a0SNathan WhitehornAC_SUBST(LIB_UNINSTALL)
57774c8945a0SNathan Whitehorn
57784c8945a0SNathan Whitehorn])dnl
57794c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
5780f4f33ea0SBaptiste Daroussindnl CF_WITH_LIBTOOL_OPTS version: 4 updated: 2015/04/17 21:13:04
57814c8945a0SNathan Whitehorndnl --------------------
57824c8945a0SNathan Whitehorndnl Allow user to pass additional libtool options into the library creation
57834c8945a0SNathan Whitehorndnl and link steps.  The main use for this is to do something like
57844c8945a0SNathan Whitehorndnl	./configure --with-libtool-opts=-static
57854c8945a0SNathan Whitehorndnl to get the same behavior as automake-flavored
57864c8945a0SNathan Whitehorndnl	./configure --enable-static
57874c8945a0SNathan WhitehornAC_DEFUN([CF_WITH_LIBTOOL_OPTS],[
57884c8945a0SNathan WhitehornAC_MSG_CHECKING(for additional libtool options)
57894c8945a0SNathan WhitehornAC_ARG_WITH(libtool-opts,
57904c8945a0SNathan Whitehorn	[  --with-libtool-opts=XXX specify additional libtool options],
57914c8945a0SNathan Whitehorn	[with_libtool_opts=$withval],
57924c8945a0SNathan Whitehorn	[with_libtool_opts=no])
57934c8945a0SNathan WhitehornAC_MSG_RESULT($with_libtool_opts)
57944c8945a0SNathan Whitehorn
57954c8945a0SNathan Whitehorncase .$with_libtool_opts in
5796f4f33ea0SBaptiste Daroussin(.yes|.no|.)
57974c8945a0SNathan Whitehorn	;;
5798f4f33ea0SBaptiste Daroussin(*)
5799f4f33ea0SBaptiste Daroussin	LIBTOOL_OPTS="$LIBTOOL_OPTS $with_libtool_opts"
58004c8945a0SNathan Whitehorn	;;
58014c8945a0SNathan Whitehornesac
58024c8945a0SNathan Whitehorn
58034c8945a0SNathan WhitehornAC_SUBST(LIBTOOL_OPTS)
58044c8945a0SNathan Whitehorn])dnl
58054c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
5806*a96ef450SBaptiste Daroussindnl CF_WITH_MAN2HTML version: 12 updated: 2021/01/03 18:30:50
5807f4f33ea0SBaptiste Daroussindnl ----------------
5808f4f33ea0SBaptiste Daroussindnl Check for man2html and groff.  Prefer man2html over groff, but use groff
5809f4f33ea0SBaptiste Daroussindnl as a fallback.  See
5810f4f33ea0SBaptiste Daroussindnl
5811f4f33ea0SBaptiste Daroussindnl		http://invisible-island.net/scripts/man2html.html
5812f4f33ea0SBaptiste Daroussindnl
5813f4f33ea0SBaptiste Daroussindnl Generate a shell script which hides the differences between the two.
5814f4f33ea0SBaptiste Daroussindnl
5815f4f33ea0SBaptiste Daroussindnl We name that "man2html.tmp".
5816f4f33ea0SBaptiste Daroussindnl
5817f4f33ea0SBaptiste Daroussindnl The shell script can be removed later, e.g., using "make distclean".
5818f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_WITH_MAN2HTML],[
5819*a96ef450SBaptiste DaroussinAC_REQUIRE([CF_PROG_GROFF])dnl
5820*a96ef450SBaptiste DaroussinAC_REQUIRE([AC_PROG_FGREP])dnl
5821f4f33ea0SBaptiste Daroussin
5822f4f33ea0SBaptiste Daroussincase "x${with_man2html}" in
5823f4f33ea0SBaptiste Daroussin(xno)
5824f4f33ea0SBaptiste Daroussin	cf_man2html=no
5825f4f33ea0SBaptiste Daroussin	;;
5826f4f33ea0SBaptiste Daroussin(x|xyes)
5827f4f33ea0SBaptiste Daroussin	AC_PATH_PROG(cf_man2html,man2html,no)
5828f4f33ea0SBaptiste Daroussin	case "x$cf_man2html" in
5829f4f33ea0SBaptiste Daroussin	(x/*)
5830f4f33ea0SBaptiste Daroussin		AC_MSG_CHECKING(for the modified Earl Hood script)
5831f4f33ea0SBaptiste Daroussin		if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null )
5832f4f33ea0SBaptiste Daroussin		then
5833f4f33ea0SBaptiste Daroussin			cf_man2html_ok=yes
5834f4f33ea0SBaptiste Daroussin		else
5835f4f33ea0SBaptiste Daroussin			cf_man2html=no
5836f4f33ea0SBaptiste Daroussin			cf_man2html_ok=no
5837f4f33ea0SBaptiste Daroussin		fi
5838f4f33ea0SBaptiste Daroussin		AC_MSG_RESULT($cf_man2html_ok)
5839f4f33ea0SBaptiste Daroussin		;;
5840f4f33ea0SBaptiste Daroussin	(*)
5841f4f33ea0SBaptiste Daroussin		cf_man2html=no
5842f4f33ea0SBaptiste Daroussin		;;
5843f4f33ea0SBaptiste Daroussin	esac
5844f4f33ea0SBaptiste Daroussinesac
5845f4f33ea0SBaptiste Daroussin
5846f4f33ea0SBaptiste DaroussinAC_MSG_CHECKING(for program to convert manpage to html)
5847f4f33ea0SBaptiste DaroussinAC_ARG_WITH(man2html,
5848f4f33ea0SBaptiste Daroussin	[  --with-man2html=XXX     use XXX rather than groff],
5849f4f33ea0SBaptiste Daroussin	[cf_man2html=$withval],
5850f4f33ea0SBaptiste Daroussin	[cf_man2html=$cf_man2html])
5851f4f33ea0SBaptiste Daroussin
5852f4f33ea0SBaptiste Daroussincf_with_groff=no
5853f4f33ea0SBaptiste Daroussin
5854f4f33ea0SBaptiste Daroussincase $cf_man2html in
5855f4f33ea0SBaptiste Daroussin(yes)
5856f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT(man2html)
5857f4f33ea0SBaptiste Daroussin	AC_PATH_PROG(cf_man2html,man2html,no)
5858f4f33ea0SBaptiste Daroussin	;;
5859f4f33ea0SBaptiste Daroussin(no|groff|*/groff*)
5860f4f33ea0SBaptiste Daroussin	cf_with_groff=yes
5861f4f33ea0SBaptiste Daroussin	cf_man2html=$GROFF_PATH
5862f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT($cf_man2html)
5863f4f33ea0SBaptiste Daroussin	;;
5864f4f33ea0SBaptiste Daroussin(*)
5865f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT($cf_man2html)
5866f4f33ea0SBaptiste Daroussin	;;
5867f4f33ea0SBaptiste Daroussinesac
5868f4f33ea0SBaptiste Daroussin
5869f4f33ea0SBaptiste DaroussinMAN2HTML_TEMP="man2html.tmp"
5870f4f33ea0SBaptiste Daroussin	cat >$MAN2HTML_TEMP <<CF_EOF
5871f4f33ea0SBaptiste Daroussin#!$SHELL
5872f4f33ea0SBaptiste Daroussin# Temporary script generated by CF_WITH_MAN2HTML
5873f4f33ea0SBaptiste Daroussin# Convert inputs to html, sending result to standard output.
5874f4f33ea0SBaptiste Daroussin#
5875f4f33ea0SBaptiste Daroussin# Parameters:
5876f4f33ea0SBaptiste Daroussin# \${1} = rootname of file to convert
5877f4f33ea0SBaptiste Daroussin# \${2} = suffix of file to convert, e.g., "1"
5878f4f33ea0SBaptiste Daroussin# \${3} = macros to use, e.g., "man"
5879f4f33ea0SBaptiste Daroussin#
5880f4f33ea0SBaptiste DaroussinROOT=\[$]1
5881f4f33ea0SBaptiste DaroussinTYPE=\[$]2
5882f4f33ea0SBaptiste DaroussinMACS=\[$]3
5883f4f33ea0SBaptiste Daroussin
5884f4f33ea0SBaptiste Daroussinunset LANG
5885f4f33ea0SBaptiste Daroussinunset LC_ALL
5886f4f33ea0SBaptiste Daroussinunset LC_CTYPE
5887f4f33ea0SBaptiste Daroussinunset LANGUAGE
5888f4f33ea0SBaptiste DaroussinGROFF_NO_SGR=stupid
5889f4f33ea0SBaptiste Daroussinexport GROFF_NO_SGR
5890f4f33ea0SBaptiste Daroussin
5891f4f33ea0SBaptiste DaroussinCF_EOF
5892f4f33ea0SBaptiste Daroussin
5893*a96ef450SBaptiste DaroussinNROFF_OPTS=
5894f4f33ea0SBaptiste Daroussinif test "x$cf_with_groff" = xyes
5895f4f33ea0SBaptiste Daroussinthen
5896f4f33ea0SBaptiste Daroussin	MAN2HTML_NOTE="$GROFF_NOTE"
5897f4f33ea0SBaptiste Daroussin	MAN2HTML_PATH="$GROFF_PATH"
5898f4f33ea0SBaptiste Daroussin	cat >>$MAN2HTML_TEMP <<CF_EOF
5899f4f33ea0SBaptiste Daroussin$SHELL -c "$TBL_PATH \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
5900f4f33ea0SBaptiste DaroussinCF_EOF
5901f4f33ea0SBaptiste Daroussinelse
5902*a96ef450SBaptiste Daroussin	# disable hyphenation if this is groff
5903*a96ef450SBaptiste Daroussin	if test "x$GROFF_PATH" != xno
5904*a96ef450SBaptiste Daroussin	then
5905*a96ef450SBaptiste Daroussin		AC_MSG_CHECKING(if nroff is really groff)
5906*a96ef450SBaptiste Daroussin		cf_check_groff="`$NROFF_PATH --version 2>/dev/null | grep groff`"
5907*a96ef450SBaptiste Daroussin		test -n "$cf_check_groff" && cf_check_groff=yes
5908*a96ef450SBaptiste Daroussin		test -n "$cf_check_groff" || cf_check_groff=no
5909*a96ef450SBaptiste Daroussin		AC_MSG_RESULT($cf_check_groff)
5910*a96ef450SBaptiste Daroussin		test "x$cf_check_groff" = xyes && NROFF_OPTS="-rHY=0"
5911*a96ef450SBaptiste Daroussin	fi
5912f4f33ea0SBaptiste Daroussin	MAN2HTML_NOTE=""
5913f4f33ea0SBaptiste Daroussin	CF_PATH_SYNTAX(cf_man2html)
5914f4f33ea0SBaptiste Daroussin	MAN2HTML_PATH="$cf_man2html"
5915f4f33ea0SBaptiste Daroussin	AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
5916f4f33ea0SBaptiste Daroussin
5917f4f33ea0SBaptiste Daroussin	# for this example, expect 3 lines of content, the remainder is head/foot
5918f4f33ea0SBaptiste Daroussin	cat >conftest.in <<CF_EOF
5919f4f33ea0SBaptiste Daroussin.TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
5920f4f33ea0SBaptiste Daroussin.SH SECTION
5921f4f33ea0SBaptiste DaroussinMARKER
5922f4f33ea0SBaptiste DaroussinCF_EOF
5923f4f33ea0SBaptiste Daroussin
5924f4f33ea0SBaptiste Daroussin	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
5925f4f33ea0SBaptiste Daroussin
5926*a96ef450SBaptiste Daroussin	cf_man2html_1st="`${FGREP-fgrep} -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`"
5927*a96ef450SBaptiste Daroussin	cf_man2html_top=`expr "$cf_man2html_1st" - 2`
5928*a96ef450SBaptiste Daroussin	cf_man2html_bot="`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`"
5929*a96ef450SBaptiste Daroussin	cf_man2html_bot=`expr "$cf_man2html_bot" - 2 - "$cf_man2html_top"`
5930f4f33ea0SBaptiste Daroussin	cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
5931f4f33ea0SBaptiste Daroussin
5932f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT($cf_man2html_top_bot)
5933f4f33ea0SBaptiste Daroussin
5934f4f33ea0SBaptiste Daroussin	AC_MSG_CHECKING(for pagesize to use)
5935f4f33ea0SBaptiste Daroussin	for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
5936f4f33ea0SBaptiste Daroussin	do
5937f4f33ea0SBaptiste Daroussin	cat >>conftest.in <<CF_EOF
5938f4f33ea0SBaptiste Daroussin.nf
5939f4f33ea0SBaptiste Daroussin0
5940f4f33ea0SBaptiste Daroussin1
5941f4f33ea0SBaptiste Daroussin2
5942f4f33ea0SBaptiste Daroussin3
5943f4f33ea0SBaptiste Daroussin4
5944f4f33ea0SBaptiste Daroussin5
5945f4f33ea0SBaptiste Daroussin6
5946f4f33ea0SBaptiste Daroussin7
5947f4f33ea0SBaptiste Daroussin8
5948f4f33ea0SBaptiste Daroussin9
5949f4f33ea0SBaptiste DaroussinCF_EOF
5950f4f33ea0SBaptiste Daroussin	done
5951f4f33ea0SBaptiste Daroussin
5952f4f33ea0SBaptiste Daroussin	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
5953*a96ef450SBaptiste Daroussin	cf_man2html_page="`${FGREP-fgrep} -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`"
5954f4f33ea0SBaptiste Daroussin	test -z "$cf_man2html_page" && cf_man2html_page=99999
5955f4f33ea0SBaptiste Daroussin	test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
5956f4f33ea0SBaptiste Daroussin
5957f4f33ea0SBaptiste Daroussin	rm -rf conftest*
5958f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT($cf_man2html_page)
5959f4f33ea0SBaptiste Daroussin
5960f4f33ea0SBaptiste Daroussin	cat >>$MAN2HTML_TEMP <<CF_EOF
5961f4f33ea0SBaptiste Daroussin: \${MAN2HTML_PATH=$MAN2HTML_PATH}
5962*a96ef450SBaptiste DaroussinMAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title=\"\$ROOT(\$TYPE)\" -compress -pgsize $cf_man2html_page"
5963f4f33ea0SBaptiste Daroussincase \${TYPE} in
5964f4f33ea0SBaptiste Daroussin(ms)
5965*a96ef450SBaptiste Daroussin	$TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH $NROFF_OPTS -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
5966f4f33ea0SBaptiste Daroussin	;;
5967f4f33ea0SBaptiste Daroussin(*)
5968*a96ef450SBaptiste Daroussin	$TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH $NROFF_OPTS -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
5969f4f33ea0SBaptiste Daroussin	;;
5970f4f33ea0SBaptiste Daroussinesac
5971f4f33ea0SBaptiste DaroussinCF_EOF
5972f4f33ea0SBaptiste Daroussinfi
5973f4f33ea0SBaptiste Daroussin
5974f4f33ea0SBaptiste Daroussinchmod 700 $MAN2HTML_TEMP
5975f4f33ea0SBaptiste Daroussin
5976f4f33ea0SBaptiste DaroussinAC_SUBST(MAN2HTML_NOTE)
5977f4f33ea0SBaptiste DaroussinAC_SUBST(MAN2HTML_PATH)
5978f4f33ea0SBaptiste DaroussinAC_SUBST(MAN2HTML_TEMP)
5979f4f33ea0SBaptiste Daroussin])dnl
5980f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
5981f4f33ea0SBaptiste Daroussindnl CF_WITH_NCURSES_ETC version: 5 updated: 2016/02/20 19:23:20
5982f4f33ea0SBaptiste Daroussindnl -------------------
5983f4f33ea0SBaptiste Daroussindnl Use this macro for programs which use any variant of "curses", e.g.,
5984f4f33ea0SBaptiste Daroussindnl "ncurses", and "PDCurses".  Programs that can use curses and some unrelated
5985f4f33ea0SBaptiste Daroussindnl library (such as slang) should use a "--with-screen=XXX" option.
5986f4f33ea0SBaptiste Daroussindnl
5987f4f33ea0SBaptiste Daroussindnl This does not use AC_DEFUN, because that would tell autoconf to run each
5988f4f33ea0SBaptiste Daroussindnl of the macros inside this one - before this macro.
5989f4f33ea0SBaptiste Daroussindefine([CF_WITH_NCURSES_ETC],[
5990f4f33ea0SBaptiste DaroussinCF_WITH_CURSES_DIR
5991f4f33ea0SBaptiste Daroussin
5992f4f33ea0SBaptiste Daroussincf_cv_screen=curses
5993f4f33ea0SBaptiste Daroussin
5994f4f33ea0SBaptiste DaroussinAC_MSG_CHECKING(for specified curses library type)
5995f4f33ea0SBaptiste DaroussinAC_ARG_WITH(screen,
5996f4f33ea0SBaptiste Daroussin	[  --with-screen=XXX       use specified curses-libraries],
5997f4f33ea0SBaptiste Daroussin	[cf_cv_screen=$withval],[
5998f4f33ea0SBaptiste Daroussin
5999f4f33ea0SBaptiste DaroussinAC_ARG_WITH(ncursesw,
6000f4f33ea0SBaptiste Daroussin	[  --with-ncursesw         use wide ncurses-libraries],
6001f4f33ea0SBaptiste Daroussin	[cf_cv_screen=ncursesw],[
6002f4f33ea0SBaptiste Daroussin
6003f4f33ea0SBaptiste DaroussinAC_ARG_WITH(ncurses,
6004f4f33ea0SBaptiste Daroussin	[  --with-ncurses          use ncurses-libraries],
6005f4f33ea0SBaptiste Daroussin	[cf_cv_screen=ncurses],[
6006f4f33ea0SBaptiste Daroussin
6007f4f33ea0SBaptiste DaroussinAC_ARG_WITH(pdcurses,
6008f4f33ea0SBaptiste Daroussin	[  --with-pdcurses         compile/link with pdcurses X11 library],
6009f4f33ea0SBaptiste Daroussin	[cf_cv_screen=pdcurses],[
6010f4f33ea0SBaptiste Daroussin
6011f4f33ea0SBaptiste DaroussinAC_ARG_WITH(curses-colr,
6012f4f33ea0SBaptiste Daroussin	[  --with-curses-colr      compile/link with HPUX 10.x color-curses],
6013f4f33ea0SBaptiste Daroussin	[cf_cv_screen=curses_colr],[
6014f4f33ea0SBaptiste Daroussin
6015f4f33ea0SBaptiste DaroussinAC_ARG_WITH(curses-5lib,
6016f4f33ea0SBaptiste Daroussin	[  --with-curses-5lib      compile/link with SunOS 5lib curses],
6017f4f33ea0SBaptiste Daroussin	[cf_cv_screen=curses_5lib])])])])])])
6018f4f33ea0SBaptiste Daroussin
6019f4f33ea0SBaptiste DaroussinAC_MSG_RESULT($cf_cv_screen)
6020f4f33ea0SBaptiste Daroussin
6021f4f33ea0SBaptiste Daroussincase $cf_cv_screen in
6022f4f33ea0SBaptiste Daroussin(curses|curses_*)
6023f4f33ea0SBaptiste Daroussin	CF_CURSES_CONFIG
6024f4f33ea0SBaptiste Daroussin	;;
6025f4f33ea0SBaptiste Daroussin(ncursesw*)
6026f4f33ea0SBaptiste Daroussin	CF_UTF8_LIB
6027f4f33ea0SBaptiste Daroussin	CF_NCURSES_CONFIG($cf_cv_screen)
6028f4f33ea0SBaptiste Daroussin	;;
6029f4f33ea0SBaptiste Daroussin(ncurses*)
6030f4f33ea0SBaptiste Daroussin	CF_NCURSES_CONFIG($cf_cv_screen)
6031f4f33ea0SBaptiste Daroussin	;;
6032f4f33ea0SBaptiste Daroussin(pdcurses)
6033f4f33ea0SBaptiste Daroussin	CF_PDCURSES_X11
6034f4f33ea0SBaptiste Daroussin	;;
6035f4f33ea0SBaptiste Daroussin(*)
6036f4f33ea0SBaptiste Daroussin	AC_MSG_ERROR(unexpected screen-value: $cf_cv_screen)
6037f4f33ea0SBaptiste Daroussin	;;
6038f4f33ea0SBaptiste Daroussinesac
6039f4f33ea0SBaptiste Daroussin
6040f4f33ea0SBaptiste DaroussinCF_NCURSES_PTHREADS($cf_cv_screen)
6041f4f33ea0SBaptiste Daroussin
6042f4f33ea0SBaptiste Daroussin])dnl
6043f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
6044*a96ef450SBaptiste Daroussindnl CF_WITH_NO_LEAKS version: 4 updated: 2021/01/05 20:08:11
60454c8945a0SNathan Whitehorndnl ----------------
60464c8945a0SNathan WhitehornAC_DEFUN([CF_WITH_NO_LEAKS],[
60474c8945a0SNathan Whitehorn
60484c8945a0SNathan WhitehornAC_REQUIRE([CF_WITH_DMALLOC])
60494c8945a0SNathan WhitehornAC_REQUIRE([CF_WITH_DBMALLOC])
60504c8945a0SNathan WhitehornAC_REQUIRE([CF_WITH_PURIFY])
60514c8945a0SNathan WhitehornAC_REQUIRE([CF_WITH_VALGRIND])
60524c8945a0SNathan Whitehorn
60534c8945a0SNathan WhitehornAC_MSG_CHECKING(if you want to perform memory-leak testing)
60544c8945a0SNathan WhitehornAC_ARG_WITH(no-leaks,
60554c8945a0SNathan Whitehorn	[  --with-no-leaks         test: free permanent memory, analyze leaks],
60562a3e3873SBaptiste Daroussin	[AC_DEFINE(NO_LEAKS,1,[Define to 1 to enable leak-checking])
60574c8945a0SNathan Whitehorn	 cf_doalloc=".${with_dmalloc}${with_dbmalloc}${with_purify}${with_valgrind}"
6058f4f33ea0SBaptiste Daroussin	 case ${cf_doalloc} in
6059f4f33ea0SBaptiste Daroussin	 (*yes*) ;;
6060f4f33ea0SBaptiste Daroussin	 (*) AC_DEFINE(DOALLOC,10000,[Define to size of malloc-array]) ;;
60614c8945a0SNathan Whitehorn	 esac
6062*a96ef450SBaptiste Daroussin	 enable_leaks=no],
6063*a96ef450SBaptiste Daroussin	[enable_leaks=yes])
6064*a96ef450SBaptiste Daroussindnl TODO - drop with_no_leaks
6065*a96ef450SBaptiste Daroussinif test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
60664c8945a0SNathan WhitehornAC_MSG_RESULT($with_no_leaks)
60674c8945a0SNathan Whitehorn])dnl
60684c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
60694c8945a0SNathan Whitehorndnl CF_WITH_PURIFY version: 2 updated: 2006/12/14 18:43:43
60704c8945a0SNathan Whitehorndnl --------------
60714c8945a0SNathan WhitehornAC_DEFUN([CF_WITH_PURIFY],[
60724c8945a0SNathan WhitehornCF_NO_LEAKS_OPTION(purify,
60734c8945a0SNathan Whitehorn	[  --with-purify           test: use Purify],
60744c8945a0SNathan Whitehorn	[USE_PURIFY],
60754c8945a0SNathan Whitehorn	[LINK_PREFIX="$LINK_PREFIX purify"])
60764c8945a0SNathan WhitehornAC_SUBST(LINK_PREFIX)
60774c8945a0SNathan Whitehorn])dnl
60784c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
6079febdb468SDevin Teskednl CF_WITH_REL_VERSION version: 1 updated: 2003/09/20 18:12:49
6080febdb468SDevin Teskednl -------------------
6081febdb468SDevin Teskednl Allow library's release-version to be overridden.  Generally this happens when a
6082febdb468SDevin Teskednl packager has incremented the release-version past that used in the original package,
6083febdb468SDevin Teskednl and wishes to keep doing this.
6084febdb468SDevin Teskednl
6085febdb468SDevin Teskednl $1 is the package name, if any, to derive corresponding {package}_MAJOR
6086febdb468SDevin Teskednl and {package}_MINOR symbols
6087febdb468SDevin Teskednl symbol.
6088febdb468SDevin TeskeAC_DEFUN([CF_WITH_REL_VERSION],[
6089febdb468SDevin Tesketest -z "$cf_cv_rel_version" && cf_cv_rel_version=0.0
6090febdb468SDevin TeskeAC_ARG_WITH(rel-version,
6091febdb468SDevin Teske[  --with-rel-version=XXX  override derived release version],
6092febdb468SDevin Teske[AC_MSG_WARN(overriding release version $cf_cv_rel_version to $withval)
6093febdb468SDevin Teske cf_cv_rel_version=$withval])
6094febdb468SDevin Teskeifelse($1,,[
6095febdb468SDevin Teske CF_NUMBER_SYNTAX($cf_cv_rel_version,Release version)
6096febdb468SDevin Teske],[
6097febdb468SDevin Teske $1_MAJOR=`echo "$cf_cv_rel_version" | sed -e 's/\..*//'`
6098febdb468SDevin Teske $1_MINOR=`echo "$cf_cv_rel_version" | sed -e 's/^[[^.]]*//' -e 's/^\.//' -e 's/\..*//'`
6099febdb468SDevin Teske CF_NUMBER_SYNTAX([$]$1_MAJOR,Release major-version)
6100febdb468SDevin Teske CF_NUMBER_SYNTAX([$]$1_MINOR,Release minor-version)
6101febdb468SDevin Teske])
6102febdb468SDevin Teske])dnl
6103febdb468SDevin Teskednl ---------------------------------------------------------------------------
6104*a96ef450SBaptiste Daroussindnl CF_WITH_SCREEN_PDCURSES version: 1 updated: 2020/08/28 16:56:27
6105*a96ef450SBaptiste Daroussindnl -----------------------
6106*a96ef450SBaptiste Daroussindnl Call this macro before CF_ENABLE_WARNINGS for configure scripts which use
6107*a96ef450SBaptiste Daroussindnl the "--with-screen=pdcurses" selection.  Doing that allows the configure
6108*a96ef450SBaptiste Daroussindnl script to search for the X11/Xt header files to declare (or not) the
6109*a96ef450SBaptiste Daroussindnl symbol needed to enable "const" in those header files.  If that configure
6110*a96ef450SBaptiste Daroussindnl option is not used, then those checks are unnecessary.
6111*a96ef450SBaptiste DaroussinAC_DEFUN([CF_WITH_SCREEN_PDCURSES],[
6112*a96ef450SBaptiste DaroussinAC_PROVIDE([AC_PATH_XTRA])
6113*a96ef450SBaptiste DaroussinAC_PROVIDE([AC_PATH_X])
6114*a96ef450SBaptiste Daroussinif test -n "$with_screen" && test "x$with_screen" = "xpdcurses"
6115*a96ef450SBaptiste Daroussinthen
6116*a96ef450SBaptiste Daroussin	AC_PATH_X
6117*a96ef450SBaptiste Daroussin	AC_PATH_XTRA
6118*a96ef450SBaptiste Daroussinfi
6119*a96ef450SBaptiste Daroussin])dnl
6120*a96ef450SBaptiste Daroussindnl ---------------------------------------------------------------------------
6121f4f33ea0SBaptiste Daroussindnl CF_WITH_SHARED_OR_LIBTOOL version: 7 updated: 2014/11/02 16:11:49
6122febdb468SDevin Teskednl -------------------------
6123febdb468SDevin Teskednl Provide shared libraries using either autoconf macros (--with-shared) or
6124febdb468SDevin Teskednl using the external libtool script (--with-libtool).
6125febdb468SDevin Teskednl
6126febdb468SDevin Teskednl $1 = program name (all caps preferred)
6127febdb468SDevin Teskednl $1 = release version
6128febdb468SDevin Teskednl $2 = ABI version
6129febdb468SDevin Teskedefine([CF_WITH_SHARED_OR_LIBTOOL],[
6130febdb468SDevin Teske
6131febdb468SDevin TeskeREL_VERSION=$2
6132febdb468SDevin TeskeABI_VERSION=$3
6133febdb468SDevin Teskecf_cv_rel_version=$REL_VERSION
6134febdb468SDevin TeskeAC_SUBST(ABI_VERSION)
6135febdb468SDevin TeskeAC_SUBST(REL_VERSION)
6136febdb468SDevin Teske
6137febdb468SDevin TeskeCF_WITH_REL_VERSION($1)
6138febdb468SDevin TeskeCF_WITH_ABI_VERSION
6139febdb468SDevin Teske
6140febdb468SDevin TeskeLIB_MODEL=static
6141febdb468SDevin TeskeDFT_LWR_MODEL=$LIB_MODEL
6142febdb468SDevin TeskeLIBTOOL_MAKE="#"
6143febdb468SDevin Teske
6144febdb468SDevin Teske# use to comment-out makefile lines
6145febdb468SDevin TeskeMAKE_NORMAL=
6146febdb468SDevin TeskeMAKE_STATIC=
6147febdb468SDevin TeskeMAKE_SHARED="#"
6148f4f33ea0SBaptiste DaroussinMAKE_DLLS="#"
6149f4f33ea0SBaptiste Daroussin
6150f4f33ea0SBaptiste Daroussinshlibdir=$libdir
6151f4f33ea0SBaptiste DaroussinAC_SUBST(shlibdir)
6152febdb468SDevin Teske
6153febdb468SDevin TeskeCF_WITH_LIBTOOL
6154febdb468SDevin Teske
6155febdb468SDevin TeskeLIB_CREATE="$LIB_CREATE \[$]@"
6156febdb468SDevin Teske
6157febdb468SDevin Teskeif test "$with_libtool" = "yes" ; then
6158febdb468SDevin Teske	OBJEXT="lo"
6159febdb468SDevin Teske	LIB_MODEL=libtool
6160febdb468SDevin Teske	DFT_LWR_MODEL=$LIB_MODEL
6161febdb468SDevin Teske	LIBTOOL_MAKE=
6162febdb468SDevin Teske	CF_WITH_LIBTOOL_OPTS
6163f4f33ea0SBaptiste Daroussin	CF_WITH_EXPORT_SYMS
6164febdb468SDevin Teske	MAKE_NORMAL="#"
6165febdb468SDevin Teske	MAKE_STATIC="#"
6166febdb468SDevin Teske	MAKE_SHARED=
6167febdb468SDevin Teskeelse
6168febdb468SDevin Teske	AC_MSG_CHECKING(if you want to build shared libraries)
6169febdb468SDevin Teske	AC_ARG_WITH(shared,
6170febdb468SDevin Teske		[  --with-shared           generate shared-libraries],
6171febdb468SDevin Teske		[with_shared=$withval],
6172febdb468SDevin Teske		[with_shared=no])
6173febdb468SDevin Teske	AC_MSG_RESULT($with_shared)
6174febdb468SDevin Teske	if test "$with_shared" = "yes" ; then
6175febdb468SDevin Teske		LIB_MODEL=shared
6176febdb468SDevin Teske		DFT_LWR_MODEL=$LIB_MODEL
6177febdb468SDevin Teske		CF_SHARED_OPTS
6178f4f33ea0SBaptiste Daroussin		CF_WITH_VERSIONED_SYMS
6179febdb468SDevin Teske		LIB_PREP=:
6180febdb468SDevin Teske		LIB_CREATE="[$]MK_SHARED_LIB"
6181febdb468SDevin Teske		CFLAGS="$CFLAGS $CC_SHARED_OPTS"
6182febdb468SDevin Teske		MAKE_NORMAL="#"
6183febdb468SDevin Teske		MAKE_STATIC="#"
6184febdb468SDevin Teske		MAKE_SHARED=
6185febdb468SDevin Teske	fi
6186febdb468SDevin Teskefi
6187febdb468SDevin Teske
6188febdb468SDevin TeskeLIB_SUFFIX=
6189febdb468SDevin TeskeCF_LIB_SUFFIX($LIB_MODEL, DFT_LIB_SUFFIX, DFT_DEP_SUFFIX)
6190febdb468SDevin TeskeLIB_SUFFIX=$DFT_LIB_SUFFIX
6191febdb468SDevin Teske
6192febdb468SDevin TeskeAC_SUBST(DFT_LWR_MODEL)
6193febdb468SDevin TeskeAC_SUBST(DFT_LIB_SUFFIX)
6194febdb468SDevin TeskeAC_SUBST(DFT_DEP_SUFFIX)
6195febdb468SDevin TeskeAC_SUBST(LIB_MODEL)
6196febdb468SDevin Teske
6197febdb468SDevin TeskeAC_SUBST(LIBTOOL_MAKE)
6198febdb468SDevin Teske
6199f4f33ea0SBaptiste DaroussinAC_SUBST(MAKE_DLLS)
6200febdb468SDevin TeskeAC_SUBST(MAKE_NORMAL)
6201febdb468SDevin TeskeAC_SUBST(MAKE_SHARED)
6202febdb468SDevin TeskeAC_SUBST(MAKE_STATIC)
6203febdb468SDevin Teske])dnl
6204febdb468SDevin Teskednl ---------------------------------------------------------------------------
62054c8945a0SNathan Whitehorndnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
62064c8945a0SNathan Whitehorndnl ----------------
62074c8945a0SNathan WhitehornAC_DEFUN([CF_WITH_VALGRIND],[
62084c8945a0SNathan WhitehornCF_NO_LEAKS_OPTION(valgrind,
62094c8945a0SNathan Whitehorn	[  --with-valgrind         test: use valgrind],
62104c8945a0SNathan Whitehorn	[USE_VALGRIND])
62114c8945a0SNathan Whitehorn])dnl
62124c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
6213*a96ef450SBaptiste Daroussindnl CF_WITH_VERSIONED_SYMS version: 10 updated: 2021/01/04 18:48:01
6214f4f33ea0SBaptiste Daroussindnl ----------------------
6215f4f33ea0SBaptiste Daroussindnl Use this when building shared library with ELF, to markup symbols with the
6216f4f33ea0SBaptiste Daroussindnl version identifier from the given input file.  Generally that identifier is
6217f4f33ea0SBaptiste Daroussindnl the same as the SONAME at which the symbol was first introduced.
6218f4f33ea0SBaptiste Daroussindnl
6219f4f33ea0SBaptiste Daroussindnl $1 = basename of the ".map" file (default $PACKAGE)
6220f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_WITH_VERSIONED_SYMS],
6221*a96ef450SBaptiste Daroussin[AC_REQUIRE([AC_PROG_FGREP])dnl
6222*a96ef450SBaptiste DaroussinAC_REQUIRE([AC_PROG_EGREP])dnl
6223*a96ef450SBaptiste Daroussin
6224f4f33ea0SBaptiste DaroussinAC_MSG_CHECKING(if versioned-symbols file should be used)
6225f4f33ea0SBaptiste DaroussinAC_ARG_WITH(versioned-syms,
6226f4f33ea0SBaptiste Daroussin	[  --with-versioned-syms=X markup versioned symbols using ld],
6227f4f33ea0SBaptiste Daroussin	[with_versioned_syms=$withval],
6228f4f33ea0SBaptiste Daroussin	[with_versioned_syms=no])
6229*a96ef450SBaptiste Daroussincase "x$with_versioned_syms" in
6230*a96ef450SBaptiste Daroussin(xyes)
6231f4f33ea0SBaptiste Daroussin	with_versioned_syms='${top_srcdir}/package/ifelse($1,,${PACKAGE},[$1]).map'
6232f4f33ea0SBaptiste Daroussin	AC_SUBST(PACKAGE)
6233*a96ef450SBaptiste Daroussin	;;
6234*a96ef450SBaptiste Daroussin(xno)
6235*a96ef450SBaptiste Daroussin	;;
6236*a96ef450SBaptiste Daroussin(x/*)
6237*a96ef450SBaptiste Daroussin	test -f "$with_versioned_syms" || AC_MSG_ERROR(expected a filename: $with_versioned_syms)
6238*a96ef450SBaptiste Daroussin	;;
6239*a96ef450SBaptiste Daroussin(*)
6240*a96ef450SBaptiste Daroussin	test -f "$with_versioned_syms" || AC_MSG_ERROR(expected a filename: $with_versioned_syms)
6241*a96ef450SBaptiste Daroussin	with_versioned_syms=`pwd`/"$with_versioned_syms"
6242*a96ef450SBaptiste Daroussin	;;
6243*a96ef450SBaptiste Daroussinesac
6244f4f33ea0SBaptiste DaroussinAC_MSG_RESULT($with_versioned_syms)
6245f4f33ea0SBaptiste Daroussin
6246f4f33ea0SBaptiste DaroussinRESULTING_SYMS=
6247f4f33ea0SBaptiste DaroussinVERSIONED_SYMS=
6248f4f33ea0SBaptiste DaroussinWILDCARD_SYMS=
6249f4f33ea0SBaptiste Daroussin
6250f4f33ea0SBaptiste Daroussinif test "x$with_versioned_syms" != xno
6251f4f33ea0SBaptiste Daroussinthen
6252f4f33ea0SBaptiste Daroussin	RESULTING_SYMS=$with_versioned_syms
6253f4f33ea0SBaptiste Daroussin	case "x$MK_SHARED_LIB" in
6254f4f33ea0SBaptiste Daroussin	(*-Wl,*)
6255f4f33ea0SBaptiste Daroussin		VERSIONED_SYMS="-Wl,--version-script,\${RESULTING_SYMS}"
6256f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB=`echo "$MK_SHARED_LIB" | sed -e "s%-Wl,%\\[$]{VERSIONED_SYMS} -Wl,%"`
6257f4f33ea0SBaptiste Daroussin		CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
6258f4f33ea0SBaptiste Daroussin		;;
6259f4f33ea0SBaptiste Daroussin	(*-dy\ *)
6260f4f33ea0SBaptiste Daroussin		VERSIONED_SYMS="-Wl,-M,\${RESULTING_SYMS}"
6261f4f33ea0SBaptiste Daroussin		MK_SHARED_LIB=`echo "$MK_SHARED_LIB" | sed -e "s%-dy%\\[$]{VERSIONED_SYMS} -dy%"`
6262f4f33ea0SBaptiste Daroussin		CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
6263f4f33ea0SBaptiste Daroussin		;;
6264f4f33ea0SBaptiste Daroussin	(*)
6265f4f33ea0SBaptiste Daroussin		AC_MSG_WARN(this system does not support versioned-symbols)
6266f4f33ea0SBaptiste Daroussin		;;
6267f4f33ea0SBaptiste Daroussin	esac
6268f4f33ea0SBaptiste Daroussin
6269f4f33ea0SBaptiste Daroussin	# Linux ld can selectively override scope, e.g., of symbols beginning with
6270f4f33ea0SBaptiste Daroussin	# "_" by first declaring some as global, and then using a wildcard to
6271f4f33ea0SBaptiste Daroussin	# declare the others as local.  Some other loaders cannot do this.  Check
6272f4f33ea0SBaptiste Daroussin	# by constructing a (very) simple shared library and inspecting its
6273f4f33ea0SBaptiste Daroussin	# symbols.
6274f4f33ea0SBaptiste Daroussin	if test "x$VERSIONED_SYMS" != "x"
6275f4f33ea0SBaptiste Daroussin	then
6276f4f33ea0SBaptiste Daroussin		AC_MSG_CHECKING(if wildcards can be used to selectively omit symbols)
6277f4f33ea0SBaptiste Daroussin		WILDCARD_SYMS=no
6278f4f33ea0SBaptiste Daroussin
6279f4f33ea0SBaptiste Daroussin		# make sources
6280f4f33ea0SBaptiste Daroussin		rm -f conftest.*
6281f4f33ea0SBaptiste Daroussin
6282f4f33ea0SBaptiste Daroussin		cat >conftest.ver <<EOF
6283f4f33ea0SBaptiste Daroussinmodule_1.0 {
6284f4f33ea0SBaptiste Daroussinglobal:
6285f4f33ea0SBaptiste Daroussin	globalf1;
6286f4f33ea0SBaptiste Daroussinlocal:
6287f4f33ea0SBaptiste Daroussin	localf1;
6288f4f33ea0SBaptiste Daroussin};
6289f4f33ea0SBaptiste Daroussinmodule_2.0 {
6290f4f33ea0SBaptiste Daroussinglobal:
6291f4f33ea0SBaptiste Daroussin	globalf2;
6292f4f33ea0SBaptiste Daroussinlocal:
6293f4f33ea0SBaptiste Daroussin	localf2;
6294f4f33ea0SBaptiste Daroussin	_*;
6295f4f33ea0SBaptiste Daroussin} module_1.0;
6296f4f33ea0SBaptiste Daroussinsubmodule_1.0 {
6297f4f33ea0SBaptiste Daroussinglobal:
6298f4f33ea0SBaptiste Daroussin	subglobalf1;
6299f4f33ea0SBaptiste Daroussin	_ismissing;
6300f4f33ea0SBaptiste Daroussinlocal:
6301f4f33ea0SBaptiste Daroussin	sublocalf1;
6302f4f33ea0SBaptiste Daroussin};
6303f4f33ea0SBaptiste Daroussinsubmodule_2.0 {
6304f4f33ea0SBaptiste Daroussinglobal:
6305f4f33ea0SBaptiste Daroussin	subglobalf2;
6306f4f33ea0SBaptiste Daroussinlocal:
6307f4f33ea0SBaptiste Daroussin	sublocalf2;
6308f4f33ea0SBaptiste Daroussin	_*;
6309f4f33ea0SBaptiste Daroussin} submodule_1.0;
6310f4f33ea0SBaptiste DaroussinEOF
6311f4f33ea0SBaptiste Daroussin		cat >conftest.$ac_ext <<EOF
6312f4f33ea0SBaptiste Daroussin#line __oline__ "configure"
6313f4f33ea0SBaptiste Daroussinint	_ismissing(void) { return 1; }
6314f4f33ea0SBaptiste Daroussinint	_localf1(void) { return 1; }
6315f4f33ea0SBaptiste Daroussinint	_localf2(void) { return 2; }
6316f4f33ea0SBaptiste Daroussinint	globalf1(void) { return 1; }
6317f4f33ea0SBaptiste Daroussinint	globalf2(void) { return 2; }
6318f4f33ea0SBaptiste Daroussinint	_sublocalf1(void) { return 1; }
6319f4f33ea0SBaptiste Daroussinint	_sublocalf2(void) { return 2; }
6320f4f33ea0SBaptiste Daroussinint	subglobalf1(void) { return 1; }
6321f4f33ea0SBaptiste Daroussinint	subglobalf2(void) { return 2; }
6322f4f33ea0SBaptiste DaroussinEOF
6323f4f33ea0SBaptiste Daroussin		cat >conftest.mk <<EOF
6324f4f33ea0SBaptiste DaroussinCC=${CC}
6325f4f33ea0SBaptiste DaroussinCFLAGS=${CFLAGS}
6326f4f33ea0SBaptiste DaroussinCPPFLAGS=${CPPFLAGS}
6327f4f33ea0SBaptiste DaroussinLDFLAGS=${LDFLAGS}
6328f4f33ea0SBaptiste DaroussinLIBS=${LIBS}
6329f4f33ea0SBaptiste DaroussinVERSIONED_SYMS=${VERSIONED_SYMS}
6330f4f33ea0SBaptiste DaroussinRESULTING_SYMS=conftest.ver
6331f4f33ea0SBaptiste DaroussinMK_SHARED_LIB=${MK_SHARED_LIB}
6332f4f33ea0SBaptiste Daroussinconftest.so: conftest.$ac_cv_objext
6333f4f33ea0SBaptiste Daroussin		\$(MK_SHARED_LIB) conftest.$ac_cv_objext
6334f4f33ea0SBaptiste DaroussinEOF
6335f4f33ea0SBaptiste Daroussin
6336f4f33ea0SBaptiste Daroussin		# compile source, make library
6337f4f33ea0SBaptiste Daroussin		if make -f conftest.mk 2>&AC_FD_CC >/dev/null
6338f4f33ea0SBaptiste Daroussin		then
6339f4f33ea0SBaptiste Daroussin			# test for missing symbol in either Data or Text section
6340*a96ef450SBaptiste Daroussin			cf_missing="`nm -P conftest.so 2>&AC_FD_CC |${FGREP-fgrep} _ismissing | ${EGREP-egrep} '[[ 	]][[DT]][[ 	]]'`"
6341f4f33ea0SBaptiste Daroussin			test -n "$cf_missing" && WILDCARD_SYMS=yes
6342f4f33ea0SBaptiste Daroussin		fi
6343f4f33ea0SBaptiste Daroussin		AC_MSG_RESULT($WILDCARD_SYMS)
6344f4f33ea0SBaptiste Daroussin		rm -f conftest.*
6345f4f33ea0SBaptiste Daroussin	fi
6346f4f33ea0SBaptiste Daroussinfi
6347f4f33ea0SBaptiste DaroussinAC_SUBST(RESULTING_SYMS)
6348f4f33ea0SBaptiste DaroussinAC_SUBST(VERSIONED_SYMS)
6349f4f33ea0SBaptiste DaroussinAC_SUBST(WILDCARD_SYMS)
6350f4f33ea0SBaptiste Daroussin])dnl
6351f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
6352*a96ef450SBaptiste Daroussindnl CF_XOPEN_CURSES version: 16 updated: 2021/01/02 09:31:20
63534c8945a0SNathan Whitehorndnl ---------------
63544c8945a0SNathan Whitehorndnl Test if we should define X/Open source for curses, needed on Digital Unix
63554c8945a0SNathan Whitehorndnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
63564c8945a0SNathan Whitehorndnl
63574c8945a0SNathan Whitehorndnl The getbegyx() check is needed for HPUX, which omits legacy macros such
63584c8945a0SNathan Whitehorndnl as getbegy().  The latter is better design, but the former is standard.
63594c8945a0SNathan WhitehornAC_DEFUN([CF_XOPEN_CURSES],
63604c8945a0SNathan Whitehorn[
63614c8945a0SNathan WhitehornAC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
6362f4f33ea0SBaptiste DaroussinAC_CACHE_CHECK(definition to turn on extended curses functions,cf_cv_need_xopen_extension,[
6363f4f33ea0SBaptiste Daroussincf_cv_need_xopen_extension=unknown
63644c8945a0SNathan WhitehornAC_TRY_LINK([
63654c8945a0SNathan Whitehorn#include <stdlib.h>
63667a1c0d96SNathan Whitehorn#include <${cf_cv_ncurses_header:-curses.h}>],[
63674c8945a0SNathan Whitehorn#if defined(NCURSES_VERSION_PATCH)
63687a1c0d96SNathan Whitehorn#if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
63694c8945a0SNathan Whitehorn	make an error
63704c8945a0SNathan Whitehorn#endif
63714c8945a0SNathan Whitehorn#endif
6372f4f33ea0SBaptiste Daroussin#ifdef NCURSES_VERSION
6373f4f33ea0SBaptiste Daroussin	cchar_t check;
6374f4f33ea0SBaptiste Daroussin	int check2 = curs_set((int)sizeof(check));
6375f4f33ea0SBaptiste Daroussin#endif
63764c8945a0SNathan Whitehorn	long x = winnstr(stdscr, "", 0);
63774c8945a0SNathan Whitehorn	int x1, y1;
6378*a96ef450SBaptiste Daroussin#ifdef NCURSES_VERSION
6379*a96ef450SBaptiste Daroussin	(void)check2;
6380*a96ef450SBaptiste Daroussin#endif
6381*a96ef450SBaptiste Daroussin	getbegyx(stdscr, y1, x1);
6382*a96ef450SBaptiste Daroussin	(void)x;
6383*a96ef450SBaptiste Daroussin	(void)y1;
6384*a96ef450SBaptiste Daroussin	(void)x1;
6385*a96ef450SBaptiste Daroussin	],
6386f4f33ea0SBaptiste Daroussin	[cf_cv_need_xopen_extension=none],
6387f4f33ea0SBaptiste Daroussin	[
6388f4f33ea0SBaptiste Daroussin	for cf_try_xopen_extension in _XOPEN_SOURCE_EXTENDED NCURSES_WIDECHAR
6389f4f33ea0SBaptiste Daroussin	do
6390f4f33ea0SBaptiste Daroussin		AC_TRY_LINK([
6391f4f33ea0SBaptiste Daroussin#define $cf_try_xopen_extension 1
63924c8945a0SNathan Whitehorn#include <stdlib.h>
63937a1c0d96SNathan Whitehorn#include <${cf_cv_ncurses_header:-curses.h}>],[
63944c8945a0SNathan Whitehorn#ifdef NCURSES_VERSION
63954c8945a0SNathan Whitehorn		cchar_t check;
63964c8945a0SNathan Whitehorn		int check2 = curs_set((int)sizeof(check));
63974c8945a0SNathan Whitehorn#endif
63984c8945a0SNathan Whitehorn		long x = winnstr(stdscr, "", 0);
63994c8945a0SNathan Whitehorn		int x1, y1;
6400*a96ef450SBaptiste Daroussin		getbegyx(stdscr, y1, x1);
6401*a96ef450SBaptiste Daroussin#ifdef NCURSES_VERSION
6402*a96ef450SBaptiste Daroussin		(void)check2;
6403*a96ef450SBaptiste Daroussin#endif
6404*a96ef450SBaptiste Daroussin		(void)x;
6405*a96ef450SBaptiste Daroussin		(void)y1;
6406*a96ef450SBaptiste Daroussin		(void)x1;
6407*a96ef450SBaptiste Daroussin		],
6408f4f33ea0SBaptiste Daroussin		[cf_cv_need_xopen_extension=$cf_try_xopen_extension; break])
6409f4f33ea0SBaptiste Daroussin	done
6410f4f33ea0SBaptiste Daroussin	])
6411f4f33ea0SBaptiste Daroussin])
6412f4f33ea0SBaptiste Daroussin
6413*a96ef450SBaptiste Daroussincase "$cf_cv_need_xopen_extension" in
6414f4f33ea0SBaptiste Daroussin(*_*)
6415f4f33ea0SBaptiste Daroussin	CF_APPEND_TEXT(CPPFLAGS,-D$cf_cv_need_xopen_extension)
6416f4f33ea0SBaptiste Daroussin	;;
6417f4f33ea0SBaptiste Daroussinesac
6418f4f33ea0SBaptiste Daroussin
64194c8945a0SNathan Whitehorn])dnl
64204c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
6421*a96ef450SBaptiste Daroussindnl CF_XOPEN_SOURCE version: 57 updated: 2021/01/01 16:53:59
64224c8945a0SNathan Whitehorndnl ---------------
64234c8945a0SNathan Whitehorndnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
64244c8945a0SNathan Whitehorndnl or adapt to the vendor's definitions to get equivalent functionality,
64254c8945a0SNathan Whitehorndnl without losing the common non-POSIX features.
64264c8945a0SNathan Whitehorndnl
64274c8945a0SNathan Whitehorndnl Parameters:
64284c8945a0SNathan Whitehorndnl	$1 is the nominal value for _XOPEN_SOURCE
64294c8945a0SNathan Whitehorndnl	$2 is the nominal value for _POSIX_C_SOURCE
64304c8945a0SNathan WhitehornAC_DEFUN([CF_XOPEN_SOURCE],[
6431febdb468SDevin TeskeAC_REQUIRE([AC_CANONICAL_HOST])
6432*a96ef450SBaptiste DaroussinAC_REQUIRE([CF_POSIX_VISIBLE])
6433*a96ef450SBaptiste Daroussin
6434*a96ef450SBaptiste Daroussinif test "$cf_cv_posix_visible" = no; then
64354c8945a0SNathan Whitehorn
64367a1c0d96SNathan Whitehorncf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
64377a1c0d96SNathan Whitehorncf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
64384c8945a0SNathan Whitehorncf_xopen_source=
64394c8945a0SNathan Whitehorn
6440*a96ef450SBaptiste Daroussincase "$host_os" in
6441f4f33ea0SBaptiste Daroussin(aix[[4-7]]*)
64424c8945a0SNathan Whitehorn	cf_xopen_source="-D_ALL_SOURCE"
64434c8945a0SNathan Whitehorn	;;
6444f4f33ea0SBaptiste Daroussin(msys)
6445682c9e0fSNathan Whitehorn	cf_XOPEN_SOURCE=600
6446682c9e0fSNathan Whitehorn	;;
6447f4f33ea0SBaptiste Daroussin(darwin[[0-8]].*)
64484c8945a0SNathan Whitehorn	cf_xopen_source="-D_APPLE_C_SOURCE"
64494c8945a0SNathan Whitehorn	;;
6450f4f33ea0SBaptiste Daroussin(darwin*)
64514c8945a0SNathan Whitehorn	cf_xopen_source="-D_DARWIN_C_SOURCE"
64522a3e3873SBaptiste Daroussin	cf_XOPEN_SOURCE=
64534c8945a0SNathan Whitehorn	;;
6454*a96ef450SBaptiste Daroussin(freebsd*|dragonfly*|midnightbsd*)
64554c8945a0SNathan Whitehorn	# 5.x headers associate
64564c8945a0SNathan Whitehorn	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
64574c8945a0SNathan Whitehorn	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
64584c8945a0SNathan Whitehorn	cf_POSIX_C_SOURCE=200112L
64594c8945a0SNathan Whitehorn	cf_XOPEN_SOURCE=600
64604c8945a0SNathan Whitehorn	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
64614c8945a0SNathan Whitehorn	;;
6462f4f33ea0SBaptiste Daroussin(hpux11*)
64634c8945a0SNathan Whitehorn	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
64644c8945a0SNathan Whitehorn	;;
6465f4f33ea0SBaptiste Daroussin(hpux*)
64664c8945a0SNathan Whitehorn	cf_xopen_source="-D_HPUX_SOURCE"
64674c8945a0SNathan Whitehorn	;;
6468f4f33ea0SBaptiste Daroussin(irix[[56]].*)
64694c8945a0SNathan Whitehorn	cf_xopen_source="-D_SGI_SOURCE"
64702a3e3873SBaptiste Daroussin	cf_XOPEN_SOURCE=
64714c8945a0SNathan Whitehorn	;;
6472f4f33ea0SBaptiste Daroussin(linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
6473f4f33ea0SBaptiste Daroussin	CF_GNU_SOURCE($cf_XOPEN_SOURCE)
64744c8945a0SNathan Whitehorn	;;
6475f4f33ea0SBaptiste Daroussin(minix*)
6476f4f33ea0SBaptiste Daroussin	cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
6477f4f33ea0SBaptiste Daroussin	;;
6478f4f33ea0SBaptiste Daroussin(mirbsd*)
64792a3e3873SBaptiste Daroussin	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
64802a3e3873SBaptiste Daroussin	cf_XOPEN_SOURCE=
64812a3e3873SBaptiste Daroussin	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
64824c8945a0SNathan Whitehorn	;;
6483f4f33ea0SBaptiste Daroussin(netbsd*)
64842a3e3873SBaptiste Daroussin	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
64852a3e3873SBaptiste Daroussin	;;
6486f4f33ea0SBaptiste Daroussin(openbsd[[4-9]]*)
64872a3e3873SBaptiste Daroussin	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
64882a3e3873SBaptiste Daroussin	cf_xopen_source="-D_BSD_SOURCE"
64892a3e3873SBaptiste Daroussin	cf_XOPEN_SOURCE=600
64904c8945a0SNathan Whitehorn	;;
6491f4f33ea0SBaptiste Daroussin(openbsd*)
64924c8945a0SNathan Whitehorn	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
64934c8945a0SNathan Whitehorn	;;
6494f4f33ea0SBaptiste Daroussin(osf[[45]]*)
64954c8945a0SNathan Whitehorn	cf_xopen_source="-D_OSF_SOURCE"
64964c8945a0SNathan Whitehorn	;;
6497f4f33ea0SBaptiste Daroussin(nto-qnx*)
64984c8945a0SNathan Whitehorn	cf_xopen_source="-D_QNX_SOURCE"
64994c8945a0SNathan Whitehorn	;;
6500f4f33ea0SBaptiste Daroussin(sco*)
65014c8945a0SNathan Whitehorn	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
65024c8945a0SNathan Whitehorn	;;
6503f4f33ea0SBaptiste Daroussin(solaris2.*)
65044c8945a0SNathan Whitehorn	cf_xopen_source="-D__EXTENSIONS__"
6505f4f33ea0SBaptiste Daroussin	cf_cv_xopen_source=broken
65064c8945a0SNathan Whitehorn	;;
6507f4f33ea0SBaptiste Daroussin(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
6508f4f33ea0SBaptiste Daroussin	cf_XOPEN_SOURCE=
6509f4f33ea0SBaptiste Daroussin	cf_POSIX_C_SOURCE=
6510f4f33ea0SBaptiste Daroussin	;;
6511f4f33ea0SBaptiste Daroussin(*)
65122a3e3873SBaptiste Daroussin	CF_TRY_XOPEN_SOURCE
65134c8945a0SNathan Whitehorn	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
65144c8945a0SNathan Whitehorn	;;
65154c8945a0SNathan Whitehornesac
65164c8945a0SNathan Whitehorn
65174c8945a0SNathan Whitehornif test -n "$cf_xopen_source" ; then
6518f4f33ea0SBaptiste Daroussin	CF_ADD_CFLAGS($cf_xopen_source,true)
65194c8945a0SNathan Whitehornfi
65202a3e3873SBaptiste Daroussin
65212a3e3873SBaptiste Daroussindnl In anything but the default case, we may have system-specific setting
65222a3e3873SBaptiste Daroussindnl which is still not guaranteed to provide all of the entrypoints that
65232a3e3873SBaptiste Daroussindnl _XOPEN_SOURCE would yield.
65242a3e3873SBaptiste Daroussinif test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
65252a3e3873SBaptiste Daroussin	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
65262a3e3873SBaptiste Daroussin	AC_TRY_COMPILE([#include <stdlib.h>],[
65272a3e3873SBaptiste Daroussin#ifndef _XOPEN_SOURCE
65282a3e3873SBaptiste Daroussinmake an error
65292a3e3873SBaptiste Daroussin#endif],
65302a3e3873SBaptiste Daroussin	[cf_XOPEN_SOURCE_set=yes],
65312a3e3873SBaptiste Daroussin	[cf_XOPEN_SOURCE_set=no])
65322a3e3873SBaptiste Daroussin	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
6533*a96ef450SBaptiste Daroussin	if test "$cf_XOPEN_SOURCE_set" = yes
65342a3e3873SBaptiste Daroussin	then
65352a3e3873SBaptiste Daroussin		AC_TRY_COMPILE([#include <stdlib.h>],[
65362a3e3873SBaptiste Daroussin#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
65372a3e3873SBaptiste Daroussinmake an error
65382a3e3873SBaptiste Daroussin#endif],
65392a3e3873SBaptiste Daroussin		[cf_XOPEN_SOURCE_set_ok=yes],
65402a3e3873SBaptiste Daroussin		[cf_XOPEN_SOURCE_set_ok=no])
6541*a96ef450SBaptiste Daroussin		if test "$cf_XOPEN_SOURCE_set_ok" = no
65422a3e3873SBaptiste Daroussin		then
65432a3e3873SBaptiste Daroussin			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
65442a3e3873SBaptiste Daroussin		fi
65452a3e3873SBaptiste Daroussin	else
65462a3e3873SBaptiste Daroussin		CF_TRY_XOPEN_SOURCE
65472a3e3873SBaptiste Daroussin	fi
65482a3e3873SBaptiste Daroussinfi
6549*a96ef450SBaptiste Daroussinfi # cf_cv_posix_visible
65504c8945a0SNathan Whitehorn])
65514c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
6552*a96ef450SBaptiste Daroussindnl CF_X_ATHENA version: 24 updated: 2020/03/10 18:53:47
6553f4f33ea0SBaptiste Daroussindnl -----------
6554f4f33ea0SBaptiste Daroussindnl Check for Xaw (Athena) libraries
6555f4f33ea0SBaptiste Daroussindnl
6556f4f33ea0SBaptiste Daroussindnl Sets $cf_x_athena according to the flavor of Xaw which is used.
6557f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_X_ATHENA],
6558f4f33ea0SBaptiste Daroussin[
6559f4f33ea0SBaptiste Daroussincf_x_athena=${cf_x_athena:-Xaw}
6560f4f33ea0SBaptiste Daroussin
6561f4f33ea0SBaptiste DaroussinAC_MSG_CHECKING(if you want to link with Xaw 3d library)
6562f4f33ea0SBaptiste Daroussinwithval=
6563f4f33ea0SBaptiste DaroussinAC_ARG_WITH(Xaw3d,
6564f4f33ea0SBaptiste Daroussin	[  --with-Xaw3d            link with Xaw 3d library])
6565f4f33ea0SBaptiste Daroussinif test "$withval" = yes ; then
6566f4f33ea0SBaptiste Daroussin	cf_x_athena=Xaw3d
6567f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT(yes)
6568f4f33ea0SBaptiste Daroussinelse
6569f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT(no)
6570f4f33ea0SBaptiste Daroussinfi
6571f4f33ea0SBaptiste Daroussin
6572f4f33ea0SBaptiste DaroussinAC_MSG_CHECKING(if you want to link with Xaw 3d xft library)
6573f4f33ea0SBaptiste Daroussinwithval=
6574f4f33ea0SBaptiste DaroussinAC_ARG_WITH(Xaw3dxft,
6575f4f33ea0SBaptiste Daroussin	[  --with-Xaw3dxft         link with Xaw 3d xft library])
6576f4f33ea0SBaptiste Daroussinif test "$withval" = yes ; then
6577f4f33ea0SBaptiste Daroussin	cf_x_athena=Xaw3dxft
6578f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT(yes)
6579f4f33ea0SBaptiste Daroussinelse
6580f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT(no)
6581f4f33ea0SBaptiste Daroussinfi
6582f4f33ea0SBaptiste Daroussin
6583f4f33ea0SBaptiste DaroussinAC_MSG_CHECKING(if you want to link with neXT Athena library)
6584f4f33ea0SBaptiste Daroussinwithval=
6585f4f33ea0SBaptiste DaroussinAC_ARG_WITH(neXtaw,
6586f4f33ea0SBaptiste Daroussin	[  --with-neXtaw           link with neXT Athena library])
6587f4f33ea0SBaptiste Daroussinif test "$withval" = yes ; then
6588f4f33ea0SBaptiste Daroussin	cf_x_athena=neXtaw
6589f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT(yes)
6590f4f33ea0SBaptiste Daroussinelse
6591f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT(no)
6592f4f33ea0SBaptiste Daroussinfi
6593f4f33ea0SBaptiste Daroussin
6594f4f33ea0SBaptiste DaroussinAC_MSG_CHECKING(if you want to link with Athena-Plus library)
6595f4f33ea0SBaptiste Daroussinwithval=
6596f4f33ea0SBaptiste DaroussinAC_ARG_WITH(XawPlus,
6597f4f33ea0SBaptiste Daroussin	[  --with-XawPlus          link with Athena-Plus library])
6598f4f33ea0SBaptiste Daroussinif test "$withval" = yes ; then
6599f4f33ea0SBaptiste Daroussin	cf_x_athena=XawPlus
6600f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT(yes)
6601f4f33ea0SBaptiste Daroussinelse
6602f4f33ea0SBaptiste Daroussin	AC_MSG_RESULT(no)
6603f4f33ea0SBaptiste Daroussinfi
6604f4f33ea0SBaptiste Daroussin
6605f4f33ea0SBaptiste Daroussincf_x_athena_lib=""
6606f4f33ea0SBaptiste Daroussin
6607f4f33ea0SBaptiste Daroussinif test "$PKG_CONFIG" != none ; then
6608f4f33ea0SBaptiste Daroussin	cf_athena_list=
6609f4f33ea0SBaptiste Daroussin	test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
6610f4f33ea0SBaptiste Daroussin	for cf_athena_pkg in \
6611f4f33ea0SBaptiste Daroussin		$cf_athena_list \
6612f4f33ea0SBaptiste Daroussin		${cf_x_athena} \
6613f4f33ea0SBaptiste Daroussin		${cf_x_athena}-devel \
6614f4f33ea0SBaptiste Daroussin		lib${cf_x_athena} \
6615f4f33ea0SBaptiste Daroussin		lib${cf_x_athena}-devel
6616f4f33ea0SBaptiste Daroussin	do
6617f4f33ea0SBaptiste Daroussin		CF_TRY_PKG_CONFIG($cf_athena_pkg,[
6618f4f33ea0SBaptiste Daroussin			cf_x_athena_lib="$cf_pkgconfig_libs"
6619f4f33ea0SBaptiste Daroussin			CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
6620f4f33ea0SBaptiste Daroussin			AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
6621f4f33ea0SBaptiste Daroussin
6622f4f33ea0SBaptiste Daroussin			CF_TRIM_X_LIBS
6623f4f33ea0SBaptiste Daroussin
6624f4f33ea0SBaptiste DaroussinAC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
6625f4f33ea0SBaptiste DaroussinAC_TRY_LINK([
6626f4f33ea0SBaptiste Daroussin#include <X11/Xmu/CharSet.h>
6627f4f33ea0SBaptiste Daroussin],[
6628*a96ef450SBaptiste Daroussinint check = XmuCompareISOLatin1("big", "small");
6629*a96ef450SBaptiste Daroussin(void)check;
6630f4f33ea0SBaptiste Daroussin],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
6631f4f33ea0SBaptiste Daroussin
6632f4f33ea0SBaptiste Daroussin			if test "$cf_cv_xaw_compat" = no
6633f4f33ea0SBaptiste Daroussin			then
6634f4f33ea0SBaptiste Daroussin				# workaround for broken ".pc" files...
6635f4f33ea0SBaptiste Daroussin				case "$cf_x_athena_lib" in
6636f4f33ea0SBaptiste Daroussin				(*-lXmu*)
6637f4f33ea0SBaptiste Daroussin					;;
6638f4f33ea0SBaptiste Daroussin				(*)
6639f4f33ea0SBaptiste Daroussin					CF_VERBOSE(work around broken package)
6640f4f33ea0SBaptiste Daroussin					cf_save_xmu="$LIBS"
6641f4f33ea0SBaptiste Daroussin					cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
6642f4f33ea0SBaptiste Daroussin					CF_TRY_PKG_CONFIG(xmu,[
6643f4f33ea0SBaptiste Daroussin							LIBS="$cf_save_xmu"
6644f4f33ea0SBaptiste Daroussin							CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
6645f4f33ea0SBaptiste Daroussin						],[
6646f4f33ea0SBaptiste Daroussin							CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
6647f4f33ea0SBaptiste Daroussin						])
6648f4f33ea0SBaptiste Daroussin					CF_TRIM_X_LIBS
6649f4f33ea0SBaptiste Daroussin					;;
6650f4f33ea0SBaptiste Daroussin				esac
6651f4f33ea0SBaptiste Daroussin			fi
6652f4f33ea0SBaptiste Daroussin
6653f4f33ea0SBaptiste Daroussin			break])
6654f4f33ea0SBaptiste Daroussin	done
6655f4f33ea0SBaptiste Daroussinfi
6656f4f33ea0SBaptiste Daroussin
6657f4f33ea0SBaptiste Daroussinif test -z "$cf_x_athena_lib" ; then
6658f4f33ea0SBaptiste Daroussin	CF_X_EXT
6659f4f33ea0SBaptiste Daroussin	CF_X_TOOLKIT
6660f4f33ea0SBaptiste Daroussin	CF_X_ATHENA_CPPFLAGS($cf_x_athena)
6661f4f33ea0SBaptiste Daroussin	CF_X_ATHENA_LIBS($cf_x_athena)
6662f4f33ea0SBaptiste Daroussinfi
6663f4f33ea0SBaptiste Daroussin])dnl
6664f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
6665*a96ef450SBaptiste Daroussindnl CF_X_ATHENA_CPPFLAGS version: 9 updated: 2020/12/31 10:54:15
6666f4f33ea0SBaptiste Daroussindnl --------------------
6667f4f33ea0SBaptiste Daroussindnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
6668f4f33ea0SBaptiste Daroussindnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
6669f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_X_ATHENA_CPPFLAGS],
6670f4f33ea0SBaptiste Daroussin[
6671*a96ef450SBaptiste DaroussinAC_REQUIRE([AC_PATH_XTRA])
6672f4f33ea0SBaptiste Daroussincf_x_athena_root=ifelse([$1],,Xaw,[$1])
6673f4f33ea0SBaptiste Daroussincf_x_athena_inc=""
6674f4f33ea0SBaptiste Daroussin
6675f4f33ea0SBaptiste Daroussinfor cf_path in default \
6676f4f33ea0SBaptiste Daroussin	/usr/contrib/X11R6 \
6677f4f33ea0SBaptiste Daroussin	/usr/contrib/X11R5 \
6678f4f33ea0SBaptiste Daroussin	/usr/lib/X11R5 \
6679f4f33ea0SBaptiste Daroussin	/usr/local
6680f4f33ea0SBaptiste Daroussindo
6681f4f33ea0SBaptiste Daroussin	if test -z "$cf_x_athena_inc" ; then
6682*a96ef450SBaptiste Daroussin		CF_SAVE_XTRA_FLAGS([CF_X_ATHENA_CPPFLAGS])
6683f4f33ea0SBaptiste Daroussin		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
6684*a96ef450SBaptiste Daroussin		if test "$cf_path" != default ; then
6685f4f33ea0SBaptiste Daroussin			CF_APPEND_TEXT(CPPFLAGS,-I$cf_path/include)
6686f4f33ea0SBaptiste Daroussin			AC_MSG_CHECKING(for $cf_test in $cf_path)
6687f4f33ea0SBaptiste Daroussin		else
6688f4f33ea0SBaptiste Daroussin			AC_MSG_CHECKING(for $cf_test)
6689f4f33ea0SBaptiste Daroussin		fi
6690f4f33ea0SBaptiste Daroussin		AC_TRY_COMPILE([
6691f4f33ea0SBaptiste Daroussin#include <X11/Intrinsic.h>
6692f4f33ea0SBaptiste Daroussin#include <$cf_test>],[],
6693f4f33ea0SBaptiste Daroussin			[cf_result=yes],
6694f4f33ea0SBaptiste Daroussin			[cf_result=no])
6695f4f33ea0SBaptiste Daroussin		AC_MSG_RESULT($cf_result)
6696*a96ef450SBaptiste Daroussin		CF_RESTORE_XTRA_FLAGS([CF_X_ATHENA_CPPFLAGS])
6697f4f33ea0SBaptiste Daroussin		if test "$cf_result" = yes ; then
6698*a96ef450SBaptiste Daroussin			test "$cf_path"  = default && cf_x_athena_inc=default
6699*a96ef450SBaptiste Daroussin			test "$cf_path" != default && cf_x_athena_inc="$cf_path/include"
6700f4f33ea0SBaptiste Daroussin			break
6701f4f33ea0SBaptiste Daroussin		fi
6702f4f33ea0SBaptiste Daroussin	fi
6703f4f33ea0SBaptiste Daroussindone
6704f4f33ea0SBaptiste Daroussin
6705f4f33ea0SBaptiste Daroussinif test -z "$cf_x_athena_inc" ; then
6706*a96ef450SBaptiste Daroussin	AC_MSG_WARN([Unable to find Athena header files])
6707f4f33ea0SBaptiste Daroussinelif test "$cf_x_athena_inc" != default ; then
6708f4f33ea0SBaptiste Daroussin	CF_APPEND_TEXT(CPPFLAGS,-I$cf_x_athena_inc)
6709f4f33ea0SBaptiste Daroussinfi
6710f4f33ea0SBaptiste Daroussin])
6711f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
6712*a96ef450SBaptiste Daroussindnl CF_X_ATHENA_LIBS version: 13 updated: 2020/01/11 18:16:10
6713f4f33ea0SBaptiste Daroussindnl ----------------
6714f4f33ea0SBaptiste Daroussindnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
6715f4f33ea0SBaptiste Daroussindnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
6716f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_X_ATHENA_LIBS],
6717f4f33ea0SBaptiste Daroussin[AC_REQUIRE([CF_X_TOOLKIT])
6718f4f33ea0SBaptiste Daroussincf_x_athena_root=ifelse([$1],,Xaw,[$1])
6719f4f33ea0SBaptiste Daroussincf_x_athena_lib=""
6720f4f33ea0SBaptiste Daroussin
6721f4f33ea0SBaptiste Daroussinfor cf_path in default \
6722f4f33ea0SBaptiste Daroussin	/usr/contrib/X11R6 \
6723f4f33ea0SBaptiste Daroussin	/usr/contrib/X11R5 \
6724f4f33ea0SBaptiste Daroussin	/usr/lib/X11R5 \
6725f4f33ea0SBaptiste Daroussin	/usr/local
6726f4f33ea0SBaptiste Daroussindo
6727f4f33ea0SBaptiste Daroussin	for cf_lib in \
6728f4f33ea0SBaptiste Daroussin		${cf_x_athena_root} \
6729f4f33ea0SBaptiste Daroussin		${cf_x_athena_root}7 \
6730f4f33ea0SBaptiste Daroussin		${cf_x_athena_root}6
6731f4f33ea0SBaptiste Daroussin	do
6732f4f33ea0SBaptiste Daroussin	for cf_libs in \
6733f4f33ea0SBaptiste Daroussin		"-l$cf_lib -lXmu" \
6734f4f33ea0SBaptiste Daroussin		"-l$cf_lib -lXpm -lXmu" \
6735f4f33ea0SBaptiste Daroussin		"-l${cf_lib}_s -lXmu_s"
6736f4f33ea0SBaptiste Daroussin	do
6737*a96ef450SBaptiste Daroussin		test -n "$cf_x_athena_lib" && break
6738*a96ef450SBaptiste Daroussin
6739*a96ef450SBaptiste Daroussin		CF_SAVE_XTRA_FLAGS([CF_X_ATHENA_LIBS])
6740f4f33ea0SBaptiste Daroussin		cf_test=XawSimpleMenuAddGlobalActions
6741*a96ef450SBaptiste Daroussin		test "$cf_path" != default && cf_libs="-L$cf_path/lib $cf_libs"
6742f4f33ea0SBaptiste Daroussin		CF_ADD_LIBS($cf_libs)
6743f4f33ea0SBaptiste Daroussin		AC_MSG_CHECKING(for $cf_test in $cf_libs)
6744f4f33ea0SBaptiste Daroussin		AC_TRY_LINK([
6745f4f33ea0SBaptiste Daroussin#include <X11/Intrinsic.h>
6746f4f33ea0SBaptiste Daroussin#include <X11/$cf_x_athena_root/SimpleMenu.h>
6747f4f33ea0SBaptiste Daroussin],[
6748f4f33ea0SBaptiste Daroussin$cf_test((XtAppContext) 0)],
6749f4f33ea0SBaptiste Daroussin			[cf_result=yes],
6750f4f33ea0SBaptiste Daroussin			[cf_result=no])
6751f4f33ea0SBaptiste Daroussin		AC_MSG_RESULT($cf_result)
6752*a96ef450SBaptiste Daroussin		CF_RESTORE_XTRA_FLAGS([CF_X_ATHENA_LIBS])
6753*a96ef450SBaptiste Daroussin
6754f4f33ea0SBaptiste Daroussin		if test "$cf_result" = yes ; then
6755f4f33ea0SBaptiste Daroussin			cf_x_athena_lib="$cf_libs"
6756f4f33ea0SBaptiste Daroussin			break
6757f4f33ea0SBaptiste Daroussin		fi
6758f4f33ea0SBaptiste Daroussin	done # cf_libs
6759f4f33ea0SBaptiste Daroussin		test -n "$cf_x_athena_lib" && break
6760f4f33ea0SBaptiste Daroussin	done # cf_lib
6761f4f33ea0SBaptiste Daroussindone
6762f4f33ea0SBaptiste Daroussin
6763f4f33ea0SBaptiste Daroussinif test -z "$cf_x_athena_lib" ; then
6764f4f33ea0SBaptiste Daroussin	AC_MSG_ERROR(
6765f4f33ea0SBaptiste Daroussin[Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
6766f4f33ea0SBaptiste Daroussinfi
6767f4f33ea0SBaptiste Daroussin
6768*a96ef450SBaptiste DaroussinCF_ADD_LIBS($cf_x_athena_lib)
6769f4f33ea0SBaptiste DaroussinCF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
6770f4f33ea0SBaptiste DaroussinAC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
6771f4f33ea0SBaptiste Daroussin])
6772f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
6773f4f33ea0SBaptiste Daroussindnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
6774f4f33ea0SBaptiste Daroussindnl --------
6775f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_X_EXT],[
6776f4f33ea0SBaptiste DaroussinCF_TRY_PKG_CONFIG(Xext,,[
6777f4f33ea0SBaptiste Daroussin	AC_CHECK_LIB(Xext,XextCreateExtension,
6778f4f33ea0SBaptiste Daroussin		[CF_ADD_LIB(Xext)])])
6779f4f33ea0SBaptiste Daroussin])dnl
6780f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
6781*a96ef450SBaptiste Daroussindnl CF_X_TOOLKIT version: 26 updated: 2021/01/02 09:31:20
6782f4f33ea0SBaptiste Daroussindnl ------------
6783f4f33ea0SBaptiste Daroussindnl Check for X Toolkit libraries
6784f4f33ea0SBaptiste DaroussinAC_DEFUN([CF_X_TOOLKIT],
6785f4f33ea0SBaptiste Daroussin[
6786f4f33ea0SBaptiste DaroussinAC_REQUIRE([AC_PATH_XTRA])
6787f4f33ea0SBaptiste DaroussinAC_REQUIRE([CF_CHECK_CACHE])
6788f4f33ea0SBaptiste Daroussin
6789*a96ef450SBaptiste Daroussin# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new) (and
6790f4f33ea0SBaptiste Daroussin# in some cases has installed dummy files in the former, other cases replaced
6791f4f33ea0SBaptiste Daroussin# it with a link to the new location).  This complicates the configure script.
6792f4f33ea0SBaptiste Daroussin# Check for that pitfall, and recover using pkg-config
6793f4f33ea0SBaptiste Daroussin#
6794f4f33ea0SBaptiste Daroussin# If none of these are set, the configuration is almost certainly broken.
6795f4f33ea0SBaptiste Daroussinif test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
6796f4f33ea0SBaptiste Daroussinthen
6797f4f33ea0SBaptiste Daroussin	CF_TRY_PKG_CONFIG(x11,,[AC_MSG_WARN(unable to find X11 library)])
6798f4f33ea0SBaptiste Daroussin	CF_TRY_PKG_CONFIG(ice,,[AC_MSG_WARN(unable to find ICE library)])
6799f4f33ea0SBaptiste Daroussin	CF_TRY_PKG_CONFIG(sm,,[AC_MSG_WARN(unable to find SM library)])
6800f4f33ea0SBaptiste Daroussin	CF_TRY_PKG_CONFIG(xt,,[AC_MSG_WARN(unable to find Xt library)])
6801*a96ef450SBaptiste Daroussinelse
6802*a96ef450SBaptiste Daroussin	LIBS="$X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
6803f4f33ea0SBaptiste Daroussinfi
6804f4f33ea0SBaptiste Daroussin
6805f4f33ea0SBaptiste Daroussincf_have_X_LIBS=no
6806f4f33ea0SBaptiste Daroussin
6807f4f33ea0SBaptiste DaroussinCF_TRY_PKG_CONFIG(xt,[
6808f4f33ea0SBaptiste Daroussin
6809f4f33ea0SBaptiste Daroussin	case "x$LIBS" in
6810f4f33ea0SBaptiste Daroussin	(*-lX11*)
6811f4f33ea0SBaptiste Daroussin		;;
6812f4f33ea0SBaptiste Daroussin	(*)
6813f4f33ea0SBaptiste Daroussin# we have an "xt" package, but it may omit Xt's dependency on X11
6814f4f33ea0SBaptiste DaroussinAC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
6815f4f33ea0SBaptiste DaroussinAC_TRY_LINK([
6816f4f33ea0SBaptiste Daroussin#include <X11/Xlib.h>
6817f4f33ea0SBaptiste Daroussin],[
6818f4f33ea0SBaptiste Daroussin	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
6819f4f33ea0SBaptiste Daroussin	int rc2 = XClearWindow((Display*) 0, (Window) 0);
6820f4f33ea0SBaptiste Daroussin	int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
6821f4f33ea0SBaptiste Daroussin	int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
6822f4f33ea0SBaptiste Daroussin],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
6823f4f33ea0SBaptiste Daroussin		if test "$cf_cv_xt_x11_compat" = no
6824f4f33ea0SBaptiste Daroussin		then
6825f4f33ea0SBaptiste Daroussin			CF_VERBOSE(work around broken X11 dependency)
6826f4f33ea0SBaptiste Daroussin			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.
6827f4f33ea0SBaptiste Daroussin			CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
6828f4f33ea0SBaptiste Daroussin		fi
6829f4f33ea0SBaptiste Daroussin		;;
6830f4f33ea0SBaptiste Daroussin	esac
6831f4f33ea0SBaptiste Daroussin
6832f4f33ea0SBaptiste DaroussinAC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
6833f4f33ea0SBaptiste DaroussinAC_TRY_LINK([
6834f4f33ea0SBaptiste Daroussin#include <X11/Shell.h>
6835*a96ef450SBaptiste Daroussin],[int num = IceConnectionNumber(0); (void) num
6836f4f33ea0SBaptiste Daroussin],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
6837f4f33ea0SBaptiste Daroussin
6838f4f33ea0SBaptiste Daroussin	if test "$cf_cv_xt_ice_compat" = no
6839f4f33ea0SBaptiste Daroussin	then
6840f4f33ea0SBaptiste Daroussin		# workaround for broken ".pc" files used for X Toolkit.
6841f4f33ea0SBaptiste Daroussin		case "x$X_PRE_LIBS" in
6842f4f33ea0SBaptiste Daroussin		(*-lICE*)
6843f4f33ea0SBaptiste Daroussin			case "x$LIBS" in
6844f4f33ea0SBaptiste Daroussin			(*-lICE*)
6845f4f33ea0SBaptiste Daroussin				;;
6846f4f33ea0SBaptiste Daroussin			(*)
6847f4f33ea0SBaptiste Daroussin				CF_VERBOSE(work around broken ICE dependency)
6848f4f33ea0SBaptiste Daroussin				CF_TRY_PKG_CONFIG(ice,
6849f4f33ea0SBaptiste Daroussin					[CF_TRY_PKG_CONFIG(sm)],
6850f4f33ea0SBaptiste Daroussin					[CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
6851f4f33ea0SBaptiste Daroussin				;;
6852f4f33ea0SBaptiste Daroussin			esac
6853f4f33ea0SBaptiste Daroussin			;;
6854f4f33ea0SBaptiste Daroussin		esac
6855f4f33ea0SBaptiste Daroussin	fi
6856f4f33ea0SBaptiste Daroussin
6857f4f33ea0SBaptiste Daroussin	cf_have_X_LIBS=yes
6858f4f33ea0SBaptiste Daroussin],[
6859f4f33ea0SBaptiste Daroussin
6860f4f33ea0SBaptiste Daroussin	LDFLAGS="$X_LIBS $LDFLAGS"
6861f4f33ea0SBaptiste Daroussin	CF_CHECK_CFLAGS($X_CFLAGS)
6862f4f33ea0SBaptiste Daroussin
6863f4f33ea0SBaptiste Daroussin	AC_CHECK_FUNC(XOpenDisplay,,[
6864f4f33ea0SBaptiste Daroussin	AC_CHECK_LIB(X11,XOpenDisplay,
6865*a96ef450SBaptiste Daroussin		[CF_ADD_LIB(X11)])])
6866f4f33ea0SBaptiste Daroussin
6867f4f33ea0SBaptiste Daroussin	AC_CHECK_FUNC(XtAppInitialize,,[
6868f4f33ea0SBaptiste Daroussin	AC_CHECK_LIB(Xt, XtAppInitialize,
6869f4f33ea0SBaptiste Daroussin		[AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
6870f4f33ea0SBaptiste Daroussin		 cf_have_X_LIBS=Xt
6871*a96ef450SBaptiste Daroussin		 LIBS="-lXt $LIBS"])])
6872f4f33ea0SBaptiste Daroussin])
6873f4f33ea0SBaptiste Daroussin
6874*a96ef450SBaptiste Daroussinif test "$cf_have_X_LIBS" = no ; then
6875f4f33ea0SBaptiste Daroussin	AC_MSG_WARN(
6876f4f33ea0SBaptiste Daroussin[Unable to successfully link X Toolkit library (-lXt) with
6877f4f33ea0SBaptiste Daroussintest program.  You will have to check and add the proper libraries by hand
6878f4f33ea0SBaptiste Daroussinto makefile.])
6879f4f33ea0SBaptiste Daroussinfi
6880f4f33ea0SBaptiste Daroussin])dnl
6881f4f33ea0SBaptiste Daroussindnl ---------------------------------------------------------------------------
6882f4f33ea0SBaptiste Daroussindnl CF__ADD_SHLIB_RULES version: 6 updated: 2016/04/21 21:07:50
6883febdb468SDevin Teskednl -------------------
6884febdb468SDevin Teskednl Append rules for creating, installing, uninstalling and cleaning library.
6885febdb468SDevin Teskednl In particular, this is needed for shared libraries since there are symbolic
6886febdb468SDevin Teskednl links which depend on configuration choices.
6887febdb468SDevin Teskednl
6888febdb468SDevin Teskednl The logic is controlled by these cache variables:
6889febdb468SDevin Teskednl $cf_cv_do_symlinks
6890febdb468SDevin Teskednl $cf_cv_shlib_version
6891febdb468SDevin Teskednl
6892febdb468SDevin Teskednl The macro uses variables set by CF__DEFINE_SHLIB_VARS
6893febdb468SDevin Teskednl
6894febdb468SDevin Teskednl $1 = makefile to append to
6895febdb468SDevin Teskednl $2 = model (static, shared, libtool)
6896febdb468SDevin Teskednl $3 = objects (dependencies)
6897febdb468SDevin Teskednl $4 = additional libraries needed to link the shared library
6898febdb468SDevin Teskedefine([CF__ADD_SHLIB_RULES],[
6899febdb468SDevin Teske
6900febdb468SDevin TeskeCF__DEFINE_LIB_TARGET
6901febdb468SDevin Teske
6902febdb468SDevin Teskecase x$2 in
6903f4f33ea0SBaptiste Daroussin(xlibtool|xshared)
6904febdb468SDevin Teske	cf_libdeps="ifelse($4,,,[$4])"
6905febdb468SDevin Teske	;;
6906f4f33ea0SBaptiste Daroussin(x*)
6907febdb468SDevin Teske	cf_libdeps=
6908febdb468SDevin Teske	;;
6909febdb468SDevin Teskeesac
6910febdb468SDevin Teske
6911febdb468SDevin Teskecat >>$1 <<CF_EOF
6912febdb468SDevin Teske
6913febdb468SDevin Teske# generated by CF__ADD_SHLIB_RULES
6914febdb468SDevin Teske# libmodel: $2
6915febdb468SDevin Teske# symlinks: $cf_cv_do_symlinks
6916febdb468SDevin Teske# shlibver: $cf_cv_shlib_version
6917febdb468SDevin Teske
6918febdb468SDevin TeskeCF_EOF
6919febdb468SDevin Teske
6920febdb468SDevin Teskecat >>$1 <<CF_EOF
6921febdb468SDevin Teske$cf_libname :: \\
6922febdb468SDevin TeskeCF_EOF
6923febdb468SDevin Teske
6924febdb468SDevin Teskecat >>$1 <<CF_EOF
6925febdb468SDevin Teske		$3
6926febdb468SDevin Teske	@echo linking \[$]@
6927febdb468SDevin Teske	\$(LIBTOOL_CREATE) $3 $cf_libdeps
6928febdb468SDevin TeskeCF_EOF
6929febdb468SDevin Teske
6930febdb468SDevin Teskeif test "x$cf_cv_do_symlinks" = xyes
6931febdb468SDevin Teskethen
6932febdb468SDevin Teskecat >>$1 <<CF_EOF
6933febdb468SDevin Teske	\$(LN_S) $cf_libname $cf_liblink
6934febdb468SDevin Teske	\$(LN_S) $cf_liblink $cf_libroot
6935febdb468SDevin TeskeCF_EOF
6936febdb468SDevin Teskefi
6937febdb468SDevin Teske
6938febdb468SDevin Teskecat >>$1 <<CF_EOF
6939febdb468SDevin Teske
6940febdb468SDevin Teskeinstall \\
6941febdb468SDevin Teskeinstall.libs :: \$(DESTDIR)\$(libdir)/$cf_libname
6942febdb468SDevin Teske
6943febdb468SDevin Teske\$(DESTDIR)\$(libdir)/$cf_libname :: \\
6944febdb468SDevin Teske		\$(DESTDIR)\$(libdir) \\
6945febdb468SDevin Teske		$3
6946febdb468SDevin Teske	@echo linking \[$]@
6947febdb468SDevin Teske	\$(LIBTOOL_CREATE) $3 $cf_libdeps
6948febdb468SDevin TeskeCF_EOF
6949febdb468SDevin Teske
6950febdb468SDevin Teskeif test "x$cf_cv_do_symlinks" = xyes
6951febdb468SDevin Teskethen
6952febdb468SDevin Teskecat >>$1 <<CF_EOF
6953febdb468SDevin Teske	cd \$(DESTDIR)\$(libdir) && (\$(LN_S) $cf_libname $cf_liblink; \$(LN_S) $cf_liblink $cf_libroot; )
6954febdb468SDevin TeskeCF_EOF
6955febdb468SDevin Teskefi
6956febdb468SDevin Teske
6957febdb468SDevin Teskeif test x$2 = xshared
6958febdb468SDevin Teskethen
6959febdb468SDevin Teskecat >>$1 <<CF_EOF
6960f4f33ea0SBaptiste Daroussin	- \$(SHELL) -c "if test -z "\$(DESTDIR)" ; then /sbin/ldconfig; fi"
6961febdb468SDevin TeskeCF_EOF
6962febdb468SDevin Teskefi
6963febdb468SDevin Teske
6964febdb468SDevin Teskecat >>$1 <<CF_EOF
6965febdb468SDevin Teske
6966febdb468SDevin Teskeuninstall \\
6967febdb468SDevin Teskeuninstall.libs ::
6968febdb468SDevin Teske	@echo uninstalling \$(DESTDIR)\$(libdir)/$cf_libname
6969febdb468SDevin TeskeCF_EOF
6970febdb468SDevin Teske
6971febdb468SDevin Teskeif test "x$cf_cv_do_symlinks" = xyes
6972febdb468SDevin Teskethen
6973febdb468SDevin Teskecat >>$1 <<CF_EOF
6974febdb468SDevin Teske	-rm -f \$(DESTDIR)\$(libdir)/$cf_libroot
6975febdb468SDevin Teske	-rm -f \$(DESTDIR)\$(libdir)/$cf_liblink
6976febdb468SDevin TeskeCF_EOF
6977febdb468SDevin Teskefi
6978febdb468SDevin Teske
6979febdb468SDevin Teskecat >>$1 <<CF_EOF
6980febdb468SDevin Teske	-rm -f \$(DESTDIR)\$(libdir)/$cf_libname
6981febdb468SDevin Teske
6982febdb468SDevin Teskeclean \\
6983febdb468SDevin Teskeclean.libs ::
6984febdb468SDevin TeskeCF_EOF
6985febdb468SDevin Teske
6986febdb468SDevin Teskeif test "x$cf_cv_do_symlinks" = xyes
6987febdb468SDevin Teskethen
6988febdb468SDevin Teskecat >>$1 <<CF_EOF
6989febdb468SDevin Teske	-rm -f $cf_libroot
6990febdb468SDevin Teske	-rm -f $cf_liblink
6991febdb468SDevin TeskeCF_EOF
6992febdb468SDevin Teskefi
6993febdb468SDevin Teske
6994febdb468SDevin Teskecat >>$1 <<CF_EOF
6995febdb468SDevin Teske	-rm -f $cf_libname
6996febdb468SDevin Teske
6997febdb468SDevin Teskemostlyclean::
6998febdb468SDevin Teske	-rm -f $3
6999febdb468SDevin Teske# end generated by CF__ADD_SHLIB_RULES
7000febdb468SDevin TeskeCF_EOF
7001febdb468SDevin Teske])dnl
7002febdb468SDevin Teskednl ---------------------------------------------------------------------------
70037a1c0d96SNathan Whitehorndnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
70044c8945a0SNathan Whitehorndnl ---------------
70054c8945a0SNathan Whitehorndnl Define a reusable chunk which includes <curses.h> and <term.h> when they
70064c8945a0SNathan Whitehorndnl are both available.
70074c8945a0SNathan Whitehorndefine([CF__CURSES_HEAD],[
70084c8945a0SNathan Whitehorn#ifdef HAVE_XCURSES
70094c8945a0SNathan Whitehorn#include <xcurses.h>
70104c8945a0SNathan Whitehornchar * XCursesProgramName = "test";
70114c8945a0SNathan Whitehorn#else
70127a1c0d96SNathan Whitehorn#include <${cf_cv_ncurses_header:-curses.h}>
70134c8945a0SNathan Whitehorn#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
70144c8945a0SNathan Whitehorn#include <ncursesw/term.h>
70154c8945a0SNathan Whitehorn#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
70164c8945a0SNathan Whitehorn#include <ncurses/term.h>
70174c8945a0SNathan Whitehorn#elif defined(HAVE_TERM_H)
70184c8945a0SNathan Whitehorn#include <term.h>
70194c8945a0SNathan Whitehorn#endif
70204c8945a0SNathan Whitehorn#endif
70214c8945a0SNathan Whitehorn])
70224c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
7023f4f33ea0SBaptiste Daroussindnl CF__DEFINE_LIB_TARGET version: 2 updated: 2015/05/10 19:52:14
7024febdb468SDevin Teskednl ---------------------
7025febdb468SDevin Teskedefine([CF__DEFINE_LIB_TARGET],[
7026febdb468SDevin Teskecf_libname=\${LIB_BASENAME}
7027febdb468SDevin Teskecf_liblink=$cf_libname
7028febdb468SDevin Teskecf_libroot=$cf_libname
7029febdb468SDevin Teske
7030febdb468SDevin Teskeif test "x$cf_cv_do_symlinks" = xyes
7031febdb468SDevin Teskethen
7032f4f33ea0SBaptiste Daroussin	case "x$cf_cv_shlib_version" in
7033f4f33ea0SBaptiste Daroussin	(xrel)
7034febdb468SDevin Teske		cf_liblink="\${LIB_ABI_NAME}"
7035febdb468SDevin Teske		cf_libname="\${LIB_REL_NAME}"
7036febdb468SDevin Teske		;;
7037f4f33ea0SBaptiste Daroussin	(xabi)
7038febdb468SDevin Teske		cf_liblink="\${LIB_REL_NAME}"
7039febdb468SDevin Teske		cf_libname="\${LIB_ABI_NAME}"
7040febdb468SDevin Teske		;;
7041febdb468SDevin Teske	esac
7042febdb468SDevin Teskefi
7043febdb468SDevin TeskeLIB_TARGET=$cf_libname
7044febdb468SDevin Teske])dnl
7045febdb468SDevin Teskednl ---------------------------------------------------------------------------
7046f4f33ea0SBaptiste Daroussindnl CF__DEFINE_SHLIB_VARS version: 4 updated: 2015/09/28 17:49:10
7047febdb468SDevin Teskednl ---------------------
7048febdb468SDevin Teskednl Substitute makefile variables useful for CF__ADD_SHLIB_RULES.
7049febdb468SDevin Teskednl
7050febdb468SDevin Teskednl The substitution requires these variables:
7051f4f33ea0SBaptiste Daroussindnl		LIB_PREFIX - "lib"
7052febdb468SDevin Teskednl		LIB_ROOTNAME - "foo"
7053febdb468SDevin Teskednl		LIB_SUFFIX - ".so"
7054febdb468SDevin Teskednl		REL_VERSION - "5.0"
7055febdb468SDevin Teskednl		ABI_VERSION - "4.2.4"
7056febdb468SDevin Teskedefine([CF__DEFINE_SHLIB_VARS],[
7057febdb468SDevin TeskeCF__DEFINE_LIB_TARGET
7058febdb468SDevin TeskeSET_SHLIB_VARS="# begin CF__DEFINE_SHLIB_VARS\\
7059f4f33ea0SBaptiste DaroussinLIB_BASENAME	= \${LIB_PREFIX}\${LIB_ROOTNAME}\${LIB_SUFFIX}\\
7060febdb468SDevin TeskeLIB_REL_NAME	= \${LIB_BASENAME}.\${REL_VERSION}\\
7061febdb468SDevin TeskeLIB_ABI_NAME	= \${LIB_BASENAME}.\${ABI_VERSION}\\
7062febdb468SDevin TeskeLIB_TARGET	= $LIB_TARGET\\
7063febdb468SDevin TeskeRM_SHARED_OPTS	= $RM_SHARED_OPTS\\
7064febdb468SDevin Teske# end CF__DEFINE_SHLIB_VARS"
7065febdb468SDevin TeskeAC_SUBST(SET_SHLIB_VARS)
7066febdb468SDevin TeskeAC_SUBST(LIB_TARGET)
7067febdb468SDevin Teske])dnl
7068febdb468SDevin Teskednl ---------------------------------------------------------------------------
70694c8945a0SNathan Whitehorndnl CF__ICONV_BODY version: 2 updated: 2007/07/26 17:35:47
70704c8945a0SNathan Whitehorndnl --------------
70714c8945a0SNathan Whitehorndnl Test-code needed for iconv compile-checks
70724c8945a0SNathan Whitehorndefine([CF__ICONV_BODY],[
70734c8945a0SNathan Whitehorn	iconv_t cd = iconv_open("","");
70744c8945a0SNathan Whitehorn	iconv(cd,NULL,NULL,NULL,NULL);
70754c8945a0SNathan Whitehorn	iconv_close(cd);]
70764c8945a0SNathan Whitehorn)dnl
70774c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
70784c8945a0SNathan Whitehorndnl CF__ICONV_HEAD version: 1 updated: 2007/07/26 15:57:03
70794c8945a0SNathan Whitehorndnl --------------
70804c8945a0SNathan Whitehorndnl Header-files needed for iconv compile-checks
70814c8945a0SNathan Whitehorndefine([CF__ICONV_HEAD],[
70824c8945a0SNathan Whitehorn#include <stdlib.h>
70834c8945a0SNathan Whitehorn#include <iconv.h>]
70844c8945a0SNathan Whitehorn)dnl
70854c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
7086febdb468SDevin Teskednl CF__INIT_SHLIB_RULES version: 2 updated: 2013/07/27 17:38:32
7087febdb468SDevin Teskednl --------------------
7088febdb468SDevin Teskednl The third parameter to AC_OUTPUT, used to pass variables needed for
7089febdb468SDevin Teskednl CF__ADD_SHLIB_RULES.
7090febdb468SDevin Teskedefine([CF__INIT_SHLIB_RULES],[
7091febdb468SDevin TeskeABI_VERSION="$ABI_VERSION"
7092febdb468SDevin TeskeREL_VERSION="$REL_VERSION"
7093febdb468SDevin TeskeLIB_MODEL="$LIB_MODEL"
7094febdb468SDevin TeskeLIB_PREFIX="$LIB_PREFIX"
7095febdb468SDevin TeskeLIB_ROOTNAME="$LIB_ROOTNAME"
7096febdb468SDevin TeskeDFT_DEP_SUFFIX="$DFT_DEP_SUFFIX"
7097febdb468SDevin TeskeRM_SHARED_OPTS="$RM_SHARED_OPTS"
7098febdb468SDevin Teskecf_cv_do_symlinks="$cf_cv_do_symlinks"
7099febdb468SDevin Teskecf_cv_shlib_version="$cf_cv_shlib_version"
7100febdb468SDevin Teske])
7101febdb468SDevin Teskednl ---------------------------------------------------------------------------
7102f4f33ea0SBaptiste Daroussindnl CF__INTL_BODY version: 3 updated: 2017/07/10 20:13:33
71034c8945a0SNathan Whitehorndnl -------------
71044c8945a0SNathan Whitehorndnl Test-code needed for libintl compile-checks
71054c8945a0SNathan Whitehorndnl $1 = parameter 2 from AM_WITH_NLS
71064c8945a0SNathan Whitehorndefine([CF__INTL_BODY],[
71074c8945a0SNathan Whitehorn	bindtextdomain ("", "");
71084c8945a0SNathan Whitehorn	return (int) gettext ("")
71094c8945a0SNathan Whitehorn			ifelse([$1], need-ngettext, [ + (int) ngettext ("", "", 0)], [])
7110f4f33ea0SBaptiste Daroussin#ifndef IGNORE_MSGFMT_HACK
71114c8945a0SNathan Whitehorn			[ + _nl_msg_cat_cntr]
7112f4f33ea0SBaptiste Daroussin#endif
71134c8945a0SNathan Whitehorn])
71144c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
71154c8945a0SNathan Whitehorndnl CF__INTL_HEAD version: 1 updated: 2007/07/26 17:35:47
71164c8945a0SNathan Whitehorndnl -------------
71174c8945a0SNathan Whitehorndnl Header-files needed for libintl compile-checks
71184c8945a0SNathan Whitehorndefine([CF__INTL_HEAD],[
71194c8945a0SNathan Whitehorn#include <libintl.h>
71204c8945a0SNathan Whitehornextern int _nl_msg_cat_cntr;
71214c8945a0SNathan Whitehorn])dnl
71224c8945a0SNathan Whitehorndnl ---------------------------------------------------------------------------
7123f4f33ea0SBaptiste Daroussindnl jm_GLIBC21 version: 4 updated: 2015/05/10 19:52:14
71244c8945a0SNathan Whitehorndnl ----------
71254c8945a0SNathan Whitehorndnl Inserted as requested by gettext 0.10.40
71264c8945a0SNathan Whitehorndnl File from /usr/share/aclocal
71274c8945a0SNathan Whitehorndnl glibc21.m4
71284c8945a0SNathan Whitehorndnl ====================
71294c8945a0SNathan Whitehorndnl serial 2
71304c8945a0SNathan Whitehorndnl
71314c8945a0SNathan Whitehorndnl Test for the GNU C Library, version 2.1 or newer.
71324c8945a0SNathan Whitehorndnl From Bruno Haible.
71334c8945a0SNathan WhitehornAC_DEFUN([jm_GLIBC21],
71344c8945a0SNathan Whitehorn[
71354c8945a0SNathan WhitehornAC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
71364c8945a0SNathan Whitehorn	ac_cv_gnu_library_2_1,
71374c8945a0SNathan Whitehorn	[AC_EGREP_CPP([Lucky GNU user],
71384c8945a0SNathan Whitehorn	[
71394c8945a0SNathan Whitehorn#include <features.h>
71404c8945a0SNathan Whitehorn#ifdef __GNU_LIBRARY__
71414c8945a0SNathan Whitehorn #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
71424c8945a0SNathan Whitehorn  Lucky GNU user
71434c8945a0SNathan Whitehorn #endif
71444c8945a0SNathan Whitehorn#endif
71454c8945a0SNathan Whitehorn	],
71464c8945a0SNathan Whitehorn	ac_cv_gnu_library_2_1=yes,
7147f4f33ea0SBaptiste Daroussin	ac_cv_gnu_library_2_1=no)])
71484c8945a0SNathan Whitehorn	AC_SUBST(GLIBC21)
71494c8945a0SNathan Whitehorn	GLIBC21="$ac_cv_gnu_library_2_1"
7150f4f33ea0SBaptiste Daroussin])
7151