aclocal.m4 revision 0bd37d32
11.14Sperrydnl $XTermId: aclocal.m4,v 1.365 2013/05/27 22:36:25 tom Exp $
21.1Slukemdnl
31.1Slukemdnl ---------------------------------------------------------------------------
41.1Slukemdnl
51.1Slukemdnl Copyright 1997-2012,2013 by Thomas E. Dickey
61.1Slukemdnl
71.1Slukemdnl                         All Rights Reserved
81.1Slukemdnl
91.1Slukemdnl Permission is hereby granted, free of charge, to any person obtaining a
101.1Slukemdnl copy of this software and associated documentation files (the
111.1Slukemdnl "Software"), to deal in the Software without restriction, including
121.1Slukemdnl without limitation the rights to use, copy, modify, merge, publish,
131.1Slukemdnl distribute, sublicense, and/or sell copies of the Software, and to
141.1Slukemdnl permit persons to whom the Software is furnished to do so, subject to
151.1Slukemdnl the following conditions:
161.1Slukemdnl
171.1Slukemdnl The above copyright notice and this permission notice shall be included
181.1Slukemdnl in all copies or substantial portions of the Software.
191.1Slukemdnl
201.1Slukemdnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
211.1Slukemdnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
221.1Slukemdnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
231.1Slukemdnl IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
241.1Slukemdnl CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
251.1Slukemdnl TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
261.1Slukemdnl SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
271.1Slukemdnl
281.1Slukemdnl Except as contained in this notice, the name(s) of the above copyright
291.1Slukemdnl holders shall not be used in advertising or otherwise to promote the
301.1Slukemdnl sale, use or other dealings in this Software without prior written
311.1Slukemdnl authorization.
321.1Slukemdnl
331.1Slukemdnl ---------------------------------------------------------------------------
341.1Slukemdnl See
351.1Slukemdnl		http://invisible-island.net/autoconf/autoconf.html
361.1Slukemdnl ---------------------------------------------------------------------------
371.1Slukemdnl ---------------------------------------------------------------------------
381.1Slukemdnl AM_LANGINFO_CODESET version: 3 updated: 2002/10/27 23:21:42
391.1Slukemdnl -------------------
401.1Slukemdnl Inserted as requested by gettext 0.10.40
411.1Slukemdnl File from /usr/share/aclocal
421.1Slukemdnl codeset.m4
431.1Slukemdnl ====================
441.1Slukemdnl serial AM1
451.1Slukemdnl
461.1Slukemdnl From Bruno Haible.
471.1SlukemAC_DEFUN([AM_LANGINFO_CODESET],
481.1Slukem[
491.6Swiz  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
501.1Slukem    [AC_TRY_LINK([#include <langinfo.h>],
511.1Slukem      [char* cs = nl_langinfo(CODESET);],
521.1Slukem      am_cv_langinfo_codeset=yes,
531.1Slukem      am_cv_langinfo_codeset=no)
541.1Slukem    ])
551.1Slukem  if test $am_cv_langinfo_codeset = yes; then
561.1Slukem    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
571.1Slukem      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
581.1Slukem  fi
591.1Slukem])dnl
601.1Slukemdnl ---------------------------------------------------------------------------
611.1Slukemdnl CF_ACVERSION_CHECK version: 4 updated: 2013/03/04 19:52:56
621.1Slukemdnl ------------------
631.6Swizdnl Conditionally generate script according to whether we're using a given autoconf.
641.1Slukemdnl
651.1Slukemdnl $1 = version to compare against
661.1Slukemdnl $2 = code to use if AC_ACVERSION is at least as high as $1.
671.1Slukemdnl $3 = code to use if AC_ACVERSION is older than $1.
681.1Slukemdefine([CF_ACVERSION_CHECK],
691.1Slukem[
701.1Slukemifdef([AC_ACVERSION], ,[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])dnl
711.1Slukemifdef([m4_version_compare],
721.1Slukem[m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
731.1Slukem[CF_ACVERSION_COMPARE(
741.1SlukemAC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
751.1SlukemAC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
761.1Slukemdnl ---------------------------------------------------------------------------
771.2Swizdnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
781.1Slukemdnl --------------------
791.1Slukemdnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
801.1Slukemdnl                      MAJOR2, MINOR2, TERNARY2,
811.1Slukemdnl                      PRINTABLE2, not FOUND, FOUND)
821.1Slukemdefine([CF_ACVERSION_COMPARE],
831.1Slukem[ifelse(builtin([eval], [$2 < $5]), 1,
841.2Swiz[ifelse([$8], , ,[$8])],
851.1Slukem[ifelse([$9], , ,[$9])])])dnl
861.1Slukemdnl ---------------------------------------------------------------------------
871.2Swizdnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
881.1Slukemdnl -------------
891.1Slukemdnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
901.1Slukemdnl The second parameter if given makes this macro verbose.
911.1Slukemdnl
921.1Slukemdnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
931.1Slukemdnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
941.2Swizdnl confused by the quotes (which require backslashes to keep them usable).
951.1SlukemAC_DEFUN([CF_ADD_CFLAGS],
961.1Slukem[
971.2Swizcf_fix_cppflags=no
981.1Slukemcf_new_cflags=
991.1Slukemcf_new_cppflags=
1001.1Slukemcf_new_extra_cppflags=
1011.1Slukem
1021.1Slukemfor cf_add_cflags in $1
1031.1Slukemdo
1041.1Slukemcase $cf_fix_cppflags in
1051.1Slukemno)
1061.13Swiz	case $cf_add_cflags in #(vi
1071.13Swiz	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
1081.1Slukem		case $cf_add_cflags in
1091.1Slukem		-D*)
1101.1Slukem			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
1111.1Slukem
1121.1Slukem			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
1131.1Slukem				&& test -z "${cf_tst_cflags}" \
1141.1Slukem				&& cf_fix_cppflags=yes
1151.1Slukem
1161.1Slukem			if test $cf_fix_cppflags = yes ; then
1171.1Slukem				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
1181.1Slukem				continue
1191.1Slukem			elif test "${cf_tst_cflags}" = "\"'" ; then
1201.1Slukem				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
1211.1Slukem				continue
1221.1Slukem			fi
1231.1Slukem			;;
1241.1Slukem		esac
1251.1Slukem		case "$CPPFLAGS" in
1261.1Slukem		*$cf_add_cflags) #(vi
1271.1Slukem			;;
1281.1Slukem		*) #(vi
1291.1Slukem			case $cf_add_cflags in #(vi
1301.1Slukem			-D*)
1311.1Slukem				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
1321.1Slukem				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
1331.1Slukem				;;
1341.1Slukem			esac
1351.1Slukem			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
1361.1Slukem			;;
1371.1Slukem		esac
1381.1Slukem		;;
1391.1Slukem	*)
1401.1Slukem		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
1411.1Slukem		;;
1421.1Slukem	esac
1431.1Slukem	;;
1441.1Slukemyes)
1451.1Slukem	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
1461.1Slukem
1471.1Slukem	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
1481.11Swiz
1491.1Slukem	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
1501.1Slukem		&& test -z "${cf_tst_cflags}" \
1511.1Slukem		&& cf_fix_cppflags=no
1521.1Slukem	;;
1531.1Slukemesac
1541.1Slukemdone
1551.1Slukem
1561.1Slukemif test -n "$cf_new_cflags" ; then
1571.1Slukem	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
1581.1Slukem	CFLAGS="$CFLAGS $cf_new_cflags"
1591.1Slukemfi
1601.1Slukem
1611.1Slukemif test -n "$cf_new_cppflags" ; then
1621.1Slukem	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
1631.1Slukem	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
1641.1Slukemfi
1651.1Slukem
1661.1Slukemif test -n "$cf_new_extra_cppflags" ; then
1671.1Slukem	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
1681.1Slukem	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
1691.1Slukemfi
1701.1Slukem
1711.1SlukemAC_SUBST(EXTRA_CPPFLAGS)
1721.1Slukem
1731.1Slukem])dnl
1741.1Slukemdnl ---------------------------------------------------------------------------
1751.1Slukemdnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
1761.1Slukemdnl ----------
1771.1Slukemdnl Add a library, used to enforce consistency.
1781.1Slukemdnl
1791.1Slukemdnl $1 = library to add, without the "-l"
1801.1Slukemdnl $2 = variable to update (default $LIBS)
1811.1SlukemAC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
1821.1Slukemdnl ---------------------------------------------------------------------------
1831.1Slukemdnl CF_ADD_LIBS version: 1 updated: 2010/06/02 05:03:05
1841.1Slukemdnl -----------
1851.1Slukemdnl Add one or more libraries, used to enforce consistency.
1861.1Slukemdnl
1871.1Slukemdnl $1 = libraries to add, with the "-l", etc.
1881.1Slukemdnl $2 = variable to update (default $LIBS)
1891.1SlukemAC_DEFUN([CF_ADD_LIBS],[ifelse($2,,LIBS,[$2])="$1 [$]ifelse($2,,LIBS,[$2])"])dnl
1901.1Slukemdnl ---------------------------------------------------------------------------
1911.1Slukemdnl CF_ADD_LIB_AFTER version: 2 updated: 2010/11/08 20:33:46
1921.1Slukemdnl ----------------
1931.1Slukemdnl Add a given library after another, e.g., following the one it satisfies a
1941.1Slukemdnl dependency for.
1951.1Slukemdnl
1961.1Slukemdnl $1 = the first library
1971.1Slukemdnl $2 = its dependency
1981.1SlukemAC_DEFUN([CF_ADD_LIB_AFTER],[
1991.1SlukemCF_VERBOSE(...before $LIBS)
2001.1SlukemLIBS=`echo "$LIBS" | sed -e "s/[[ 	]][[ 	]]*/ /g" -e "s,$1 ,$1 $2 ," -e 's/  / /g'`
2011.1SlukemCF_VERBOSE(...after  $LIBS)
2021.1Slukem])dnl
2031.1Slukemdnl ---------------------------------------------------------------------------
2041.1Slukemdnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
2051.1Slukemdnl --------------
2061.1Slukemdnl Allow user to disable a normally-on option.
2071.1SlukemAC_DEFUN([CF_ARG_DISABLE],
2081.1Slukem[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
2091.1Slukemdnl ---------------------------------------------------------------------------
2101.1Slukemdnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
2111.1Slukemdnl -------------
2121.1Slukemdnl Allow user to enable a normally-off option.
2131.1SlukemAC_DEFUN([CF_ARG_ENABLE],
2141.1Slukem[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
2151.1Slukemdnl ---------------------------------------------------------------------------
2161.1Slukemdnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
2171.1Slukemdnl -------------
2181.1Slukemdnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
2191.1Slukemdnl values.
2201.1Slukemdnl
2211.1Slukemdnl Parameters:
2221.1Slukemdnl $1 = option name
2231.1Slukemdnl $2 = help-string
2241.1Slukemdnl $3 = action to perform if option is not default
2251.1Slukemdnl $4 = action if perform if option is default
2261.1Slukemdnl $5 = default option value (either 'yes' or 'no')
2271.1SlukemAC_DEFUN([CF_ARG_OPTION],
2281.1Slukem[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
2291.1Slukem  if test "$enableval" != "$5" ; then
2301.1Slukemifelse([$3],,[    :]dnl
2311.1Slukem,[    $3]) ifelse([$4],,,[
2321.1Slukem  else
2331.1Slukem    $4])
2341.1Slukem  fi],[enableval=$5 ifelse([$4],,,[
2351.1Slukem  $4
2361.1Slukem])dnl
2371.1Slukem  ])])dnl
2381.1Slukemdnl ---------------------------------------------------------------------------
2391.1Slukemdnl CF_CC_ENV_FLAGS version: 1 updated: 2012/10/03 05:25:49
2401.1Slukemdnl ---------------
2411.1Slukemdnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
2421.1Slukemdnl into CC.  This will not help with broken scripts that wrap the compiler with
2431.1Slukemdnl options, but eliminates a more common category of user confusion.
2441.1SlukemAC_DEFUN([CF_CC_ENV_FLAGS],
2451.1Slukem[
2461.1Slukem# This should have been defined by AC_PROG_CC
2471.1Slukem: ${CC:=cc}
2481.1Slukem
2491.1SlukemAC_MSG_CHECKING(\$CC variable)
2501.1Slukemcase "$CC" in #(vi
2511.1Slukem*[[\ \	]]-[[IUD]]*)
2521.2Swiz	AC_MSG_RESULT(broken)
2531.1Slukem	AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
2541.1Slukem	# humor him...
2551.2Swiz	cf_flags=`echo "$CC" | sed -e 's/^[[^ 	]]*[[ 	]]//'`
2561.1Slukem	CC=`echo "$CC" | sed -e 's/[[ 	]].*//'`
2571.1Slukem	CF_ADD_CFLAGS($cf_flags)
2581.1Slukem	;;
2591.1Slukem*)
2601.1Slukem	AC_MSG_RESULT(ok)
2611.1Slukem	;;
2621.1Slukemesac
2631.1Slukem])dnl
2641.2Swizdnl ---------------------------------------------------------------------------
2651.1Slukemdnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
2661.1Slukemdnl --------------
2671.1Slukemdnl Check if we're accidentally using a cache from a different machine.
2681.1Slukemdnl Derive the system name, as a check for reusing the autoconf cache.
2691.1Slukemdnl
2701.1Slukemdnl If we've packaged config.guess and config.sub, run that (since it does a
2711.1Slukemdnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
2721.1Slukemdnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
2731.1Slukemdnl which is useful in cross-compiles.
2741.1Slukemdnl
2751.1Slukemdnl Note: we would use $ac_config_sub, but that is one of the places where
2761.1Slukemdnl autoconf 2.5x broke compatibility with autoconf 2.13
2771.1SlukemAC_DEFUN([CF_CHECK_CACHE],
2781.1Slukem[
2791.1Slukemif test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
2801.1Slukem	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
2811.1Slukem	system_name="$host_os"
2821.1Slukemelse
2831.1Slukem	system_name="`(uname -s -r) 2>/dev/null`"
2841.1Slukem	if test -z "$system_name" ; then
2851.1Slukem		system_name="`(hostname) 2>/dev/null`"
2861.1Slukem	fi
2871.1Slukemfi
2881.1Slukemtest -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
2891.1SlukemAC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
2901.1Slukem
2911.1Slukemtest -z "$system_name" && system_name="$cf_cv_system_name"
2921.1Slukemtest -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
2931.1Slukem
2941.1Slukemif test ".$system_name" != ".$cf_cv_system_name" ; then
2951.1Slukem	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
2961.1Slukem	AC_MSG_ERROR("Please remove config.cache and try again.")
2971.1Slukemfi
2981.1Slukem])dnl
2991.1Slukemdnl ---------------------------------------------------------------------------
3001.1Slukemdnl CF_CHECK_CFLAGS version: 2 updated: 2001/12/30 19:09:58
3011.9Swizdnl ---------------
3021.1Slukemdnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
3031.1Slukemdnl a build-configuration such as imake.  These have the pitfall that they
3041.1Slukemdnl often contain compiler-specific options which we cannot use, mixed with
3051.1Slukemdnl preprocessor options that we usually can.
3061.1SlukemAC_DEFUN([CF_CHECK_CFLAGS],
3071.1Slukem[
3081.1SlukemCF_VERBOSE(checking additions to CFLAGS)
3091.1Slukemcf_check_cflags="$CFLAGS"
3101.1Slukemcf_check_cppflags="$CPPFLAGS"
3111.1SlukemCF_ADD_CFLAGS($1,yes)
3121.1Slukemif test "$cf_check_cflags" != "$CFLAGS" ; then
3131.1SlukemAC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
3141.1Slukem	[CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
3151.1Slukem	 if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
3161.1Slukem		 CF_VERBOSE(but keeping change to \$CPPFLAGS)
3171.1Slukem	 fi
3181.1Slukem	 CFLAGS="$cf_check_flags"])
3191.1Slukemfi
3201.1Slukem])dnl
3211.1Slukemdnl ---------------------------------------------------------------------------
3221.1Slukemdnl CF_CHECK_ERRNO version: 11 updated: 2010/05/26 05:38:42
3231.1Slukemdnl --------------
3241.1Slukemdnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
3251.1Slukemdnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
3261.1Slukemdnl ourselves.
3271.1Slukemdnl
3281.1Slukemdnl $1 = the name to check
3291.1Slukemdnl $2 = the assumed type
3301.1SlukemAC_DEFUN([CF_CHECK_ERRNO],
3311.1Slukem[
3321.1SlukemAC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
3331.1Slukem    AC_TRY_COMPILE([
3341.1Slukem#ifdef HAVE_STDLIB_H
3351.1Slukem#include <stdlib.h>
3361.1Slukem#endif
3371.1Slukem#include <stdio.h>
3381.1Slukem#include <sys/types.h>
3391.1Slukem#include <errno.h> ],
3401.1Slukem    ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1,
3411.1Slukem    [cf_cv_dcl_$1=yes],
3421.5Smrg    [cf_cv_dcl_$1=no])
3431.1Slukem])
3441.1Slukem
3451.1Slukemif test "$cf_cv_dcl_$1" = no ; then
3461.1Slukem    CF_UPPER(cf_result,decl_$1)
3471.1Slukem    AC_DEFINE_UNQUOTED($cf_result)
3481.1Slukemfi
3491.1Slukem
3501.1Slukem# It's possible (for near-UNIX clones) that the data doesn't exist
3511.1SlukemCF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
3521.1Slukem])dnl
3531.1Slukemdnl ---------------------------------------------------------------------------
3541.1Slukemdnl CF_CHECK_EXTERN_DATA version: 3 updated: 2001/12/30 18:03:23
3551.1Slukemdnl --------------------
3561.1Slukemdnl Check for existence of external data in the current set of libraries.  If
3571.1Slukemdnl we can modify it, it's real enough.
3581.1Slukemdnl $1 = the name to check
3591.1Slukemdnl $2 = its type
3601.1SlukemAC_DEFUN([CF_CHECK_EXTERN_DATA],
3611.1Slukem[
3621.1SlukemAC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
3631.1Slukem    AC_TRY_LINK([
3641.1Slukem#undef $1
3651.1Slukemextern $2 $1;
3661.1Slukem],
3671.1Slukem    [$1 = 2],
3681.1Slukem    [cf_cv_have_$1=yes],
3691.1Slukem    [cf_cv_have_$1=no])
3701.1Slukem])
3711.1Slukem
3721.1Slukemif test "$cf_cv_have_$1" = yes ; then
3731.1Slukem    CF_UPPER(cf_result,have_$1)
3741.1Slukem    AC_DEFINE_UNQUOTED($cf_result)
3751.1Slukemfi
3761.1Slukem
3771.1Slukem])dnl
3781.1Slukemdnl ---------------------------------------------------------------------------
3791.1Slukemdnl CF_CLANG_COMPILER version: 1 updated: 2012/06/16 14:55:39
3801.1Slukemdnl -----------------
3811.1Slukemdnl Check if the given compiler is really clang.  clang's C driver defines
3821.1Slukemdnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
3831.1Slukemdnl not ignore some gcc options.
3841.1Slukemdnl
3851.1Slukemdnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
3861.1Slukemdnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
3871.4Swizdnl the wrappers for gcc and g++ warnings.
3881.1Slukemdnl
3891.1Slukemdnl $1 = GCC (default) or GXX
3901.1Slukemdnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
3911.1Slukemdnl $3 = CFLAGS (default) or CXXFLAGS
3921.1SlukemAC_DEFUN([CF_CLANG_COMPILER],[
3931.1Slukemifelse([$2],,CLANG_COMPILER,[$2])=no
3941.1Slukem
3951.1Slukemif test "$ifelse([$1],,[$1],GCC)" = yes ; then
3961.1Slukem	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
3971.1Slukem	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
3981.1Slukem	ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
3991.1Slukem	AC_TRY_COMPILE([],[
4001.1Slukem#ifdef __clang__
4011.1Slukem#else
4021.1Slukemmake an error
4031.1Slukem#endif
4041.1Slukem],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
4051.1Slukemcf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
4061.1Slukem],[])
4071.1Slukem	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
4081.1Slukem	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
4091.1Slukemfi
4101.1Slukem])
4111.1Slukemdnl ---------------------------------------------------------------------------
4121.1Slukemdnl CF_DISABLE_DESKTOP version: 2 updated: 2011/04/22 05:17:37
4131.1Slukemdnl ------------------
4141.1Slukemdnl Handle a configure option "--disable-desktop", which sets a shell
4151.1Slukemdnl variable $desktop_utils to a "#" if the feature is not wanted, or to an
4161.1Slukemdnl empty string if enabled.  The variable is used to substitute in front of
4171.1Slukemdnl corresponding makefile-rules.
4181.1Slukemdnl
4191.1Slukemdnl It also tells the configure script to substitute the environment variable
4201.1Slukemdnl $DESKTOP_FLAGS, which can be used by external scripts to customize the
4211.1Slukemdnl invocation of desktop-file-util.
4221.1Slukemdnl
4231.1Slukemdnl $1 = program name
4241.1SlukemAC_DEFUN([CF_DISABLE_DESKTOP],[
4251.1Slukem# Comment-out the install-desktop rule if the desktop-utils are not found.
4261.1SlukemAC_MSG_CHECKING(if you want to install desktop files)
4271.1SlukemCF_ARG_OPTION(desktop,
4281.1Slukem	[  --disable-desktop       disable install of $1 desktop files],
4291.1Slukem	[enable_desktop=$enableval],
4301.1Slukem	[enable_desktop=$enableval],yes)
4311.1SlukemAC_MSG_RESULT($enable_desktop)
4321.1Slukem
4331.1Slukemdesktop_utils=
4341.1Slukemif test "$enable_desktop" = yes ; then
4351.1SlukemAC_CHECK_PROG(desktop_utils,desktop-file-install,yes,no)
4361.1Slukemfi
4371.1Slukem
4381.1Slukemtest "$desktop_utils" = yes && desktop_utils= || desktop_utils="#"
4391.1SlukemAC_SUBST(DESKTOP_FLAGS)
4401.1Slukem])
4411.1Slukemdnl ---------------------------------------------------------------------------
4421.1Slukemdnl CF_DISABLE_ECHO version: 12 updated: 2012/10/06 16:30:28
4431.1Slukemdnl ---------------
4441.1Slukemdnl You can always use "make -n" to see the actual options, but it's hard to
4451.1Slukemdnl pick out/analyze warning messages when the compile-line is long.
4461.1Slukemdnl
4471.1Slukemdnl Sets:
4481.1Slukemdnl	ECHO_LT - symbol to control if libtool is verbose
4491.1Slukemdnl	ECHO_LD - symbol to prefix "cc -o" lines
4501.1Slukemdnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
4511.1Slukemdnl	SHOW_CC - symbol to put before explicit "cc -c" lines
4521.1Slukemdnl	ECHO_CC - symbol to put before any "cc" line
4531.1Slukemdnl
4541.1SlukemAC_DEFUN([CF_DISABLE_ECHO],[
4551.1SlukemAC_MSG_CHECKING(if you want to see long compiling messages)
4561.1SlukemCF_ARG_DISABLE(echo,
4571.1Slukem	[  --disable-echo          do not display "compiling" commands],
4581.1Slukem	[
4591.1Slukem    ECHO_LT='--silent'
4601.1Slukem    ECHO_LD='@echo linking [$]@;'
4611.1Slukem    RULE_CC='@echo compiling [$]<'
4621.1Slukem    SHOW_CC='@echo compiling [$]@'
4631.1Slukem    ECHO_CC='@'
4641.1Slukem],[
4651.1Slukem    ECHO_LT=''
4661.1Slukem    ECHO_LD=''
4671.1Slukem    RULE_CC=''
4681.1Slukem    SHOW_CC=''
4691.1Slukem    ECHO_CC=''
4701.1Slukem])
4711.1SlukemAC_MSG_RESULT($enableval)
4721.5SmrgAC_SUBST(ECHO_LT)
4731.1SlukemAC_SUBST(ECHO_LD)
4741.1SlukemAC_SUBST(RULE_CC)
4751.1SlukemAC_SUBST(SHOW_CC)
4761.1SlukemAC_SUBST(ECHO_CC)
4771.1Slukem])dnl
4781.1Slukemdnl ---------------------------------------------------------------------------
4791.1Slukemdnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
4801.1Slukemdnl ----------------
4811.1Slukemdnl Combine no-leak checks with the libraries or tools that are used for the
4821.1Slukemdnl checks.
4831.1SlukemAC_DEFUN([CF_DISABLE_LEAKS],[
4841.1Slukem
4851.1SlukemAC_REQUIRE([CF_WITH_DMALLOC])
4861.1SlukemAC_REQUIRE([CF_WITH_DBMALLOC])
4871.1SlukemAC_REQUIRE([CF_WITH_VALGRIND])
4881.1Slukem
4891.1SlukemAC_MSG_CHECKING(if you want to perform memory-leak testing)
4901.1SlukemAC_ARG_ENABLE(leaks,
4911.3Sitojun	[  --disable-leaks         test: free permanent memory, analyze leaks],
4921.3Sitojun	[if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
4931.1Slukem	: ${with_no_leaks:=no})
4941.1SlukemAC_MSG_RESULT($with_no_leaks)
4951.1Slukem
4961.1Slukemif test "$with_no_leaks" = yes ; then
4971.1Slukem	AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
4981.1Slukem	AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
4991.1Slukemfi
5001.1Slukem])dnl
5011.1Slukemdnl ---------------------------------------------------------------------------
5021.1Slukemdnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
5031.1Slukemdnl ---------------------
5041.1Slukemdnl The rpath-hack makes it simpler to build programs, particularly with the
5051.1Slukemdnl *BSD ports which may have essential libraries in unusual places.  But it
5061.1Slukemdnl can interfere with building an executable for the base system.  Use this
5071.1Slukemdnl option in that case.
5081.1SlukemAC_DEFUN([CF_DISABLE_RPATH_HACK],
5091.3Sitojun[
5101.3SitojunAC_MSG_CHECKING(if rpath-hack should be disabled)
5111.1SlukemCF_ARG_DISABLE(rpath-hack,
5121.1Slukem	[  --disable-rpath-hack    don't add rpath options for additional libraries],
5131.1Slukem	[cf_disable_rpath_hack=yes],
5141.1Slukem	[cf_disable_rpath_hack=no])
5151.1SlukemAC_MSG_RESULT($cf_disable_rpath_hack)
5161.1Slukemif test "$cf_disable_rpath_hack" = no ; then
5171.1Slukem	CF_RPATH_HACK
5181.1Slukemfi
5191.1Slukem])
5201.1Slukemdnl ---------------------------------------------------------------------------
5211.1Slukemdnl CF_ENABLE_NARROWPROTO version: 3 updated: 2006/02/12 17:46:00
5221.1Slukemdnl ---------------------
5231.1Slukemdnl If this is not set properly, Xaw's scrollbars will not work.
5241.1Slukemdnl The so-called "modular" configuration for X.org omits most of the
5251.1Slukemdnl configure checks that would be needed to provide compatibility with
5261.1Slukemdnl older X builds.  This one breaks things noticeably.
5271.1SlukemAC_DEFUN([CF_ENABLE_NARROWPROTO],
5281.1Slukem[
5291.1SlukemAC_MSG_CHECKING(if you want narrow prototypes for X libraries)
5301.1Slukem
5311.1Slukemcase `$ac_config_guess` in #(vi
5321.1Slukem*cygwin*|*freebsd*|*gnu*|*irix5*|*irix6*|*linux-gnu*|*netbsd*|*openbsd*|*qnx*|*sco*|*sgi*) #(vi
5331.1Slukem	cf_default_narrowproto=yes
5341.1Slukem	;;
5351.1Slukem*)
5361.1Slukem	cf_default_narrowproto=no
5371.1Slukem	;;
5381.1Slukemesac
5391.1Slukem
5401.1SlukemCF_ARG_OPTION(narrowproto,
5411.1Slukem	[  --enable-narrowproto    enable narrow prototypes for X libraries],
5421.1Slukem	[enable_narrowproto=$enableval],
5431.1Slukem	[enable_narrowproto=$cf_default_narrowproto],
5441.1Slukem	[$cf_default_narrowproto])
5451.1SlukemAC_MSG_RESULT($enable_narrowproto)
5461.1Slukem])
5471.1Slukemdnl ---------------------------------------------------------------------------
5481.1Slukemdnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
5491.1Slukemdnl --------
5501.1Slukemdnl Check if 'errno' is declared in <errno.h>
5511.1SlukemAC_DEFUN([CF_ERRNO],
5521.1Slukem[
5531.1SlukemCF_CHECK_ERRNO(errno)
5541.1Slukem])dnl
5551.1Slukemdnl ---------------------------------------------------------------------------
5561.1Slukemdnl CF_FUNC_GRANTPT version: 10 updated: 2013/04/17 05:31:24
5571.1Slukemdnl ---------------
5581.1Slukemdnl Check for grantpt versus openpty, as well as functions that "should" be
5591.1Slukemdnl available if grantpt is available.
5601.1SlukemAC_DEFUN([CF_FUNC_GRANTPT],[
5611.1Slukem
5621.1SlukemAC_CHECK_HEADERS( \
5631.1Slukemstropts.h \
5641.1Slukem)
5651.1Slukem
5661.1Slukemcf_func_grantpt="grantpt ptsname"
5671.1Slukemcase $host_os in #(vi
5681.1Slukemdarwin[[0-9]].*) #(vi
5691.1Slukem	;;
5701.1Slukem*)
5711.1Slukem	cf_func_grantpt="$cf_func_grantpt posix_openpt"
5721.1Slukem	;;
5731.1Slukemesac
5741.1Slukem
5751.1SlukemAC_CHECK_FUNCS($cf_func_grantpt)
5761.1Slukem
5771.1Slukemcf_grantpt_opts=
5781.1Slukemif test "x$ac_cv_func_grantpt" = "xyes" ; then
5791.1Slukem	AC_MSG_CHECKING(if grantpt really works)
5801.1Slukem	AC_TRY_LINK(CF__GRANTPT_HEAD,CF__GRANTPT_BODY,[
5811.1Slukem	AC_TRY_RUN(CF__GRANTPT_HEAD
5821.1Slukemint main(void)
5831.1Slukem{
5841.1SlukemCF__GRANTPT_BODY
5851.1Slukem}
5861.1Slukem,
5871.1Slukem,ac_cv_func_grantpt=no
5881.1Slukem,ac_cv_func_grantpt=maybe)
5891.1Slukem	],ac_cv_func_grantpt=no)
5901.14Sperry	AC_MSG_RESULT($ac_cv_func_grantpt)
5911.14Sperry
5921.14Sperry	if test "x$ac_cv_func_grantpt" != "xno" ; then
5931.14Sperry
5941.1Slukem		if test "x$ac_cv_func_grantpt" = "xyes" ; then
5951.14Sperry			AC_MSG_CHECKING(for pty features)
5961.1Slukemdnl if we have no stropts.h, skip the checks for streams modules
5971.1Slukem			if test "x$ac_cv_header_stropts_h" = xyes
5981.1Slukem			then
5991.1Slukem				cf_pty_this=0
6001.1Slukem			else
6011.1Slukem				cf_pty_this=3
6021.1Slukem			fi
6031.1Slukem
6041.1Slukem			cf_pty_defines=
6051.1Slukem			while test $cf_pty_this != 6
6061.1Slukem			do
6071.1Slukem
6081.1Slukem				cf_pty_feature=
6091.1Slukem				cf_pty_next=`expr $cf_pty_this + 1`
6101.1Slukem				CF_MSG_LOG(pty feature test $cf_pty_next:5)
6111.1Slukem				AC_TRY_RUN(#define CONFTEST $cf_pty_this
6121.1Slukem$cf_pty_defines
6131.1SlukemCF__GRANTPT_HEAD
6141.1Slukemint main(void)
6151.1Slukem{
6161.1SlukemCF__GRANTPT_BODY
6171.1Slukem}
6181.1Slukem,
6191.1Slukem[
6201.1Slukem				case $cf_pty_next in #(vi
6211.1Slukem				1) #(vi - streams
6221.1Slukem					cf_pty_feature=ptem
6231.1Slukem					;;
6241.1Slukem				2) #(vi - streams
6251.1Slukem					cf_pty_feature=ldterm
6261.1Slukem					;;
6271.1Slukem				3) #(vi - streams
6281.1Slukem					cf_pty_feature=ttcompat
6291.1Slukem					;;
6301.1Slukem				4) #(vi
6311.1Slukem					cf_pty_feature=pty_isatty
6321.1Slukem					;;
6331.1Slukem				5) #(vi
6341.1Slukem					cf_pty_feature=pty_tcsetattr
6351.1Slukem					;;
6361.1Slukem				6) #(vi
6371.1Slukem					cf_pty_feature=tty_tcsetattr
6381.1Slukem					;;
6391.1Slukem				esac
6401.1Slukem],[
6411.1Slukem				case $cf_pty_next in #(vi
6421.1Slukem				1|2|3)
6431.1Slukem					CF_MSG_LOG(skipping remaining streams features $cf_pty_this..2)
6441.1Slukem					cf_pty_next=3
6451.1Slukem					;;
6461.1Slukem				esac
6471.8Sitojun])
6481.7Sitojun				if test -n "$cf_pty_feature"
6491.1Slukem				then
6501.7Sitojun					cf_pty_defines="$cf_pty_defines
6511.1Slukem#define CONFTEST_$cf_pty_feature 1
6521.1Slukem"
6531.1Slukem					cf_grantpt_opts="$cf_grantpt_opts $cf_pty_feature"
6541.11Swiz				fi
6551.1Slukem
6561.1Slukem				cf_pty_this=$cf_pty_next
6571.1Slukem			done
6581.1Slukem			AC_MSG_RESULT($cf_grantpt_opts)
6591.1Slukem			cf_grantpt_opts=`echo "$cf_grantpt_opts" | sed -e 's/ isatty//'`
6601.1Slukem		fi
6611.1Slukem	fi
6621.1Slukemfi
6631.1Slukem
6641.2Swizdnl If we found grantpt, but no features, e.g., for streams or if we are not
6651.1Slukemdnl able to use tcsetattr, then give openpty a try.  In particular, Darwin 10.7
6661.1Slukemdnl has a more functional openpty than posix_openpt.
6671.1Slukemdnl
6681.1Slukemdnl There is no configure run-test for openpty, since older implementations do
6691.1Slukemdnl not always run properly as a non-root user.  For that reason, we also allow
6701.1Slukemdnl the configure script to suppress this check entirely with $disable_openpty.
6711.1Slukemif test "x$disable_openpty" != "xyes" || test -z "$cf_grantpt_opts" ; then
6721.1Slukem	AC_CHECK_LIB(util, openpty, [cf_have_openpty=yes],[cf_have_openpty=no])
6731.1Slukem	if test "$cf_have_openpty" = yes ; then
6741.1Slukem		ac_cv_func_grantpt=no
6751.1Slukem		LIBS="-lutil $LIBS"
6761.1Slukem		AC_DEFINE(HAVE_OPENPTY,1,[Define to 1 if you have the openpty function])
6771.1Slukem		AC_CHECK_HEADERS( \
6781.1Slukem			util.h \
6791.1Slukem			libutil.h \
6801.1Slukem			pty.h \
6811.1Slukem		)
6821.1Slukem	fi
6831.1Slukemfi
6841.1Slukem
6851.1Slukemdnl If we did not settle on using openpty, fill in the definitions for grantpt.
6861.1Slukemif test "x$ac_cv_func_grantpt" != xno
6871.1Slukemthen
6881.1Slukem	CF_VERBOSE(will rely upon grantpt)
6891.1Slukem	AC_DEFINE(HAVE_WORKING_GRANTPT,1,[Define to 1 if the grantpt function seems to work])
6901.1Slukem	for cf_feature in $cf_grantpt_opts
6911.1Slukem	do
6921.1Slukem		cf_feature=`echo "$cf_feature" | sed -e 's/ //g'`
6931.1Slukem		CF_UPPER(cf_FEATURE,$cf_feature)
6941.1Slukem		AC_DEFINE_UNQUOTED(HAVE_GRANTPT_$cf_FEATURE)
6951.1Slukem	done
6961.1Slukemelif test "x$cf_have_openpty" = xno
6971.1Slukemthen
6981.1Slukem	CF_VERBOSE(will rely upon BSD-pseudoterminals)
6991.1Slukemelse
7001.1Slukem	CF_VERBOSE(will rely upon openpty)
7011.1Slukemfi
7021.1Slukem])dnl
7031.1Slukemdnl ---------------------------------------------------------------------------
7041.1Slukemdnl CF_FUNC_TGETENT version: 19 updated: 2012/10/04 20:12:20
7051.1Slukemdnl ---------------
7061.1Slukemdnl Check for tgetent function in termcap library.  If we cannot find this,
7071.1Slukemdnl we'll use the $LINES and $COLUMNS environment variables to pass screen
7081.1Slukemdnl size information to subprocesses.  (We cannot use terminfo's compatibility
7091.1Slukemdnl function, since it cannot provide the termcap-format data).
7101.1Slukemdnl
7111.1Slukemdnl If the --disable-full-tgetent option is given, we'll settle for the first
7121.1Slukemdnl tgetent function we find.  Since the search list in that case does not
7131.1Slukemdnl include the termcap library, that allows us to default to terminfo.
7141.1SlukemAC_DEFUN([CF_FUNC_TGETENT],
7151.1Slukem[
7161.1Slukem# compute a reasonable value for $TERM to give tgetent(), since we may be
7171.1Slukem# running in 'screen', which sets $TERMCAP to a specific entry that is not
7181.1Slukem# necessarily in /etc/termcap - unsetenv is not portable, so we cannot simply
7191.12Skleink# discard $TERMCAP.
7201.12Skleinkcf_TERMVAR=vt100
7211.1Slukemif test -n "$TERMCAP"
7221.1Slukemthen
7231.1Slukem	cf_TERMCAP=`echo "$TERMCAP" | tr '\n' ' ' | sed -e 's/^..|//' -e 's/|.*//'`
7241.1Slukem	case "$cf_TERMCAP" in #(vi
7251.1Slukem	screen*.*) #(vi
7261.1Slukem		;;
7271.1Slukem	*)
7281.1Slukem		cf_TERMVAR="$cf_TERMCAP"
7291.1Slukem		;;
7301.1Slukem	esac
7311.1Slukemfi
7321.1Slukemtest -z "$cf_TERMVAR" && cf_TERMVAR=vt100
7331.1Slukem
7341.1SlukemAC_MSG_CHECKING(if we want full tgetent function)
7351.1SlukemCF_ARG_DISABLE(full-tgetent,
7361.1Slukem	[  --disable-full-tgetent  disable check for full tgetent function],
7371.1Slukem	cf_full_tgetent=no,
7381.1Slukem	cf_full_tgetent=yes,yes)
7391.1SlukemAC_MSG_RESULT($cf_full_tgetent)
7401.1Slukem
7411.1Slukemif test "$cf_full_tgetent" = yes ; then
7421.1Slukem	cf_test_message="full tgetent"
7431.1Slukemelse
7441.1Slukem	cf_test_message="tgetent"
7451.1Slukemfi
7461.1Slukem
7471.1SlukemAC_CACHE_CHECK(for $cf_test_message function,cf_cv_lib_tgetent,[
7481.1Slukemcf_save_LIBS="$LIBS"
7491.1Slukemcf_cv_lib_tgetent=no
7501.1Slukemif test "$cf_full_tgetent" = yes ; then
7511.2Swiz	cf_TERMLIB="otermcap termcap termlib ncurses curses"
7521.1Slukem	cf_TERMTST="buffer[[0]] == 0"
7531.1Slukemelse
7541.1Slukem	cf_TERMLIB="termlib ncurses curses"
7551.1Slukem	cf_TERMTST="0"
7561.1Slukemfi
7571.1Slukemfor cf_termlib in '' $cf_TERMLIB ; do
7581.1Slukem	LIBS="$cf_save_LIBS"
7591.1Slukem	test -n "$cf_termlib" && CF_ADD_LIB($cf_termlib)
7601.1Slukem	AC_TRY_RUN([
7611.1Slukem/* terminfo implementations ignore the buffer argument, making it useless for
7621.1Slukem * the xterm application, which uses this information to make a new TERMCAP
7631.1Slukem * environment variable.
7641.1Slukem */
7651.1Slukemint main()
7661.1Slukem{
7671.1Slukem	char buffer[1024];
7681.1Slukem	buffer[0] = 0;
7691.1Slukem	tgetent(buffer, "$cf_TERMVAR");
7701.1Slukem	${cf_cv_main_return:-return} ($cf_TERMTST); }],
7711.1Slukem	[echo "yes, there is a termcap/tgetent in $cf_termlib" 1>&AC_FD_CC
7721.1Slukem	 if test -n "$cf_termlib" ; then
7731.1Slukem	 	cf_cv_lib_tgetent="-l$cf_termlib"
7741.1Slukem	 else
7751.1Slukem	 	cf_cv_lib_tgetent=yes
7761.1Slukem	 fi
7771.1Slukem	 break],
7781.1Slukem	[echo "no, there is no termcap/tgetent in $cf_termlib" 1>&AC_FD_CC],
7791.1Slukem	[echo "cross-compiling, cannot verify if a termcap/tgetent is present in $cf_termlib" 1>&AC_FD_CC])
7801.1Slukemdone
7811.1SlukemLIBS="$cf_save_LIBS"
7821.1Slukem])
783
784# If we found a working tgetent(), set LIBS and check for termcap.h.
785# (LIBS cannot be set inside AC_CACHE_CHECK; the commands there should
786# not have side effects other than setting the cache variable, because
787# they are not executed when a cached value exists.)
788if test "x$cf_cv_lib_tgetent" != xno ; then
789	test "x$cf_cv_lib_tgetent" != xyes && CF_ADD_LIBS($cf_cv_lib_tgetent)
790	AC_DEFINE(USE_TERMCAP,1,[Define 1 to indicate that working tgetent is found])
791	if test "$cf_full_tgetent" = no ; then
792		AC_TRY_COMPILE([
793#include <termcap.h>],[
794#ifdef NCURSES_VERSION
795make an error
796#endif],[AC_DEFINE(HAVE_TERMCAP_H)])
797	else
798		AC_CHECK_HEADERS(termcap.h)
799	fi
800else
801        # If we didn't find a tgetent() that supports the buffer
802        # argument, look again to see whether we can find even
803        # a crippled one.  A crippled tgetent() is still useful to
804        # validate values for the TERM environment variable given to
805        # child processes.
806	AC_CACHE_CHECK(for partial tgetent function,cf_cv_lib_part_tgetent,[
807	cf_cv_lib_part_tgetent=no
808	for cf_termlib in $cf_TERMLIB ; do
809		LIBS="$cf_save_LIBS -l$cf_termlib"
810		AC_TRY_LINK([],[tgetent(0, "$cf_TERMVAR")],
811			[echo "there is a terminfo/tgetent in $cf_termlib" 1>&AC_FD_CC
812			 cf_cv_lib_part_tgetent="-l$cf_termlib"
813			 break])
814	done
815	LIBS="$cf_save_LIBS"
816	])
817
818	if test "$cf_cv_lib_part_tgetent" != no ; then
819		CF_ADD_LIBS($cf_cv_lib_part_tgetent)
820		AC_CHECK_HEADERS(termcap.h)
821
822                # If this is linking against ncurses, we'll trigger the
823                # ifdef in resize.c that turns the termcap stuff back off.
824		AC_DEFINE(USE_TERMINFO,1,[Define to 1 to indicate that terminfo provides the tgetent interface])
825	fi
826fi
827])dnl
828dnl ---------------------------------------------------------------------------
829dnl CF_GCC_ATTRIBUTES version: 16 updated: 2012/10/02 20:55:03
830dnl -----------------
831dnl Test for availability of useful gcc __attribute__ directives to quiet
832dnl compiler warnings.  Though useful, not all are supported -- and contrary
833dnl to documentation, unrecognized directives cause older compilers to barf.
834AC_DEFUN([CF_GCC_ATTRIBUTES],
835[
836if test "$GCC" = yes
837then
838cat > conftest.i <<EOF
839#ifndef GCC_PRINTF
840#define GCC_PRINTF 0
841#endif
842#ifndef GCC_SCANF
843#define GCC_SCANF 0
844#endif
845#ifndef GCC_NORETURN
846#define GCC_NORETURN /* nothing */
847#endif
848#ifndef GCC_UNUSED
849#define GCC_UNUSED /* nothing */
850#endif
851EOF
852if test "$GCC" = yes
853then
854	AC_CHECKING([for $CC __attribute__ directives])
855cat > conftest.$ac_ext <<EOF
856#line __oline__ "${as_me:-configure}"
857#include "confdefs.h"
858#include "conftest.h"
859#include "conftest.i"
860#if	GCC_PRINTF
861#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
862#else
863#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
864#endif
865#if	GCC_SCANF
866#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
867#else
868#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
869#endif
870extern void wow(char *,...) GCC_SCANFLIKE(1,2);
871extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
872extern void foo(void) GCC_NORETURN;
873int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
874EOF
875	cf_printf_attribute=no
876	cf_scanf_attribute=no
877	for cf_attribute in scanf printf unused noreturn
878	do
879		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
880		cf_directive="__attribute__(($cf_attribute))"
881		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
882
883		case $cf_attribute in #(vi
884		printf) #(vi
885			cf_printf_attribute=yes
886			cat >conftest.h <<EOF
887#define GCC_$cf_ATTRIBUTE 1
888EOF
889			;;
890		scanf) #(vi
891			cf_scanf_attribute=yes
892			cat >conftest.h <<EOF
893#define GCC_$cf_ATTRIBUTE 1
894EOF
895			;;
896		*) #(vi
897			cat >conftest.h <<EOF
898#define GCC_$cf_ATTRIBUTE $cf_directive
899EOF
900			;;
901		esac
902
903		if AC_TRY_EVAL(ac_compile); then
904			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
905			cat conftest.h >>confdefs.h
906			case $cf_attribute in #(vi
907			noreturn) #(vi
908				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
909				;;
910			printf) #(vi
911				cf_value='/* nothing */'
912				if test "$cf_printf_attribute" != no ; then
913					cf_value='__attribute__((format(printf,fmt,var)))'
914					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
915				fi
916				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
917				;;
918			scanf) #(vi
919				cf_value='/* nothing */'
920				if test "$cf_scanf_attribute" != no ; then
921					cf_value='__attribute__((format(scanf,fmt,var)))'
922					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
923				fi
924				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
925				;;
926			unused) #(vi
927				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
928				;;
929			esac
930		fi
931	done
932else
933	fgrep define conftest.i >>confdefs.h
934fi
935rm -rf conftest*
936fi
937])dnl
938dnl ---------------------------------------------------------------------------
939dnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
940dnl --------------
941dnl Find version of gcc
942AC_DEFUN([CF_GCC_VERSION],[
943AC_REQUIRE([AC_PROG_CC])
944GCC_VERSION=none
945if test "$GCC" = yes ; then
946	AC_MSG_CHECKING(version of $CC)
947	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.]].*//'`"
948	test -z "$GCC_VERSION" && GCC_VERSION=unknown
949	AC_MSG_RESULT($GCC_VERSION)
950fi
951])dnl
952dnl ---------------------------------------------------------------------------
953dnl CF_GCC_WARNINGS version: 29 updated: 2012/06/16 14:55:39
954dnl ---------------
955dnl Check if the compiler supports useful warning options.  There's a few that
956dnl we don't use, simply because they're too noisy:
957dnl
958dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
959dnl	-Wredundant-decls (system headers make this too noisy)
960dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
961dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
962dnl		is enabled for ncurses using "--enable-const".
963dnl	-pedantic
964dnl
965dnl Parameter:
966dnl	$1 is an optional list of gcc warning flags that a particular
967dnl		application might want to use, e.g., "no-unused" for
968dnl		-Wno-unused
969dnl Special:
970dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
971dnl
972AC_DEFUN([CF_GCC_WARNINGS],
973[
974AC_REQUIRE([CF_GCC_VERSION])
975CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
976CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
977
978cat > conftest.$ac_ext <<EOF
979#line __oline__ "${as_me:-configure}"
980int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
981EOF
982
983if test "$INTEL_COMPILER" = yes
984then
985# The "-wdXXX" options suppress warnings:
986# remark #1419: external declaration in primary source file
987# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
988# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
989# remark #193: zero used for undefined preprocessing identifier
990# remark #593: variable "curs_sb_left_arrow" was set but never used
991# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
992# remark #869: parameter "tw" was never referenced
993# remark #981: operands are evaluated in unspecified order
994# warning #279: controlling expression is constant
995
996	AC_CHECKING([for $CC warning options])
997	cf_save_CFLAGS="$CFLAGS"
998	EXTRA_CFLAGS="-Wall"
999	for cf_opt in \
1000		wd1419 \
1001		wd1683 \
1002		wd1684 \
1003		wd193 \
1004		wd593 \
1005		wd279 \
1006		wd810 \
1007		wd869 \
1008		wd981
1009	do
1010		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1011		if AC_TRY_EVAL(ac_compile); then
1012			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1013			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1014		fi
1015	done
1016	CFLAGS="$cf_save_CFLAGS"
1017
1018elif test "$GCC" = yes
1019then
1020	AC_CHECKING([for $CC warning options])
1021	cf_save_CFLAGS="$CFLAGS"
1022	EXTRA_CFLAGS=
1023	cf_warn_CONST=""
1024	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1025	for cf_opt in W Wall \
1026		Wbad-function-cast \
1027		Wcast-align \
1028		Wcast-qual \
1029		Winline \
1030		Wmissing-declarations \
1031		Wmissing-prototypes \
1032		Wnested-externs \
1033		Wpointer-arith \
1034		Wshadow \
1035		Wstrict-prototypes \
1036		Wundef $cf_warn_CONST $1
1037	do
1038		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1039		if AC_TRY_EVAL(ac_compile); then
1040			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1041			case $cf_opt in #(vi
1042			Wcast-qual) #(vi
1043				CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1044				;;
1045			Winline) #(vi
1046				case $GCC_VERSION in
1047				[[34]].*)
1048					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1049					continue;;
1050				esac
1051				;;
1052			Wpointer-arith) #(vi
1053				case $GCC_VERSION in
1054				[[12]].*)
1055					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1056					continue;;
1057				esac
1058				;;
1059			esac
1060			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1061		fi
1062	done
1063	CFLAGS="$cf_save_CFLAGS"
1064fi
1065rm -rf conftest*
1066
1067AC_SUBST(EXTRA_CFLAGS)
1068])dnl
1069dnl ---------------------------------------------------------------------------
1070dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1071dnl -------------
1072dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1073dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1074dnl (or misfeature) of glibc2, which breaks portability of many applications,
1075dnl since it is interwoven with GNU extensions.
1076dnl
1077dnl Well, yes we could work around it...
1078AC_DEFUN([CF_GNU_SOURCE],
1079[
1080AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1081AC_TRY_COMPILE([#include <sys/types.h>],[
1082#ifndef _XOPEN_SOURCE
1083make an error
1084#endif],
1085	[cf_cv_gnu_source=no],
1086	[cf_save="$CPPFLAGS"
1087	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1088	 AC_TRY_COMPILE([#include <sys/types.h>],[
1089#ifdef _XOPEN_SOURCE
1090make an error
1091#endif],
1092	[cf_cv_gnu_source=no],
1093	[cf_cv_gnu_source=yes])
1094	CPPFLAGS="$cf_save"
1095	])
1096])
1097test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1098])dnl
1099dnl ---------------------------------------------------------------------------
1100dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1101dnl ---------------
1102dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1103AC_DEFUN([CF_HELP_MESSAGE],
1104[AC_DIVERT_HELP([$1])dnl
1105])dnl
1106dnl ---------------------------------------------------------------------------
1107dnl CF_IMAKE_CFLAGS version: 31 updated: 2010/05/26 05:38:42
1108dnl ---------------
1109dnl Use imake to obtain compiler flags.  We could, in principle, write tests to
1110dnl get these, but if imake is properly configured there is no point in doing
1111dnl this.
1112dnl
1113dnl Parameters (used in constructing a sample Imakefile):
1114dnl	$1 = optional value to append to $IMAKE_CFLAGS
1115dnl	$2 = optional value to append to $IMAKE_LOADFLAGS
1116AC_DEFUN([CF_IMAKE_CFLAGS],
1117[
1118AC_PATH_PROGS(IMAKE,xmkmf imake)
1119
1120if test -n "$IMAKE" ; then
1121
1122case $IMAKE in # (vi
1123*/imake)
1124	cf_imake_opts="-DUseInstalled=YES" # (vi
1125	;;
1126*/util/xmkmf)
1127	# A single parameter tells xmkmf where the config-files are:
1128	cf_imake_opts="`echo $IMAKE|sed -e s,/config/util/xmkmf,,`" # (vi
1129	;;
1130*)
1131	cf_imake_opts=
1132	;;
1133esac
1134
1135# If it's installed properly, imake (or its wrapper, xmkmf) will point to the
1136# config directory.
1137if mkdir conftestdir; then
1138	CDPATH=; export CDPATH
1139	cf_makefile=`cd $srcdir;pwd`/Imakefile
1140	cd conftestdir
1141
1142	cat >fix_cflags.sed <<'CF_EOF'
1143s/\\//g
1144s/[[ 	]][[ 	]]*/ /g
1145s/"//g
1146:pack
1147s/\(=[[^ ]][[^ ]]*\) \([[^-]]\)/\1	\2/g
1148t pack
1149s/\(-D[[a-zA-Z0-9_]][[a-zA-Z0-9_]]*\)=\([[^\'0-9 ]][[^ ]]*\)/\1='\\"\2\\"'/g
1150s/^IMAKE[[ ]]/IMAKE_CFLAGS="/
1151s/	/ /g
1152s/$/"/
1153CF_EOF
1154
1155	cat >fix_lflags.sed <<'CF_EOF'
1156s/^IMAKE[[ 	]]*/IMAKE_LOADFLAGS="/
1157s/$/"/
1158CF_EOF
1159
1160	echo >./Imakefile
1161	test -f $cf_makefile && cat $cf_makefile >>./Imakefile
1162
1163	cat >> ./Imakefile <<'CF_EOF'
1164findstddefs:
1165	@echo IMAKE ${ALLDEFINES}ifelse([$1],,,[ $1])       | sed -f fix_cflags.sed
1166	@echo IMAKE ${EXTRA_LOAD_FLAGS}ifelse([$2],,,[ $2]) | sed -f fix_lflags.sed
1167CF_EOF
1168
1169	if ( $IMAKE $cf_imake_opts 1>/dev/null 2>&AC_FD_CC && test -f Makefile)
1170	then
1171		CF_VERBOSE(Using $IMAKE $cf_imake_opts)
1172	else
1173		# sometimes imake doesn't have the config path compiled in.  Find it.
1174		cf_config=
1175		for cf_libpath in $X_LIBS $LIBS ; do
1176			case $cf_libpath in # (vi
1177			-L*)
1178				cf_libpath=`echo .$cf_libpath | sed -e 's/^...//'`
1179				cf_libpath=$cf_libpath/X11/config
1180				if test -d $cf_libpath ; then
1181					cf_config=$cf_libpath
1182					break
1183				fi
1184				;;
1185			esac
1186		done
1187		if test -z "$cf_config" ; then
1188			AC_MSG_WARN(Could not find imake config-directory)
1189		else
1190			cf_imake_opts="$cf_imake_opts -I$cf_config"
1191			if ( $IMAKE -v $cf_imake_opts 2>&AC_FD_CC)
1192			then
1193				CF_VERBOSE(Using $IMAKE $cf_config)
1194			else
1195				AC_MSG_WARN(Cannot run $IMAKE)
1196			fi
1197		fi
1198	fi
1199
1200	# GNU make sometimes prints "make[1]: Entering...", which
1201	# would confuse us.
1202	eval `make findstddefs 2>/dev/null | grep -v make`
1203
1204	cd ..
1205	rm -rf conftestdir
1206
1207	# We use ${ALLDEFINES} rather than ${STD_DEFINES} because the former
1208	# declares XTFUNCPROTO there.  However, some vendors (e.g., SGI) have
1209	# modified it to support site.cf, adding a kludge for the /usr/include
1210	# directory.  Try to filter that out, otherwise gcc won't find its
1211	# headers.
1212	if test -n "$GCC" ; then
1213	    if test -n "$IMAKE_CFLAGS" ; then
1214		cf_nostdinc=""
1215		cf_std_incl=""
1216		cf_cpp_opts=""
1217		for cf_opt in $IMAKE_CFLAGS
1218		do
1219		    case "$cf_opt" in
1220		    -nostdinc) #(vi
1221			cf_nostdinc="$cf_opt"
1222			;;
1223		    -I/usr/include) #(vi
1224			cf_std_incl="$cf_opt"
1225			;;
1226		    *) #(vi
1227			cf_cpp_opts="$cf_cpp_opts $cf_opt"
1228			;;
1229		    esac
1230		done
1231		if test -z "$cf_nostdinc" ; then
1232		    IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl"
1233		elif test -z "$cf_std_incl" ; then
1234		    IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc"
1235		else
1236		    CF_VERBOSE(suppressed \"$cf_nostdinc\" and \"$cf_std_incl\")
1237		    IMAKE_CFLAGS="$cf_cpp_opts"
1238		fi
1239	    fi
1240	fi
1241fi
1242
1243# Some imake configurations define PROJECTROOT with an empty value.  Remove
1244# the empty definition.
1245case $IMAKE_CFLAGS in
1246*-DPROJECTROOT=/*)
1247	;;
1248*)
1249	IMAKE_CFLAGS=`echo "$IMAKE_CFLAGS" |sed -e "s,-DPROJECTROOT=[[ 	]], ,"`
1250	;;
1251esac
1252
1253fi
1254
1255CF_VERBOSE(IMAKE_CFLAGS $IMAKE_CFLAGS)
1256CF_VERBOSE(IMAKE_LOADFLAGS $IMAKE_LOADFLAGS)
1257
1258AC_SUBST(IMAKE_CFLAGS)
1259AC_SUBST(IMAKE_LOADFLAGS)
1260])dnl
1261dnl ---------------------------------------------------------------------------
1262dnl CF_INPUT_METHOD version: 3 updated: 2000/04/11 23:46:57
1263dnl ---------------
1264dnl Check if the X libraries support input-method
1265AC_DEFUN([CF_INPUT_METHOD],
1266[
1267AC_CACHE_CHECK([if X libraries support input-method],cf_cv_input_method,[
1268AC_TRY_LINK([
1269#include <X11/IntrinsicP.h>
1270#include <X11/Xatom.h>
1271#include <X11/Xutil.h>
1272#include <X11/Xmu/Atoms.h>
1273#include <X11/Xmu/Converters.h>
1274#include <X11/Xaw/XawImP.h>
1275],[
1276{
1277	XIM xim;
1278	XIMStyles *xim_styles = 0;
1279	XIMStyle input_style;
1280	Widget w = 0;
1281
1282	XSetLocaleModifiers("@im=none");
1283	xim = XOpenIM(XtDisplay(w), NULL, NULL, NULL);
1284	XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);
1285	XCloseIM(xim);
1286	input_style = (XIMPreeditNothing | XIMStatusNothing);
1287}
1288],
1289[cf_cv_input_method=yes],
1290[cf_cv_input_method=no])])
1291])dnl
1292dnl ---------------------------------------------------------------------------
1293dnl CF_INTEL_COMPILER version: 5 updated: 2013/02/10 10:41:05
1294dnl -----------------
1295dnl Check if the given compiler is really the Intel compiler for Linux.  It
1296dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1297dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1298dnl
1299dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1300dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1301dnl the wrappers for gcc and g++ warnings.
1302dnl
1303dnl $1 = GCC (default) or GXX
1304dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1305dnl $3 = CFLAGS (default) or CXXFLAGS
1306AC_DEFUN([CF_INTEL_COMPILER],[
1307AC_REQUIRE([AC_CANONICAL_HOST])
1308ifelse([$2],,INTEL_COMPILER,[$2])=no
1309
1310if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1311	case $host_os in
1312	linux*|gnu*)
1313		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
1314		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1315		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1316		AC_TRY_COMPILE([],[
1317#ifdef __INTEL_COMPILER
1318#else
1319make an error
1320#endif
1321],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1322cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
1323],[])
1324		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1325		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1326		;;
1327	esac
1328fi
1329])dnl
1330dnl ---------------------------------------------------------------------------
1331dnl CF_LASTLOG version: 5 updated: 2012/10/04 20:12:20
1332dnl ----------
1333dnl Check for header defining _PATH_LASTLOG, or failing that, see if the lastlog
1334dnl file exists.
1335AC_DEFUN([CF_LASTLOG],
1336[
1337AC_CHECK_HEADERS(lastlog.h paths.h)
1338AC_CACHE_CHECK(for lastlog path,cf_cv_path_lastlog,[
1339AC_TRY_COMPILE([
1340#include <sys/types.h>
1341#ifdef HAVE_LASTLOG_H
1342#include <lastlog.h>
1343#else
1344#ifdef HAVE_PATHS_H
1345#include <paths.h>
1346#endif
1347#endif],[char *path = _PATH_LASTLOG],
1348	[cf_cv_path_lastlog="_PATH_LASTLOG"],
1349	[if test -f /usr/adm/lastlog ; then
1350	 	cf_cv_path_lastlog=/usr/adm/lastlog
1351	else
1352		cf_cv_path_lastlog=no
1353	fi])
1354])
1355test $cf_cv_path_lastlog != no && AC_DEFINE(USE_LASTLOG,1,[Define to 1 if we can define lastlog pathname])
1356])dnl
1357dnl ---------------------------------------------------------------------------
1358dnl CF_LD_RPATH_OPT version: 5 updated: 2011/07/17 14:48:41
1359dnl ---------------
1360dnl For the given system and compiler, find the compiler flags to pass to the
1361dnl loader to use the "rpath" feature.
1362AC_DEFUN([CF_LD_RPATH_OPT],
1363[
1364AC_REQUIRE([CF_CHECK_CACHE])
1365
1366LD_RPATH_OPT=
1367AC_MSG_CHECKING(for an rpath option)
1368case $cf_cv_system_name in #(vi
1369irix*) #(vi
1370	if test "$GCC" = yes; then
1371		LD_RPATH_OPT="-Wl,-rpath,"
1372	else
1373		LD_RPATH_OPT="-rpath "
1374	fi
1375	;;
1376linux*|gnu*|k*bsd*-gnu) #(vi
1377	LD_RPATH_OPT="-Wl,-rpath,"
1378	;;
1379openbsd[[2-9]].*|mirbsd*) #(vi
1380	LD_RPATH_OPT="-Wl,-rpath,"
1381	;;
1382dragonfly*|freebsd*) #(vi
1383	LD_RPATH_OPT="-rpath "
1384	;;
1385netbsd*) #(vi
1386	LD_RPATH_OPT="-Wl,-rpath,"
1387	;;
1388osf*|mls+*) #(vi
1389	LD_RPATH_OPT="-rpath "
1390	;;
1391solaris2*) #(vi
1392	LD_RPATH_OPT="-R"
1393	;;
1394*)
1395	;;
1396esac
1397AC_MSG_RESULT($LD_RPATH_OPT)
1398
1399case "x$LD_RPATH_OPT" in #(vi
1400x-R*)
1401	AC_MSG_CHECKING(if we need a space after rpath option)
1402	cf_save_LIBS="$LIBS"
1403	CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
1404	AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1405	LIBS="$cf_save_LIBS"
1406	AC_MSG_RESULT($cf_rpath_space)
1407	test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
1408	;;
1409esac
1410])dnl
1411dnl ---------------------------------------------------------------------------
1412dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
1413dnl ------------
1414dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
1415dnl a monocase filesystem.
1416AC_DEFUN([CF_MAKE_TAGS],[
1417AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1418
1419AC_CHECK_PROGS(CTAGS, exctags ctags)
1420AC_CHECK_PROGS(ETAGS, exetags etags)
1421
1422AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1423
1424if test "$cf_cv_mixedcase" = yes ; then
1425	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1426else
1427	MAKE_UPPER_TAGS=no
1428fi
1429
1430if test "$MAKE_UPPER_TAGS" = yes ; then
1431	MAKE_UPPER_TAGS=
1432else
1433	MAKE_UPPER_TAGS="#"
1434fi
1435
1436if test "$MAKE_LOWER_TAGS" = yes ; then
1437	MAKE_LOWER_TAGS=
1438else
1439	MAKE_LOWER_TAGS="#"
1440fi
1441
1442AC_SUBST(CTAGS)
1443AC_SUBST(ETAGS)
1444
1445AC_SUBST(MAKE_UPPER_TAGS)
1446AC_SUBST(MAKE_LOWER_TAGS)
1447])dnl
1448dnl ---------------------------------------------------------------------------
1449dnl CF_MIXEDCASE_FILENAMES version: 4 updated: 2012/10/02 20:55:03
1450dnl ----------------------
1451dnl Check if the file-system supports mixed-case filenames.  If we're able to
1452dnl create a lowercase name and see it as uppercase, it doesn't support that.
1453AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1454[
1455AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1456if test "$cross_compiling" = yes ; then
1457	case $target_alias in #(vi
1458	*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
1459		cf_cv_mixedcase=no
1460		;;
1461	*)
1462		cf_cv_mixedcase=yes
1463		;;
1464	esac
1465else
1466	rm -f conftest CONFTEST
1467	echo test >conftest
1468	if test -f CONFTEST ; then
1469		cf_cv_mixedcase=no
1470	else
1471		cf_cv_mixedcase=yes
1472	fi
1473	rm -f conftest CONFTEST
1474fi
1475])
1476test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
1477])dnl
1478dnl ---------------------------------------------------------------------------
1479dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1480dnl ----------
1481dnl Write a debug message to config.log, along with the line number in the
1482dnl configure script.
1483AC_DEFUN([CF_MSG_LOG],[
1484echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1485])dnl
1486dnl ---------------------------------------------------------------------------
1487dnl CF_NO_LEAKS_OPTION version: 5 updated: 2012/10/02 20:55:03
1488dnl ------------------
1489dnl see CF_WITH_NO_LEAKS
1490AC_DEFUN([CF_NO_LEAKS_OPTION],[
1491AC_MSG_CHECKING(if you want to use $1 for testing)
1492AC_ARG_WITH($1,
1493	[$2],
1494	[AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
1495	 $4
1496])
1497	: ${with_cflags:=-g}
1498	: ${with_no_leaks:=yes}
1499	 with_$1=yes],
1500	[with_$1=])
1501AC_MSG_RESULT(${with_$1:-no})
1502
1503case .$with_cflags in #(vi
1504.*-g*)
1505	case .$CFLAGS in #(vi
1506	.*-g*) #(vi
1507		;;
1508	*)
1509		CF_ADD_CFLAGS([-g])
1510		;;
1511	esac
1512	;;
1513esac
1514])dnl
1515dnl ---------------------------------------------------------------------------
1516dnl CF_PATHSEP version: 6 updated: 2012/09/29 18:38:12
1517dnl ----------
1518dnl Provide a value for the $PATH and similar separator (or amend the value
1519dnl as provided in autoconf 2.5x).
1520AC_DEFUN([CF_PATHSEP],
1521[
1522	AC_MSG_CHECKING(for PATH separator)
1523	case $cf_cv_system_name in
1524	os2*)	PATH_SEPARATOR=';'  ;;
1525	*)	${PATH_SEPARATOR:=':'}  ;;
1526	esac
1527ifelse([$1],,,[$1=$PATH_SEPARATOR])
1528	AC_SUBST(PATH_SEPARATOR)
1529	AC_MSG_RESULT($PATH_SEPARATOR)
1530])dnl
1531dnl ---------------------------------------------------------------------------
1532dnl CF_PATH_PROG version: 9 updated: 2012/10/04 20:12:20
1533dnl ------------
1534dnl Check for a given program, defining corresponding symbol.
1535dnl	$1 = environment variable, which is suffixed by "_PATH" in the #define.
1536dnl	$2 = program name to find.
1537dnl	$3 = optional list of additional program names to test.
1538dnl
1539dnl If there is more than one token in the result, #define the remaining tokens
1540dnl to $1_ARGS.  We need this for 'install' in particular.
1541dnl
1542dnl FIXME: we should allow this to be overridden by environment variables
1543dnl
1544AC_DEFUN([CF_PATH_PROG],[
1545AC_REQUIRE([CF_PATHSEP])
1546test -z "[$]$1" && $1=$2
1547AC_PATH_PROGS($1,[$]$1 $2 $3,[$]$1)
1548
1549cf_path_prog=""
1550cf_path_args=""
1551IFS="${IFS:- 	}"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
1552for cf_temp in $ac_cv_path_$1
1553do
1554	if test -z "$cf_path_prog" ; then
1555		if test "$with_full_paths" = yes ; then
1556			CF_PATH_SYNTAX(cf_temp,break)
1557			cf_path_prog="$cf_temp"
1558		else
1559			cf_path_prog="`basename $cf_temp`"
1560		fi
1561	elif test -z "$cf_path_args" ; then
1562		cf_path_args="$cf_temp"
1563	else
1564		cf_path_args="$cf_path_args $cf_temp"
1565	fi
1566done
1567IFS="$cf_save_ifs"
1568
1569if test -n "$cf_path_prog" ; then
1570	CF_MSG_LOG(defining path for ${cf_path_prog})
1571	AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog",Define to pathname $1)
1572	test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args",Define to provide args for $1)
1573fi
1574])dnl
1575dnl ---------------------------------------------------------------------------
1576dnl CF_PATH_SYNTAX version: 14 updated: 2012/06/19 20:58:54
1577dnl --------------
1578dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1579dnl begins with one of the prefix/exec_prefix variables, and then again if the
1580dnl result begins with 'NONE'.  This is necessary to work around autoconf's
1581dnl delayed evaluation of those symbols.
1582AC_DEFUN([CF_PATH_SYNTAX],[
1583if test "x$prefix" != xNONE; then
1584  cf_path_syntax="$prefix"
1585else
1586  cf_path_syntax="$ac_default_prefix"
1587fi
1588
1589case ".[$]$1" in #(vi
1590.\[$]\(*\)*|.\'*\'*) #(vi
1591  ;;
1592..|./*|.\\*) #(vi
1593  ;;
1594.[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
1595  ;;
1596.\[$]{*prefix}*|.\[$]{*dir}*) #(vi
1597  eval $1="[$]$1"
1598  case ".[$]$1" in #(vi
1599  .NONE/*)
1600    $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1601    ;;
1602  esac
1603  ;; #(vi
1604.no|.NONE/*)
1605  $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1606  ;;
1607*)
1608  ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1609  ;;
1610esac
1611])dnl
1612dnl ---------------------------------------------------------------------------
1613dnl CF_PKG_CONFIG version: 7 updated: 2011/04/29 04:53:22
1614dnl -------------
1615dnl Check for the package-config program, unless disabled by command-line.
1616AC_DEFUN([CF_PKG_CONFIG],
1617[
1618AC_MSG_CHECKING(if you want to use pkg-config)
1619AC_ARG_WITH(pkg-config,
1620	[  --with-pkg-config{=path} enable/disable use of pkg-config],
1621	[cf_pkg_config=$withval],
1622	[cf_pkg_config=yes])
1623AC_MSG_RESULT($cf_pkg_config)
1624
1625case $cf_pkg_config in #(vi
1626no) #(vi
1627	PKG_CONFIG=none
1628	;;
1629yes) #(vi
1630	CF_ACVERSION_CHECK(2.52,
1631		[AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
1632		[AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
1633	;;
1634*)
1635	PKG_CONFIG=$withval
1636	;;
1637esac
1638
1639test -z "$PKG_CONFIG" && PKG_CONFIG=none
1640if test "$PKG_CONFIG" != none ; then
1641	CF_PATH_SYNTAX(PKG_CONFIG)
1642fi
1643
1644AC_SUBST(PKG_CONFIG)
1645])dnl
1646dnl ---------------------------------------------------------------------------
1647dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
1648dnl -----------------
1649dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1650dnl
1651dnl	POSIX.1-1990				_POSIX_SOURCE
1652dnl	POSIX.1-1990 and			_POSIX_SOURCE and
1653dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
1654dnl		Bindings Option
1655dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
1656dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
1657dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
1658dnl
1659dnl Parameters:
1660dnl	$1 is the nominal value for _POSIX_C_SOURCE
1661AC_DEFUN([CF_POSIX_C_SOURCE],
1662[
1663cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1664
1665cf_save_CFLAGS="$CFLAGS"
1666cf_save_CPPFLAGS="$CPPFLAGS"
1667
1668CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1669CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1670
1671AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1672	CF_MSG_LOG(if the symbol is already defined go no further)
1673	AC_TRY_COMPILE([#include <sys/types.h>],[
1674#ifndef _POSIX_C_SOURCE
1675make an error
1676#endif],
1677	[cf_cv_posix_c_source=no],
1678	[cf_want_posix_source=no
1679	 case .$cf_POSIX_C_SOURCE in #(vi
1680	 .[[12]]??*) #(vi
1681		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1682		;;
1683	 .2) #(vi
1684		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1685		cf_want_posix_source=yes
1686		;;
1687	 .*)
1688		cf_want_posix_source=yes
1689		;;
1690	 esac
1691	 if test "$cf_want_posix_source" = yes ; then
1692		AC_TRY_COMPILE([#include <sys/types.h>],[
1693#ifdef _POSIX_SOURCE
1694make an error
1695#endif],[],
1696		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1697	 fi
1698	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1699	 CFLAGS="$cf_trim_CFLAGS"
1700	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1701	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1702	 AC_TRY_COMPILE([#include <sys/types.h>],[
1703#ifndef _POSIX_C_SOURCE
1704make an error
1705#endif],,
1706	 [cf_cv_posix_c_source=no])
1707	 CFLAGS="$cf_save_CFLAGS"
1708	 CPPFLAGS="$cf_save_CPPFLAGS"
1709	])
1710])
1711
1712if test "$cf_cv_posix_c_source" != no ; then
1713	CFLAGS="$cf_trim_CFLAGS"
1714	CPPFLAGS="$cf_trim_CPPFLAGS"
1715	CF_ADD_CFLAGS($cf_cv_posix_c_source)
1716fi
1717
1718])dnl
1719dnl ---------------------------------------------------------------------------
1720dnl CF_POSIX_SAVED_IDS version: 8 updated: 2012/10/04 20:12:20
1721dnl ------------------
1722dnl
1723dnl Check first if saved-ids are always supported.  Some systems
1724dnl may require runtime checks.
1725AC_DEFUN([CF_POSIX_SAVED_IDS],
1726[
1727AC_CHECK_HEADERS( \
1728sys/param.h \
1729)
1730
1731AC_CACHE_CHECK(if POSIX saved-ids are supported,cf_cv_posix_saved_ids,[
1732AC_TRY_LINK(
1733[
1734#include <unistd.h>
1735#ifdef HAVE_SYS_PARAM_H
1736#include <sys/param.h>		/* this may define "BSD" */
1737#endif
1738],[
1739#if defined(_POSIX_SAVED_IDS) && (_POSIX_SAVED_IDS > 0)
1740	void *p = (void *) seteuid;
1741	int x = seteuid(geteuid());
1742#elif defined(BSD) && (BSD >= 199103)
1743/* The BSD's may implement the runtime check - and it fails.
1744 * However, saved-ids work almost like POSIX (close enough for most uses).
1745 */
1746#else
1747make an error
1748#endif
1749],[cf_cv_posix_saved_ids=yes
1750],[
1751AC_TRY_RUN([
1752#ifdef HAVE_STDLIB_H
1753#include <stdlib.h>
1754#endif
1755#include <unistd.h>
1756int main()
1757{
1758	void *p = (void *) seteuid;
1759	long code = sysconf(_SC_SAVED_IDS);
1760	${cf_cv_main_return:-return}  ((code > 0) ? 0 : 1);
1761}],
1762	cf_cv_posix_saved_ids=yes,
1763	cf_cv_posix_saved_ids=no,
1764	cf_cv_posix_saved_ids=unknown)
1765])
1766])
1767
1768test "$cf_cv_posix_saved_ids" = yes && AC_DEFINE(HAVE_POSIX_SAVED_IDS,1,[Define to 1 if POSIX saved-ids are supported])
1769])
1770dnl ---------------------------------------------------------------------------
1771dnl CF_POSIX_WAIT version: 3 updated: 2012/10/04 20:12:20
1772dnl -------------
1773dnl Check for POSIX wait support
1774AC_DEFUN([CF_POSIX_WAIT],
1775[
1776AC_REQUIRE([AC_HEADER_SYS_WAIT])
1777AC_CACHE_CHECK(for POSIX wait functions,cf_cv_posix_wait,[
1778AC_TRY_LINK([
1779#include <stdlib.h>
1780#include <stdio.h>
1781#include <sys/types.h>
1782#ifdef HAVE_SYS_WAIT_H
1783#include <sys/wait.h>
1784#endif
1785],[
1786	int stat_loc;
1787	pid_t pid = waitpid(-1, &stat_loc, WNOHANG|WUNTRACED);
1788	pid_t pid2 = wait(&stat_loc);
1789],
1790[cf_cv_posix_wait=yes],
1791[cf_cv_posix_wait=no])
1792])
1793test "$cf_cv_posix_wait" = yes && AC_DEFINE(USE_POSIX_WAIT,1,[Define to 1 if we have POSIX wait functions])
1794])dnl
1795dnl ---------------------------------------------------------------------------
1796dnl CF_PROCFS_CWD version: 2 updated: 2007/03/12 20:39:04
1797dnl -------------
1798dnl Find /proc tree (may be in a different place) which implements the "cwd"
1799dnl link.
1800AC_DEFUN([CF_PROCFS_CWD],[
1801AC_CACHE_CHECK(for proc tree with cwd-support,cf_cv_procfs_cwd,[
1802cf_cv_procfs_cwd=no
1803for cf_path in /proc /compat/linux/proc /usr/compat/linux/proc
1804do
1805	if test -d $cf_path && \
1806	   test -d $cf_path/$$ && \
1807	   ( test -d $cf_path/$$/cwd || \
1808	     test -L $cf_path/$$/cwd ); then
1809		cf_cv_procfs_cwd=$cf_path
1810		break
1811	fi
1812done
1813])
1814])dnl
1815dnl ---------------------------------------------------------------------------
1816dnl CF_PROG_CC version: 3 updated: 2012/10/06 15:31:55
1817dnl ----------
1818dnl standard check for CC, plus followup sanity checks
1819dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
1820AC_DEFUN([CF_PROG_CC],[
1821ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
1822CF_GCC_VERSION
1823CF_ACVERSION_CHECK(2.52,
1824	[AC_PROG_CC_STDC],
1825	[CF_ANSI_CC_REQD])
1826CF_CC_ENV_FLAGS 
1827])dnl
1828dnl ---------------------------------------------------------------------------
1829dnl CF_PROG_GROFF version: 1 updated: 2013/01/02 20:37:18
1830dnl -------------
1831dnl Check if groff is available, for cases (such as html output) where nroff
1832dnl is not enough.
1833AC_DEFUN([CF_PROG_GROFF],[
1834AC_PATH_PROG(GROFF_PATH,groff,no)
1835if test "x$GROFF_PATH" = xno
1836then
1837	NROFF_NOTE=
1838	GROFF_NOTE="#"
1839else
1840	NROFF_NOTE="#"
1841	GROFF_NOTE=
1842fi
1843AC_SUBST(GROFF_PATH)
1844AC_SUBST(GROFF_NOTE)
1845AC_SUBST(NROFF_NOTE)
1846])dnl
1847dnl ---------------------------------------------------------------------------
1848dnl CF_REGEX version: 10 updated: 2012/10/04 20:12:20
1849dnl --------
1850dnl Attempt to determine if we've got one of the flavors of regular-expression
1851dnl code that we can support.
1852AC_DEFUN([CF_REGEX],
1853[
1854
1855cf_regex_func=no
1856
1857cf_regex_libs="regex re"
1858case $host_os in #(vi
1859mingw*)
1860	cf_regex_libs="gnurx $cf_regex_libs"
1861	;;
1862esac
1863
1864AC_CHECK_FUNC(regcomp,[cf_regex_func=regcomp],[
1865	for cf_regex_lib in $cf_regex_libs
1866	do
1867		AC_CHECK_LIB($cf_regex_lib,regcomp,[
1868				CF_ADD_LIB($cf_regex_lib)
1869				cf_regex_func=regcomp
1870				break])
1871	done
1872])
1873
1874if test "$cf_regex_func" = no ; then
1875	AC_CHECK_FUNC(compile,[cf_regex_func=compile],[
1876		AC_CHECK_LIB(gen,compile,[
1877				CF_ADD_LIB(gen)
1878				cf_regex_func=compile])])
1879fi
1880
1881if test "$cf_regex_func" = no ; then
1882	AC_MSG_WARN(cannot find regular expression library)
1883fi
1884
1885AC_CACHE_CHECK(for regular-expression headers,cf_cv_regex_hdrs,[
1886
1887cf_cv_regex_hdrs=no
1888case $cf_regex_func in #(vi
1889compile) #(vi
1890	for cf_regex_hdr in regexp.h regexpr.h
1891	do
1892		AC_TRY_LINK([#include <$cf_regex_hdr>],[
1893			char *p = compile("", "", "", 0);
1894			int x = step("", "");
1895		],[
1896			cf_cv_regex_hdrs=$cf_regex_hdr
1897			break
1898		])
1899	done
1900	;;
1901*)
1902	for cf_regex_hdr in regex.h
1903	do
1904		AC_TRY_LINK([#include <sys/types.h>
1905#include <$cf_regex_hdr>],[
1906			regex_t *p;
1907			int x = regcomp(p, "", 0);
1908			int y = regexec(p, "", 0, 0, 0);
1909			regfree(p);
1910		],[
1911			cf_cv_regex_hdrs=$cf_regex_hdr
1912			break
1913		])
1914	done
1915	;;
1916esac
1917
1918])
1919
1920case $cf_cv_regex_hdrs in #(vi
1921    no)	       AC_MSG_WARN(no regular expression header found) ;; #(vi
1922    regex.h)   AC_DEFINE(HAVE_REGEX_H_FUNCS,1,[Define to 1 to include regex.h for regular expressions]) ;; #(vi
1923    regexp.h)  AC_DEFINE(HAVE_REGEXP_H_FUNCS,1,[Define to 1 to include regexp.h for regular expressions]) ;; #(vi
1924    regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS,1,[Define to 1 to include regexpr.h for regular expressions]) ;;
1925esac
1926])dnl
1927dnl ---------------------------------------------------------------------------
1928dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
1929dnl ----------------
1930dnl Remove all -U and -D options that refer to the given symbol from a list
1931dnl of C compiler options.  This works around the problem that not all
1932dnl compilers process -U and -D options from left-to-right, so a -U option
1933dnl cannot be used to cancel the effect of a preceding -D option.
1934dnl
1935dnl $1 = target (which could be the same as the source variable)
1936dnl $2 = source (including '$')
1937dnl $3 = symbol to remove
1938define([CF_REMOVE_DEFINE],
1939[
1940$1=`echo "$2" | \
1941	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
1942		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
1943])dnl
1944dnl ---------------------------------------------------------------------------
1945dnl CF_RPATH_HACK version: 9 updated: 2011/02/13 13:31:33
1946dnl -------------
1947AC_DEFUN([CF_RPATH_HACK],
1948[
1949AC_REQUIRE([CF_LD_RPATH_OPT])
1950AC_MSG_CHECKING(for updated LDFLAGS)
1951if test -n "$LD_RPATH_OPT" ; then
1952	AC_MSG_RESULT(maybe)
1953
1954	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
1955	cf_rpath_list="/usr/lib /lib"
1956	if test "$cf_ldd_prog" != no
1957	then
1958		cf_rpath_oops=
1959
1960AC_TRY_LINK([#include <stdio.h>],
1961		[printf("Hello");],
1962		[cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort -u`
1963		 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort -u`])
1964
1965		# If we passed the link-test, but get a "not found" on a given library,
1966		# this could be due to inept reconfiguration of gcc to make it only
1967		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
1968		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
1969		# /usr/local libraries.
1970		if test -n "$cf_rpath_oops"
1971		then
1972			for cf_rpath_src in $cf_rpath_oops
1973			do
1974				for cf_rpath_dir in \
1975					/usr/local \
1976					/usr/pkg \
1977					/opt/sfw
1978				do
1979					if test -f $cf_rpath_dir/lib/$cf_rpath_src
1980					then
1981						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
1982						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
1983						break
1984					fi
1985				done
1986			done
1987		fi
1988	fi
1989
1990	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
1991
1992	CF_RPATH_HACK_2(LDFLAGS)
1993	CF_RPATH_HACK_2(LIBS)
1994
1995	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
1996fi
1997AC_SUBST(EXTRA_LDFLAGS)
1998])dnl
1999dnl ---------------------------------------------------------------------------
2000dnl CF_RPATH_HACK_2 version: 6 updated: 2010/04/17 16:31:24
2001dnl ---------------
2002dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
2003dnl EXTRA_LDFLAGS for each -L option found.
2004dnl
2005dnl $cf_rpath_list contains a list of directories to ignore.
2006dnl
2007dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
2008dnl      but LIBS often has misplaced -L options.
2009AC_DEFUN([CF_RPATH_HACK_2],
2010[
2011CF_VERBOSE(...checking $1 [$]$1)
2012
2013cf_rpath_dst=
2014for cf_rpath_src in [$]$1
2015do
2016	case $cf_rpath_src in #(vi
2017	-L*) #(vi
2018
2019		# check if this refers to a directory which we will ignore
2020		cf_rpath_skip=no
2021		if test -n "$cf_rpath_list"
2022		then
2023			for cf_rpath_item in $cf_rpath_list
2024			do
2025				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
2026				then
2027					cf_rpath_skip=yes
2028					break
2029				fi
2030			done
2031		fi
2032
2033		if test "$cf_rpath_skip" = no
2034		then
2035			# transform the option
2036			if test "$LD_RPATH_OPT" = "-R " ; then
2037				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
2038			else
2039				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
2040			fi
2041
2042			# if we have not already added this, add it now
2043			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
2044			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
2045			then
2046				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
2047				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
2048			fi
2049		fi
2050		;;
2051	esac
2052	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
2053done
2054$1=$cf_rpath_dst
2055
2056CF_VERBOSE(...checked $1 [$]$1)
2057AC_SUBST(EXTRA_LDFLAGS)
2058])dnl
2059dnl ---------------------------------------------------------------------------
2060dnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
2061dnl -----------
2062dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
2063dnl programs need this test).
2064dnl
2065dnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
2066dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
2067dnl winsize declaration is left alone - we may revisit this if Apple choose to
2068dnl break that part of the interface as well.
2069AC_DEFUN([CF_SIGWINCH],
2070[
2071AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
2072	AC_TRY_COMPILE([
2073#include <sys/types.h>
2074#include <sys/signal.h>
2075],[int x = SIGWINCH],
2076	[cf_cv_define_sigwinch=yes],
2077	[AC_TRY_COMPILE([
2078#undef _XOPEN_SOURCE
2079#undef _POSIX_SOURCE
2080#undef _POSIX_C_SOURCE
2081#include <sys/types.h>
2082#include <sys/signal.h>
2083],[int x = SIGWINCH],
2084	[cf_cv_define_sigwinch=maybe],
2085	[cf_cv_define_sigwinch=no])
2086])
2087])
2088
2089if test "$cf_cv_define_sigwinch" = maybe ; then
2090AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
2091cf_cv_fixup_sigwinch=unknown
2092cf_sigwinch=32
2093while test $cf_sigwinch != 1
2094do
2095	AC_TRY_COMPILE([
2096#undef _XOPEN_SOURCE
2097#undef _POSIX_SOURCE
2098#undef _POSIX_C_SOURCE
2099#include <sys/types.h>
2100#include <sys/signal.h>
2101],[
2102#if SIGWINCH != $cf_sigwinch
2103make an error
2104#endif
2105int x = SIGWINCH],
2106	[cf_cv_fixup_sigwinch=$cf_sigwinch
2107	 break])
2108
2109cf_sigwinch=`expr $cf_sigwinch - 1`
2110done
2111])
2112
2113	if test "$cf_cv_fixup_sigwinch" != unknown ; then
2114		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
2115	fi
2116fi
2117])dnl
2118dnl ---------------------------------------------------------------------------
2119dnl CF_SIG_ATOMIC_T version: 3 updated: 2012/10/04 20:12:20
2120dnl ---------------
2121dnl signal handler, but there are some gcc depedencies in that recommendation.
2122dnl Try anyway.
2123AC_DEFUN([CF_SIG_ATOMIC_T],
2124[
2125AC_MSG_CHECKING(for signal global datatype)
2126AC_CACHE_VAL(cf_cv_sig_atomic_t,[
2127	for cf_type in \
2128		"volatile sig_atomic_t" \
2129		"sig_atomic_t" \
2130		"int"
2131	do
2132	AC_TRY_COMPILE([
2133#include <sys/types.h>
2134#include <signal.h>
2135#include <stdio.h>
2136
2137extern $cf_type x;
2138$cf_type x;
2139static void handler(int sig)
2140{
2141	x = 5;
2142}],
2143		[signal(SIGINT, handler);
2144		 x = 1],
2145		[cf_cv_sig_atomic_t=$cf_type],
2146		[cf_cv_sig_atomic_t=no])
2147		test "$cf_cv_sig_atomic_t" != no && break
2148	done
2149	])
2150AC_MSG_RESULT($cf_cv_sig_atomic_t)
2151test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
2152])dnl
2153dnl ---------------------------------------------------------------------------
2154dnl CF_STRUCT_LASTLOG version: 2 updated: 2012/10/04 20:12:20
2155dnl -----------------
2156dnl Check for header defining struct lastlog, ensure that its .ll_time member
2157dnl is compatible with time().
2158AC_DEFUN([CF_STRUCT_LASTLOG],
2159[
2160AC_CHECK_HEADERS(lastlog.h)
2161AC_CACHE_CHECK(for struct lastlog,cf_cv_struct_lastlog,[
2162AC_TRY_RUN([
2163#include <sys/types.h>
2164#include <time.h>
2165#include <lastlog.h>
2166
2167int main()
2168{
2169	struct lastlog data;
2170	return (sizeof(data.ll_time) != sizeof(time_t));
2171}],[
2172cf_cv_struct_lastlog=yes],[
2173cf_cv_struct_lastlog=no],[
2174cf_cv_struct_lastlog=unknown])])
2175
2176test $cf_cv_struct_lastlog != no && AC_DEFINE(USE_STRUCT_LASTLOG,1,[Define to 1 if we have struct lastlog])
2177])dnl
2178dnl ---------------------------------------------------------------------------
2179dnl CF_SVR4 version: 5 updated: 2012/10/04 05:24:07
2180dnl -------
2181dnl Check if this is an SVR4 system.  We need the definition for xterm
2182AC_DEFUN([CF_SVR4],
2183[
2184AC_CHECK_LIB(elf, elf_begin,[
2185AC_CACHE_CHECK(if this is an SVR4 system, cf_cv_svr4,[
2186AC_TRY_COMPILE([
2187#if defined(__CYGWIN__)
2188make an error
2189#endif
2190#include <elf.h>
2191#include <sys/termio.h>
2192],[
2193static struct termio d_tio;
2194	d_tio.c_cc[VINTR] = 0;
2195	d_tio.c_cc[VQUIT] = 0;
2196	d_tio.c_cc[VERASE] = 0;
2197	d_tio.c_cc[VKILL] = 0;
2198	d_tio.c_cc[VEOF] = 0;
2199	d_tio.c_cc[VEOL] = 0;
2200	d_tio.c_cc[VMIN] = 0;
2201	d_tio.c_cc[VTIME] = 0;
2202	d_tio.c_cc[VLNEXT] = 0;
2203],
2204[cf_cv_svr4=yes],
2205[cf_cv_svr4=no])
2206])
2207])
2208test "$cf_cv_svr4" = yes && AC_DEFINE(SVR4,1,[Define to 1 if this is an SVR4 system])
2209])dnl
2210dnl ---------------------------------------------------------------------------
2211dnl CF_SYSV version: 15 updated: 2012/10/04 05:24:07
2212dnl -------
2213dnl Check if this is a SYSV platform, e.g., as used in <X11/Xos.h>, and whether
2214dnl defining it will be helpful.  The following features are used to check:
2215dnl
2216dnl a) bona-fide SVSV doesn't use const for sys_errlist[].  Since this is a
2217dnl legacy (pre-ANSI) feature, const should not apply.  Modern systems only
2218dnl declare strerror().  Xos.h declares the legacy form of str_errlist[], and
2219dnl a compile-time error will result from trying to assign to a const array.
2220dnl
2221dnl b) compile with headers that exist on SYSV hosts.
2222dnl
2223dnl c) compile with type definitions that differ on SYSV hosts from standard C.
2224AC_DEFUN([CF_SYSV],
2225[
2226AC_CHECK_HEADERS( \
2227termios.h \
2228stdlib.h \
2229X11/Intrinsic.h \
2230)
2231
2232AC_REQUIRE([CF_SYS_ERRLIST])
2233
2234AC_CACHE_CHECK(if we should define SYSV,cf_cv_sysv,[
2235AC_TRY_COMPILE([
2236#undef  SYSV
2237#define SYSV 1			/* get Xos.h to declare sys_errlist[] */
2238#ifdef HAVE_STDLIB_H
2239#include <stdlib.h>		/* look for wchar_t */
2240#endif
2241#ifdef HAVE_X11_INTRINSIC_H
2242#include <X11/Intrinsic.h>	/* Intrinsic.h has other traps... */
2243#endif
2244#ifdef HAVE_TERMIOS_H		/* needed for HPUX 10.20 */
2245#include <termios.h>
2246#define STRUCT_TERMIOS struct termios
2247#else
2248#define STRUCT_TERMIOS struct termio
2249#endif
2250#include <curses.h>
2251#include <term.h>		/* eliminate most BSD hacks */
2252#include <errno.h>		/* declare sys_errlist on older systems */
2253#include <sys/termio.h>		/* eliminate most of the remaining ones */
2254],[
2255static STRUCT_TERMIOS d_tio;
2256	d_tio.c_cc[VINTR] = 0;
2257	d_tio.c_cc[VQUIT] = 0;
2258	d_tio.c_cc[VERASE] = 0;
2259	d_tio.c_cc[VKILL] = 0;
2260	d_tio.c_cc[VEOF] = 0;
2261	d_tio.c_cc[VEOL] = 0;
2262	d_tio.c_cc[VMIN] = 0;
2263	d_tio.c_cc[VTIME] = 0;
2264#if defined(HAVE_SYS_ERRLIST) && !defined(DECL_SYS_ERRLIST)
2265sys_errlist[0] = "";		/* Cygwin mis-declares this */
2266#endif
2267],
2268[cf_cv_sysv=yes],
2269[cf_cv_sysv=no])
2270])
2271test "$cf_cv_sysv" = yes && AC_DEFINE(SYSV,1,[Define to 1 if this is an SYSV system])
2272])dnl
2273dnl ---------------------------------------------------------------------------
2274dnl CF_SYSV_UTMP version: 6 updated: 2012/10/04 20:12:20
2275dnl ------------
2276dnl Check if this is a SYSV flavor of UTMP
2277AC_DEFUN([CF_SYSV_UTMP],
2278[
2279AC_CACHE_CHECK(if $cf_cv_have_utmp is SYSV flavor,cf_cv_sysv_utmp,[
2280test "$cf_cv_have_utmp" = "utmp" && cf_prefix="ut" || cf_prefix="utx"
2281AC_TRY_LINK([
2282#include <sys/types.h>
2283#include <${cf_cv_have_utmp}.h>],[
2284struct $cf_cv_have_utmp x;
2285	set${cf_prefix}ent ();
2286	get${cf_prefix}id(&x);
2287	put${cf_prefix}line(&x);
2288	end${cf_prefix}ent();],
2289	[cf_cv_sysv_utmp=yes],
2290	[cf_cv_sysv_utmp=no])
2291])
2292test $cf_cv_sysv_utmp = yes && AC_DEFINE(USE_SYSV_UTMP,1,[Define to 1 if utmp is SYSV flavor])
2293])dnl
2294dnl ---------------------------------------------------------------------------
2295dnl CF_SYS_ERRLIST version: 6 updated: 2001/12/30 13:03:23
2296dnl --------------
2297dnl Check for declaration of sys_nerr and sys_errlist in one of stdio.h and
2298dnl errno.h.  Declaration of sys_errlist on BSD4.4 interferes with our
2299dnl declaration.  Reported by Keith Bostic.
2300AC_DEFUN([CF_SYS_ERRLIST],
2301[
2302    CF_CHECK_ERRNO(sys_nerr)
2303    CF_CHECK_ERRNO(sys_errlist)
2304])dnl
2305dnl ---------------------------------------------------------------------------
2306dnl CF_TERMIO_C_ISPEED version: 3 updated: 2012/10/04 20:12:20
2307dnl ------------------
2308dnl Check for SGI's broken redefinition of baud rates introduced in IRIX 6.5
2309dnl (there doesn't appear to be a useful predefined symbol).
2310AC_DEFUN([CF_TERMIO_C_ISPEED],
2311[
2312AC_CACHE_CHECK(for IRIX 6.5 baud-rate redefinitions,cf_cv_termio_c_ispeed,[
2313AC_TRY_COMPILE([
2314#include <sys/types.h>
2315#include <sys/termio.h>],[
2316struct termio foo;
2317foo.c_ispeed = B38400;
2318foo.c_ospeed = B9600;
2319],[cf_cv_termio_c_ispeed=yes
2320],[cf_cv_termio_c_ispeed=no])
2321])
2322test "$cf_cv_termio_c_ispeed" = yes && AC_DEFINE(HAVE_TERMIO_C_ISPEED,1,[define 1 if we have IRIX 6.5 baud-rate redefinitions])
2323])dnl
2324dnl ---------------------------------------------------------------------------
2325dnl CF_TRY_PKG_CONFIG version: 4 updated: 2010/06/14 17:42:30
2326dnl -----------------
2327dnl This is a simple wrapper to use for pkg-config, for libraries which may be
2328dnl available in that form.
2329dnl
2330dnl $1 = package name
2331dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
2332dnl $3 = logic to use if pkg-config does not have the package
2333AC_DEFUN([CF_TRY_PKG_CONFIG],[
2334AC_REQUIRE([CF_PKG_CONFIG])
2335
2336if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
2337	CF_VERBOSE(found package $1)
2338	cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
2339	cf_pkgconfig_libs="`$PKG_CONFIG --libs   $1 2>/dev/null`"
2340	CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
2341	CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
2342	CF_ADD_CFLAGS($cf_pkgconfig_incs)
2343	CF_ADD_LIBS($cf_pkgconfig_libs)
2344	ifelse([$2],,:,[$2])
2345else
2346	ifelse([$3],,:,[$3])
2347fi
2348])
2349dnl ---------------------------------------------------------------------------
2350dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
2351dnl -------------------
2352dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
2353dnl can define it successfully.
2354AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
2355AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
2356	AC_TRY_COMPILE([
2357#include <stdlib.h>
2358#include <string.h>
2359#include <sys/types.h>
2360],[
2361#ifndef _XOPEN_SOURCE
2362make an error
2363#endif],
2364	[cf_cv_xopen_source=no],
2365	[cf_save="$CPPFLAGS"
2366	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2367	 AC_TRY_COMPILE([
2368#include <stdlib.h>
2369#include <string.h>
2370#include <sys/types.h>
2371],[
2372#ifdef _XOPEN_SOURCE
2373make an error
2374#endif],
2375	[cf_cv_xopen_source=no],
2376	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
2377	CPPFLAGS="$cf_save"
2378	])
2379])
2380
2381if test "$cf_cv_xopen_source" != no ; then
2382	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
2383	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
2384	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
2385	CF_ADD_CFLAGS($cf_temp_xopen_source)
2386fi
2387])
2388dnl ---------------------------------------------------------------------------
2389dnl CF_TTY_GROUP version: 8 updated: 2012/10/04 20:12:20
2390dnl ------------
2391dnl Check if the system has a tty-group defined.  This is used in xterm when
2392dnl setting pty ownership.
2393AC_DEFUN([CF_TTY_GROUP],
2394[
2395AC_MSG_CHECKING(for explicit tty group name)
2396AC_ARG_WITH(tty-group,
2397	[  --with-tty-group=XXX    use XXX for the tty-group],
2398	[cf_tty_group=$withval],
2399	[cf_tty_group=auto...])
2400test -z "$cf_tty_group"    && cf_tty_group=auto...
2401test "$cf_tty_group" = yes && cf_tty_group=auto...
2402AC_MSG_RESULT($cf_tty_group)
2403
2404if test "$cf_tty_group" = "auto..." ; then
2405AC_CACHE_CHECK(for tty group name,cf_cv_tty_group_name,[
2406
2407# If we are configuring as root, it is hard to get a clue about the tty group.
2408# But we'll guess based on how our connection is set up - assuming it is done
2409# properly.
2410
2411cf_uid=`id | sed -e 's/^[^=]*=//' -e 's/(.*$//'`
2412# )vi
2413if test "$cf_uid" != 0 ; then
2414cf_cv_tty_group_name=
2415cf_tty_name=`tty`
2416test "$cf_tty_name" = "not a tty" && cf_tty_name=/dev/tty
2417test -z "$cf_tty_name" && cf_tty_name=/dev/tty
2418if test -c "$cf_tty_name"
2419then
2420	cf_option="-l -L"
2421
2422	# Expect listing to have fields like this:
2423	#-rwxrwxrwx   1 user      group       34293 Jul 18 16:29 pathname
2424	ls $cf_option $cf_tty_name >conftest.out
2425	read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
2426	if test -z "$cf_rest" ; then
2427		cf_option="$cf_option -g"
2428		ls $cf_option $cf_tty_name >conftest.out
2429		read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
2430	fi
2431	rm -f conftest.out
2432	cf_cv_tty_group_name=$cf_grp
2433fi
2434fi
2435
2436# If we cannot deduce the tty group, fall back on hardcoded cases
2437
2438if test -z "$cf_cv_tty_group_name"
2439then
2440case $host_os in #(vi
2441osf*) #(vi
2442	cf_cv_tty_group_name="terminal"
2443	;;
2444*)
2445	cf_cv_tty_group_name="unknown"
2446	if ( egrep '^tty:' /etc/group 2>/dev/null 1>/dev/null ) then
2447		cf_cv_tty_group_name="tty"
2448	fi
2449	;;
2450esac
2451fi
2452])
2453cf_tty_group="$cf_cv_tty_group_name"
2454else
2455	# if configure option, always do this
2456	AC_DEFINE(USE_TTY_GROUP,1,[Define to 1 if we have a tty groupname])
2457fi
2458
2459AC_DEFINE_UNQUOTED(TTY_GROUP_NAME,"$cf_tty_group",[Define to the name use for tty group])
2460
2461# This is only a double-check that the group-name we obtained above really
2462# does apply to the device.  We cannot perform this test if we are in batch
2463# mode, or if we are cross-compiling.
2464
2465AC_CACHE_CHECK(if we may use the $cf_tty_group group,cf_cv_tty_group,[
2466cf_tty_name=`tty`
2467if test "$cf_tty_name" != "not a tty"
2468then
2469AC_TRY_RUN([
2470#include <unistd.h>
2471#include <sys/types.h>
2472#include <sys/stat.h>
2473#include <grp.h>
2474int main()
2475{
2476	struct stat sb;
2477	struct group *ttygrp = getgrnam(TTY_GROUP_NAME);
2478	char *name = ttyname(0);
2479
2480	endgrent();
2481	if (ttygrp != 0
2482	 && name != 0
2483	 && stat(name, &sb) == 0
2484	 && sb.st_gid != getgid()
2485	 && sb.st_gid == ttygrp->gr_gid) {
2486		${cf_cv_main_return:-return} (0);
2487	}
2488	${cf_cv_main_return:-return} (1);
2489}
2490	],
2491	[cf_cv_tty_group=yes],
2492	[cf_cv_tty_group=no],
2493	[cf_cv_tty_group=unknown])
2494elif test "$cross_compiling" = yes; then
2495	cf_cv_tty_group=unknown
2496else
2497	cf_cv_tty_group=yes
2498fi
2499])
2500
2501if test $cf_cv_tty_group = no ; then
2502	AC_MSG_WARN(Cannot use $cf_tty_group group)
2503else
2504	AC_DEFINE(USE_TTY_GROUP)
2505fi
2506])dnl
2507dnl ---------------------------------------------------------------------------
2508dnl CF_TYPE_CC_T version: 2 updated: 2012/10/04 20:12:20
2509dnl ------------
2510dnl	Check for cc_t type, used in termio.
2511AC_DEFUN([CF_TYPE_CC_T],
2512[
2513AC_MSG_CHECKING(for cc_t in <termios.h> or <termio.h>)
2514AC_CACHE_VAL(cf_cv_type_cc_t,[
2515	AC_TRY_COMPILE([
2516#include <sys/types.h>
2517#if defined(HAVE_TERMIOS_H)
2518#include <termios.h>
2519#else
2520#include <termio.h>
2521#include <sys/ioctl.h>
2522#endif
2523],
2524		[cc_t x],
2525		[cf_cv_type_cc_t=yes],
2526		[cf_cv_type_cc_t=no])
2527	])
2528AC_MSG_RESULT($cf_cv_type_cc_t)
2529test $cf_cv_type_cc_t = no && AC_DEFINE(cc_t, unsigned char,[Define to cc_t type used in termio])
2530])dnl
2531dnl ---------------------------------------------------------------------------
2532dnl CF_TYPE_FD_MASK version: 3 updated: 2012/10/04 06:57:36
2533dnl ---------------
2534dnl Check for the declaration of fd_mask, which is like fd_set, associated
2535dnl with select().  The check for fd_set should have pulled in this as well,
2536dnl but there is a special case for Mac OS X, possibly other BSD-derived
2537dnl platforms.
2538AC_DEFUN([CF_TYPE_FD_MASK],
2539[
2540AC_REQUIRE([CF_TYPE_FD_SET])
2541
2542AC_CACHE_CHECK(for declaration of fd_mask,cf_cv_type_fd_mask,[
2543    if test x$cf_cv_type_fd_set = xX11/Xpoll.h ; then
2544        AC_TRY_COMPILE([
2545#include <X11/Xpoll.h>],[fd_mask x],,
2546        [CF_MSG_LOG(if we must define CSRG_BASED)
2547# Xosdefs.h on Mac OS X may not define this (but it should).
2548            AC_TRY_COMPILE([
2549#define CSRG_BASED
2550#include <X11/Xpoll.h>],[fd_mask x],
2551        cf_cv_type_fd_mask=CSRG_BASED)])
2552    else
2553        cf_cv_type_fd_mask=$cf_cv_type_fd_set
2554    fi
2555])
2556if test x$cf_cv_type_fd_mask = xCSRG_BASED ; then
2557    AC_DEFINE(CSRG_BASED,1,[Define to 1 if needed for declaring fd_mask()])
2558fi
2559])dnl
2560dnl ---------------------------------------------------------------------------
2561dnl CF_TYPE_FD_SET version: 5 updated: 2012/10/04 20:12:20
2562dnl --------------
2563dnl Check for the declaration of fd_set.  Some platforms declare it in
2564dnl <sys/types.h>, and some in <sys/select.h>, which requires <sys/types.h>.
2565dnl Finally, if we are using this for an X application, Xpoll.h may include
2566dnl <sys/select.h>, so we don't want to do it twice.
2567AC_DEFUN([CF_TYPE_FD_SET],
2568[
2569AC_CHECK_HEADERS(X11/Xpoll.h)
2570
2571AC_CACHE_CHECK(for declaration of fd_set,cf_cv_type_fd_set,
2572	[CF_MSG_LOG(sys/types alone)
2573AC_TRY_COMPILE([
2574#include <sys/types.h>],
2575	[fd_set x],
2576	[cf_cv_type_fd_set=sys/types.h],
2577	[CF_MSG_LOG(X11/Xpoll.h)
2578AC_TRY_COMPILE([
2579#ifdef HAVE_X11_XPOLL_H
2580#include <X11/Xpoll.h>
2581#endif],
2582	[fd_set x],
2583	[cf_cv_type_fd_set=X11/Xpoll.h],
2584	[CF_MSG_LOG(sys/select.h)
2585AC_TRY_COMPILE([
2586#include <sys/types.h>
2587#include <sys/select.h>],
2588	[fd_set x],
2589	[cf_cv_type_fd_set=sys/select.h],
2590	[cf_cv_type_fd_set=unknown])])])])
2591if test $cf_cv_type_fd_set = sys/select.h ; then
2592	AC_DEFINE(USE_SYS_SELECT_H,1,[Define to 1 to include sys/select.h to declare fd_set])
2593fi
2594])
2595dnl ---------------------------------------------------------------------------
2596dnl CF_UNDO_CFLAGS version: 1 updated: 2011/07/02 09:27:51
2597dnl --------------
2598dnl Remove flags from $CFLAGS or similar shell variable using sed.
2599dnl $1 = variable
2600dnl $2 = message
2601dnl $3 = pattern to remove
2602AC_DEFUN([CF_UNDO_CFLAGS],
2603[
2604	CF_VERBOSE(removing $2 flags from $1)
2605	$1=`echo "[$]$1" | sed -e 's/$3//'`
2606	CF_VERBOSE(...result [$]$1)
2607])dnl
2608dnl ---------------------------------------------------------------------------
2609dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
2610dnl --------
2611dnl Make an uppercase version of a variable
2612dnl $1=uppercase($2)
2613AC_DEFUN([CF_UPPER],
2614[
2615$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2616])dnl
2617dnl ---------------------------------------------------------------------------
2618dnl CF_UTEMPTER version: 4 updated: 2012/10/04 20:12:20
2619dnl -----------
2620dnl Try to link with utempter library
2621AC_DEFUN([CF_UTEMPTER],
2622[
2623AC_CACHE_CHECK(if we can link with utempter library,cf_cv_have_utempter,[
2624cf_save_LIBS="$LIBS"
2625CF_ADD_LIB(utempter)
2626AC_TRY_LINK([
2627#include <utempter.h>
2628],[
2629	addToUtmp("/dev/tty", 0, 1);
2630	removeFromUtmp();
2631],[
2632	cf_cv_have_utempter=yes],[
2633	cf_cv_have_utempter=no])
2634LIBS="$cf_save_LIBS"
2635])
2636if test "$cf_cv_have_utempter" = yes ; then
2637	AC_DEFINE(USE_UTEMPTER,1,[Define to 1 if we can/should link with utempter])
2638	CF_ADD_LIB(utempter)
2639fi
2640])dnl
2641dnl ---------------------------------------------------------------------------
2642dnl CF_UTMP version: 10 updated: 2012/10/04 20:12:20
2643dnl -------
2644dnl Check for UTMP/UTMPX headers
2645AC_DEFUN([CF_UTMP],
2646[
2647AC_REQUIRE([CF_LASTLOG])
2648
2649AC_CACHE_CHECK(for utmp implementation,cf_cv_have_utmp,[
2650	cf_cv_have_utmp=no
2651for cf_header in utmpx utmp ; do
2652cf_utmp_includes="
2653#include <sys/types.h>
2654#include <${cf_header}.h>
2655#define getutent getutxent
2656#ifdef USE_LASTLOG
2657#include <lastlog.h>	/* may conflict with utmpx.h on Linux */
2658#endif
2659"
2660	AC_TRY_COMPILE([$cf_utmp_includes],
2661	[struct $cf_header x;
2662	 char *name = x.ut_name; /* utmp.h and compatible definitions */
2663	],
2664	[cf_cv_have_utmp=$cf_header
2665	 break],
2666	[
2667	AC_TRY_COMPILE([$cf_utmp_includes],
2668	[struct $cf_header x;
2669	 char *name = x.ut_user; /* utmpx.h must declare this */
2670	],
2671	[cf_cv_have_utmp=$cf_header
2672	 break
2673	])])
2674done
2675])
2676
2677if test $cf_cv_have_utmp != no ; then
2678	AC_DEFINE(HAVE_UTMP,1,[Define to 1 if the utmp interface is available])
2679	test $cf_cv_have_utmp = utmpx && AC_DEFINE(UTMPX_FOR_UTMP,1,[Define if we have utmpx interface])
2680	CF_UTMP_UT_HOST
2681	CF_UTMP_UT_SYSLEN
2682	CF_UTMP_UT_NAME
2683	CF_UTMP_UT_XSTATUS
2684	CF_UTMP_UT_XTIME
2685	CF_UTMP_UT_SESSION
2686	CF_SYSV_UTMP
2687fi
2688])dnl
2689dnl ---------------------------------------------------------------------------
2690dnl CF_UTMP_GROUP version: 1 updated: 2005/10/06 20:29:29
2691dnl -------------
2692dnl Find the utmp/utmpx file and determine its group to allow setgid programs
2693dnl to manipulate it, e.g., when there is no intermediary.
2694AC_DEFUN([CF_UTMP_GROUP],[
2695AC_REQUIRE([CF_UTMP])
2696if test $cf_cv_have_utmp != no ; then
2697AC_CACHE_CHECK(for utmp/utmpx group,cf_cv_utmp_group,[
2698for cf_utmp_path in /var/adm /var/run
2699do
2700	for cf_utmp_file in utmpx utmp
2701	do
2702		if test -f $cf_utmp_path/$cf_utmp_file
2703		then
2704			cf_cv_utmp_group=root
2705
2706			cf_option="-l -L"
2707
2708			# Expect listing to have fields like this:
2709			#-r--r--r--   1 user      group       34293 Jul 18 16:29 pathname
2710			ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
2711			read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
2712			if test -z "$cf_rest" ; then
2713				cf_option="$cf_option -g"
2714				ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
2715				read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
2716			fi
2717			rm -f conftest
2718
2719			# If we have a pathname, and the date fields look right, assume we've
2720			# captured the group as well.
2721			if test -n "$cf_rest" ; then
2722				cf_test=`echo "${cf_date2}${cf_date3}" | sed -e 's/[[0-9:]]//g'`
2723				if test -z "$cf_test" ; then
2724					cf_cv_utmp_group=$cf_grp;
2725				fi
2726			fi
2727			break
2728		fi
2729	done
2730	test -n "$cf_cv_utmp_group" && break
2731done
2732])
2733else
2734	AC_MSG_ERROR(cannot find utmp group)
2735fi
2736])dnl
2737dnl ---------------------------------------------------------------------------
2738dnl CF_UTMP_UT_HOST version: 8 updated: 2012/10/04 20:12:20
2739dnl ---------------
2740dnl Check if UTMP/UTMPX struct defines ut_host member
2741AC_DEFUN([CF_UTMP_UT_HOST],
2742[
2743if test $cf_cv_have_utmp != no ; then
2744AC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_host is declared)
2745AC_CACHE_VAL(cf_cv_have_utmp_ut_host,[
2746	AC_TRY_COMPILE([
2747#include <sys/types.h>
2748#include <${cf_cv_have_utmp}.h>],
2749	[struct $cf_cv_have_utmp x; char *y = &x.ut_host[0]],
2750	[cf_cv_have_utmp_ut_host=yes],
2751	[cf_cv_have_utmp_ut_host=no])
2752	])
2753AC_MSG_RESULT($cf_cv_have_utmp_ut_host)
2754test $cf_cv_have_utmp_ut_host != no && AC_DEFINE(HAVE_UTMP_UT_HOST,1,[Define to 1 if UTMP/UTMPX struct defines ut_host member])
2755fi
2756])dnl
2757dnl ---------------------------------------------------------------------------
2758dnl CF_UTMP_UT_NAME version: 5 updated: 2012/10/04 20:12:20
2759dnl ---------------
2760dnl Check if UTMP/UTMPX struct defines ut_name member
2761AC_DEFUN([CF_UTMP_UT_NAME],
2762[
2763if test $cf_cv_have_utmp != no ; then
2764AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_name is declared,cf_cv_have_utmp_ut_name,[
2765	cf_cv_have_utmp_ut_name=no
2766cf_utmp_includes="
2767#include <sys/types.h>
2768#include <${cf_cv_have_utmp}.h>
2769#define getutent getutxent
2770#ifdef USE_LASTLOG
2771#include <lastlog.h>		/* may conflict with utmpx.h on Linux */
2772#endif
2773"
2774for cf_header in ut_name ut_user ; do
2775	AC_TRY_COMPILE([$cf_utmp_includes],
2776	[struct $cf_cv_have_utmp x;
2777	 char *name = x.$cf_header;
2778	],
2779	[cf_cv_have_utmp_ut_name=$cf_header
2780	 break])
2781done
2782])
2783
2784case $cf_cv_have_utmp_ut_name in #(vi
2785no) #(vi
2786	AC_MSG_ERROR(Cannot find declaration for ut.ut_name)
2787	;;
2788ut_user)
2789	AC_DEFINE(ut_name,ut_user,[Define to rename UTMP/UTMPX struct ut_name member])
2790	;;
2791esac
2792fi
2793])dnl
2794dnl ---------------------------------------------------------------------------
2795dnl CF_UTMP_UT_SESSION version: 6 updated: 2012/10/04 20:12:20
2796dnl ------------------
2797dnl Check if UTMP/UTMPX struct defines ut_session member
2798AC_DEFUN([CF_UTMP_UT_SESSION],
2799[
2800if test $cf_cv_have_utmp != no ; then
2801AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_session is declared, cf_cv_have_utmp_ut_session,[
2802	AC_TRY_COMPILE([
2803#include <sys/types.h>
2804#include <${cf_cv_have_utmp}.h>],
2805	[struct $cf_cv_have_utmp x; long y = x.ut_session],
2806	[cf_cv_have_utmp_ut_session=yes],
2807	[cf_cv_have_utmp_ut_session=no])
2808])
2809if test $cf_cv_have_utmp_ut_session != no ; then
2810	AC_DEFINE(HAVE_UTMP_UT_SESSION,1,[Define to 1 if UTMP/UTMPX struct defines ut_session member])
2811fi
2812fi
2813])dnl
2814dnl ---------------------------------------------------------------------------
2815dnl CF_UTMP_UT_SYSLEN version: 2 updated: 2012/10/04 20:12:20
2816dnl -----------------
2817dnl Check if UTMP/UTMPX struct defines ut_syslen member
2818AC_DEFUN([CF_UTMP_UT_SYSLEN],
2819[
2820if test $cf_cv_have_utmp != no ; then
2821AC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_syslen is declared)
2822AC_CACHE_VAL(cf_cv_have_utmp_ut_syslen,[
2823	AC_TRY_COMPILE([
2824#include <sys/types.h>
2825#include <${cf_cv_have_utmp}.h>],
2826	[struct $cf_cv_have_utmp x; int y = x.ut_syslen],
2827	[cf_cv_have_utmp_ut_syslen=yes],
2828	[cf_cv_have_utmp_ut_syslen=no])
2829	])
2830AC_MSG_RESULT($cf_cv_have_utmp_ut_syslen)
2831test $cf_cv_have_utmp_ut_syslen != no && AC_DEFINE(HAVE_UTMP_UT_SYSLEN,1,[Define to 1 if UTMP/UTMPX struct defines ut_syslen member])
2832fi
2833])dnl
2834dnl ---------------------------------------------------------------------------
2835dnl CF_UTMP_UT_XSTATUS version: 4 updated: 2012/10/04 20:12:20
2836dnl ------------------
2837dnl Check for known variants on the UTMP/UTMPX struct's exit-status as reported
2838dnl by various people:
2839dnl
2840dnl	ut_exit.__e_exit (HPUX 11 - David Ellement, also in glibc2)
2841dnl	ut_exit.e_exit (SVR4)
2842dnl	ut_exit.ut_e_exit (os390 - Greg Smith)
2843dnl	ut_exit.ut_exit (Tru64 4.0f - Jeremie Petit, 4.0e - Tomas Vanhala)
2844dnl
2845dnl Note: utmp_xstatus is not a conventional compatibility definition in the
2846dnl system header files.
2847AC_DEFUN([CF_UTMP_UT_XSTATUS],
2848[
2849if test $cf_cv_have_utmp != no ; then
2850AC_CACHE_CHECK(for exit-status in $cf_cv_have_utmp,cf_cv_have_utmp_ut_xstatus,[
2851for cf_result in \
2852	ut_exit.__e_exit \
2853	ut_exit.e_exit \
2854	ut_exit.ut_e_exit \
2855	ut_exit.ut_exit
2856do
2857AC_TRY_COMPILE([
2858#include <sys/types.h>
2859#include <${cf_cv_have_utmp}.h>],
2860	[struct $cf_cv_have_utmp x; long y = x.$cf_result = 0],
2861	[cf_cv_have_utmp_ut_xstatus=$cf_result
2862	 break],
2863	[cf_cv_have_utmp_ut_xstatus=no])
2864done
2865])
2866if test $cf_cv_have_utmp_ut_xstatus != no ; then
2867	AC_DEFINE(HAVE_UTMP_UT_XSTATUS,1,[Define to 1 if UTMP/UTMPX has exit-status member])
2868	AC_DEFINE_UNQUOTED(ut_xstatus,$cf_cv_have_utmp_ut_xstatus,[Define if needed to rename member ut_xstatus of UTMP/UTMPX])
2869fi
2870fi
2871])dnl
2872dnl ---------------------------------------------------------------------------
2873dnl CF_UTMP_UT_XTIME version: 9 updated: 2012/10/04 20:12:20
2874dnl ----------------
2875dnl Check if UTMP/UTMPX struct defines ut_xtime member
2876AC_DEFUN([CF_UTMP_UT_XTIME],
2877[
2878if test $cf_cv_have_utmp != no ; then
2879AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_xtime is declared, cf_cv_have_utmp_ut_xtime,[
2880	AC_TRY_COMPILE([
2881#include <sys/types.h>
2882#include <${cf_cv_have_utmp}.h>],
2883	[struct $cf_cv_have_utmp x; long y = x.ut_xtime = 0],
2884	[cf_cv_have_utmp_ut_xtime=yes],
2885	[AC_TRY_COMPILE([
2886#include <sys/types.h>
2887#include <${cf_cv_have_utmp}.h>],
2888	[struct $cf_cv_have_utmp x; long y = x.ut_tv.tv_sec],
2889	[cf_cv_have_utmp_ut_xtime=define],
2890	[cf_cv_have_utmp_ut_xtime=no])
2891	])
2892])
2893if test $cf_cv_have_utmp_ut_xtime != no ; then
2894	AC_DEFINE(HAVE_UTMP_UT_XTIME,1,[Define to 1 if UTMP/UTMPX struct defines ut_xtime member])
2895	if test $cf_cv_have_utmp_ut_xtime = define ; then
2896		AC_DEFINE(ut_xtime,ut_tv.tv_sec,[Define if needed to alternate name for utmpx.ut_xtime member])
2897	fi
2898fi
2899fi
2900])dnl
2901dnl ---------------------------------------------------------------------------
2902dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
2903dnl ----------
2904dnl Use AC_VERBOSE w/o the warnings
2905AC_DEFUN([CF_VERBOSE],
2906[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
2907CF_MSG_LOG([$1])
2908])dnl
2909dnl ---------------------------------------------------------------------------
2910dnl CF_WITH_APP_CLASS version: 2 updated: 2012/10/04 04:29:52
2911dnl -----------------
2912dnl Handle configure option "--with-app-class", setting the $APP_CLASS
2913dnl variable, used for X resources.
2914dnl
2915dnl $1 = default value.
2916AC_DEFUN([CF_WITH_APP_CLASS],[
2917AC_MSG_CHECKING(for X applications class)
2918AC_ARG_WITH(app-class,
2919	[  --with-app-class=XXX    override X applications class (default $1)],
2920	[APP_CLASS=$withval],
2921	[APP_CLASS=$1])
2922
2923case x$APP_CLASS in #(vi
2924*[[/@,%]]*) #(vi
2925	AC_MSG_WARN(X applications class cannot contain punctuation)
2926	APP_CLASS=$1
2927	;;
2928x[[A-Z]]*) #(vi
2929	;;
2930*)
2931	AC_MSG_WARN([X applications class must start with capital, ignoring $APP_CLASS])
2932	APP_CLASS=$1
2933	;;
2934esac
2935
2936AC_MSG_RESULT($APP_CLASS)
2937
2938AC_SUBST(APP_CLASS)
2939])dnl
2940dnl ---------------------------------------------------------------------------
2941dnl CF_WITH_APP_DEFAULTS version: 5 updated: 2012/10/04 04:29:52
2942dnl --------------------
2943dnl Handle configure option "--with-app-defaults", setting these shell
2944dnl variables:
2945dnl
2946dnl $APPSDIR is the option value, used for installing app-defaults files.
2947dnl $no_appsdir is a "#" (comment) if "--without-app-defaults" is given.
2948dnl
2949dnl Most Linux's use this:
2950dnl 	/usr/share/X11/app-defaults
2951dnl Debian uses this:
2952dnl 	/etc/X11/app-defaults
2953dnl DragonFlyBSD ports uses this:
2954dnl 	/usr/pkg/lib/X11/app-defaults
2955dnl FreeBSD ports use these:
2956dnl 	/usr/local/lib/X11/app-defaults
2957dnl 	/usr/local/share/X11/app-defaults
2958dnl Mandriva has these:
2959dnl 	/usr/lib/X11/app-defaults
2960dnl 	/usr/lib64/X11/app-defaults
2961dnl NetBSD has these
2962dnl 	/usr/X11R7/lib/X11/app-defaults
2963dnl OpenSolaris uses
2964dnl 	32-bit:
2965dnl 	/usr/X11/etc/X11/app-defaults
2966dnl 	/usr/X11/share/X11/app-defaults
2967dnl 	/usr/X11/lib/X11/app-defaults
2968dnl	64-bit:
2969dnl 	/usr/X11/etc/X11/app-defaults
2970dnl 	/usr/X11/share/X11/app-defaults (I mkdir'd this)
2971dnl 	/usr/X11/lib/amd64/X11/app-defaults
2972dnl Solaris10 uses (in this order):
2973dnl 	/usr/openwin/lib/X11/app-defaults
2974dnl 	/usr/X11/lib/X11/app-defaults
2975AC_DEFUN([CF_WITH_APP_DEFAULTS],[
2976AC_MSG_CHECKING(for directory to install resource files)
2977AC_ARG_WITH(app-defaults,
2978	[  --with-app-defaults=DIR directory in which to install resource files (EPREFIX/lib/X11/app-defaults)],
2979	[APPSDIR=$withval],
2980	[APPSDIR='${exec_prefix}/lib/X11/app-defaults'])
2981
2982if test "x[$]APPSDIR" = xauto
2983then
2984	APPSDIR='${exec_prefix}/lib/X11/app-defaults'
2985	for cf_path in \
2986		/usr/share/X11/app-defaults \
2987		/usr/X11/share/X11/app-defaults \
2988		/usr/X11/lib/X11/app-defaults \
2989		/usr/lib/X11/app-defaults \
2990		/etc/X11/app-defaults \
2991		/usr/pkg/lib/X11/app-defaults \
2992		/usr/X11R7/lib/X11/app-defaults \
2993		/usr/X11R6/lib/X11/app-defaults \
2994		/usr/X11R5/lib/X11/app-defaults \
2995		/usr/X11R4/lib/X11/app-defaults \
2996		/usr/local/lib/X11/app-defaults \
2997		/usr/local/share/X11/app-defaults \
2998		/usr/lib64/X11/app-defaults
2999	do
3000		if test -d "$cf_path" ; then
3001			APPSDIR="$cf_path"
3002			break
3003		fi
3004	done
3005else
3006	cf_path=$APPSDIR
3007	CF_PATH_SYNTAX(cf_path)
3008fi
3009
3010AC_MSG_RESULT($APPSDIR)
3011AC_SUBST(APPSDIR)
3012
3013no_appsdir=
3014if test "$APPSDIR" = no
3015then
3016	no_appsdir="#"
3017else
3018	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(APPSDIR)"
3019fi
3020AC_SUBST(no_appsdir)
3021])dnl
3022dnl ---------------------------------------------------------------------------
3023dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
3024dnl ----------------
3025dnl Configure-option for dbmalloc.  The optional parameter is used to override
3026dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3027AC_DEFUN([CF_WITH_DBMALLOC],[
3028CF_NO_LEAKS_OPTION(dbmalloc,
3029	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
3030	[USE_DBMALLOC])
3031
3032if test "$with_dbmalloc" = yes ; then
3033	AC_CHECK_HEADER(dbmalloc.h,
3034		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
3035fi
3036])dnl
3037dnl ---------------------------------------------------------------------------
3038dnl CF_WITH_DESKTOP_CATEGORY version: 4 updated: 2013/01/01 10:50:14
3039dnl ------------------------
3040dnl Taking into account the absence of standardization of desktop categories
3041dnl take a look to see whether other applications on the current system are
3042dnl assigned any/all of a set of suggested categories.
3043dnl
3044dnl $1 = program name
3045dnl $2 = case-pattern to match comparable desktop files to obtain category
3046dnl      This pattern may contain wildcards.
3047dnl $3 = suggested categories, also a case-pattern but without wildcards,
3048dnl      since it doubles as a default value for a shell case-statement.
3049dnl $4 = categories to use if no match is found on the build-machine for the
3050dnl      --with-desktop-category "auto" setting.
3051dnl
3052dnl The macro tells the configure script to substitute the $DESKTOP_CATEGORY
3053dnl value.
3054AC_DEFUN([CF_WITH_DESKTOP_CATEGORY],[
3055AC_REQUIRE([CF_DISABLE_DESKTOP])
3056
3057if test -z "$desktop_utils"
3058then
3059	AC_MSG_CHECKING(for requested desktop-category)
3060	AC_ARG_WITH(desktop-category,
3061		[  --with-desktop-category=XXX  one or more desktop catgories or auto],
3062		[cf_desktop_want=$withval],
3063		[cf_desktop_want=auto])
3064	AC_MSG_RESULT($cf_desktop_want)
3065
3066	if test "$cf_desktop_want" = auto
3067	then
3068		rm -rf conftest*
3069		cf_desktop_also=
3070		for cf_desktop_dir in  \
3071			/usr/share/app-install \
3072			/usr/share/applications
3073		do
3074			if test -d $cf_desktop_dir
3075			then
3076				find $cf_desktop_dir -name '*.desktop' | \
3077				while true
3078				do
3079					read cf_desktop_path
3080					test -z "$cf_desktop_path" && break
3081					cf_desktop_name=`basename $cf_desktop_path .desktop`
3082					case $cf_desktop_name in #(vi
3083					$1|*-$1|$2)
3084						CF_VERBOSE(inspect $cf_desktop_path)
3085						egrep '^Categories=' $cf_desktop_path | \
3086							tr ';' '\n' | \
3087							sed -e 's%^.*=%%' -e '/^$/d' >>conftest.1
3088						;;
3089					esac
3090				done
3091			fi
3092		done
3093		if test -s conftest.1
3094		then
3095			cf_desktop_last=
3096			sort conftest.1 | \
3097			while true
3098			do
3099				read cf_desktop_this
3100				test -z "$cf_desktop_this" && break
3101				case $cf_desktop_this in #(vi
3102				Qt*|GTK*|KDE*|GNOME*|*XFCE*|*Xfce*) #(vi
3103					;;
3104				$3)
3105					test "x$cf_desktop_last" != "x$cf_desktop_this" && echo $cf_desktop_this >>conftest.2
3106					;;
3107				esac
3108				cf_desktop_last=$cf_desktop_this
3109			done
3110			cf_desktop_want=`cat conftest.2 | tr '\n' ';'`
3111		fi
3112		if test -n "$cf_desktop_want"
3113		then
3114			if test "$cf_desktop_want" = auto
3115			then
3116				cf_desktop_want=
3117			else
3118				# do a sanity check on the semicolon-separated list, ignore on failure
3119				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/[[^;]]//g'`
3120				test -z "$cf_desktop_test" && cf_desktop_want=
3121				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/^.*;$/./g'`
3122				test -z "$cf_desktop_test" && cf_desktop_want=
3123			fi
3124		fi
3125		if test -z "$cf_desktop_want"
3126		then
3127			cf_desktop_want="ifelse([$4],,ifelse([$3],,[Application;],[`echo "$3" | sed -e 's/\*//g' -e 's/|/;/g' -e 's/[[;]]*$/;/g'`]),[$4])"
3128			CF_VERBOSE(no usable value found for desktop category, using $cf_desktop_want)
3129		fi
3130	fi
3131	DESKTOP_CATEGORY=`echo "$cf_desktop_want" | sed -e 's/[[ ,]]/;/g'`
3132	CF_VERBOSE(will use Categories=$DESKTOP_CATEGORY)
3133	AC_SUBST(DESKTOP_CATEGORY)
3134fi
3135])
3136dnl ---------------------------------------------------------------------------
3137dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
3138dnl ---------------
3139dnl Configure-option for dmalloc.  The optional parameter is used to override
3140dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3141AC_DEFUN([CF_WITH_DMALLOC],[
3142CF_NO_LEAKS_OPTION(dmalloc,
3143	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
3144	[USE_DMALLOC])
3145
3146if test "$with_dmalloc" = yes ; then
3147	AC_CHECK_HEADER(dmalloc.h,
3148		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
3149fi
3150])dnl
3151dnl ---------------------------------------------------------------------------
3152dnl CF_WITH_ICONDIR version: 5 updated: 2012/07/22 09:18:02
3153dnl ---------------
3154dnl Handle configure option "--with-icondir", setting these shell variables:
3155dnl
3156dnl $ICONDIR is the option value, used for installing icon files.
3157dnl $no_icondir is a "#" (comment) if "--without-icondir" is given.
3158AC_DEFUN([CF_WITH_ICONDIR],[
3159AC_MSG_CHECKING(for directory to install icons)
3160AC_ARG_WITH(icondir,
3161	[  --with-icondir=DIR      directory in which to install icons for desktop],
3162	[ICONDIR=$withval],
3163	[test -z "$ICONDIR" && ICONDIR=no])
3164
3165if test "x[$]ICONDIR" = xauto
3166then
3167	ICONDIR='${datadir}/icons'
3168	for cf_path in \
3169		/usr/share/icons \
3170		/usr/X11R6/share/icons
3171	do
3172		if test -d "$cf_path" ; then
3173			ICONDIR="$cf_path"
3174			break
3175		fi
3176	done
3177else
3178	cf_path=$ICONDIR
3179	CF_PATH_SYNTAX(cf_path)
3180fi
3181AC_MSG_RESULT($ICONDIR)
3182AC_SUBST(ICONDIR)
3183
3184no_icondir=
3185if test "$ICONDIR" = no
3186then
3187	no_icondir="#"
3188else
3189	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(ICONDIR)"
3190fi
3191AC_SUBST(no_icondir)
3192])dnl
3193dnl ---------------------------------------------------------------------------
3194dnl CF_WITH_ICON_NAME version: 2 updated: 2013/05/27 18:34:42
3195dnl -----------------
3196dnl Allow a default icon-name to be overridden.
3197dnl $1 = default icon name
3198AC_DEFUN([CF_WITH_ICON_NAME],[
3199AC_MSG_CHECKING(for the icon name)
3200AC_ARG_WITH(icon-name,
3201	[  --with-icon-name=XXXX   override icon name (default: $1)],
3202	[ICON_NAME="$withval"],
3203	[ICON_NAME=$1])
3204case "x$ICON_NAME" in
3205xyes|xno|x)
3206	ICON_NAME=$1
3207	;;
3208esac
3209AC_SUBST(ICON_NAME)
3210AC_MSG_RESULT($ICON_NAME)
3211])dnl
3212dnl ---------------------------------------------------------------------------
3213dnl CF_WITH_ICON_SYMLINK version: 1 updated: 2013/05/27 18:34:42
3214dnl --------------------
3215dnl Workaround for systems which are (mis)configured to map all icon references
3216dnl for xterm into "xterm" name.  For instance, recent (2013) KDE ignores both
3217dnl the name given in the .desktop file (xterm-color) and the application name
3218dnl (xterm-dev).
3219dnl
3220dnl $1 = default icon name to use if symlink is wanted
3221AC_DEFUN([CF_WITH_ICON_SYMLINK],[
3222AC_MSG_CHECKING(for icon symlink to use)
3223AC_ARG_WITH(icon-symlink,
3224	[  --with-icon-symlink=XXX make symbolic link for icon name (default: $1)],
3225	[ICON_SYMLINK="$withval"],
3226	[ICON_SYMLINK=NONE])
3227case "x$ICON_SYMLINK" in
3228xyes)
3229	ICON_SYMLINK=$1
3230	;;
3231xno|x)
3232	ICON_SYMLINK=NONE
3233	;;
3234esac
3235AC_SUBST(ICON_SYMLINK)
3236AC_MSG_RESULT($ICON_SYMLINK)
3237])dnl
3238dnl ---------------------------------------------------------------------------
3239dnl CF_WITH_ICON_THEME version: 9 updated: 2013/04/17 05:31:24
3240dnl ------------------
3241dnl If asked, check for prerequisites and setup symbols to permit installing
3242dnl one or more application icons in the Red Hat icon-theme directory
3243dnl hierarchy. 
3244dnl
3245dnl If the prerequisites are missing, give a warning and revert to the long-
3246dnl standing pixmaps directory.
3247dnl
3248dnl Parameters:
3249dnl
3250dnl $1 = application icon.  This can be a list, and is not optional.
3251dnl $2 = default theme (defaults to hicolor)
3252dnl $3 = formats (defaults to list [.svg .png .xpm])
3253dnl $4 = alternate icon if no theme is used (defaults to $1).
3254dnl
3255dnl Result:
3256dnl ICON_NAME = basename of first item in $1
3257dnl ICON_LIST = reprocessed $1
3258dnl ICON_THEME = reprocessed $2
3259dnl ICON_FORMAT = reprocessed $3
3260AC_DEFUN([CF_WITH_ICON_THEME],
3261[
3262ifelse([$1],,[
3263	AC_MSG_ERROR([macro [CF_WITH_ICON_THEME] requires application-icon name])
3264],[
3265
3266CF_WITH_PIXMAPDIR
3267CF_WITH_ICONDIR
3268
3269AC_MSG_CHECKING(if icon theme should be used)
3270AC_ARG_WITH(icon-theme,
3271	[  --with-icon-theme=XXX   install icons into desktop theme (hicolor)],
3272	[ICON_THEME=$withval],
3273	[ICON_THEME=no])
3274
3275case "x$ICON_THEME" in #(vi
3276xno) #(vi
3277	;;
3278x|xyes)
3279	ICON_THEME=ifelse([$2],,hicolor,$2)
3280	;;
3281esac
3282AC_MSG_RESULT($ICON_THEME)
3283
3284if test "x$ICON_THEME" = xno
3285then
3286	if test "x$ICONDIR" != xno
3287	then
3288		CF_VERBOSE(ignoring icondir without theme)
3289		no_icondir="#"
3290	fi
3291else
3292	if test "x$ICONDIR" = xno
3293	then
3294		AC_MSG_ERROR(icondir must be set for icon theme)
3295	fi
3296fi
3297
3298: ${ICON_FORMAT:=ifelse([$3],,[".svg .png .xpm"],[$3])}
3299
3300# ICON_NAME=
3301ICON_LIST=
3302
3303ifelse([$4],,[cf_icon_list=$1],[
3304if test "x$ICON_THEME" != xno
3305then
3306	cf_icon_list="$1"
3307else
3308	cf_icon_list="$4"
3309fi
3310])
3311
3312AC_MSG_CHECKING([for icon(s) to install])
3313for cf_name in $cf_icon_list
3314do
3315	CF_VERBOSE(using $ICON_FORMAT)
3316	for cf_suffix in $ICON_FORMAT
3317	do
3318		cf_icon="${cf_name}${cf_suffix}"
3319		cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
3320		if test ! -f "${cf_left}"
3321		then
3322			if test "x$srcdir" != "x."
3323			then
3324				cf_icon="${srcdir}/${cf_left}"
3325				cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
3326				if test ! -f "${cf_left}"
3327				then
3328					continue
3329				fi
3330			else
3331				continue
3332			fi
3333		fi
3334		if test "x$ICON_THEME" != xno
3335		then
3336			cf_base=`basename $cf_left`
3337			cf_trim=`echo "$cf_base" | sed -e 's/_[[0-9]][[0-9]]x[[0-9]][[0-9]]\././'`
3338			case "x${cf_base}" in #(vi
3339			*:*) #(vi
3340				cf_next=$cf_base
3341				# user-defined mapping
3342				;;
3343			*.png) #(vi
3344				cf_size=`file "$cf_left"|sed -e 's/^[[^:]]*://' -e 's/^.*[[^0-9]]\([[0-9]][[0-9]]* x [[0-9]][[0-9]]*\)[[^0-9]].*$/\1/' -e 's/ //g'`
3345				if test -z "$cf_size"
3346				then
3347					AC_MSG_WARN(cannot determine size of $cf_left)
3348					continue
3349				fi
3350				cf_next="$cf_size/apps/$cf_trim"
3351				;;
3352			*.svg) #(vi
3353				cf_next="scalable/apps/$cf_trim"
3354				;;
3355			*.xpm)
3356				CF_VERBOSE(ignored XPM file in icon theme)
3357				continue
3358				;;
3359			*_[[0-9]][[0-9]]*x[[0-9]][[0-9]]*.*) #(vi
3360				cf_size=`echo "$cf_left"|sed -e 's/^.*_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\..*$/\1/'`
3361				cf_left=`echo "$cf_left"|sed -e 's/^\(.*\)_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\(\..*\)$/\1\3/'`
3362				cf_next="$cf_size/apps/$cf_base"
3363				;;
3364			esac
3365			CF_VERBOSE(adding $cf_next)
3366			cf_icon="${cf_icon}:${cf_next}"
3367		fi
3368		test -n "$ICON_LIST" && ICON_LIST="$ICON_LIST "
3369		ICON_LIST="$ICON_LIST${cf_icon}"
3370		if test -z "$ICON_NAME"
3371		then
3372			ICON_NAME=`basename $cf_icon | sed -e 's/[[.:]].*//'`
3373		fi
3374	done
3375done
3376
3377if test -n "$verbose"
3378then
3379	AC_MSG_CHECKING(result)
3380fi
3381AC_MSG_RESULT($ICON_LIST)
3382
3383if test -z "$ICON_LIST"
3384then
3385	AC_MSG_ERROR(no icons found)
3386fi
3387])
3388
3389AC_MSG_CHECKING(for icon name)
3390AC_MSG_RESULT($ICON_NAME)
3391
3392AC_SUBST(ICON_FORMAT)
3393AC_SUBST(ICON_THEME)
3394AC_SUBST(ICON_LIST)
3395AC_SUBST(ICON_NAME)
3396])dnl
3397dnl ---------------------------------------------------------------------------
3398dnl CF_WITH_IMAKE_CFLAGS version: 9 updated: 2010/05/26 05:38:42
3399dnl --------------------
3400dnl xterm and similar programs build more readily when propped up with imake's
3401dnl hand-tuned definitions.  If we do not use imake, provide fallbacks for the
3402dnl most common definitions that we're not likely to do by autoconf tests.
3403AC_DEFUN([CF_WITH_IMAKE_CFLAGS],[
3404AC_REQUIRE([CF_ENABLE_NARROWPROTO])
3405
3406AC_MSG_CHECKING(if we should use imake to help)
3407CF_ARG_DISABLE(imake,
3408	[  --disable-imake         disable use of imake for definitions],
3409	[enable_imake=no],
3410	[enable_imake=yes])
3411AC_MSG_RESULT($enable_imake)
3412
3413if test "$enable_imake" = yes ; then
3414	CF_IMAKE_CFLAGS(ifelse([$1],,,[$1]))
3415fi
3416
3417if test -n "$IMAKE" && test -n "$IMAKE_CFLAGS" ; then
3418	CF_ADD_CFLAGS($IMAKE_CFLAGS)
3419else
3420	IMAKE_CFLAGS=
3421	IMAKE_LOADFLAGS=
3422	CF_VERBOSE(make fallback definitions)
3423
3424	# We prefer config.guess' values when we can get them, to avoid
3425	# inconsistent results with uname (AIX for instance).  However,
3426	# config.guess is not always consistent either.
3427	case $host_os in
3428	*[[0-9]].[[0-9]]*)
3429		UNAME_RELEASE="$host_os"
3430		;;
3431	*)
3432		UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
3433		;;
3434	esac
3435
3436	case .$UNAME_RELEASE in
3437	*[[0-9]].[[0-9]]*)
3438		OSMAJORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/\..*//'`
3439		OSMINORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/^[[^.]]*\.//' -e 's/\..*//' -e 's/[[^0-9]].*//' `
3440		test -z "$OSMAJORVERSION" && OSMAJORVERSION=1
3441		test -z "$OSMINORVERSION" && OSMINORVERSION=0
3442		IMAKE_CFLAGS="-DOSMAJORVERSION=$OSMAJORVERSION -DOSMINORVERSION=$OSMINORVERSION $IMAKE_CFLAGS"
3443		;;
3444	esac
3445
3446	# FUNCPROTO is standard with X11R6, but XFree86 drops it, leaving some
3447	# fallback/fragments for NeedPrototypes, etc.
3448	IMAKE_CFLAGS="-DFUNCPROTO=15 $IMAKE_CFLAGS"
3449
3450	# If this is not set properly, Xaw's scrollbars will not work
3451	if test "$enable_narrowproto" = yes ; then
3452		IMAKE_CFLAGS="-DNARROWPROTO=1 $IMAKE_CFLAGS"
3453	fi
3454
3455	# Other special definitions:
3456	case $host_os in
3457	aix*)
3458		# imake on AIX 5.1 defines AIXV3.  really.
3459		IMAKE_CFLAGS="-DAIXV3 -DAIXV4 $IMAKE_CFLAGS"
3460		;;
3461	irix[[56]].*) #(vi
3462		# these are needed to make SIGWINCH work in xterm
3463		IMAKE_CFLAGS="-DSYSV -DSVR4 $IMAKE_CFLAGS"
3464		;;
3465	esac
3466
3467	CF_ADD_CFLAGS($IMAKE_CFLAGS)
3468
3469	AC_SUBST(IMAKE_CFLAGS)
3470	AC_SUBST(IMAKE_LOADFLAGS)
3471fi
3472])dnl
3473dnl ---------------------------------------------------------------------------
3474dnl CF_WITH_PCRE version: 10 updated: 2012/10/04 20:12:20
3475dnl ------------
3476dnl Add PCRE (Perl-compatible regular expressions) to the build if it is
3477dnl available and the user requests it.  Assume the application will otherwise
3478dnl use the POSIX interface.
3479dnl
3480dnl TODO allow $withval to specify package location
3481AC_DEFUN([CF_WITH_PCRE],
3482[
3483AC_REQUIRE([CF_PKG_CONFIG])
3484
3485AC_MSG_CHECKING(if you want to use PCRE for regular-expressions)
3486AC_ARG_WITH(pcre,
3487	[  --with-pcre             use PCRE for regular-expressions])
3488test -z "$with_pcre" && with_pcre=no
3489AC_MSG_RESULT($with_pcre)
3490
3491if test "$with_pcre" != no ; then
3492	CF_TRY_PKG_CONFIG(libpcre,,[
3493		AC_CHECK_LIB(pcre,pcre_compile,,
3494			AC_MSG_ERROR(Cannot find PCRE library))])
3495
3496		AC_DEFINE(HAVE_LIB_PCRE,1,[Define to 1 if we can/should compile with the PCRE library])
3497
3498		case $LIBS in #(vi
3499		*pcreposix*) #(vi
3500			;;
3501		*)
3502			AC_CHECK_LIB(pcreposix,pcreposix_regcomp,
3503				[AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we should include pcreposix.h])
3504				 CF_ADD_LIB(pcreposix)],
3505				[AC_CHECK_LIB(pcreposix,regcomp,[
3506					AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we should include pcreposix.h])
3507					CF_ADD_LIB(pcreposix)],
3508					AC_MSG_ERROR(Cannot find PCRE POSIX library)]))
3509			;;
3510		esac
3511fi
3512])dnl
3513dnl ---------------------------------------------------------------------------
3514dnl CF_WITH_PIXMAPDIR version: 3 updated: 2012/07/22 09:18:02
3515dnl -----------------
3516dnl Handle configure option "--with-pixmapdir", setting these shell variables:
3517dnl
3518dnl $PIXMAPDIR is the option value, used for installing pixmap files.
3519dnl $no_pixmapdir is a "#" (comment) if "--without-pixmapdir" is given.
3520AC_DEFUN([CF_WITH_PIXMAPDIR],[
3521AC_MSG_CHECKING(for directory to install pixmaps)
3522AC_ARG_WITH(pixmapdir,
3523	[  --with-pixmapdir=DIR    directory in which to install pixmaps (DATADIR/pixmaps)],
3524	[PIXMAPDIR=$withval],
3525	[test -z "$PIXMAPDIR" && PIXMAPDIR='${datadir}/pixmaps'])
3526
3527if test "x[$]PIXMAPDIR" = xauto
3528then
3529	PIXMAPDIR='${datadir}/pixmaps'
3530	for cf_path in \
3531		/usr/share/pixmaps \
3532		/usr/X11R6/share/pixmaps
3533	do
3534		if test -d "$cf_path" ; then
3535			PIXMAPDIR="$cf_path"
3536			break
3537		fi
3538	done
3539else
3540	cf_path=$PIXMAPDIR
3541	CF_PATH_SYNTAX(cf_path)
3542fi
3543AC_MSG_RESULT($PIXMAPDIR)
3544AC_SUBST(PIXMAPDIR)
3545
3546no_pixmapdir=
3547if test "$PIXMAPDIR" = no
3548then
3549	no_pixmapdir="#"
3550else
3551	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(PIXMAPDIR)"
3552fi
3553AC_SUBST(no_pixmapdir)
3554])dnl
3555dnl ---------------------------------------------------------------------------
3556dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
3557dnl ----------------
3558AC_DEFUN([CF_WITH_VALGRIND],[
3559CF_NO_LEAKS_OPTION(valgrind,
3560	[  --with-valgrind         test: use valgrind],
3561	[USE_VALGRIND])
3562])dnl
3563dnl ---------------------------------------------------------------------------
3564dnl CF_WITH_XPM version: 3 updated: 2012/10/04 06:57:36
3565dnl -----------
3566dnl Test for Xpm library, update compiler/loader flags if it is wanted and
3567dnl found.
3568dnl
3569dnl Also sets ICON_SUFFIX
3570AC_DEFUN([CF_WITH_XPM],
3571[
3572ICON_SUFFIX=.xbm
3573
3574cf_save_cppflags="${CPPFLAGS}"
3575cf_save_ldflags="${LDFLAGS}"
3576
3577AC_MSG_CHECKING(if you want to use the Xpm library for colored icon)
3578AC_ARG_WITH(xpm,
3579[  --with-xpm=DIR          use Xpm library for colored icon, may specify path],
3580	[cf_Xpm_library="$withval"],
3581	[cf_Xpm_library=yes])
3582AC_MSG_RESULT($cf_Xpm_library)
3583
3584if test "$cf_Xpm_library" != no ; then
3585    if test "$cf_Xpm_library" != yes ; then
3586	CPPFLAGS="$CPPFLAGS -I$withval/include"
3587	LDFLAGS="$LDFLAGS -L$withval/lib"
3588    fi
3589    AC_CHECK_HEADER(X11/xpm.h,[
3590	AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData,[
3591	    AC_DEFINE(HAVE_LIBXPM,1,[Define to 1 if we should use Xpm library])
3592	    ICON_SUFFIX=.xpm
3593	    LIBS="-lXpm $LIBS"],
3594	    [CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"],
3595	    [-lX11 $X_LIBS])],
3596	[CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"])
3597fi
3598
3599AC_SUBST(ICON_SUFFIX)
3600])dnl
3601dnl ---------------------------------------------------------------------------
3602dnl CF_XBOOL_RESULT version: 2 updated: 2012/10/04 06:57:36
3603dnl ---------------
3604dnl Translate an autoconf boolean yes/no into X11's booleans, e.g., True/False.
3605dnl Allow for more than two values, e.g., "maybe", still using the same leading
3606dnl capital convention.
3607dnl
3608dnl $1 = symbol to define
3609dnl $2 = symbol holding value
3610dnl $3 = description
3611define([CF_XBOOL_RESULT],[
3612AC_MSG_RESULT([$]$2)
3613case [$]$2 in #(vi
3614yes) #(vi
3615	$2=true
3616	;;
3617no) #(vi
3618	$2=false
3619	;;
3620esac
3621cf_xbool1=`echo "[$]$2"|sed -e 's/^\(.\).*/\1/'`
3622CF_UPPER(cf_xbool1,$cf_xbool1)
3623cf_xbool2=`echo "[$]$2"|sed -e 's/^.//'`
3624$2=${cf_xbool1}${cf_xbool2}
3625AC_DEFINE_UNQUOTED($1,[$]$2,$3)
3626AC_SUBST($2)
3627])
3628dnl ---------------------------------------------------------------------------
3629dnl CF_XKB_BELL_EXT version: 4 updated: 2012/10/04 20:12:20
3630dnl ---------------
3631dnl Check for XKB bell extension
3632AC_DEFUN([CF_XKB_BELL_EXT],[
3633AC_CACHE_CHECK(for XKB Bell extension, cf_cv_xkb_bell_ext,[
3634AC_TRY_LINK([
3635#include <X11/Intrinsic.h>
3636#include <X11/XKBlib.h>		/* has the prototype */
3637#include <X11/extensions/XKBbells.h>	/* has the XkbBI_xxx definitions */
3638],[
3639	int x = (XkbBI_Info |XkbBI_MinorError |XkbBI_MajorError |XkbBI_TerminalBell |XkbBI_MarginBell);
3640	Atom y;
3641	XkbBell((Display *)0, (Widget)0, 0, y);
3642],[cf_cv_xkb_bell_ext=yes],[cf_cv_xkb_bell_ext=no])
3643])
3644test "$cf_cv_xkb_bell_ext" = yes && AC_DEFINE(HAVE_XKB_BELL_EXT,1,[Define 1 if we have XKB Bell extension])
3645])
3646dnl ---------------------------------------------------------------------------
3647dnl CF_XKB_KEYCODE_TO_KEYSYM version: 2 updated: 2012/09/28 20:23:33
3648dnl ------------------------
3649dnl Some older vendor-unix systems made a practice of delivering fragments of
3650dnl Xkb, requiring test-compiles.
3651AC_DEFUN([CF_XKB_KEYCODE_TO_KEYSYM],[
3652AC_CACHE_CHECK(if we can use XkbKeycodeToKeysym, cf_cv_xkb_keycode_to_keysym,[
3653AC_TRY_COMPILE([
3654#include <X11/Xlib.h>
3655#include <X11/XKBlib.h>
3656],[
3657    KeySym keysym = XkbKeycodeToKeysym((Display *)0, 0, 0, 0);
3658],[
3659cf_cv_xkb_keycode_to_keysym=yes
3660],[
3661cf_cv_xkb_keycode_to_keysym=no
3662])
3663])
3664
3665if test $cf_cv_xkb_keycode_to_keysym = yes
3666then
3667	AC_CHECK_FUNCS(XkbKeycodeToKeysym)
3668fi
3669])
3670dnl ---------------------------------------------------------------------------
3671dnl CF_XKB_QUERY_EXTENSION version: 2 updated: 2012/09/28 20:23:46
3672dnl ----------------------
3673dnl see ifdef in scrollbar.c - iron out here
3674AC_DEFUN([CF_XKB_QUERY_EXTENSION],[
3675AC_CACHE_CHECK(if we can use XkbQueryExtension, cf_cv_xkb_query_extension,[
3676AC_TRY_COMPILE([
3677#include <X11/Xlib.h>
3678#include <X11/extensions/XKB.h>
3679#include <X11/XKBlib.h>
3680],[
3681	int xkbmajor = XkbMajorVersion;
3682	int xkbminor = XkbMinorVersion;
3683	int xkbopcode, xkbevent, xkberror;
3684
3685	if (XkbLibraryVersion(&xkbmajor, &xkbminor)
3686	    && XkbQueryExtension((Display *)0,
3687				 &xkbopcode,
3688				 &xkbevent,
3689				 &xkberror,
3690				 &xkbmajor,
3691				 &xkbminor))
3692		 return 0;
3693],[
3694cf_cv_xkb_query_extension=yes
3695],[
3696cf_cv_xkb_query_extension=no
3697])
3698])
3699
3700if test $cf_cv_xkb_query_extension = yes
3701then
3702	AC_CHECK_FUNCS(XkbQueryExtension)
3703fi
3704])
3705dnl ---------------------------------------------------------------------------
3706dnl CF_XOPEN_SOURCE version: 43 updated: 2013/02/10 10:41:05
3707dnl ---------------
3708dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3709dnl or adapt to the vendor's definitions to get equivalent functionality,
3710dnl without losing the common non-POSIX features.
3711dnl
3712dnl Parameters:
3713dnl	$1 is the nominal value for _XOPEN_SOURCE
3714dnl	$2 is the nominal value for _POSIX_C_SOURCE
3715AC_DEFUN([CF_XOPEN_SOURCE],[
3716AC_REQUIRE([AC_CANONICAL_HOST])
3717
3718cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
3719cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
3720cf_xopen_source=
3721
3722case $host_os in #(vi
3723aix[[4-7]]*) #(vi
3724	cf_xopen_source="-D_ALL_SOURCE"
3725	;;
3726cygwin) #(vi
3727	cf_XOPEN_SOURCE=600
3728	;;
3729darwin[[0-8]].*) #(vi
3730	cf_xopen_source="-D_APPLE_C_SOURCE"
3731	;;
3732darwin*) #(vi
3733	cf_xopen_source="-D_DARWIN_C_SOURCE"
3734	cf_XOPEN_SOURCE=
3735	;;
3736freebsd*|dragonfly*) #(vi
3737	# 5.x headers associate
3738	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
3739	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
3740	cf_POSIX_C_SOURCE=200112L
3741	cf_XOPEN_SOURCE=600
3742	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3743	;;
3744hpux11*) #(vi
3745	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3746	;;
3747hpux*) #(vi
3748	cf_xopen_source="-D_HPUX_SOURCE"
3749	;;
3750irix[[56]].*) #(vi
3751	cf_xopen_source="-D_SGI_SOURCE"
3752	cf_XOPEN_SOURCE=
3753	;;
3754linux*|gnu*|mint*|k*bsd*-gnu) #(vi
3755	CF_GNU_SOURCE
3756	;;
3757mirbsd*) #(vi
3758	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
3759	cf_XOPEN_SOURCE=
3760	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3761	;;
3762netbsd*) #(vi
3763	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
3764	;;
3765openbsd[[4-9]]*) #(vi
3766	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
3767	cf_xopen_source="-D_BSD_SOURCE"
3768	cf_XOPEN_SOURCE=600
3769	;;
3770openbsd*) #(vi
3771	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3772	;;
3773osf[[45]]*) #(vi
3774	cf_xopen_source="-D_OSF_SOURCE"
3775	;;
3776nto-qnx*) #(vi
3777	cf_xopen_source="-D_QNX_SOURCE"
3778	;;
3779sco*) #(vi
3780	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
3781	;;
3782solaris2.*) #(vi
3783	cf_xopen_source="-D__EXTENSIONS__"
3784	;;
3785*)
3786	CF_TRY_XOPEN_SOURCE
3787	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3788	;;
3789esac
3790
3791if test -n "$cf_xopen_source" ; then
3792	CF_ADD_CFLAGS($cf_xopen_source)
3793fi
3794
3795dnl In anything but the default case, we may have system-specific setting
3796dnl which is still not guaranteed to provide all of the entrypoints that
3797dnl _XOPEN_SOURCE would yield.
3798if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
3799	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
3800	AC_TRY_COMPILE([#include <stdlib.h>],[
3801#ifndef _XOPEN_SOURCE
3802make an error
3803#endif],
3804	[cf_XOPEN_SOURCE_set=yes],
3805	[cf_XOPEN_SOURCE_set=no])
3806	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
3807	if test $cf_XOPEN_SOURCE_set = yes
3808	then
3809		AC_TRY_COMPILE([#include <stdlib.h>],[
3810#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
3811make an error
3812#endif],
3813		[cf_XOPEN_SOURCE_set_ok=yes],
3814		[cf_XOPEN_SOURCE_set_ok=no])
3815		if test $cf_XOPEN_SOURCE_set_ok = no
3816		then
3817			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
3818		fi
3819	else
3820		CF_TRY_XOPEN_SOURCE
3821	fi
3822fi
3823])
3824dnl ---------------------------------------------------------------------------
3825dnl CF_X_ATHENA version: 20 updated: 2010/11/09 05:18:02
3826dnl -----------
3827dnl Check for Xaw (Athena) libraries
3828dnl
3829dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
3830AC_DEFUN([CF_X_ATHENA],
3831[
3832cf_x_athena=${cf_x_athena:-Xaw}
3833
3834AC_MSG_CHECKING(if you want to link with Xaw 3d library)
3835withval=
3836AC_ARG_WITH(Xaw3d,
3837	[  --with-Xaw3d            link with Xaw 3d library])
3838if test "$withval" = yes ; then
3839	cf_x_athena=Xaw3d
3840	AC_MSG_RESULT(yes)
3841else
3842	AC_MSG_RESULT(no)
3843fi
3844
3845AC_MSG_CHECKING(if you want to link with neXT Athena library)
3846withval=
3847AC_ARG_WITH(neXtaw,
3848	[  --with-neXtaw           link with neXT Athena library])
3849if test "$withval" = yes ; then
3850	cf_x_athena=neXtaw
3851	AC_MSG_RESULT(yes)
3852else
3853	AC_MSG_RESULT(no)
3854fi
3855
3856AC_MSG_CHECKING(if you want to link with Athena-Plus library)
3857withval=
3858AC_ARG_WITH(XawPlus,
3859	[  --with-XawPlus          link with Athena-Plus library])
3860if test "$withval" = yes ; then
3861	cf_x_athena=XawPlus
3862	AC_MSG_RESULT(yes)
3863else
3864	AC_MSG_RESULT(no)
3865fi
3866
3867cf_x_athena_lib=""
3868
3869if test "$PKG_CONFIG" != none ; then
3870	cf_athena_list=
3871	test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
3872	for cf_athena_pkg in \
3873		$cf_athena_list \
3874		${cf_x_athena} \
3875		${cf_x_athena}-devel \
3876		lib${cf_x_athena} \
3877		lib${cf_x_athena}-devel
3878	do
3879		CF_TRY_PKG_CONFIG($cf_athena_pkg,[
3880			cf_x_athena_lib="$cf_pkgconfig_libs"
3881			CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
3882			AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
3883
3884AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
3885AC_TRY_LINK([
3886#include <X11/Xmu/CharSet.h>
3887],[
3888int check = XmuCompareISOLatin1("big", "small")
3889],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
3890
3891			if test "$cf_cv_xaw_compat" = no
3892			then
3893				# workaround for broken ".pc" files...
3894				case "$cf_x_athena_lib" in #(vi
3895				*-lXmu*) #(vi
3896					;;
3897				*)
3898					CF_VERBOSE(work around broken package)
3899					CF_TRY_PKG_CONFIG(xmu,,[CF_ADD_LIB_AFTER(-lXt,-lXmu)])
3900					;;
3901				esac
3902			fi
3903
3904			break])
3905	done
3906fi
3907
3908if test -z "$cf_x_athena_lib" ; then
3909	CF_X_EXT
3910	CF_X_TOOLKIT
3911	CF_X_ATHENA_CPPFLAGS($cf_x_athena)
3912	CF_X_ATHENA_LIBS($cf_x_athena)
3913fi
3914])dnl
3915dnl ---------------------------------------------------------------------------
3916dnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
3917dnl --------------------
3918dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
3919dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
3920AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
3921[
3922cf_x_athena_root=ifelse([$1],,Xaw,[$1])
3923cf_x_athena_inc=""
3924
3925for cf_path in default \
3926	/usr/contrib/X11R6 \
3927	/usr/contrib/X11R5 \
3928	/usr/lib/X11R5 \
3929	/usr/local
3930do
3931	if test -z "$cf_x_athena_inc" ; then
3932		cf_save="$CPPFLAGS"
3933		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
3934		if test $cf_path != default ; then
3935			CPPFLAGS="$cf_save -I$cf_path/include"
3936			AC_MSG_CHECKING(for $cf_test in $cf_path)
3937		else
3938			AC_MSG_CHECKING(for $cf_test)
3939		fi
3940		AC_TRY_COMPILE([
3941#include <X11/Intrinsic.h>
3942#include <$cf_test>],[],
3943			[cf_result=yes],
3944			[cf_result=no])
3945		AC_MSG_RESULT($cf_result)
3946		if test "$cf_result" = yes ; then
3947			cf_x_athena_inc=$cf_path
3948			break
3949		else
3950			CPPFLAGS="$cf_save"
3951		fi
3952	fi
3953done
3954
3955if test -z "$cf_x_athena_inc" ; then
3956	AC_MSG_WARN(
3957[Unable to successfully find Athena header files with test program])
3958elif test "$cf_x_athena_inc" != default ; then
3959	CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
3960fi
3961])
3962dnl ---------------------------------------------------------------------------
3963dnl CF_X_ATHENA_LIBS version: 12 updated: 2011/07/17 19:55:02
3964dnl ----------------
3965dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
3966dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
3967AC_DEFUN([CF_X_ATHENA_LIBS],
3968[AC_REQUIRE([CF_X_TOOLKIT])
3969cf_x_athena_root=ifelse([$1],,Xaw,[$1])
3970cf_x_athena_lib=""
3971
3972for cf_path in default \
3973	/usr/contrib/X11R6 \
3974	/usr/contrib/X11R5 \
3975	/usr/lib/X11R5 \
3976	/usr/local
3977do
3978	for cf_lib in \
3979		${cf_x_athena_root} \
3980		${cf_x_athena_root}7 \
3981		${cf_x_athena_root}6
3982	do
3983	for cf_libs in \
3984		"-l$cf_lib -lXmu" \
3985		"-l$cf_lib -lXpm -lXmu" \
3986		"-l${cf_lib}_s -lXmu_s"
3987	do
3988		if test -z "$cf_x_athena_lib" ; then
3989			cf_save="$LIBS"
3990			cf_test=XawSimpleMenuAddGlobalActions
3991			if test $cf_path != default ; then
3992				CF_ADD_LIBS(-L$cf_path/lib $cf_libs)
3993				AC_MSG_CHECKING(for $cf_libs in $cf_path)
3994			else
3995				CF_ADD_LIBS($cf_libs)
3996				AC_MSG_CHECKING(for $cf_test in $cf_libs)
3997			fi
3998			AC_TRY_LINK([
3999#include <X11/Intrinsic.h>
4000#include <X11/$cf_x_athena_root/SimpleMenu.h>
4001],[
4002$cf_test((XtAppContext) 0)],
4003				[cf_result=yes],
4004				[cf_result=no])
4005			AC_MSG_RESULT($cf_result)
4006			if test "$cf_result" = yes ; then
4007				cf_x_athena_lib="$cf_libs"
4008				break
4009			fi
4010			LIBS="$cf_save"
4011		fi
4012	done # cf_libs
4013		test -n "$cf_x_athena_lib" && break
4014	done # cf_lib
4015done
4016
4017if test -z "$cf_x_athena_lib" ; then
4018	AC_MSG_ERROR(
4019[Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
4020fi
4021
4022CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
4023AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
4024])
4025dnl ---------------------------------------------------------------------------
4026dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
4027dnl --------
4028AC_DEFUN([CF_X_EXT],[
4029CF_TRY_PKG_CONFIG(Xext,,[
4030	AC_CHECK_LIB(Xext,XextCreateExtension,
4031		[CF_ADD_LIB(Xext)])])
4032])dnl
4033dnl ---------------------------------------------------------------------------
4034dnl CF_X_FONTCONFIG version: 4 updated: 2011/07/04 10:01:31
4035dnl ---------------
4036dnl Check for fontconfig library, a dependency of the X FreeType library.
4037AC_DEFUN([CF_X_FONTCONFIG],
4038[
4039AC_REQUIRE([CF_X_FREETYPE])
4040
4041if test "$cf_cv_found_freetype" = yes ; then
4042AC_CACHE_CHECK(for usable Xft/fontconfig package,cf_cv_xft_compat,[
4043AC_TRY_LINK([
4044#include <X11/Xft/Xft.h>
4045],[
4046	XftPattern *pat;
4047	XftPatternBuild(pat,
4048					XFT_FAMILY, XftTypeString, "mono",
4049					(void *) 0);
4050],[cf_cv_xft_compat=yes],[cf_cv_xft_compat=no])
4051])
4052
4053if test "$cf_cv_xft_compat" = no
4054then
4055	# workaround for broken ".pc" files used for Xft.
4056	case "$cf_cv_x_freetype_libs" in #(vi
4057	*-lfontconfig*) #(vi
4058		;;
4059	*)
4060		CF_VERBOSE(work around broken package)
4061		CF_TRY_PKG_CONFIG(fontconfig,,[CF_ADD_LIB_AFTER(-lXft,-lfontconfig)])
4062		;;
4063	esac
4064fi
4065fi
4066])dnl
4067dnl ---------------------------------------------------------------------------
4068dnl CF_X_FREETYPE version: 26 updated: 2012/10/04 20:12:20
4069dnl -------------
4070dnl Check for X FreeType headers and libraries (XFree86 4.x, etc).
4071dnl
4072dnl First check for the appropriate config program, since the developers for
4073dnl these libraries change their configuration (and config program) more or
4074dnl less randomly.  If we cannot find the config program, do not bother trying
4075dnl to guess the latest variation of include/lib directories.
4076dnl
4077dnl If either or both of these configure-script options are not given, rely on
4078dnl the output of the config program to provide the cflags/libs options:
4079dnl	--with-freetype-cflags
4080dnl	--with-freetype-libs
4081AC_DEFUN([CF_X_FREETYPE],
4082[
4083AC_REQUIRE([CF_PKG_CONFIG])
4084
4085cf_cv_x_freetype_incs=no
4086cf_cv_x_freetype_libs=no
4087cf_extra_freetype_libs=
4088FREETYPE_CONFIG=none
4089FREETYPE_PARAMS=
4090
4091AC_MSG_CHECKING(for FreeType configuration script)
4092AC_ARG_WITH(freetype-config,
4093	[  --with-freetype-config  configure script to use for FreeType],
4094	[cf_cv_x_freetype_cfgs="$withval"],
4095	[cf_cv_x_freetype_cfgs=auto])
4096test -z $cf_cv_x_freetype_cfgs && cf_cv_x_freetype_cfgs=auto
4097test $cf_cv_x_freetype_cfgs = no && cf_cv_x_freetype_cfgs=none
4098AC_MSG_RESULT($cf_cv_x_freetype_cfgs)
4099
4100case $cf_cv_x_freetype_cfgs in
4101none) #(vi
4102	AC_MSG_CHECKING(if you specified -D/-I options for FreeType)
4103	AC_ARG_WITH(freetype-cflags,
4104		[  --with-freetype-cflags  -D/-I options for compiling with FreeType],
4105		[cf_cv_x_freetype_incs="$with_freetype_cflags"],
4106		[cf_cv_x_freetype_incs=no])
4107	AC_MSG_RESULT($cf_cv_x_freetype_incs)
4108
4109	AC_MSG_CHECKING(if you specified -L/-l options for FreeType)
4110	AC_ARG_WITH(freetype-libs,
4111		[  --with-freetype-libs    -L/-l options to link FreeType],
4112		[cf_cv_x_freetype_libs="$with_freetype_libs"],
4113		[cf_cv_x_freetype_libs=no])
4114	AC_MSG_RESULT($cf_cv_x_freetype_libs)
4115	;;
4116auto) #(vi
4117	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
4118		FREETYPE_CONFIG=$PKG_CONFIG
4119		FREETYPE_PARAMS=xft
4120	else
4121		AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, none)
4122		if test "$FREETYPE_CONFIG" != none; then
4123			FREETYPE_CONFIG=$FREETYPE_CONFIG
4124			cf_extra_freetype_libs="-lXft"
4125		else
4126			AC_PATH_PROG(FREETYPE_OLD_CONFIG, xft-config, none)
4127			if test "$FREETYPE_OLD_CONFIG" != none; then
4128				FREETYPE_CONFIG=$FREETYPE_OLD_CONFIG
4129			fi
4130		fi
4131	fi
4132	;;
4133pkg*) #(vi
4134	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
4135		FREETYPE_CONFIG=$cf_cv_x_freetype_cfgs
4136		FREETYPE_PARAMS=xft
4137	else
4138		AC_MSG_WARN(cannot find pkg-config for Xft)
4139	fi
4140	;;
4141*) #(vi
4142	AC_PATH_PROG(FREETYPE_XFT_CONFIG, $cf_cv_x_freetype_cfgs, none)
4143	if test "$FREETYPE_XFT_CONFIG" != none; then
4144		FREETYPE_CONFIG=$FREETYPE_XFT_CONFIG
4145	else
4146		AC_MSG_WARN(cannot find config script for Xft)
4147	fi
4148	;;
4149esac
4150
4151if test "$FREETYPE_CONFIG" != none ; then
4152	AC_MSG_CHECKING(for FreeType config)
4153	AC_MSG_RESULT($FREETYPE_CONFIG $FREETYPE_PARAMS)
4154
4155	if test "$cf_cv_x_freetype_incs" = no ; then
4156		AC_MSG_CHECKING(for $FREETYPE_CONFIG cflags)
4157		cf_cv_x_freetype_incs="`$FREETYPE_CONFIG $FREETYPE_PARAMS --cflags 2>/dev/null`"
4158		AC_MSG_RESULT($cf_cv_x_freetype_incs)
4159	fi
4160
4161	if test "$cf_cv_x_freetype_libs" = no ; then
4162		AC_MSG_CHECKING(for $FREETYPE_CONFIG libs)
4163		cf_cv_x_freetype_libs="$cf_extra_freetype_libs `$FREETYPE_CONFIG $FREETYPE_PARAMS --libs 2>/dev/null`"
4164		AC_MSG_RESULT($cf_cv_x_freetype_libs)
4165	fi
4166fi
4167
4168if test "$cf_cv_x_freetype_incs" = no ; then
4169	cf_cv_x_freetype_incs=
4170fi
4171
4172if test "$cf_cv_x_freetype_libs" = no ; then
4173	cf_cv_x_freetype_libs=-lXft
4174fi
4175
4176AC_MSG_CHECKING(if we can link with FreeType libraries)
4177
4178cf_save_LIBS="$LIBS"
4179cf_save_INCS="$CPPFLAGS"
4180
4181CF_ADD_LIBS($cf_cv_x_freetype_libs)
4182CPPFLAGS="$CPPFLAGS $cf_cv_x_freetype_incs"
4183
4184AC_TRY_LINK([
4185#include <X11/Xlib.h>
4186#include <X11/extensions/Xrender.h>
4187#include <X11/Xft/Xft.h>],[
4188	XftPattern  *pat = XftNameParse ("name");],
4189	[cf_cv_found_freetype=yes],
4190	[cf_cv_found_freetype=no])
4191AC_MSG_RESULT($cf_cv_found_freetype)
4192
4193LIBS="$cf_save_LIBS"
4194CPPFLAGS="$cf_save_INCS"
4195
4196if test "$cf_cv_found_freetype" = yes ; then
4197	CF_ADD_LIBS($cf_cv_x_freetype_libs)
4198	CF_ADD_CFLAGS($cf_cv_x_freetype_incs)
4199	AC_DEFINE(XRENDERFONT,1,[Define to 1 if we can/should link with FreeType libraries])
4200
4201AC_CHECK_FUNCS( \
4202	XftDrawCharSpec \
4203	XftDrawSetClip \
4204	XftDrawSetClipRectangles \
4205)
4206
4207else
4208	AC_MSG_WARN(No libraries found for FreeType)
4209	CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
4210fi
4211
4212# FIXME: revisit this if needed
4213AC_SUBST(HAVE_TYPE_FCCHAR32)
4214AC_SUBST(HAVE_TYPE_XFTCHARSPEC)
4215])
4216dnl ---------------------------------------------------------------------------
4217dnl CF_X_TOOLKIT version: 21 updated: 2012/10/04 06:57:36
4218dnl ------------
4219dnl Check for X Toolkit libraries
4220dnl
4221AC_DEFUN([CF_X_TOOLKIT],
4222[
4223AC_REQUIRE([AC_PATH_XTRA])
4224AC_REQUIRE([CF_CHECK_CACHE])
4225
4226cf_have_X_LIBS=no
4227
4228CF_TRY_PKG_CONFIG(xt,[
4229
4230	case "x$LIBS" in #(vi
4231	*-lX11*) #(vi
4232		;;
4233	*)
4234# we have an "xt" package, but it may omit Xt's dependency on X11
4235AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
4236AC_TRY_LINK([
4237#include <X11/Xlib.h>
4238],[
4239	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
4240	int rc2 = XClearWindow((Display*) 0, (Window) 0);
4241	int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
4242	int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
4243],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
4244		if test "$cf_cv_xt_x11_compat" = no
4245		then
4246			CF_VERBOSE(work around broken X11 dependency)
4247			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.
4248			CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
4249		fi
4250		;;
4251	esac
4252
4253AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
4254AC_TRY_LINK([
4255#include <X11/Shell.h>
4256],[int num = IceConnectionNumber(0)
4257],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
4258
4259	if test "$cf_cv_xt_ice_compat" = no
4260	then
4261		# workaround for broken ".pc" files used for X Toolkit.
4262		case "x$X_PRE_LIBS" in #(vi
4263		*-lICE*)
4264			case "x$LIBS" in #(vi
4265			*-lICE*) #(vi
4266				;;
4267			*)
4268				CF_VERBOSE(work around broken ICE dependency)
4269				CF_TRY_PKG_CONFIG(ice,
4270					[CF_TRY_PKG_CONFIG(sm)],
4271					[CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
4272				;;
4273			esac
4274			;;
4275		esac
4276	fi
4277
4278	cf_have_X_LIBS=yes
4279],[
4280
4281	LDFLAGS="$X_LIBS $LDFLAGS"
4282	CF_CHECK_CFLAGS($X_CFLAGS)
4283
4284	AC_CHECK_FUNC(XOpenDisplay,,[
4285	AC_CHECK_LIB(X11,XOpenDisplay,
4286		[CF_ADD_LIB(X11)],,
4287		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
4288
4289	AC_CHECK_FUNC(XtAppInitialize,,[
4290	AC_CHECK_LIB(Xt, XtAppInitialize,
4291		[AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
4292		 cf_have_X_LIBS=Xt
4293		 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
4294		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
4295])
4296
4297if test $cf_have_X_LIBS = no ; then
4298	AC_MSG_WARN(
4299[Unable to successfully link X Toolkit library (-lXt) with
4300test program.  You will have to check and add the proper libraries by hand
4301to makefile.])
4302fi
4303])dnl
4304dnl ---------------------------------------------------------------------------
4305dnl CF__GRANTPT_BODY version: 4 updated: 2012/05/07 19:39:45
4306dnl ----------------
4307dnl Body for workability check of grantpt.
4308define([CF__GRANTPT_BODY],[
4309	int code = 0;
4310	int rc;
4311	int pty;
4312	int tty;
4313	char *slave;
4314	struct termios tio;
4315
4316	signal(SIGALRM, my_timeout);
4317
4318	if (alarm(2) == 9)
4319		failed(9);
4320	else if ((pty = posix_openpt(O_RDWR)) < 0)
4321		failed(1);
4322	else if ((rc = grantpt(pty)) < 0)
4323		failed(2);
4324	else if ((rc = unlockpt(pty)) < 0)
4325		failed(3);
4326	else if ((slave = ptsname(pty)) == 0)
4327		failed(4);
4328#if (CONFTEST == 3) || defined(CONFTEST_isatty)
4329	else if (!isatty(pty))
4330		failed(4);
4331#endif
4332#if CONFTEST >= 4
4333    else if ((rc = tcgetattr(pty, &tio)) < 0)
4334		failed(20);
4335    else if ((rc = tcsetattr(pty, TCSAFLUSH, &tio)) < 0)
4336		failed(21);
4337#endif
4338	/* BSD posix_openpt does not treat pty as a terminal until slave is opened.
4339	 * Linux does treat it that way.
4340	 */
4341	else if ((tty = open(slave, O_RDWR)) < 0)
4342		failed(5);
4343#ifdef CONFTEST
4344#ifdef I_PUSH
4345#if (CONFTEST == 0) || defined(CONFTEST_ptem)
4346    else if ((rc = ioctl(tty, I_PUSH, "ptem")) < 0)
4347		failed(10);
4348#endif
4349#if (CONFTEST == 1) || defined(CONFTEST_ldterm)
4350    else if ((rc = ioctl(tty, I_PUSH, "ldterm")) < 0)
4351		failed(11);
4352#endif
4353#if (CONFTEST == 2) || defined(CONFTEST_ttcompat)
4354    else if ((rc = ioctl(tty, I_PUSH, "ttcompat")) < 0)
4355		failed(12);
4356#endif
4357#endif /* I_PUSH */
4358#if CONFTEST >= 5
4359    else if ((rc = tcgetattr(tty, &tio)) < 0)
4360		failed(30);
4361    else if ((rc = tcsetattr(tty, TCSAFLUSH, &tio)) < 0)
4362		failed(31);
4363#endif
4364#endif /* CONFTEST */
4365
4366	${cf_cv_main_return:-return}(code);
4367])
4368dnl ---------------------------------------------------------------------------
4369dnl CF__GRANTPT_HEAD version: 3 updated: 2012/01/29 17:13:14
4370dnl ----------------
4371dnl Headers for workability check of grantpt.
4372define([CF__GRANTPT_HEAD],[
4373#include <stdlib.h>
4374#include <termios.h>
4375#include <unistd.h>
4376#include <signal.h>
4377#include <fcntl.h>
4378#include <errno.h>
4379
4380#ifndef HAVE_POSIX_OPENPT
4381#undef posix_openpt
4382#define posix_openpt(mode) open("/dev/ptmx", mode)
4383#endif
4384
4385#ifdef HAVE_STROPTS_H
4386#include <stropts.h>
4387#endif
4388
4389static void failed(int code)
4390{
4391	perror("conftest");
4392	exit(code);
4393}
4394
4395static void my_timeout(int sig)
4396{
4397	exit(99);
4398}
4399])
4400