aclocal.m4 revision 01037d57
101037d57Smrgdnl $XTermId: aclocal.m4,v 1.404 2015/04/12 19:43:57 tom Exp $
2d522f475Smrgdnl
3d522f475Smrgdnl ---------------------------------------------------------------------------
4d522f475Smrgdnl
501037d57Smrgdnl Copyright 1997-2014,2015 by Thomas E. Dickey
6d522f475Smrgdnl
7d522f475Smrgdnl                         All Rights Reserved
8d522f475Smrgdnl
920d2c4d2Smrgdnl Permission is hereby granted, free of charge, to any person obtaining a
1020d2c4d2Smrgdnl copy of this software and associated documentation files (the
1120d2c4d2Smrgdnl "Software"), to deal in the Software without restriction, including
1220d2c4d2Smrgdnl without limitation the rights to use, copy, modify, merge, publish,
1320d2c4d2Smrgdnl distribute, sublicense, and/or sell copies of the Software, and to
1420d2c4d2Smrgdnl permit persons to whom the Software is furnished to do so, subject to
1520d2c4d2Smrgdnl the following conditions:
160bd37d32Smrgdnl
1720d2c4d2Smrgdnl The above copyright notice and this permission notice shall be included
1820d2c4d2Smrgdnl in all copies or substantial portions of the Software.
190bd37d32Smrgdnl
2020d2c4d2Smrgdnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2120d2c4d2Smrgdnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2220d2c4d2Smrgdnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
2320d2c4d2Smrgdnl IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
2420d2c4d2Smrgdnl CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2520d2c4d2Smrgdnl TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2620d2c4d2Smrgdnl SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
270bd37d32Smrgdnl
2820d2c4d2Smrgdnl Except as contained in this notice, the name(s) of the above copyright
2920d2c4d2Smrgdnl holders shall not be used in advertising or otherwise to promote the
3020d2c4d2Smrgdnl sale, use or other dealings in this Software without prior written
3120d2c4d2Smrgdnl authorization.
32d522f475Smrgdnl
33d522f475Smrgdnl ---------------------------------------------------------------------------
3420d2c4d2Smrgdnl See
3520d2c4d2Smrgdnl		http://invisible-island.net/autoconf/autoconf.html
3620d2c4d2Smrgdnl ---------------------------------------------------------------------------
37d522f475Smrgdnl ---------------------------------------------------------------------------
38d522f475Smrgdnl AM_LANGINFO_CODESET version: 3 updated: 2002/10/27 23:21:42
39d522f475Smrgdnl -------------------
40d522f475Smrgdnl Inserted as requested by gettext 0.10.40
41d522f475Smrgdnl File from /usr/share/aclocal
42d522f475Smrgdnl codeset.m4
43d522f475Smrgdnl ====================
44d522f475Smrgdnl serial AM1
45d522f475Smrgdnl
46d522f475Smrgdnl From Bruno Haible.
47d522f475SmrgAC_DEFUN([AM_LANGINFO_CODESET],
48d522f475Smrg[
49d522f475Smrg  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
50d522f475Smrg    [AC_TRY_LINK([#include <langinfo.h>],
51d522f475Smrg      [char* cs = nl_langinfo(CODESET);],
52d522f475Smrg      am_cv_langinfo_codeset=yes,
53d522f475Smrg      am_cv_langinfo_codeset=no)
54d522f475Smrg    ])
55d522f475Smrg  if test $am_cv_langinfo_codeset = yes; then
56d522f475Smrg    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
57d522f475Smrg      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
58d522f475Smrg  fi
59d522f475Smrg])dnl
60d522f475Smrgdnl ---------------------------------------------------------------------------
6101037d57Smrgdnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
62e39b573cSmrgdnl ------------------
63e39b573cSmrgdnl Conditionally generate script according to whether we're using a given autoconf.
64e39b573cSmrgdnl
65e39b573cSmrgdnl $1 = version to compare against
66e39b573cSmrgdnl $2 = code to use if AC_ACVERSION is at least as high as $1.
67e39b573cSmrgdnl $3 = code to use if AC_ACVERSION is older than $1.
680bd37d32Smrgdefine([CF_ACVERSION_CHECK],
69e39b573cSmrg[
7001037d57Smrgifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
71e39b573cSmrgifdef([m4_version_compare],
72e39b573cSmrg[m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
73e39b573cSmrg[CF_ACVERSION_COMPARE(
74e39b573cSmrgAC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
75e39b573cSmrgAC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
76e39b573cSmrgdnl ---------------------------------------------------------------------------
770bd37d32Smrgdnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
78e39b573cSmrgdnl --------------------
79e39b573cSmrgdnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
80e39b573cSmrgdnl                      MAJOR2, MINOR2, TERNARY2,
81e39b573cSmrgdnl                      PRINTABLE2, not FOUND, FOUND)
820bd37d32Smrgdefine([CF_ACVERSION_COMPARE],
83e39b573cSmrg[ifelse(builtin([eval], [$2 < $5]), 1,
84e39b573cSmrg[ifelse([$8], , ,[$8])],
85e39b573cSmrg[ifelse([$9], , ,[$9])])])dnl
86e39b573cSmrgdnl ---------------------------------------------------------------------------
8701037d57Smrgdnl CF_ADD_CFLAGS version: 12 updated: 2015/04/12 15:39:00
88d522f475Smrgdnl -------------
89d522f475Smrgdnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
90d522f475Smrgdnl The second parameter if given makes this macro verbose.
91d522f475Smrgdnl
92d522f475Smrgdnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
93d522f475Smrgdnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
94d522f475Smrgdnl confused by the quotes (which require backslashes to keep them usable).
95d522f475SmrgAC_DEFUN([CF_ADD_CFLAGS],
96d522f475Smrg[
97d522f475Smrgcf_fix_cppflags=no
98d522f475Smrgcf_new_cflags=
99d522f475Smrgcf_new_cppflags=
100d522f475Smrgcf_new_extra_cppflags=
101d522f475Smrg
102d522f475Smrgfor cf_add_cflags in $1
103d522f475Smrgdo
104d522f475Smrgcase $cf_fix_cppflags in
10501037d57Smrg(no)
10601037d57Smrg	case $cf_add_cflags in
10701037d57Smrg	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
108d522f475Smrg		case $cf_add_cflags in
10901037d57Smrg		(-D*)
110d522f475Smrg			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
111d522f475Smrg
11201037d57Smrg			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
11320d2c4d2Smrg				&& test -z "${cf_tst_cflags}" \
11420d2c4d2Smrg				&& cf_fix_cppflags=yes
115d522f475Smrg
116d522f475Smrg			if test $cf_fix_cppflags = yes ; then
117d522f475Smrg				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
118d522f475Smrg				continue
119d522f475Smrg			elif test "${cf_tst_cflags}" = "\"'" ; then
120d522f475Smrg				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
121d522f475Smrg				continue
122d522f475Smrg			fi
123d522f475Smrg			;;
124d522f475Smrg		esac
125d522f475Smrg		case "$CPPFLAGS" in
12601037d57Smrg		(*$cf_add_cflags)
127d522f475Smrg			;;
12801037d57Smrg		(*)
12901037d57Smrg			case $cf_add_cflags in
13001037d57Smrg			(-D*)
13120d2c4d2Smrg				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
13220d2c4d2Smrg				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
13320d2c4d2Smrg				;;
13420d2c4d2Smrg			esac
135d522f475Smrg			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
136d522f475Smrg			;;
137d522f475Smrg		esac
138d522f475Smrg		;;
13901037d57Smrg	(*)
140d522f475Smrg		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
141d522f475Smrg		;;
142d522f475Smrg	esac
143d522f475Smrg	;;
14401037d57Smrg(yes)
145d522f475Smrg	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
146d522f475Smrg
147d522f475Smrg	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
148d522f475Smrg
14901037d57Smrg	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
15020d2c4d2Smrg		&& test -z "${cf_tst_cflags}" \
15120d2c4d2Smrg		&& cf_fix_cppflags=no
152d522f475Smrg	;;
153d522f475Smrgesac
154d522f475Smrgdone
155d522f475Smrg
156d522f475Smrgif test -n "$cf_new_cflags" ; then
15720d2c4d2Smrg	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
158d522f475Smrg	CFLAGS="$CFLAGS $cf_new_cflags"
159d522f475Smrgfi
160d522f475Smrg
161d522f475Smrgif test -n "$cf_new_cppflags" ; then
16220d2c4d2Smrg	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
163956cc18dSsnj	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
164d522f475Smrgfi
165d522f475Smrg
166d522f475Smrgif test -n "$cf_new_extra_cppflags" ; then
16720d2c4d2Smrg	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
168d522f475Smrg	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
169d522f475Smrgfi
170d522f475Smrg
171d522f475SmrgAC_SUBST(EXTRA_CPPFLAGS)
172d522f475Smrg
173d522f475Smrg])dnl
174d522f475Smrgdnl ---------------------------------------------------------------------------
17520d2c4d2Smrgdnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
17620d2c4d2Smrgdnl ----------
17720d2c4d2Smrgdnl Add a library, used to enforce consistency.
17820d2c4d2Smrgdnl
17920d2c4d2Smrgdnl $1 = library to add, without the "-l"
18020d2c4d2Smrgdnl $2 = variable to update (default $LIBS)
18120d2c4d2SmrgAC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
18220d2c4d2Smrgdnl ---------------------------------------------------------------------------
18301037d57Smrgdnl CF_ADD_LIBS version: 2 updated: 2014/07/13 14:33:27
18420d2c4d2Smrgdnl -----------
18501037d57Smrgdnl Add one or more libraries, used to enforce consistency.  Libraries are
18601037d57Smrgdnl prepended to an existing list, since their dependencies are assumed to
18701037d57Smrgdnl already exist in the list.
18820d2c4d2Smrgdnl
18920d2c4d2Smrgdnl $1 = libraries to add, with the "-l", etc.
19020d2c4d2Smrgdnl $2 = variable to update (default $LIBS)
19101037d57SmrgAC_DEFUN([CF_ADD_LIBS],[
19201037d57Smrgcf_add_libs="$1"
19301037d57Smrg# Filter out duplicates - this happens with badly-designed ".pc" files...
19401037d57Smrgfor cf_add_1lib in [$]ifelse($2,,LIBS,[$2])
19501037d57Smrgdo
19601037d57Smrg	for cf_add_2lib in $cf_add_libs
19701037d57Smrg	do
19801037d57Smrg		if test "x$cf_add_1lib" = "x$cf_add_2lib"
19901037d57Smrg		then
20001037d57Smrg			cf_add_1lib=
20101037d57Smrg			break
20201037d57Smrg		fi
20301037d57Smrg	done
20401037d57Smrg	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
20501037d57Smrgdone
20601037d57Smrgifelse($2,,LIBS,[$2])="$cf_add_libs"
20701037d57Smrg])dnl
20820d2c4d2Smrgdnl ---------------------------------------------------------------------------
209e0a2b6dfSmrgdnl CF_ADD_LIB_AFTER version: 3 updated: 2013/07/09 21:27:22
2106879286fSmrgdnl ----------------
2116879286fSmrgdnl Add a given library after another, e.g., following the one it satisfies a
2126879286fSmrgdnl dependency for.
2136879286fSmrgdnl
2146879286fSmrgdnl $1 = the first library
2156879286fSmrgdnl $2 = its dependency
2166879286fSmrgAC_DEFUN([CF_ADD_LIB_AFTER],[
2176879286fSmrgCF_VERBOSE(...before $LIBS)
218e0a2b6dfSmrgLIBS=`echo "$LIBS" | sed -e "s/[[ 	]][[ 	]]*/ /g" -e "s%$1 %$1 $2 %" -e 's%  % %g'`
2196879286fSmrgCF_VERBOSE(...after  $LIBS)
2206879286fSmrg])dnl
2216879286fSmrgdnl ---------------------------------------------------------------------------
222d522f475Smrgdnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
223d522f475Smrgdnl --------------
224d522f475Smrgdnl Allow user to disable a normally-on option.
225d522f475SmrgAC_DEFUN([CF_ARG_DISABLE],
226d522f475Smrg[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
227d522f475Smrgdnl ---------------------------------------------------------------------------
228d522f475Smrgdnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
229d522f475Smrgdnl -------------
230d522f475Smrgdnl Allow user to enable a normally-off option.
231d522f475SmrgAC_DEFUN([CF_ARG_ENABLE],
232d522f475Smrg[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
233d522f475Smrgdnl ---------------------------------------------------------------------------
23420d2c4d2Smrgdnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
235d522f475Smrgdnl -------------
236d522f475Smrgdnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
237d522f475Smrgdnl values.
238d522f475Smrgdnl
239d522f475Smrgdnl Parameters:
240d522f475Smrgdnl $1 = option name
241d522f475Smrgdnl $2 = help-string
242d522f475Smrgdnl $3 = action to perform if option is not default
243d522f475Smrgdnl $4 = action if perform if option is default
244d522f475Smrgdnl $5 = default option value (either 'yes' or 'no')
245d522f475SmrgAC_DEFUN([CF_ARG_OPTION],
24620d2c4d2Smrg[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
247d522f475Smrg  if test "$enableval" != "$5" ; then
24820d2c4d2Smrgifelse([$3],,[    :]dnl
24920d2c4d2Smrg,[    $3]) ifelse([$4],,,[
250d522f475Smrg  else
251d522f475Smrg    $4])
25220d2c4d2Smrg  fi],[enableval=$5 ifelse([$4],,,[
253d522f475Smrg  $4
254d522f475Smrg])dnl
255d522f475Smrg  ])])dnl
256d522f475Smrgdnl ---------------------------------------------------------------------------
25701037d57Smrgdnl CF_CC_ENV_FLAGS version: 2 updated: 2015/04/12 15:39:00
2580bd37d32Smrgdnl ---------------
2590bd37d32Smrgdnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
2600bd37d32Smrgdnl into CC.  This will not help with broken scripts that wrap the compiler with
2610bd37d32Smrgdnl options, but eliminates a more common category of user confusion.
2620bd37d32SmrgAC_DEFUN([CF_CC_ENV_FLAGS],
2630bd37d32Smrg[
2640bd37d32Smrg# This should have been defined by AC_PROG_CC
2650bd37d32Smrg: ${CC:=cc}
2660bd37d32Smrg
2670bd37d32SmrgAC_MSG_CHECKING(\$CC variable)
26801037d57Smrgcase "$CC" in
26901037d57Smrg(*[[\ \	]]-[[IUD]]*)
2700bd37d32Smrg	AC_MSG_RESULT(broken)
2710bd37d32Smrg	AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
2720bd37d32Smrg	# humor him...
2730bd37d32Smrg	cf_flags=`echo "$CC" | sed -e 's/^[[^ 	]]*[[ 	]]//'`
2740bd37d32Smrg	CC=`echo "$CC" | sed -e 's/[[ 	]].*//'`
2750bd37d32Smrg	CF_ADD_CFLAGS($cf_flags)
2760bd37d32Smrg	;;
27701037d57Smrg(*)
2780bd37d32Smrg	AC_MSG_RESULT(ok)
2790bd37d32Smrg	;;
2800bd37d32Smrgesac
2810bd37d32Smrg])dnl
2820bd37d32Smrgdnl ---------------------------------------------------------------------------
2830bd37d32Smrgdnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
284d522f475Smrgdnl --------------
285d522f475Smrgdnl Check if we're accidentally using a cache from a different machine.
286d522f475Smrgdnl Derive the system name, as a check for reusing the autoconf cache.
287d522f475Smrgdnl
288d522f475Smrgdnl If we've packaged config.guess and config.sub, run that (since it does a
289d522f475Smrgdnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
290d522f475Smrgdnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
291d522f475Smrgdnl which is useful in cross-compiles.
292d522f475Smrgdnl
293d522f475Smrgdnl Note: we would use $ac_config_sub, but that is one of the places where
294d522f475Smrgdnl autoconf 2.5x broke compatibility with autoconf 2.13
295d522f475SmrgAC_DEFUN([CF_CHECK_CACHE],
296d522f475Smrg[
297d522f475Smrgif test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
298d522f475Smrg	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
299d522f475Smrg	system_name="$host_os"
300d522f475Smrgelse
301d522f475Smrg	system_name="`(uname -s -r) 2>/dev/null`"
302d522f475Smrg	if test -z "$system_name" ; then
303d522f475Smrg		system_name="`(hostname) 2>/dev/null`"
304d522f475Smrg	fi
305d522f475Smrgfi
3060bd37d32Smrgtest -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
307d522f475SmrgAC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
308d522f475Smrg
309d522f475Smrgtest -z "$system_name" && system_name="$cf_cv_system_name"
310d522f475Smrgtest -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
311d522f475Smrg
312d522f475Smrgif test ".$system_name" != ".$cf_cv_system_name" ; then
313d522f475Smrg	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
314d522f475Smrg	AC_MSG_ERROR("Please remove config.cache and try again.")
315d522f475Smrgfi
316d522f475Smrg])dnl
317d522f475Smrgdnl ---------------------------------------------------------------------------
31801037d57Smrgdnl CF_CHECK_CFLAGS version: 3 updated: 2014/07/22 05:32:57
319d522f475Smrgdnl ---------------
320d522f475Smrgdnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
321d522f475Smrgdnl a build-configuration such as imake.  These have the pitfall that they
322d522f475Smrgdnl often contain compiler-specific options which we cannot use, mixed with
323d522f475Smrgdnl preprocessor options that we usually can.
324d522f475SmrgAC_DEFUN([CF_CHECK_CFLAGS],
325d522f475Smrg[
326d522f475SmrgCF_VERBOSE(checking additions to CFLAGS)
327d522f475Smrgcf_check_cflags="$CFLAGS"
328d522f475Smrgcf_check_cppflags="$CPPFLAGS"
329d522f475SmrgCF_ADD_CFLAGS($1,yes)
33001037d57Smrgif test "x$cf_check_cflags" != "x$CFLAGS" ; then
331d522f475SmrgAC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
332d522f475Smrg	[CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
33301037d57Smrg	 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
334d522f475Smrg		 CF_VERBOSE(but keeping change to \$CPPFLAGS)
335d522f475Smrg	 fi
336d522f475Smrg	 CFLAGS="$cf_check_flags"])
337d522f475Smrgfi
338d522f475Smrg])dnl
339d522f475Smrgdnl ---------------------------------------------------------------------------
34020d2c4d2Smrgdnl CF_CHECK_ERRNO version: 11 updated: 2010/05/26 05:38:42
341d522f475Smrgdnl --------------
342d522f475Smrgdnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
343d522f475Smrgdnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
344d522f475Smrgdnl ourselves.
345d522f475Smrgdnl
346d522f475Smrgdnl $1 = the name to check
3472eaa94a1Schristosdnl $2 = the assumed type
348d522f475SmrgAC_DEFUN([CF_CHECK_ERRNO],
349d522f475Smrg[
350d522f475SmrgAC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
351d522f475Smrg    AC_TRY_COMPILE([
352d522f475Smrg#ifdef HAVE_STDLIB_H
353d522f475Smrg#include <stdlib.h>
354d522f475Smrg#endif
355d522f475Smrg#include <stdio.h>
356d522f475Smrg#include <sys/types.h>
357d522f475Smrg#include <errno.h> ],
35820d2c4d2Smrg    ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1,
359d522f475Smrg    [cf_cv_dcl_$1=yes],
360d522f475Smrg    [cf_cv_dcl_$1=no])
361d522f475Smrg])
362d522f475Smrg
363d522f475Smrgif test "$cf_cv_dcl_$1" = no ; then
364d522f475Smrg    CF_UPPER(cf_result,decl_$1)
365d522f475Smrg    AC_DEFINE_UNQUOTED($cf_result)
366d522f475Smrgfi
367d522f475Smrg
368d522f475Smrg# It's possible (for near-UNIX clones) that the data doesn't exist
36920d2c4d2SmrgCF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
370d522f475Smrg])dnl
371d522f475Smrgdnl ---------------------------------------------------------------------------
372d522f475Smrgdnl CF_CHECK_EXTERN_DATA version: 3 updated: 2001/12/30 18:03:23
373d522f475Smrgdnl --------------------
374d522f475Smrgdnl Check for existence of external data in the current set of libraries.  If
375d522f475Smrgdnl we can modify it, it's real enough.
376d522f475Smrgdnl $1 = the name to check
377d522f475Smrgdnl $2 = its type
378d522f475SmrgAC_DEFUN([CF_CHECK_EXTERN_DATA],
379d522f475Smrg[
380d522f475SmrgAC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
381d522f475Smrg    AC_TRY_LINK([
382d522f475Smrg#undef $1
383d522f475Smrgextern $2 $1;
384d522f475Smrg],
385d522f475Smrg    [$1 = 2],
386d522f475Smrg    [cf_cv_have_$1=yes],
387d522f475Smrg    [cf_cv_have_$1=no])
388d522f475Smrg])
389d522f475Smrg
390d522f475Smrgif test "$cf_cv_have_$1" = yes ; then
391d522f475Smrg    CF_UPPER(cf_result,have_$1)
392d522f475Smrg    AC_DEFINE_UNQUOTED($cf_result)
393d522f475Smrgfi
394d522f475Smrg
395d522f475Smrg])dnl
396d522f475Smrgdnl ---------------------------------------------------------------------------
397e0a2b6dfSmrgdnl CF_CLANG_COMPILER version: 2 updated: 2013/11/19 19:23:35
3980bd37d32Smrgdnl -----------------
3990bd37d32Smrgdnl Check if the given compiler is really clang.  clang's C driver defines
4000bd37d32Smrgdnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
4010bd37d32Smrgdnl not ignore some gcc options.
4020bd37d32Smrgdnl
4030bd37d32Smrgdnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
4040bd37d32Smrgdnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
4050bd37d32Smrgdnl the wrappers for gcc and g++ warnings.
4060bd37d32Smrgdnl
4070bd37d32Smrgdnl $1 = GCC (default) or GXX
408e0a2b6dfSmrgdnl $2 = CLANG_COMPILER (default)
4090bd37d32Smrgdnl $3 = CFLAGS (default) or CXXFLAGS
4100bd37d32SmrgAC_DEFUN([CF_CLANG_COMPILER],[
4110bd37d32Smrgifelse([$2],,CLANG_COMPILER,[$2])=no
4120bd37d32Smrg
4130bd37d32Smrgif test "$ifelse([$1],,[$1],GCC)" = yes ; then
4140bd37d32Smrg	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
4150bd37d32Smrg	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
4160bd37d32Smrg	ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
4170bd37d32Smrg	AC_TRY_COMPILE([],[
4180bd37d32Smrg#ifdef __clang__
4190bd37d32Smrg#else
4200bd37d32Smrgmake an error
4210bd37d32Smrg#endif
4220bd37d32Smrg],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
4230bd37d32Smrgcf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
4240bd37d32Smrg],[])
4250bd37d32Smrg	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
4260bd37d32Smrg	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
4270bd37d32Smrgfi
4280bd37d32Smrg])
4290bd37d32Smrgdnl ---------------------------------------------------------------------------
430e39b573cSmrgdnl CF_DISABLE_DESKTOP version: 2 updated: 2011/04/22 05:17:37
431e39b573cSmrgdnl ------------------
432e39b573cSmrgdnl Handle a configure option "--disable-desktop", which sets a shell
433e39b573cSmrgdnl variable $desktop_utils to a "#" if the feature is not wanted, or to an
434e39b573cSmrgdnl empty string if enabled.  The variable is used to substitute in front of
435e39b573cSmrgdnl corresponding makefile-rules.
436e39b573cSmrgdnl
437e39b573cSmrgdnl It also tells the configure script to substitute the environment variable
438e39b573cSmrgdnl $DESKTOP_FLAGS, which can be used by external scripts to customize the
439e39b573cSmrgdnl invocation of desktop-file-util.
440e39b573cSmrgdnl
441e39b573cSmrgdnl $1 = program name
442e39b573cSmrgAC_DEFUN([CF_DISABLE_DESKTOP],[
443e39b573cSmrg# Comment-out the install-desktop rule if the desktop-utils are not found.
444e39b573cSmrgAC_MSG_CHECKING(if you want to install desktop files)
445e39b573cSmrgCF_ARG_OPTION(desktop,
446e39b573cSmrg	[  --disable-desktop       disable install of $1 desktop files],
447e39b573cSmrg	[enable_desktop=$enableval],
448e39b573cSmrg	[enable_desktop=$enableval],yes)
449e39b573cSmrgAC_MSG_RESULT($enable_desktop)
450e39b573cSmrg
451e39b573cSmrgdesktop_utils=
452e39b573cSmrgif test "$enable_desktop" = yes ; then
453e39b573cSmrgAC_CHECK_PROG(desktop_utils,desktop-file-install,yes,no)
454e39b573cSmrgfi
455e39b573cSmrg
456e39b573cSmrgtest "$desktop_utils" = yes && desktop_utils= || desktop_utils="#"
457e39b573cSmrgAC_SUBST(DESKTOP_FLAGS)
458e39b573cSmrg])
459e39b573cSmrgdnl ---------------------------------------------------------------------------
4600bd37d32Smrgdnl CF_DISABLE_ECHO version: 12 updated: 2012/10/06 16:30:28
461d522f475Smrgdnl ---------------
462d522f475Smrgdnl You can always use "make -n" to see the actual options, but it's hard to
463d522f475Smrgdnl pick out/analyze warning messages when the compile-line is long.
464d522f475Smrgdnl
465d522f475Smrgdnl Sets:
466d522f475Smrgdnl	ECHO_LT - symbol to control if libtool is verbose
467d522f475Smrgdnl	ECHO_LD - symbol to prefix "cc -o" lines
468d522f475Smrgdnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
469d522f475Smrgdnl	SHOW_CC - symbol to put before explicit "cc -c" lines
470d522f475Smrgdnl	ECHO_CC - symbol to put before any "cc" line
471d522f475Smrgdnl
472d522f475SmrgAC_DEFUN([CF_DISABLE_ECHO],[
473d522f475SmrgAC_MSG_CHECKING(if you want to see long compiling messages)
474d522f475SmrgCF_ARG_DISABLE(echo,
4750bd37d32Smrg	[  --disable-echo          do not display "compiling" commands],
476d522f475Smrg	[
477d522f475Smrg    ECHO_LT='--silent'
478d522f475Smrg    ECHO_LD='@echo linking [$]@;'
47920d2c4d2Smrg    RULE_CC='@echo compiling [$]<'
48020d2c4d2Smrg    SHOW_CC='@echo compiling [$]@'
481d522f475Smrg    ECHO_CC='@'
482d522f475Smrg],[
483d522f475Smrg    ECHO_LT=''
484d522f475Smrg    ECHO_LD=''
48520d2c4d2Smrg    RULE_CC=''
48620d2c4d2Smrg    SHOW_CC=''
487d522f475Smrg    ECHO_CC=''
488d522f475Smrg])
489d522f475SmrgAC_MSG_RESULT($enableval)
490d522f475SmrgAC_SUBST(ECHO_LT)
491d522f475SmrgAC_SUBST(ECHO_LD)
492d522f475SmrgAC_SUBST(RULE_CC)
493d522f475SmrgAC_SUBST(SHOW_CC)
494d522f475SmrgAC_SUBST(ECHO_CC)
495d522f475Smrg])dnl
496d522f475Smrgdnl ---------------------------------------------------------------------------
4970bd37d32Smrgdnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
4980bd37d32Smrgdnl ----------------
4990bd37d32Smrgdnl Combine no-leak checks with the libraries or tools that are used for the
5000bd37d32Smrgdnl checks.
5010bd37d32SmrgAC_DEFUN([CF_DISABLE_LEAKS],[
5020bd37d32Smrg
5030bd37d32SmrgAC_REQUIRE([CF_WITH_DMALLOC])
5040bd37d32SmrgAC_REQUIRE([CF_WITH_DBMALLOC])
5050bd37d32SmrgAC_REQUIRE([CF_WITH_VALGRIND])
5060bd37d32Smrg
5070bd37d32SmrgAC_MSG_CHECKING(if you want to perform memory-leak testing)
5080bd37d32SmrgAC_ARG_ENABLE(leaks,
5090bd37d32Smrg	[  --disable-leaks         test: free permanent memory, analyze leaks],
5100bd37d32Smrg	[if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
5110bd37d32Smrg	: ${with_no_leaks:=no})
5120bd37d32SmrgAC_MSG_RESULT($with_no_leaks)
5130bd37d32Smrg
5140bd37d32Smrgif test "$with_no_leaks" = yes ; then
5150bd37d32Smrg	AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
5160bd37d32Smrg	AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
5170bd37d32Smrgfi
5180bd37d32Smrg])dnl
5190bd37d32Smrgdnl ---------------------------------------------------------------------------
520a1f3da82Smrgdnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
52120d2c4d2Smrgdnl ---------------------
52220d2c4d2Smrgdnl The rpath-hack makes it simpler to build programs, particularly with the
52320d2c4d2Smrgdnl *BSD ports which may have essential libraries in unusual places.  But it
52420d2c4d2Smrgdnl can interfere with building an executable for the base system.  Use this
52520d2c4d2Smrgdnl option in that case.
52620d2c4d2SmrgAC_DEFUN([CF_DISABLE_RPATH_HACK],
52720d2c4d2Smrg[
528a1f3da82SmrgAC_MSG_CHECKING(if rpath-hack should be disabled)
52920d2c4d2SmrgCF_ARG_DISABLE(rpath-hack,
53020d2c4d2Smrg	[  --disable-rpath-hack    don't add rpath options for additional libraries],
53120d2c4d2Smrg	[cf_disable_rpath_hack=yes],
53220d2c4d2Smrg	[cf_disable_rpath_hack=no])
53320d2c4d2SmrgAC_MSG_RESULT($cf_disable_rpath_hack)
53420d2c4d2Smrgif test "$cf_disable_rpath_hack" = no ; then
53520d2c4d2Smrg	CF_RPATH_HACK
53620d2c4d2Smrgfi
53720d2c4d2Smrg])
53820d2c4d2Smrgdnl ---------------------------------------------------------------------------
53901037d57Smrgdnl CF_ENABLE_NARROWPROTO version: 5 updated: 2015/04/12 15:39:00
540d522f475Smrgdnl ---------------------
541d522f475Smrgdnl If this is not set properly, Xaw's scrollbars will not work.
542d522f475Smrgdnl The so-called "modular" configuration for X.org omits most of the
543d522f475Smrgdnl configure checks that would be needed to provide compatibility with
544d522f475Smrgdnl older X builds.  This one breaks things noticeably.
545d522f475SmrgAC_DEFUN([CF_ENABLE_NARROWPROTO],
546d522f475Smrg[
547d522f475SmrgAC_MSG_CHECKING(if you want narrow prototypes for X libraries)
548d522f475Smrg
54901037d57Smrgcase `$ac_config_guess` in
55001037d57Smrg(*freebsd*|*gnu*|*irix5*|*irix6*|*linux-gnu*|*netbsd*|*openbsd*|*qnx*|*sco*|*sgi*)
551d522f475Smrg	cf_default_narrowproto=yes
552d522f475Smrg	;;
55301037d57Smrg(*)
554d522f475Smrg	cf_default_narrowproto=no
555d522f475Smrg	;;
556d522f475Smrgesac
557d522f475Smrg
558d522f475SmrgCF_ARG_OPTION(narrowproto,
559d522f475Smrg	[  --enable-narrowproto    enable narrow prototypes for X libraries],
560d522f475Smrg	[enable_narrowproto=$enableval],
561d522f475Smrg	[enable_narrowproto=$cf_default_narrowproto],
562d522f475Smrg	[$cf_default_narrowproto])
563d522f475SmrgAC_MSG_RESULT($enable_narrowproto)
564d522f475Smrg])
565d522f475Smrgdnl ---------------------------------------------------------------------------
566d522f475Smrgdnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
567d522f475Smrgdnl --------
568d522f475Smrgdnl Check if 'errno' is declared in <errno.h>
569d522f475SmrgAC_DEFUN([CF_ERRNO],
570d522f475Smrg[
571d522f475SmrgCF_CHECK_ERRNO(errno)
572d522f475Smrg])dnl
573d522f475Smrgdnl ---------------------------------------------------------------------------
57401037d57Smrgdnl CF_FUNC_GRANTPT version: 11 updated: 2015/04/12 15:39:00
575d522f475Smrgdnl ---------------
5760bd37d32Smrgdnl Check for grantpt versus openpty, as well as functions that "should" be
5770bd37d32Smrgdnl available if grantpt is available.
5780bd37d32SmrgAC_DEFUN([CF_FUNC_GRANTPT],[
5790bd37d32Smrg
5800bd37d32SmrgAC_CHECK_HEADERS( \
5810bd37d32Smrgstropts.h \
5820bd37d32Smrg)
5830bd37d32Smrg
5840bd37d32Smrgcf_func_grantpt="grantpt ptsname"
58501037d57Smrgcase $host_os in
58601037d57Smrg(darwin[[0-9]].*)
5870bd37d32Smrg	;;
58801037d57Smrg(*)
5890bd37d32Smrg	cf_func_grantpt="$cf_func_grantpt posix_openpt"
5900bd37d32Smrg	;;
5910bd37d32Smrgesac
5920bd37d32Smrg
5930bd37d32SmrgAC_CHECK_FUNCS($cf_func_grantpt)
5940bd37d32Smrg
5950bd37d32Smrgcf_grantpt_opts=
5960bd37d32Smrgif test "x$ac_cv_func_grantpt" = "xyes" ; then
5970bd37d32Smrg	AC_MSG_CHECKING(if grantpt really works)
5980bd37d32Smrg	AC_TRY_LINK(CF__GRANTPT_HEAD,CF__GRANTPT_BODY,[
5990bd37d32Smrg	AC_TRY_RUN(CF__GRANTPT_HEAD
6000bd37d32Smrgint main(void)
6010bd37d32Smrg{
6020bd37d32SmrgCF__GRANTPT_BODY
603d522f475Smrg}
6040bd37d32Smrg,
6050bd37d32Smrg,ac_cv_func_grantpt=no
6060bd37d32Smrg,ac_cv_func_grantpt=maybe)
6070bd37d32Smrg	],ac_cv_func_grantpt=no)
6080bd37d32Smrg	AC_MSG_RESULT($ac_cv_func_grantpt)
6090bd37d32Smrg
6100bd37d32Smrg	if test "x$ac_cv_func_grantpt" != "xno" ; then
6110bd37d32Smrg
6120bd37d32Smrg		if test "x$ac_cv_func_grantpt" = "xyes" ; then
6130bd37d32Smrg			AC_MSG_CHECKING(for pty features)
6140bd37d32Smrgdnl if we have no stropts.h, skip the checks for streams modules
6150bd37d32Smrg			if test "x$ac_cv_header_stropts_h" = xyes
6160bd37d32Smrg			then
6170bd37d32Smrg				cf_pty_this=0
6180bd37d32Smrg			else
6190bd37d32Smrg				cf_pty_this=3
6200bd37d32Smrg			fi
6210bd37d32Smrg
6220bd37d32Smrg			cf_pty_defines=
6230bd37d32Smrg			while test $cf_pty_this != 6
6240bd37d32Smrg			do
6250bd37d32Smrg
6260bd37d32Smrg				cf_pty_feature=
6270bd37d32Smrg				cf_pty_next=`expr $cf_pty_this + 1`
6280bd37d32Smrg				CF_MSG_LOG(pty feature test $cf_pty_next:5)
6290bd37d32Smrg				AC_TRY_RUN(#define CONFTEST $cf_pty_this
6300bd37d32Smrg$cf_pty_defines
6310bd37d32SmrgCF__GRANTPT_HEAD
6320bd37d32Smrgint main(void)
6330bd37d32Smrg{
6340bd37d32SmrgCF__GRANTPT_BODY
6350bd37d32Smrg}
6360bd37d32Smrg,
6370bd37d32Smrg[
63801037d57Smrg				case $cf_pty_next in
63901037d57Smrg				(1) # - streams
6400bd37d32Smrg					cf_pty_feature=ptem
6410bd37d32Smrg					;;
64201037d57Smrg				(2) # - streams
6430bd37d32Smrg					cf_pty_feature=ldterm
6440bd37d32Smrg					;;
64501037d57Smrg				(3) # - streams
6460bd37d32Smrg					cf_pty_feature=ttcompat
6470bd37d32Smrg					;;
64801037d57Smrg				(4)
6490bd37d32Smrg					cf_pty_feature=pty_isatty
6500bd37d32Smrg					;;
65101037d57Smrg				(5)
6520bd37d32Smrg					cf_pty_feature=pty_tcsetattr
6530bd37d32Smrg					;;
65401037d57Smrg				(6)
6550bd37d32Smrg					cf_pty_feature=tty_tcsetattr
6560bd37d32Smrg					;;
6570bd37d32Smrg				esac
6580bd37d32Smrg],[
65901037d57Smrg				case $cf_pty_next in
66001037d57Smrg				(1|2|3)
6610bd37d32Smrg					CF_MSG_LOG(skipping remaining streams features $cf_pty_this..2)
6620bd37d32Smrg					cf_pty_next=3
6630bd37d32Smrg					;;
6640bd37d32Smrg				esac
6650bd37d32Smrg])
6660bd37d32Smrg				if test -n "$cf_pty_feature"
6670bd37d32Smrg				then
6680bd37d32Smrg					cf_pty_defines="$cf_pty_defines
6690bd37d32Smrg#define CONFTEST_$cf_pty_feature 1
6700bd37d32Smrg"
6710bd37d32Smrg					cf_grantpt_opts="$cf_grantpt_opts $cf_pty_feature"
6720bd37d32Smrg				fi
6730bd37d32Smrg
6740bd37d32Smrg				cf_pty_this=$cf_pty_next
6750bd37d32Smrg			done
6760bd37d32Smrg			AC_MSG_RESULT($cf_grantpt_opts)
6770bd37d32Smrg			cf_grantpt_opts=`echo "$cf_grantpt_opts" | sed -e 's/ isatty//'`
6780bd37d32Smrg		fi
679d522f475Smrg	fi
6800bd37d32Smrgfi
6810bd37d32Smrg
6820bd37d32Smrgdnl If we found grantpt, but no features, e.g., for streams or if we are not
6830bd37d32Smrgdnl able to use tcsetattr, then give openpty a try.  In particular, Darwin 10.7
6840bd37d32Smrgdnl has a more functional openpty than posix_openpt.
6850bd37d32Smrgdnl
6860bd37d32Smrgdnl There is no configure run-test for openpty, since older implementations do
6870bd37d32Smrgdnl not always run properly as a non-root user.  For that reason, we also allow
6880bd37d32Smrgdnl the configure script to suppress this check entirely with $disable_openpty.
6890bd37d32Smrgif test "x$disable_openpty" != "xyes" || test -z "$cf_grantpt_opts" ; then
6900bd37d32Smrg	AC_CHECK_LIB(util, openpty, [cf_have_openpty=yes],[cf_have_openpty=no])
6910bd37d32Smrg	if test "$cf_have_openpty" = yes ; then
6920bd37d32Smrg		ac_cv_func_grantpt=no
6930bd37d32Smrg		LIBS="-lutil $LIBS"
6940bd37d32Smrg		AC_DEFINE(HAVE_OPENPTY,1,[Define to 1 if you have the openpty function])
6950bd37d32Smrg		AC_CHECK_HEADERS( \
6960bd37d32Smrg			util.h \
6970bd37d32Smrg			libutil.h \
6980bd37d32Smrg			pty.h \
6990bd37d32Smrg		)
7000bd37d32Smrg	fi
7010bd37d32Smrgfi
7020bd37d32Smrg
7030bd37d32Smrgdnl If we did not settle on using openpty, fill in the definitions for grantpt.
7040bd37d32Smrgif test "x$ac_cv_func_grantpt" != xno
7050bd37d32Smrgthen
7060bd37d32Smrg	CF_VERBOSE(will rely upon grantpt)
7070bd37d32Smrg	AC_DEFINE(HAVE_WORKING_GRANTPT,1,[Define to 1 if the grantpt function seems to work])
7080bd37d32Smrg	for cf_feature in $cf_grantpt_opts
7090bd37d32Smrg	do
7100bd37d32Smrg		cf_feature=`echo "$cf_feature" | sed -e 's/ //g'`
7110bd37d32Smrg		CF_UPPER(cf_FEATURE,$cf_feature)
7120bd37d32Smrg		AC_DEFINE_UNQUOTED(HAVE_GRANTPT_$cf_FEATURE)
7130bd37d32Smrg	done
7140bd37d32Smrgelif test "x$cf_have_openpty" = xno
7150bd37d32Smrgthen
7160bd37d32Smrg	CF_VERBOSE(will rely upon BSD-pseudoterminals)
7170bd37d32Smrgelse
7180bd37d32Smrg	CF_VERBOSE(will rely upon openpty)
7190bd37d32Smrgfi
7200bd37d32Smrg])dnl
721d522f475Smrgdnl ---------------------------------------------------------------------------
72201037d57Smrgdnl CF_FUNC_TGETENT version: 20 updated: 2015/04/12 15:39:00
723d522f475Smrgdnl ---------------
724d522f475Smrgdnl Check for tgetent function in termcap library.  If we cannot find this,
725d522f475Smrgdnl we'll use the $LINES and $COLUMNS environment variables to pass screen
726d522f475Smrgdnl size information to subprocesses.  (We cannot use terminfo's compatibility
727d522f475Smrgdnl function, since it cannot provide the termcap-format data).
728d522f475Smrgdnl
729d522f475Smrgdnl If the --disable-full-tgetent option is given, we'll settle for the first
730d522f475Smrgdnl tgetent function we find.  Since the search list in that case does not
731d522f475Smrgdnl include the termcap library, that allows us to default to terminfo.
732d522f475SmrgAC_DEFUN([CF_FUNC_TGETENT],
733d522f475Smrg[
734d522f475Smrg# compute a reasonable value for $TERM to give tgetent(), since we may be
735d522f475Smrg# running in 'screen', which sets $TERMCAP to a specific entry that is not
736d522f475Smrg# necessarily in /etc/termcap - unsetenv is not portable, so we cannot simply
737d522f475Smrg# discard $TERMCAP.
738d522f475Smrgcf_TERMVAR=vt100
739e39b573cSmrgif test -n "$TERMCAP"
740e39b573cSmrgthen
741e39b573cSmrg	cf_TERMCAP=`echo "$TERMCAP" | tr '\n' ' ' | sed -e 's/^..|//' -e 's/|.*//'`
74201037d57Smrg	case "$cf_TERMCAP" in
74301037d57Smrg	(screen*.*)
744e39b573cSmrg		;;
74501037d57Smrg	(*)
746e39b573cSmrg		cf_TERMVAR="$cf_TERMCAP"
747e39b573cSmrg		;;
748e39b573cSmrg	esac
749e39b573cSmrgfi
750d522f475Smrgtest -z "$cf_TERMVAR" && cf_TERMVAR=vt100
751d522f475Smrg
752d522f475SmrgAC_MSG_CHECKING(if we want full tgetent function)
753d522f475SmrgCF_ARG_DISABLE(full-tgetent,
754d522f475Smrg	[  --disable-full-tgetent  disable check for full tgetent function],
755d522f475Smrg	cf_full_tgetent=no,
756d522f475Smrg	cf_full_tgetent=yes,yes)
757d522f475SmrgAC_MSG_RESULT($cf_full_tgetent)
758d522f475Smrg
759d522f475Smrgif test "$cf_full_tgetent" = yes ; then
760d522f475Smrg	cf_test_message="full tgetent"
761d522f475Smrgelse
762d522f475Smrg	cf_test_message="tgetent"
763d522f475Smrgfi
764d522f475Smrg
765d522f475SmrgAC_CACHE_CHECK(for $cf_test_message function,cf_cv_lib_tgetent,[
766d522f475Smrgcf_save_LIBS="$LIBS"
767d522f475Smrgcf_cv_lib_tgetent=no
768d522f475Smrgif test "$cf_full_tgetent" = yes ; then
7690bd37d32Smrg	cf_TERMLIB="otermcap termcap termlib ncurses curses"
770d522f475Smrg	cf_TERMTST="buffer[[0]] == 0"
771d522f475Smrgelse
772d522f475Smrg	cf_TERMLIB="termlib ncurses curses"
773d522f475Smrg	cf_TERMTST="0"
774d522f475Smrgfi
775d522f475Smrgfor cf_termlib in '' $cf_TERMLIB ; do
776d522f475Smrg	LIBS="$cf_save_LIBS"
77720d2c4d2Smrg	test -n "$cf_termlib" && CF_ADD_LIB($cf_termlib)
778d522f475Smrg	AC_TRY_RUN([
779d522f475Smrg/* terminfo implementations ignore the buffer argument, making it useless for
780d522f475Smrg * the xterm application, which uses this information to make a new TERMCAP
781d522f475Smrg * environment variable.
782d522f475Smrg */
783d522f475Smrgint main()
784d522f475Smrg{
785d522f475Smrg	char buffer[1024];
786d522f475Smrg	buffer[0] = 0;
787d522f475Smrg	tgetent(buffer, "$cf_TERMVAR");
788d522f475Smrg	${cf_cv_main_return:-return} ($cf_TERMTST); }],
789d522f475Smrg	[echo "yes, there is a termcap/tgetent in $cf_termlib" 1>&AC_FD_CC
790d522f475Smrg	 if test -n "$cf_termlib" ; then
791d522f475Smrg	 	cf_cv_lib_tgetent="-l$cf_termlib"
792d522f475Smrg	 else
793d522f475Smrg	 	cf_cv_lib_tgetent=yes
794d522f475Smrg	 fi
795d522f475Smrg	 break],
796d522f475Smrg	[echo "no, there is no termcap/tgetent in $cf_termlib" 1>&AC_FD_CC],
797d522f475Smrg	[echo "cross-compiling, cannot verify if a termcap/tgetent is present in $cf_termlib" 1>&AC_FD_CC])
798d522f475Smrgdone
799d522f475SmrgLIBS="$cf_save_LIBS"
800d522f475Smrg])
801d522f475Smrg
802d522f475Smrg# If we found a working tgetent(), set LIBS and check for termcap.h.
803d522f475Smrg# (LIBS cannot be set inside AC_CACHE_CHECK; the commands there should
804d522f475Smrg# not have side effects other than setting the cache variable, because
805d522f475Smrg# they are not executed when a cached value exists.)
806e39b573cSmrgif test "x$cf_cv_lib_tgetent" != xno ; then
807e39b573cSmrg	test "x$cf_cv_lib_tgetent" != xyes && CF_ADD_LIBS($cf_cv_lib_tgetent)
8080bd37d32Smrg	AC_DEFINE(USE_TERMCAP,1,[Define 1 to indicate that working tgetent is found])
80920d2c4d2Smrg	if test "$cf_full_tgetent" = no ; then
81020d2c4d2Smrg		AC_TRY_COMPILE([
811d522f475Smrg#include <termcap.h>],[
812d522f475Smrg#ifdef NCURSES_VERSION
813d522f475Smrgmake an error
814d522f475Smrg#endif],[AC_DEFINE(HAVE_TERMCAP_H)])
81520d2c4d2Smrg	else
81620d2c4d2Smrg		AC_CHECK_HEADERS(termcap.h)
81720d2c4d2Smrg	fi
818d522f475Smrgelse
819d522f475Smrg        # If we didn't find a tgetent() that supports the buffer
820d522f475Smrg        # argument, look again to see whether we can find even
821d522f475Smrg        # a crippled one.  A crippled tgetent() is still useful to
822d522f475Smrg        # validate values for the TERM environment variable given to
823d522f475Smrg        # child processes.
824d522f475Smrg	AC_CACHE_CHECK(for partial tgetent function,cf_cv_lib_part_tgetent,[
825d522f475Smrg	cf_cv_lib_part_tgetent=no
826d522f475Smrg	for cf_termlib in $cf_TERMLIB ; do
827d522f475Smrg		LIBS="$cf_save_LIBS -l$cf_termlib"
828d522f475Smrg		AC_TRY_LINK([],[tgetent(0, "$cf_TERMVAR")],
829d522f475Smrg			[echo "there is a terminfo/tgetent in $cf_termlib" 1>&AC_FD_CC
830d522f475Smrg			 cf_cv_lib_part_tgetent="-l$cf_termlib"
831d522f475Smrg			 break])
832d522f475Smrg	done
833d522f475Smrg	LIBS="$cf_save_LIBS"
834d522f475Smrg	])
835d522f475Smrg
836d522f475Smrg	if test "$cf_cv_lib_part_tgetent" != no ; then
83720d2c4d2Smrg		CF_ADD_LIBS($cf_cv_lib_part_tgetent)
838d522f475Smrg		AC_CHECK_HEADERS(termcap.h)
839d522f475Smrg
840d522f475Smrg                # If this is linking against ncurses, we'll trigger the
841d522f475Smrg                # ifdef in resize.c that turns the termcap stuff back off.
8420bd37d32Smrg		AC_DEFINE(USE_TERMINFO,1,[Define to 1 to indicate that terminfo provides the tgetent interface])
843d522f475Smrg	fi
844d522f475Smrgfi
845d522f475Smrg])dnl
846d522f475Smrgdnl ---------------------------------------------------------------------------
84701037d57Smrgdnl CF_GCC_ATTRIBUTES version: 17 updated: 2015/04/12 15:39:00
848d522f475Smrgdnl -----------------
849d522f475Smrgdnl Test for availability of useful gcc __attribute__ directives to quiet
850d522f475Smrgdnl compiler warnings.  Though useful, not all are supported -- and contrary
851d522f475Smrgdnl to documentation, unrecognized directives cause older compilers to barf.
852d522f475SmrgAC_DEFUN([CF_GCC_ATTRIBUTES],
853d522f475Smrg[
854d522f475Smrgif test "$GCC" = yes
855d522f475Smrgthen
856d522f475Smrgcat > conftest.i <<EOF
857d522f475Smrg#ifndef GCC_PRINTF
858d522f475Smrg#define GCC_PRINTF 0
859d522f475Smrg#endif
860d522f475Smrg#ifndef GCC_SCANF
861d522f475Smrg#define GCC_SCANF 0
862d522f475Smrg#endif
863d522f475Smrg#ifndef GCC_NORETURN
864d522f475Smrg#define GCC_NORETURN /* nothing */
865d522f475Smrg#endif
866d522f475Smrg#ifndef GCC_UNUSED
867d522f475Smrg#define GCC_UNUSED /* nothing */
868d522f475Smrg#endif
869d522f475SmrgEOF
870d522f475Smrgif test "$GCC" = yes
871d522f475Smrgthen
872d522f475Smrg	AC_CHECKING([for $CC __attribute__ directives])
873d522f475Smrgcat > conftest.$ac_ext <<EOF
8746879286fSmrg#line __oline__ "${as_me:-configure}"
875d522f475Smrg#include "confdefs.h"
876d522f475Smrg#include "conftest.h"
877d522f475Smrg#include "conftest.i"
878d522f475Smrg#if	GCC_PRINTF
879d522f475Smrg#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
880d522f475Smrg#else
881d522f475Smrg#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
882d522f475Smrg#endif
883d522f475Smrg#if	GCC_SCANF
884d522f475Smrg#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
885d522f475Smrg#else
886d522f475Smrg#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
887d522f475Smrg#endif
888d522f475Smrgextern void wow(char *,...) GCC_SCANFLIKE(1,2);
889d522f475Smrgextern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
890d522f475Smrgextern void foo(void) GCC_NORETURN;
891d522f475Smrgint main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
892d522f475SmrgEOF
89320d2c4d2Smrg	cf_printf_attribute=no
89420d2c4d2Smrg	cf_scanf_attribute=no
895d522f475Smrg	for cf_attribute in scanf printf unused noreturn
896d522f475Smrg	do
897d522f475Smrg		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
898d522f475Smrg		cf_directive="__attribute__(($cf_attribute))"
899d522f475Smrg		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
90020d2c4d2Smrg
90101037d57Smrg		case $cf_attribute in
90201037d57Smrg		(printf)
90320d2c4d2Smrg			cf_printf_attribute=yes
90420d2c4d2Smrg			cat >conftest.h <<EOF
905d522f475Smrg#define GCC_$cf_ATTRIBUTE 1
906d522f475SmrgEOF
907d522f475Smrg			;;
90801037d57Smrg		(scanf)
90920d2c4d2Smrg			cf_scanf_attribute=yes
91020d2c4d2Smrg			cat >conftest.h <<EOF
91120d2c4d2Smrg#define GCC_$cf_ATTRIBUTE 1
91220d2c4d2SmrgEOF
91320d2c4d2Smrg			;;
91401037d57Smrg		(*)
91520d2c4d2Smrg			cat >conftest.h <<EOF
916d522f475Smrg#define GCC_$cf_ATTRIBUTE $cf_directive
917d522f475SmrgEOF
918d522f475Smrg			;;
919d522f475Smrg		esac
92020d2c4d2Smrg
921d522f475Smrg		if AC_TRY_EVAL(ac_compile); then
922d522f475Smrg			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
923d522f475Smrg			cat conftest.h >>confdefs.h
92401037d57Smrg			case $cf_attribute in
92501037d57Smrg			(noreturn)
9260bd37d32Smrg				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
9270bd37d32Smrg				;;
92801037d57Smrg			(printf)
9290bd37d32Smrg				cf_value='/* nothing */'
9300bd37d32Smrg				if test "$cf_printf_attribute" != no ; then
9310bd37d32Smrg					cf_value='__attribute__((format(printf,fmt,var)))'
9320bd37d32Smrg					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
93320d2c4d2Smrg				fi
9340bd37d32Smrg				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
93520d2c4d2Smrg				;;
93601037d57Smrg			(scanf)
9370bd37d32Smrg				cf_value='/* nothing */'
9380bd37d32Smrg				if test "$cf_scanf_attribute" != no ; then
9390bd37d32Smrg					cf_value='__attribute__((format(scanf,fmt,var)))'
9400bd37d32Smrg					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
94120d2c4d2Smrg				fi
9420bd37d32Smrg				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
9430bd37d32Smrg				;;
94401037d57Smrg			(unused)
9450bd37d32Smrg				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
94620d2c4d2Smrg				;;
94720d2c4d2Smrg			esac
948d522f475Smrg		fi
949d522f475Smrg	done
950d522f475Smrgelse
951d522f475Smrg	fgrep define conftest.i >>confdefs.h
952d522f475Smrgfi
953d522f475Smrgrm -rf conftest*
954d522f475Smrgfi
955d522f475Smrg])dnl
956d522f475Smrgdnl ---------------------------------------------------------------------------
9570bd37d32Smrgdnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
958d522f475Smrgdnl --------------
959d522f475Smrgdnl Find version of gcc
960d522f475SmrgAC_DEFUN([CF_GCC_VERSION],[
961d522f475SmrgAC_REQUIRE([AC_PROG_CC])
962d522f475SmrgGCC_VERSION=none
963d522f475Smrgif test "$GCC" = yes ; then
964d522f475Smrg	AC_MSG_CHECKING(version of $CC)
9650bd37d32Smrg	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.]].*//'`"
966d522f475Smrg	test -z "$GCC_VERSION" && GCC_VERSION=unknown
967d522f475Smrg	AC_MSG_RESULT($GCC_VERSION)
968d522f475Smrgfi
969d522f475Smrg])dnl
970d522f475Smrgdnl ---------------------------------------------------------------------------
97101037d57Smrgdnl CF_GCC_WARNINGS version: 32 updated: 2015/04/12 15:39:00
972d522f475Smrgdnl ---------------
973d522f475Smrgdnl Check if the compiler supports useful warning options.  There's a few that
974d522f475Smrgdnl we don't use, simply because they're too noisy:
975d522f475Smrgdnl
976d522f475Smrgdnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
977d522f475Smrgdnl	-Wredundant-decls (system headers make this too noisy)
978d522f475Smrgdnl	-Wtraditional (combines too many unrelated messages, only a few useful)
979d522f475Smrgdnl	-Wwrite-strings (too noisy, but should review occasionally).  This
980d522f475Smrgdnl		is enabled for ncurses using "--enable-const".
981d522f475Smrgdnl	-pedantic
982d522f475Smrgdnl
983d522f475Smrgdnl Parameter:
984d522f475Smrgdnl	$1 is an optional list of gcc warning flags that a particular
985d522f475Smrgdnl		application might want to use, e.g., "no-unused" for
986d522f475Smrgdnl		-Wno-unused
987d522f475Smrgdnl Special:
988d522f475Smrgdnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
989d522f475Smrgdnl
990d522f475SmrgAC_DEFUN([CF_GCC_WARNINGS],
991d522f475Smrg[
992d522f475SmrgAC_REQUIRE([CF_GCC_VERSION])
993d522f475SmrgCF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
9940bd37d32SmrgCF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
995d522f475Smrg
996d522f475Smrgcat > conftest.$ac_ext <<EOF
9976879286fSmrg#line __oline__ "${as_me:-configure}"
998d522f475Smrgint main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
999d522f475SmrgEOF
1000d522f475Smrg
1001d522f475Smrgif test "$INTEL_COMPILER" = yes
1002d522f475Smrgthen
1003d522f475Smrg# The "-wdXXX" options suppress warnings:
1004d522f475Smrg# remark #1419: external declaration in primary source file
1005d522f475Smrg# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1006d522f475Smrg# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1007d522f475Smrg# remark #193: zero used for undefined preprocessing identifier
1008d522f475Smrg# remark #593: variable "curs_sb_left_arrow" was set but never used
1009d522f475Smrg# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1010d522f475Smrg# remark #869: parameter "tw" was never referenced
1011d522f475Smrg# remark #981: operands are evaluated in unspecified order
1012956cc18dSsnj# warning #279: controlling expression is constant
1013d522f475Smrg
1014d522f475Smrg	AC_CHECKING([for $CC warning options])
1015d522f475Smrg	cf_save_CFLAGS="$CFLAGS"
1016d522f475Smrg	EXTRA_CFLAGS="-Wall"
1017d522f475Smrg	for cf_opt in \
1018d522f475Smrg		wd1419 \
1019d522f475Smrg		wd1683 \
1020d522f475Smrg		wd1684 \
1021d522f475Smrg		wd193 \
1022d522f475Smrg		wd593 \
1023956cc18dSsnj		wd279 \
1024d522f475Smrg		wd810 \
1025d522f475Smrg		wd869 \
1026d522f475Smrg		wd981
1027d522f475Smrg	do
1028d522f475Smrg		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1029d522f475Smrg		if AC_TRY_EVAL(ac_compile); then
1030d522f475Smrg			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1031d522f475Smrg			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1032d522f475Smrg		fi
1033d522f475Smrg	done
1034d522f475Smrg	CFLAGS="$cf_save_CFLAGS"
1035d522f475Smrg
1036d522f475Smrgelif test "$GCC" = yes
1037d522f475Smrgthen
1038d522f475Smrg	AC_CHECKING([for $CC warning options])
1039d522f475Smrg	cf_save_CFLAGS="$CFLAGS"
104020d2c4d2Smrg	EXTRA_CFLAGS=
1041d522f475Smrg	cf_warn_CONST=""
1042d522f475Smrg	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1043e0a2b6dfSmrg	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
1044e0a2b6dfSmrg	test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
104520d2c4d2Smrg	for cf_opt in W Wall \
1046d522f475Smrg		Wbad-function-cast \
1047d522f475Smrg		Wcast-align \
1048d522f475Smrg		Wcast-qual \
1049e0a2b6dfSmrg		Wdeclaration-after-statement \
1050e0a2b6dfSmrg		Wextra \
1051d522f475Smrg		Winline \
1052d522f475Smrg		Wmissing-declarations \
1053d522f475Smrg		Wmissing-prototypes \
1054d522f475Smrg		Wnested-externs \
1055d522f475Smrg		Wpointer-arith \
1056d522f475Smrg		Wshadow \
1057d522f475Smrg		Wstrict-prototypes \
1058e0a2b6dfSmrg		Wundef $cf_gcc_warnings $cf_warn_CONST $1
1059d522f475Smrg	do
1060d522f475Smrg		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1061d522f475Smrg		if AC_TRY_EVAL(ac_compile); then
1062d522f475Smrg			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
106301037d57Smrg			case $cf_opt in
106401037d57Smrg			(Wcast-qual)
1065d522f475Smrg				CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1066d522f475Smrg				;;
106701037d57Smrg			(Winline)
1068d522f475Smrg				case $GCC_VERSION in
106901037d57Smrg				([[34]].*)
1070d522f475Smrg					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1071d522f475Smrg					continue;;
1072d522f475Smrg				esac
1073d522f475Smrg				;;
107401037d57Smrg			(Wpointer-arith)
10750bd37d32Smrg				case $GCC_VERSION in
107601037d57Smrg				([[12]].*)
10770bd37d32Smrg					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
10780bd37d32Smrg					continue;;
10790bd37d32Smrg				esac
10800bd37d32Smrg				;;
1081d522f475Smrg			esac
1082d522f475Smrg			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1083d522f475Smrg		fi
1084d522f475Smrg	done
1085d522f475Smrg	CFLAGS="$cf_save_CFLAGS"
1086d522f475Smrgfi
10876879286fSmrgrm -rf conftest*
1088d522f475Smrg
1089d522f475SmrgAC_SUBST(EXTRA_CFLAGS)
1090d522f475Smrg])dnl
1091d522f475Smrgdnl ---------------------------------------------------------------------------
1092d522f475Smrgdnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1093d522f475Smrgdnl -------------
1094d522f475Smrgdnl Check if we must define _GNU_SOURCE to get a reasonable value for
1095d522f475Smrgdnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1096d522f475Smrgdnl (or misfeature) of glibc2, which breaks portability of many applications,
1097d522f475Smrgdnl since it is interwoven with GNU extensions.
1098d522f475Smrgdnl
1099d522f475Smrgdnl Well, yes we could work around it...
1100d522f475SmrgAC_DEFUN([CF_GNU_SOURCE],
1101d522f475Smrg[
1102d522f475SmrgAC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1103d522f475SmrgAC_TRY_COMPILE([#include <sys/types.h>],[
1104d522f475Smrg#ifndef _XOPEN_SOURCE
1105d522f475Smrgmake an error
1106d522f475Smrg#endif],
1107d522f475Smrg	[cf_cv_gnu_source=no],
1108d522f475Smrg	[cf_save="$CPPFLAGS"
1109d522f475Smrg	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1110d522f475Smrg	 AC_TRY_COMPILE([#include <sys/types.h>],[
1111d522f475Smrg#ifdef _XOPEN_SOURCE
1112d522f475Smrgmake an error
1113d522f475Smrg#endif],
1114d522f475Smrg	[cf_cv_gnu_source=no],
1115d522f475Smrg	[cf_cv_gnu_source=yes])
1116d522f475Smrg	CPPFLAGS="$cf_save"
1117d522f475Smrg	])
1118d522f475Smrg])
1119d522f475Smrgtest "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1120d522f475Smrg])dnl
1121d522f475Smrgdnl ---------------------------------------------------------------------------
1122d522f475Smrgdnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1123d522f475Smrgdnl ---------------
1124d522f475Smrgdnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1125d522f475SmrgAC_DEFUN([CF_HELP_MESSAGE],
1126d522f475Smrg[AC_DIVERT_HELP([$1])dnl
1127d522f475Smrg])dnl
1128d522f475Smrgdnl ---------------------------------------------------------------------------
112901037d57Smrgdnl CF_IMAKE_CFLAGS version: 32 updated: 2015/04/12 15:39:00
1130d522f475Smrgdnl ---------------
1131d522f475Smrgdnl Use imake to obtain compiler flags.  We could, in principle, write tests to
1132d522f475Smrgdnl get these, but if imake is properly configured there is no point in doing
1133d522f475Smrgdnl this.
1134d522f475Smrgdnl
1135d522f475Smrgdnl Parameters (used in constructing a sample Imakefile):
1136d522f475Smrgdnl	$1 = optional value to append to $IMAKE_CFLAGS
1137d522f475Smrgdnl	$2 = optional value to append to $IMAKE_LOADFLAGS
1138d522f475SmrgAC_DEFUN([CF_IMAKE_CFLAGS],
1139d522f475Smrg[
1140d522f475SmrgAC_PATH_PROGS(IMAKE,xmkmf imake)
1141d522f475Smrg
1142d522f475Smrgif test -n "$IMAKE" ; then
1143d522f475Smrg
114401037d57Smrgcase $IMAKE in
114501037d57Smrg(*/imake)
114601037d57Smrg	cf_imake_opts="-DUseInstalled=YES"
1147d522f475Smrg	;;
114801037d57Smrg(*/util/xmkmf)
1149d522f475Smrg	# A single parameter tells xmkmf where the config-files are:
115001037d57Smrg	cf_imake_opts="`echo $IMAKE|sed -e s,/config/util/xmkmf,,`"
1151d522f475Smrg	;;
115201037d57Smrg(*)
1153d522f475Smrg	cf_imake_opts=
1154d522f475Smrg	;;
1155d522f475Smrgesac
1156d522f475Smrg
1157d522f475Smrg# If it's installed properly, imake (or its wrapper, xmkmf) will point to the
1158d522f475Smrg# config directory.
1159d522f475Smrgif mkdir conftestdir; then
1160d522f475Smrg	CDPATH=; export CDPATH
1161d522f475Smrg	cf_makefile=`cd $srcdir;pwd`/Imakefile
1162d522f475Smrg	cd conftestdir
1163d522f475Smrg
1164d522f475Smrg	cat >fix_cflags.sed <<'CF_EOF'
1165d522f475Smrgs/\\//g
1166d522f475Smrgs/[[ 	]][[ 	]]*/ /g
1167d522f475Smrgs/"//g
1168d522f475Smrg:pack
1169d522f475Smrgs/\(=[[^ ]][[^ ]]*\) \([[^-]]\)/\1	\2/g
1170d522f475Smrgt pack
1171d522f475Smrgs/\(-D[[a-zA-Z0-9_]][[a-zA-Z0-9_]]*\)=\([[^\'0-9 ]][[^ ]]*\)/\1='\\"\2\\"'/g
1172d522f475Smrgs/^IMAKE[[ ]]/IMAKE_CFLAGS="/
1173d522f475Smrgs/	/ /g
1174d522f475Smrgs/$/"/
1175d522f475SmrgCF_EOF
1176d522f475Smrg
1177d522f475Smrg	cat >fix_lflags.sed <<'CF_EOF'
1178d522f475Smrgs/^IMAKE[[ 	]]*/IMAKE_LOADFLAGS="/
1179d522f475Smrgs/$/"/
1180d522f475SmrgCF_EOF
1181d522f475Smrg
1182d522f475Smrg	echo >./Imakefile
1183d522f475Smrg	test -f $cf_makefile && cat $cf_makefile >>./Imakefile
1184d522f475Smrg
1185d522f475Smrg	cat >> ./Imakefile <<'CF_EOF'
1186d522f475Smrgfindstddefs:
118720d2c4d2Smrg	@echo IMAKE ${ALLDEFINES}ifelse([$1],,,[ $1])       | sed -f fix_cflags.sed
118820d2c4d2Smrg	@echo IMAKE ${EXTRA_LOAD_FLAGS}ifelse([$2],,,[ $2]) | sed -f fix_lflags.sed
1189d522f475SmrgCF_EOF
1190d522f475Smrg
1191d522f475Smrg	if ( $IMAKE $cf_imake_opts 1>/dev/null 2>&AC_FD_CC && test -f Makefile)
1192d522f475Smrg	then
1193d522f475Smrg		CF_VERBOSE(Using $IMAKE $cf_imake_opts)
1194d522f475Smrg	else
1195d522f475Smrg		# sometimes imake doesn't have the config path compiled in.  Find it.
1196d522f475Smrg		cf_config=
1197d522f475Smrg		for cf_libpath in $X_LIBS $LIBS ; do
119801037d57Smrg			case $cf_libpath in
119901037d57Smrg			(-L*)
1200d522f475Smrg				cf_libpath=`echo .$cf_libpath | sed -e 's/^...//'`
1201d522f475Smrg				cf_libpath=$cf_libpath/X11/config
1202d522f475Smrg				if test -d $cf_libpath ; then
1203d522f475Smrg					cf_config=$cf_libpath
1204d522f475Smrg					break
1205d522f475Smrg				fi
1206d522f475Smrg				;;
1207d522f475Smrg			esac
1208d522f475Smrg		done
1209d522f475Smrg		if test -z "$cf_config" ; then
1210d522f475Smrg			AC_MSG_WARN(Could not find imake config-directory)
1211d522f475Smrg		else
1212d522f475Smrg			cf_imake_opts="$cf_imake_opts -I$cf_config"
1213d522f475Smrg			if ( $IMAKE -v $cf_imake_opts 2>&AC_FD_CC)
1214d522f475Smrg			then
1215d522f475Smrg				CF_VERBOSE(Using $IMAKE $cf_config)
1216d522f475Smrg			else
1217d522f475Smrg				AC_MSG_WARN(Cannot run $IMAKE)
1218d522f475Smrg			fi
1219d522f475Smrg		fi
1220d522f475Smrg	fi
1221d522f475Smrg
1222d522f475Smrg	# GNU make sometimes prints "make[1]: Entering...", which
1223d522f475Smrg	# would confuse us.
1224d522f475Smrg	eval `make findstddefs 2>/dev/null | grep -v make`
1225d522f475Smrg
1226d522f475Smrg	cd ..
1227d522f475Smrg	rm -rf conftestdir
1228d522f475Smrg
1229d522f475Smrg	# We use ${ALLDEFINES} rather than ${STD_DEFINES} because the former
1230d522f475Smrg	# declares XTFUNCPROTO there.  However, some vendors (e.g., SGI) have
1231d522f475Smrg	# modified it to support site.cf, adding a kludge for the /usr/include
1232d522f475Smrg	# directory.  Try to filter that out, otherwise gcc won't find its
1233d522f475Smrg	# headers.
1234d522f475Smrg	if test -n "$GCC" ; then
1235d522f475Smrg	    if test -n "$IMAKE_CFLAGS" ; then
1236d522f475Smrg		cf_nostdinc=""
1237d522f475Smrg		cf_std_incl=""
1238d522f475Smrg		cf_cpp_opts=""
1239d522f475Smrg		for cf_opt in $IMAKE_CFLAGS
1240d522f475Smrg		do
1241d522f475Smrg		    case "$cf_opt" in
124201037d57Smrg		    (-nostdinc)
1243d522f475Smrg			cf_nostdinc="$cf_opt"
1244d522f475Smrg			;;
124501037d57Smrg		    (-I/usr/include)
1246d522f475Smrg			cf_std_incl="$cf_opt"
1247d522f475Smrg			;;
124801037d57Smrg		    (*)
1249d522f475Smrg			cf_cpp_opts="$cf_cpp_opts $cf_opt"
1250d522f475Smrg			;;
1251d522f475Smrg		    esac
1252d522f475Smrg		done
1253d522f475Smrg		if test -z "$cf_nostdinc" ; then
1254d522f475Smrg		    IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl"
1255d522f475Smrg		elif test -z "$cf_std_incl" ; then
1256d522f475Smrg		    IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc"
1257d522f475Smrg		else
1258d522f475Smrg		    CF_VERBOSE(suppressed \"$cf_nostdinc\" and \"$cf_std_incl\")
1259d522f475Smrg		    IMAKE_CFLAGS="$cf_cpp_opts"
1260d522f475Smrg		fi
1261d522f475Smrg	    fi
1262d522f475Smrg	fi
1263d522f475Smrgfi
1264d522f475Smrg
1265d522f475Smrg# Some imake configurations define PROJECTROOT with an empty value.  Remove
1266d522f475Smrg# the empty definition.
1267d522f475Smrgcase $IMAKE_CFLAGS in
126801037d57Smrg(*-DPROJECTROOT=/*)
1269d522f475Smrg	;;
127001037d57Smrg(*)
1271d522f475Smrg	IMAKE_CFLAGS=`echo "$IMAKE_CFLAGS" |sed -e "s,-DPROJECTROOT=[[ 	]], ,"`
1272d522f475Smrg	;;
1273d522f475Smrgesac
1274d522f475Smrg
1275d522f475Smrgfi
1276d522f475Smrg
1277d522f475SmrgCF_VERBOSE(IMAKE_CFLAGS $IMAKE_CFLAGS)
1278d522f475SmrgCF_VERBOSE(IMAKE_LOADFLAGS $IMAKE_LOADFLAGS)
1279d522f475Smrg
1280d522f475SmrgAC_SUBST(IMAKE_CFLAGS)
1281d522f475SmrgAC_SUBST(IMAKE_LOADFLAGS)
1282d522f475Smrg])dnl
1283d522f475Smrgdnl ---------------------------------------------------------------------------
1284d522f475Smrgdnl CF_INPUT_METHOD version: 3 updated: 2000/04/11 23:46:57
1285d522f475Smrgdnl ---------------
1286d522f475Smrgdnl Check if the X libraries support input-method
1287d522f475SmrgAC_DEFUN([CF_INPUT_METHOD],
1288d522f475Smrg[
1289d522f475SmrgAC_CACHE_CHECK([if X libraries support input-method],cf_cv_input_method,[
1290d522f475SmrgAC_TRY_LINK([
1291d522f475Smrg#include <X11/IntrinsicP.h>
1292d522f475Smrg#include <X11/Xatom.h>
1293d522f475Smrg#include <X11/Xutil.h>
1294d522f475Smrg#include <X11/Xmu/Atoms.h>
1295d522f475Smrg#include <X11/Xmu/Converters.h>
1296d522f475Smrg#include <X11/Xaw/XawImP.h>
1297d522f475Smrg],[
1298d522f475Smrg{
1299d522f475Smrg	XIM xim;
1300d522f475Smrg	XIMStyles *xim_styles = 0;
1301d522f475Smrg	XIMStyle input_style;
1302d522f475Smrg	Widget w = 0;
1303d522f475Smrg
1304d522f475Smrg	XSetLocaleModifiers("@im=none");
1305d522f475Smrg	xim = XOpenIM(XtDisplay(w), NULL, NULL, NULL);
1306d522f475Smrg	XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);
1307d522f475Smrg	XCloseIM(xim);
1308d522f475Smrg	input_style = (XIMPreeditNothing | XIMStatusNothing);
1309d522f475Smrg}
1310d522f475Smrg],
1311d522f475Smrg[cf_cv_input_method=yes],
1312d522f475Smrg[cf_cv_input_method=no])])
1313d522f475Smrg])dnl
1314d522f475Smrgdnl ---------------------------------------------------------------------------
131501037d57Smrgdnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00
1316d522f475Smrgdnl -----------------
1317d522f475Smrgdnl Check if the given compiler is really the Intel compiler for Linux.  It
1318d522f475Smrgdnl tries to imitate gcc, but does not return an error when it finds a mismatch
1319d522f475Smrgdnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1320d522f475Smrgdnl
1321d522f475Smrgdnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1322d522f475Smrgdnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1323d522f475Smrgdnl the wrappers for gcc and g++ warnings.
1324d522f475Smrgdnl
1325d522f475Smrgdnl $1 = GCC (default) or GXX
1326d522f475Smrgdnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1327d522f475Smrgdnl $3 = CFLAGS (default) or CXXFLAGS
1328d522f475SmrgAC_DEFUN([CF_INTEL_COMPILER],[
13290bd37d32SmrgAC_REQUIRE([AC_CANONICAL_HOST])
133020d2c4d2Smrgifelse([$2],,INTEL_COMPILER,[$2])=no
1331d522f475Smrg
133220d2c4d2Smrgif test "$ifelse([$1],,[$1],GCC)" = yes ; then
1333d522f475Smrg	case $host_os in
133401037d57Smrg	(linux*|gnu*)
133520d2c4d2Smrg		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
133620d2c4d2Smrg		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
133720d2c4d2Smrg		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1338d522f475Smrg		AC_TRY_COMPILE([],[
1339d522f475Smrg#ifdef __INTEL_COMPILER
1340d522f475Smrg#else
1341d522f475Smrgmake an error
1342d522f475Smrg#endif
134320d2c4d2Smrg],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1344894e0ac8Smrgcf_save_CFLAGS="$cf_save_CFLAGS -we147"
1345d522f475Smrg],[])
134620d2c4d2Smrg		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
134720d2c4d2Smrg		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1348d522f475Smrg		;;
1349d522f475Smrg	esac
1350d522f475Smrgfi
1351d522f475Smrg])dnl
1352d522f475Smrgdnl ---------------------------------------------------------------------------
13530bd37d32Smrgdnl CF_LASTLOG version: 5 updated: 2012/10/04 20:12:20
1354d522f475Smrgdnl ----------
1355d522f475Smrgdnl Check for header defining _PATH_LASTLOG, or failing that, see if the lastlog
1356d522f475Smrgdnl file exists.
1357d522f475SmrgAC_DEFUN([CF_LASTLOG],
1358d522f475Smrg[
1359d522f475SmrgAC_CHECK_HEADERS(lastlog.h paths.h)
1360d522f475SmrgAC_CACHE_CHECK(for lastlog path,cf_cv_path_lastlog,[
1361d522f475SmrgAC_TRY_COMPILE([
1362d522f475Smrg#include <sys/types.h>
1363d522f475Smrg#ifdef HAVE_LASTLOG_H
1364d522f475Smrg#include <lastlog.h>
1365d522f475Smrg#else
1366d522f475Smrg#ifdef HAVE_PATHS_H
1367d522f475Smrg#include <paths.h>
1368d522f475Smrg#endif
1369d522f475Smrg#endif],[char *path = _PATH_LASTLOG],
1370d522f475Smrg	[cf_cv_path_lastlog="_PATH_LASTLOG"],
1371d522f475Smrg	[if test -f /usr/adm/lastlog ; then
1372d522f475Smrg	 	cf_cv_path_lastlog=/usr/adm/lastlog
1373d522f475Smrg	else
1374d522f475Smrg		cf_cv_path_lastlog=no
1375d522f475Smrg	fi])
1376d522f475Smrg])
13770bd37d32Smrgtest $cf_cv_path_lastlog != no && AC_DEFINE(USE_LASTLOG,1,[Define to 1 if we can define lastlog pathname])
1378d522f475Smrg])dnl
1379d522f475Smrgdnl ---------------------------------------------------------------------------
138001037d57Smrgdnl CF_LD_RPATH_OPT version: 6 updated: 2015/04/12 15:39:00
138120d2c4d2Smrgdnl ---------------
138220d2c4d2Smrgdnl For the given system and compiler, find the compiler flags to pass to the
138320d2c4d2Smrgdnl loader to use the "rpath" feature.
138420d2c4d2SmrgAC_DEFUN([CF_LD_RPATH_OPT],
138520d2c4d2Smrg[
138620d2c4d2SmrgAC_REQUIRE([CF_CHECK_CACHE])
138720d2c4d2Smrg
138820d2c4d2SmrgLD_RPATH_OPT=
138920d2c4d2SmrgAC_MSG_CHECKING(for an rpath option)
139001037d57Smrgcase $cf_cv_system_name in
139101037d57Smrg(irix*)
139220d2c4d2Smrg	if test "$GCC" = yes; then
139320d2c4d2Smrg		LD_RPATH_OPT="-Wl,-rpath,"
139420d2c4d2Smrg	else
139520d2c4d2Smrg		LD_RPATH_OPT="-rpath "
139620d2c4d2Smrg	fi
139720d2c4d2Smrg	;;
139801037d57Smrg(linux*|gnu*|k*bsd*-gnu)
139920d2c4d2Smrg	LD_RPATH_OPT="-Wl,-rpath,"
140020d2c4d2Smrg	;;
140101037d57Smrg(openbsd[[2-9]].*|mirbsd*)
140220d2c4d2Smrg	LD_RPATH_OPT="-Wl,-rpath,"
140320d2c4d2Smrg	;;
140401037d57Smrg(dragonfly*|freebsd*)
140520d2c4d2Smrg	LD_RPATH_OPT="-rpath "
140620d2c4d2Smrg	;;
140701037d57Smrg(netbsd*)
140820d2c4d2Smrg	LD_RPATH_OPT="-Wl,-rpath,"
140920d2c4d2Smrg	;;
141001037d57Smrg(osf*|mls+*)
141120d2c4d2Smrg	LD_RPATH_OPT="-rpath "
141220d2c4d2Smrg	;;
141301037d57Smrg(solaris2*)
141420d2c4d2Smrg	LD_RPATH_OPT="-R"
141520d2c4d2Smrg	;;
141601037d57Smrg(*)
141720d2c4d2Smrg	;;
141820d2c4d2Smrgesac
141920d2c4d2SmrgAC_MSG_RESULT($LD_RPATH_OPT)
142020d2c4d2Smrg
142101037d57Smrgcase "x$LD_RPATH_OPT" in
142201037d57Smrg(x-R*)
142320d2c4d2Smrg	AC_MSG_CHECKING(if we need a space after rpath option)
142420d2c4d2Smrg	cf_save_LIBS="$LIBS"
142520d2c4d2Smrg	CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
142620d2c4d2Smrg	AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
142720d2c4d2Smrg	LIBS="$cf_save_LIBS"
142820d2c4d2Smrg	AC_MSG_RESULT($cf_rpath_space)
142920d2c4d2Smrg	test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
143020d2c4d2Smrg	;;
143120d2c4d2Smrgesac
143220d2c4d2Smrg])dnl
143320d2c4d2Smrgdnl ---------------------------------------------------------------------------
14346879286fSmrgdnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
143520d2c4d2Smrgdnl ------------
143620d2c4d2Smrgdnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
143720d2c4d2Smrgdnl a monocase filesystem.
143820d2c4d2SmrgAC_DEFUN([CF_MAKE_TAGS],[
143920d2c4d2SmrgAC_REQUIRE([CF_MIXEDCASE_FILENAMES])
144020d2c4d2Smrg
144120d2c4d2SmrgAC_CHECK_PROGS(CTAGS, exctags ctags)
144220d2c4d2SmrgAC_CHECK_PROGS(ETAGS, exetags etags)
144320d2c4d2Smrg
14446879286fSmrgAC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
144520d2c4d2Smrg
144620d2c4d2Smrgif test "$cf_cv_mixedcase" = yes ; then
14476879286fSmrg	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
144820d2c4d2Smrgelse
144920d2c4d2Smrg	MAKE_UPPER_TAGS=no
145020d2c4d2Smrgfi
145120d2c4d2Smrg
145220d2c4d2Smrgif test "$MAKE_UPPER_TAGS" = yes ; then
145320d2c4d2Smrg	MAKE_UPPER_TAGS=
145420d2c4d2Smrgelse
145520d2c4d2Smrg	MAKE_UPPER_TAGS="#"
145620d2c4d2Smrgfi
145720d2c4d2Smrg
145820d2c4d2Smrgif test "$MAKE_LOWER_TAGS" = yes ; then
145920d2c4d2Smrg	MAKE_LOWER_TAGS=
146020d2c4d2Smrgelse
146120d2c4d2Smrg	MAKE_LOWER_TAGS="#"
146220d2c4d2Smrgfi
146320d2c4d2Smrg
146420d2c4d2SmrgAC_SUBST(CTAGS)
146520d2c4d2SmrgAC_SUBST(ETAGS)
146620d2c4d2Smrg
146720d2c4d2SmrgAC_SUBST(MAKE_UPPER_TAGS)
146820d2c4d2SmrgAC_SUBST(MAKE_LOWER_TAGS)
146920d2c4d2Smrg])dnl
147020d2c4d2Smrgdnl ---------------------------------------------------------------------------
1471894e0ac8Smrgdnl CF_MATH_LIB version: 8 updated: 2010/05/29 16:31:02
1472894e0ac8Smrgdnl -----------
1473894e0ac8Smrgdnl Checks for libraries.  At least one UNIX system, Apple Macintosh
1474894e0ac8Smrgdnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
1475894e0ac8Smrgdnl AC_CHECK_LIB(m,sin), because that fails for C++.
1476894e0ac8SmrgAC_DEFUN([CF_MATH_LIB],
1477894e0ac8Smrg[
1478894e0ac8SmrgAC_CACHE_CHECK(if -lm needed for math functions,
1479894e0ac8Smrg	cf_cv_need_libm,[
1480894e0ac8Smrg	AC_TRY_LINK([
1481894e0ac8Smrg	#include <stdio.h>
1482894e0ac8Smrg	#include <math.h>
1483894e0ac8Smrg	],
1484894e0ac8Smrg	[double x = rand(); printf("result = %g\n", ]ifelse([$2],,sin(x),$2)[)],
1485894e0ac8Smrg	[cf_cv_need_libm=no],
1486894e0ac8Smrg	[cf_cv_need_libm=yes])])
1487894e0ac8Smrgif test "$cf_cv_need_libm" = yes
1488894e0ac8Smrgthen
1489894e0ac8Smrgifelse($1,,[
1490894e0ac8Smrg	CF_ADD_LIB(m)
1491894e0ac8Smrg],[$1=-lm])
1492894e0ac8Smrgfi
1493894e0ac8Smrg])
1494894e0ac8Smrgdnl ---------------------------------------------------------------------------
149501037d57Smrgdnl CF_MIXEDCASE_FILENAMES version: 7 updated: 2015/04/12 15:39:00
149620d2c4d2Smrgdnl ----------------------
149720d2c4d2Smrgdnl Check if the file-system supports mixed-case filenames.  If we're able to
149820d2c4d2Smrgdnl create a lowercase name and see it as uppercase, it doesn't support that.
149920d2c4d2SmrgAC_DEFUN([CF_MIXEDCASE_FILENAMES],
150020d2c4d2Smrg[
150120d2c4d2SmrgAC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
150220d2c4d2Smrgif test "$cross_compiling" = yes ; then
150301037d57Smrg	case $target_alias in
150401037d57Smrg	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
150520d2c4d2Smrg		cf_cv_mixedcase=no
150620d2c4d2Smrg		;;
150701037d57Smrg	(*)
150820d2c4d2Smrg		cf_cv_mixedcase=yes
150920d2c4d2Smrg		;;
151020d2c4d2Smrg	esac
151120d2c4d2Smrgelse
151220d2c4d2Smrg	rm -f conftest CONFTEST
151320d2c4d2Smrg	echo test >conftest
151420d2c4d2Smrg	if test -f CONFTEST ; then
151520d2c4d2Smrg		cf_cv_mixedcase=no
151620d2c4d2Smrg	else
151720d2c4d2Smrg		cf_cv_mixedcase=yes
151820d2c4d2Smrg	fi
151920d2c4d2Smrg	rm -f conftest CONFTEST
152020d2c4d2Smrgfi
152120d2c4d2Smrg])
15220bd37d32Smrgtest "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
152320d2c4d2Smrg])dnl
152420d2c4d2Smrgdnl ---------------------------------------------------------------------------
15256879286fSmrgdnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1526d522f475Smrgdnl ----------
1527d522f475Smrgdnl Write a debug message to config.log, along with the line number in the
1528d522f475Smrgdnl configure script.
1529d522f475SmrgAC_DEFUN([CF_MSG_LOG],[
15306879286fSmrgecho "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1531d522f475Smrg])dnl
1532d522f475Smrgdnl ---------------------------------------------------------------------------
153301037d57Smrgdnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
15340bd37d32Smrgdnl ------------------
15350bd37d32Smrgdnl see CF_WITH_NO_LEAKS
15360bd37d32SmrgAC_DEFUN([CF_NO_LEAKS_OPTION],[
15370bd37d32SmrgAC_MSG_CHECKING(if you want to use $1 for testing)
15380bd37d32SmrgAC_ARG_WITH($1,
15390bd37d32Smrg	[$2],
15400bd37d32Smrg	[AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
15410bd37d32Smrg	 $4
15420bd37d32Smrg])
15430bd37d32Smrg	: ${with_cflags:=-g}
15440bd37d32Smrg	: ${with_no_leaks:=yes}
15450bd37d32Smrg	 with_$1=yes],
15460bd37d32Smrg	[with_$1=])
15470bd37d32SmrgAC_MSG_RESULT(${with_$1:-no})
15480bd37d32Smrg
154901037d57Smrgcase .$with_cflags in
155001037d57Smrg(.*-g*)
155101037d57Smrg	case .$CFLAGS in
155201037d57Smrg	(.*-g*)
15530bd37d32Smrg		;;
155401037d57Smrg	(*)
15550bd37d32Smrg		CF_ADD_CFLAGS([-g])
15560bd37d32Smrg		;;
15570bd37d32Smrg	esac
15580bd37d32Smrg	;;
15590bd37d32Smrgesac
15600bd37d32Smrg])dnl
15610bd37d32Smrgdnl ---------------------------------------------------------------------------
156201037d57Smrgdnl CF_PATHSEP version: 7 updated: 2015/04/12 15:39:00
1563956cc18dSsnjdnl ----------
15640bd37d32Smrgdnl Provide a value for the $PATH and similar separator (or amend the value
15650bd37d32Smrgdnl as provided in autoconf 2.5x).
1566956cc18dSsnjAC_DEFUN([CF_PATHSEP],
1567956cc18dSsnj[
15680bd37d32Smrg	AC_MSG_CHECKING(for PATH separator)
1569956cc18dSsnj	case $cf_cv_system_name in
157001037d57Smrg	(os2*)	PATH_SEPARATOR=';'  ;;
157101037d57Smrg	(*)	${PATH_SEPARATOR:=':'}  ;;
1572956cc18dSsnj	esac
157320d2c4d2Smrgifelse([$1],,,[$1=$PATH_SEPARATOR])
1574956cc18dSsnj	AC_SUBST(PATH_SEPARATOR)
15750bd37d32Smrg	AC_MSG_RESULT($PATH_SEPARATOR)
1576956cc18dSsnj])dnl
1577956cc18dSsnjdnl ---------------------------------------------------------------------------
15780bd37d32Smrgdnl CF_PATH_PROG version: 9 updated: 2012/10/04 20:12:20
1579d522f475Smrgdnl ------------
1580d522f475Smrgdnl Check for a given program, defining corresponding symbol.
1581d522f475Smrgdnl	$1 = environment variable, which is suffixed by "_PATH" in the #define.
1582d522f475Smrgdnl	$2 = program name to find.
1583d522f475Smrgdnl	$3 = optional list of additional program names to test.
1584d522f475Smrgdnl
1585d522f475Smrgdnl If there is more than one token in the result, #define the remaining tokens
1586d522f475Smrgdnl to $1_ARGS.  We need this for 'install' in particular.
1587d522f475Smrgdnl
1588d522f475Smrgdnl FIXME: we should allow this to be overridden by environment variables
1589d522f475Smrgdnl
1590d522f475SmrgAC_DEFUN([CF_PATH_PROG],[
1591956cc18dSsnjAC_REQUIRE([CF_PATHSEP])
1592d522f475Smrgtest -z "[$]$1" && $1=$2
1593d522f475SmrgAC_PATH_PROGS($1,[$]$1 $2 $3,[$]$1)
1594d522f475Smrg
1595d522f475Smrgcf_path_prog=""
1596d522f475Smrgcf_path_args=""
15976879286fSmrgIFS="${IFS:- 	}"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
1598d522f475Smrgfor cf_temp in $ac_cv_path_$1
1599d522f475Smrgdo
1600d522f475Smrg	if test -z "$cf_path_prog" ; then
1601d522f475Smrg		if test "$with_full_paths" = yes ; then
1602d522f475Smrg			CF_PATH_SYNTAX(cf_temp,break)
1603d522f475Smrg			cf_path_prog="$cf_temp"
1604d522f475Smrg		else
1605d522f475Smrg			cf_path_prog="`basename $cf_temp`"
1606d522f475Smrg		fi
1607d522f475Smrg	elif test -z "$cf_path_args" ; then
1608d522f475Smrg		cf_path_args="$cf_temp"
1609d522f475Smrg	else
1610d522f475Smrg		cf_path_args="$cf_path_args $cf_temp"
1611d522f475Smrg	fi
1612d522f475Smrgdone
1613d522f475SmrgIFS="$cf_save_ifs"
1614d522f475Smrg
1615d522f475Smrgif test -n "$cf_path_prog" ; then
1616d522f475Smrg	CF_MSG_LOG(defining path for ${cf_path_prog})
16170bd37d32Smrg	AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog",Define to pathname $1)
16180bd37d32Smrg	test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args",Define to provide args for $1)
1619d522f475Smrgfi
1620d522f475Smrg])dnl
1621d522f475Smrgdnl ---------------------------------------------------------------------------
162201037d57Smrgdnl CF_PATH_SYNTAX version: 15 updated: 2015/04/12 15:39:00
1623d522f475Smrgdnl --------------
1624d522f475Smrgdnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1625d522f475Smrgdnl begins with one of the prefix/exec_prefix variables, and then again if the
1626d522f475Smrgdnl result begins with 'NONE'.  This is necessary to work around autoconf's
1627d522f475Smrgdnl delayed evaluation of those symbols.
1628d522f475SmrgAC_DEFUN([CF_PATH_SYNTAX],[
1629d522f475Smrgif test "x$prefix" != xNONE; then
1630d522f475Smrg  cf_path_syntax="$prefix"
1631d522f475Smrgelse
1632d522f475Smrg  cf_path_syntax="$ac_default_prefix"
1633d522f475Smrgfi
1634d522f475Smrg
163501037d57Smrgcase ".[$]$1" in
163601037d57Smrg(.\[$]\(*\)*|.\'*\'*)
1637d522f475Smrg  ;;
163801037d57Smrg(..|./*|.\\*)
1639d522f475Smrg  ;;
164001037d57Smrg(.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
1641d522f475Smrg  ;;
164201037d57Smrg(.\[$]{*prefix}*|.\[$]{*dir}*)
1643d522f475Smrg  eval $1="[$]$1"
164401037d57Smrg  case ".[$]$1" in
164501037d57Smrg  (.NONE/*)
1646d522f475Smrg    $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1647d522f475Smrg    ;;
1648d522f475Smrg  esac
164901037d57Smrg  ;;
165001037d57Smrg(.no|.NONE/*)
1651d522f475Smrg  $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1652d522f475Smrg  ;;
165301037d57Smrg(*)
165420d2c4d2Smrg  ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1655d522f475Smrg  ;;
1656d522f475Smrgesac
1657d522f475Smrg])dnl
1658d522f475Smrgdnl ---------------------------------------------------------------------------
165901037d57Smrgdnl CF_PKG_CONFIG version: 9 updated: 2015/04/12 15:39:00
1660956cc18dSsnjdnl -------------
1661956cc18dSsnjdnl Check for the package-config program, unless disabled by command-line.
1662956cc18dSsnjAC_DEFUN([CF_PKG_CONFIG],
1663956cc18dSsnj[
1664956cc18dSsnjAC_MSG_CHECKING(if you want to use pkg-config)
1665956cc18dSsnjAC_ARG_WITH(pkg-config,
1666956cc18dSsnj	[  --with-pkg-config{=path} enable/disable use of pkg-config],
1667956cc18dSsnj	[cf_pkg_config=$withval],
1668956cc18dSsnj	[cf_pkg_config=yes])
1669956cc18dSsnjAC_MSG_RESULT($cf_pkg_config)
1670956cc18dSsnj
167101037d57Smrgcase $cf_pkg_config in
167201037d57Smrg(no)
1673956cc18dSsnj	PKG_CONFIG=none
1674956cc18dSsnj	;;
167501037d57Smrg(yes)
1676e39b573cSmrg	CF_ACVERSION_CHECK(2.52,
1677e39b573cSmrg		[AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
1678e39b573cSmrg		[AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
1679956cc18dSsnj	;;
168001037d57Smrg(*)
1681956cc18dSsnj	PKG_CONFIG=$withval
1682956cc18dSsnj	;;
1683956cc18dSsnjesac
1684956cc18dSsnj
1685956cc18dSsnjtest -z "$PKG_CONFIG" && PKG_CONFIG=none
1686956cc18dSsnjif test "$PKG_CONFIG" != none ; then
1687956cc18dSsnj	CF_PATH_SYNTAX(PKG_CONFIG)
168801037d57Smrgelse
168901037d57Smrg	AC_MSG_WARN(pkg-config is not installed)
1690956cc18dSsnjfi
1691956cc18dSsnj
1692956cc18dSsnjAC_SUBST(PKG_CONFIG)
1693956cc18dSsnj])dnl
1694956cc18dSsnjdnl ---------------------------------------------------------------------------
169501037d57Smrgdnl CF_POSIX_C_SOURCE version: 9 updated: 2015/04/12 15:39:00
1696d522f475Smrgdnl -----------------
1697d522f475Smrgdnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1698d522f475Smrgdnl
1699d522f475Smrgdnl	POSIX.1-1990				_POSIX_SOURCE
1700d522f475Smrgdnl	POSIX.1-1990 and			_POSIX_SOURCE and
1701d522f475Smrgdnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
1702d522f475Smrgdnl		Bindings Option
1703d522f475Smrgdnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
1704d522f475Smrgdnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
1705d522f475Smrgdnl	X/Open 2000				_POSIX_C_SOURCE=200112L
1706d522f475Smrgdnl
1707d522f475Smrgdnl Parameters:
1708d522f475Smrgdnl	$1 is the nominal value for _POSIX_C_SOURCE
1709d522f475SmrgAC_DEFUN([CF_POSIX_C_SOURCE],
1710d522f475Smrg[
171120d2c4d2Smrgcf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1712d522f475Smrg
1713d522f475Smrgcf_save_CFLAGS="$CFLAGS"
1714d522f475Smrgcf_save_CPPFLAGS="$CPPFLAGS"
1715d522f475Smrg
1716d522f475SmrgCF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1717d522f475SmrgCF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1718d522f475Smrg
1719d522f475SmrgAC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1720d522f475Smrg	CF_MSG_LOG(if the symbol is already defined go no further)
1721d522f475Smrg	AC_TRY_COMPILE([#include <sys/types.h>],[
1722d522f475Smrg#ifndef _POSIX_C_SOURCE
1723d522f475Smrgmake an error
1724d522f475Smrg#endif],
1725d522f475Smrg	[cf_cv_posix_c_source=no],
1726d522f475Smrg	[cf_want_posix_source=no
172701037d57Smrg	 case .$cf_POSIX_C_SOURCE in
172801037d57Smrg	 (.[[12]]??*)
1729d522f475Smrg		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1730d522f475Smrg		;;
173101037d57Smrg	 (.2)
1732d522f475Smrg		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1733d522f475Smrg		cf_want_posix_source=yes
1734d522f475Smrg		;;
173501037d57Smrg	 (.*)
1736d522f475Smrg		cf_want_posix_source=yes
1737d522f475Smrg		;;
1738d522f475Smrg	 esac
1739d522f475Smrg	 if test "$cf_want_posix_source" = yes ; then
1740d522f475Smrg		AC_TRY_COMPILE([#include <sys/types.h>],[
1741d522f475Smrg#ifdef _POSIX_SOURCE
1742d522f475Smrgmake an error
1743d522f475Smrg#endif],[],
1744d522f475Smrg		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1745d522f475Smrg	 fi
1746d522f475Smrg	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1747d522f475Smrg	 CFLAGS="$cf_trim_CFLAGS"
1748d522f475Smrg	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1749d522f475Smrg	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1750d522f475Smrg	 AC_TRY_COMPILE([#include <sys/types.h>],[
1751d522f475Smrg#ifndef _POSIX_C_SOURCE
1752d522f475Smrgmake an error
1753d522f475Smrg#endif],,
1754d522f475Smrg	 [cf_cv_posix_c_source=no])
1755d522f475Smrg	 CFLAGS="$cf_save_CFLAGS"
1756d522f475Smrg	 CPPFLAGS="$cf_save_CPPFLAGS"
1757d522f475Smrg	])
1758d522f475Smrg])
1759d522f475Smrg
1760d522f475Smrgif test "$cf_cv_posix_c_source" != no ; then
1761d522f475Smrg	CFLAGS="$cf_trim_CFLAGS"
1762d522f475Smrg	CPPFLAGS="$cf_trim_CPPFLAGS"
176320d2c4d2Smrg	CF_ADD_CFLAGS($cf_cv_posix_c_source)
1764d522f475Smrgfi
1765d522f475Smrg
1766d522f475Smrg])dnl
1767d522f475Smrgdnl ---------------------------------------------------------------------------
17680bd37d32Smrgdnl CF_POSIX_SAVED_IDS version: 8 updated: 2012/10/04 20:12:20
1769d522f475Smrgdnl ------------------
1770d522f475Smrgdnl
1771d522f475Smrgdnl Check first if saved-ids are always supported.  Some systems
1772d522f475Smrgdnl may require runtime checks.
1773d522f475SmrgAC_DEFUN([CF_POSIX_SAVED_IDS],
1774d522f475Smrg[
1775d522f475SmrgAC_CHECK_HEADERS( \
1776d522f475Smrgsys/param.h \
1777d522f475Smrg)
1778d522f475Smrg
1779d522f475SmrgAC_CACHE_CHECK(if POSIX saved-ids are supported,cf_cv_posix_saved_ids,[
1780d522f475SmrgAC_TRY_LINK(
1781d522f475Smrg[
1782d522f475Smrg#include <unistd.h>
1783d522f475Smrg#ifdef HAVE_SYS_PARAM_H
1784d522f475Smrg#include <sys/param.h>		/* this may define "BSD" */
1785d522f475Smrg#endif
1786d522f475Smrg],[
1787d522f475Smrg#if defined(_POSIX_SAVED_IDS) && (_POSIX_SAVED_IDS > 0)
1788d522f475Smrg	void *p = (void *) seteuid;
1789d522f475Smrg	int x = seteuid(geteuid());
1790d522f475Smrg#elif defined(BSD) && (BSD >= 199103)
1791d522f475Smrg/* The BSD's may implement the runtime check - and it fails.
1792d522f475Smrg * However, saved-ids work almost like POSIX (close enough for most uses).
1793d522f475Smrg */
1794d522f475Smrg#else
1795d522f475Smrgmake an error
1796d522f475Smrg#endif
1797d522f475Smrg],[cf_cv_posix_saved_ids=yes
1798d522f475Smrg],[
1799d522f475SmrgAC_TRY_RUN([
1800d522f475Smrg#ifdef HAVE_STDLIB_H
1801d522f475Smrg#include <stdlib.h>
1802d522f475Smrg#endif
1803d522f475Smrg#include <unistd.h>
1804d522f475Smrgint main()
1805d522f475Smrg{
1806d522f475Smrg	void *p = (void *) seteuid;
1807d522f475Smrg	long code = sysconf(_SC_SAVED_IDS);
1808d522f475Smrg	${cf_cv_main_return:-return}  ((code > 0) ? 0 : 1);
1809d522f475Smrg}],
1810d522f475Smrg	cf_cv_posix_saved_ids=yes,
1811d522f475Smrg	cf_cv_posix_saved_ids=no,
1812d522f475Smrg	cf_cv_posix_saved_ids=unknown)
1813d522f475Smrg])
1814d522f475Smrg])
1815d522f475Smrg
18160bd37d32Smrgtest "$cf_cv_posix_saved_ids" = yes && AC_DEFINE(HAVE_POSIX_SAVED_IDS,1,[Define to 1 if POSIX saved-ids are supported])
1817d522f475Smrg])
1818d522f475Smrgdnl ---------------------------------------------------------------------------
18190bd37d32Smrgdnl CF_POSIX_WAIT version: 3 updated: 2012/10/04 20:12:20
1820d522f475Smrgdnl -------------
1821d522f475Smrgdnl Check for POSIX wait support
1822d522f475SmrgAC_DEFUN([CF_POSIX_WAIT],
1823d522f475Smrg[
1824d522f475SmrgAC_REQUIRE([AC_HEADER_SYS_WAIT])
1825d522f475SmrgAC_CACHE_CHECK(for POSIX wait functions,cf_cv_posix_wait,[
1826d522f475SmrgAC_TRY_LINK([
1827d522f475Smrg#include <stdlib.h>
1828d522f475Smrg#include <stdio.h>
1829d522f475Smrg#include <sys/types.h>
1830d522f475Smrg#ifdef HAVE_SYS_WAIT_H
1831d522f475Smrg#include <sys/wait.h>
1832d522f475Smrg#endif
1833d522f475Smrg],[
1834d522f475Smrg	int stat_loc;
1835d522f475Smrg	pid_t pid = waitpid(-1, &stat_loc, WNOHANG|WUNTRACED);
1836d522f475Smrg	pid_t pid2 = wait(&stat_loc);
1837d522f475Smrg],
1838d522f475Smrg[cf_cv_posix_wait=yes],
1839d522f475Smrg[cf_cv_posix_wait=no])
1840d522f475Smrg])
18410bd37d32Smrgtest "$cf_cv_posix_wait" = yes && AC_DEFINE(USE_POSIX_WAIT,1,[Define to 1 if we have POSIX wait functions])
1842d522f475Smrg])dnl
1843d522f475Smrgdnl ---------------------------------------------------------------------------
1844d522f475Smrgdnl CF_PROCFS_CWD version: 2 updated: 2007/03/12 20:39:04
1845d522f475Smrgdnl -------------
1846d522f475Smrgdnl Find /proc tree (may be in a different place) which implements the "cwd"
1847d522f475Smrgdnl link.
1848d522f475SmrgAC_DEFUN([CF_PROCFS_CWD],[
1849d522f475SmrgAC_CACHE_CHECK(for proc tree with cwd-support,cf_cv_procfs_cwd,[
1850d522f475Smrgcf_cv_procfs_cwd=no
1851d522f475Smrgfor cf_path in /proc /compat/linux/proc /usr/compat/linux/proc
1852d522f475Smrgdo
1853d522f475Smrg	if test -d $cf_path && \
1854d522f475Smrg	   test -d $cf_path/$$ && \
1855d522f475Smrg	   ( test -d $cf_path/$$/cwd || \
1856d522f475Smrg	     test -L $cf_path/$$/cwd ); then
1857d522f475Smrg		cf_cv_procfs_cwd=$cf_path
1858d522f475Smrg		break
1859d522f475Smrg	fi
1860d522f475Smrgdone
1861d522f475Smrg])
1862d522f475Smrg])dnl
1863d522f475Smrgdnl ---------------------------------------------------------------------------
186401037d57Smrgdnl CF_PROG_CC version: 4 updated: 2014/07/12 18:57:58
18650bd37d32Smrgdnl ----------
18660bd37d32Smrgdnl standard check for CC, plus followup sanity checks
18670bd37d32Smrgdnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
18680bd37d32SmrgAC_DEFUN([CF_PROG_CC],[
18690bd37d32Smrgifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
18700bd37d32SmrgCF_GCC_VERSION
18710bd37d32SmrgCF_ACVERSION_CHECK(2.52,
18720bd37d32Smrg	[AC_PROG_CC_STDC],
18730bd37d32Smrg	[CF_ANSI_CC_REQD])
187401037d57SmrgCF_CC_ENV_FLAGS
1875d522f475Smrg])dnl
1876d522f475Smrgdnl ---------------------------------------------------------------------------
18770bd37d32Smrgdnl CF_PROG_GROFF version: 1 updated: 2013/01/02 20:37:18
18780bd37d32Smrgdnl -------------
18790bd37d32Smrgdnl Check if groff is available, for cases (such as html output) where nroff
18800bd37d32Smrgdnl is not enough.
18810bd37d32SmrgAC_DEFUN([CF_PROG_GROFF],[
18820bd37d32SmrgAC_PATH_PROG(GROFF_PATH,groff,no)
18830bd37d32Smrgif test "x$GROFF_PATH" = xno
18840bd37d32Smrgthen
18850bd37d32Smrg	NROFF_NOTE=
18860bd37d32Smrg	GROFF_NOTE="#"
18870bd37d32Smrgelse
18880bd37d32Smrg	NROFF_NOTE="#"
18890bd37d32Smrg	GROFF_NOTE=
18900bd37d32Smrgfi
18910bd37d32SmrgAC_SUBST(GROFF_PATH)
18920bd37d32SmrgAC_SUBST(GROFF_NOTE)
18930bd37d32SmrgAC_SUBST(NROFF_NOTE)
1894d522f475Smrg])dnl
1895d522f475Smrgdnl ---------------------------------------------------------------------------
189601037d57Smrgdnl CF_REGEX version: 11 updated: 2015/04/12 15:39:00
1897d522f475Smrgdnl --------
1898d522f475Smrgdnl Attempt to determine if we've got one of the flavors of regular-expression
1899d522f475Smrgdnl code that we can support.
1900d522f475SmrgAC_DEFUN([CF_REGEX],
1901d522f475Smrg[
190220d2c4d2Smrg
190320d2c4d2Smrgcf_regex_func=no
190420d2c4d2Smrg
19056879286fSmrgcf_regex_libs="regex re"
190601037d57Smrgcase $host_os in
190701037d57Smrg(mingw*)
19080bd37d32Smrg	cf_regex_libs="gnurx $cf_regex_libs"
19096879286fSmrg	;;
19106879286fSmrgesac
19116879286fSmrg
191220d2c4d2SmrgAC_CHECK_FUNC(regcomp,[cf_regex_func=regcomp],[
19136879286fSmrg	for cf_regex_lib in $cf_regex_libs
191420d2c4d2Smrg	do
191520d2c4d2Smrg		AC_CHECK_LIB($cf_regex_lib,regcomp,[
191620d2c4d2Smrg				CF_ADD_LIB($cf_regex_lib)
191720d2c4d2Smrg				cf_regex_func=regcomp
191820d2c4d2Smrg				break])
191920d2c4d2Smrg	done
192020d2c4d2Smrg])
192120d2c4d2Smrg
192220d2c4d2Smrgif test "$cf_regex_func" = no ; then
192320d2c4d2Smrg	AC_CHECK_FUNC(compile,[cf_regex_func=compile],[
192420d2c4d2Smrg		AC_CHECK_LIB(gen,compile,[
192520d2c4d2Smrg				CF_ADD_LIB(gen)
192620d2c4d2Smrg				cf_regex_func=compile])])
192720d2c4d2Smrgfi
192820d2c4d2Smrg
192920d2c4d2Smrgif test "$cf_regex_func" = no ; then
193020d2c4d2Smrg	AC_MSG_WARN(cannot find regular expression library)
193120d2c4d2Smrgfi
193220d2c4d2Smrg
193320d2c4d2SmrgAC_CACHE_CHECK(for regular-expression headers,cf_cv_regex_hdrs,[
193420d2c4d2Smrg
193520d2c4d2Smrgcf_cv_regex_hdrs=no
193601037d57Smrgcase $cf_regex_func in
193701037d57Smrg(compile)
193820d2c4d2Smrg	for cf_regex_hdr in regexp.h regexpr.h
193920d2c4d2Smrg	do
194020d2c4d2Smrg		AC_TRY_LINK([#include <$cf_regex_hdr>],[
194120d2c4d2Smrg			char *p = compile("", "", "", 0);
1942d522f475Smrg			int x = step("", "");
194320d2c4d2Smrg		],[
194420d2c4d2Smrg			cf_cv_regex_hdrs=$cf_regex_hdr
194520d2c4d2Smrg			break
194620d2c4d2Smrg		])
194720d2c4d2Smrg	done
194820d2c4d2Smrg	;;
194901037d57Smrg(*)
195020d2c4d2Smrg	for cf_regex_hdr in regex.h
195120d2c4d2Smrg	do
195220d2c4d2Smrg		AC_TRY_LINK([#include <sys/types.h>
195320d2c4d2Smrg#include <$cf_regex_hdr>],[
195420d2c4d2Smrg			regex_t *p;
195520d2c4d2Smrg			int x = regcomp(p, "", 0);
195620d2c4d2Smrg			int y = regexec(p, "", 0, 0, 0);
195720d2c4d2Smrg			regfree(p);
195820d2c4d2Smrg		],[
195920d2c4d2Smrg			cf_cv_regex_hdrs=$cf_regex_hdr
196020d2c4d2Smrg			break
196120d2c4d2Smrg		])
196220d2c4d2Smrg	done
196320d2c4d2Smrg	;;
196420d2c4d2Smrgesac
196520d2c4d2Smrg
1966d522f475Smrg])
196720d2c4d2Smrg
196801037d57Smrgcase $cf_cv_regex_hdrs in
196901037d57Smrg    (no)	    AC_MSG_WARN(no regular expression header found) ;;
197001037d57Smrg    (regex.h)   AC_DEFINE(HAVE_REGEX_H_FUNCS,1,[Define to 1 to include regex.h for regular expressions]) ;;
197101037d57Smrg    (regexp.h)  AC_DEFINE(HAVE_REGEXP_H_FUNCS,1,[Define to 1 to include regexp.h for regular expressions]) ;;
197201037d57Smrg    (regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS,1,[Define to 1 to include regexpr.h for regular expressions]) ;;
1973d522f475Smrgesac
1974d522f475Smrg])dnl
1975d522f475Smrgdnl ---------------------------------------------------------------------------
197620d2c4d2Smrgdnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
1977d522f475Smrgdnl ----------------
1978d522f475Smrgdnl Remove all -U and -D options that refer to the given symbol from a list
1979d522f475Smrgdnl of C compiler options.  This works around the problem that not all
1980d522f475Smrgdnl compilers process -U and -D options from left-to-right, so a -U option
1981d522f475Smrgdnl cannot be used to cancel the effect of a preceding -D option.
1982d522f475Smrgdnl
1983d522f475Smrgdnl $1 = target (which could be the same as the source variable)
1984d522f475Smrgdnl $2 = source (including '$')
1985d522f475Smrgdnl $3 = symbol to remove
1986d522f475Smrgdefine([CF_REMOVE_DEFINE],
1987d522f475Smrg[
1988d522f475Smrg$1=`echo "$2" | \
198920d2c4d2Smrg	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
199020d2c4d2Smrg		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
199120d2c4d2Smrg])dnl
199220d2c4d2Smrgdnl ---------------------------------------------------------------------------
1993e0a2b6dfSmrgdnl CF_RPATH_HACK version: 11 updated: 2013/09/01 13:02:00
199420d2c4d2Smrgdnl -------------
199520d2c4d2SmrgAC_DEFUN([CF_RPATH_HACK],
199620d2c4d2Smrg[
199720d2c4d2SmrgAC_REQUIRE([CF_LD_RPATH_OPT])
199820d2c4d2SmrgAC_MSG_CHECKING(for updated LDFLAGS)
199920d2c4d2Smrgif test -n "$LD_RPATH_OPT" ; then
200020d2c4d2Smrg	AC_MSG_RESULT(maybe)
200120d2c4d2Smrg
200220d2c4d2Smrg	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
200320d2c4d2Smrg	cf_rpath_list="/usr/lib /lib"
200420d2c4d2Smrg	if test "$cf_ldd_prog" != no
200520d2c4d2Smrg	then
2006a1f3da82Smrg		cf_rpath_oops=
2007a1f3da82Smrg
200820d2c4d2SmrgAC_TRY_LINK([#include <stdio.h>],
200920d2c4d2Smrg		[printf("Hello");],
2010e0a2b6dfSmrg		[cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
2011e0a2b6dfSmrg		 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
2012a1f3da82Smrg
2013a1f3da82Smrg		# If we passed the link-test, but get a "not found" on a given library,
2014a1f3da82Smrg		# this could be due to inept reconfiguration of gcc to make it only
2015a1f3da82Smrg		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
2016a1f3da82Smrg		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
2017a1f3da82Smrg		# /usr/local libraries.
2018a1f3da82Smrg		if test -n "$cf_rpath_oops"
2019a1f3da82Smrg		then
2020a1f3da82Smrg			for cf_rpath_src in $cf_rpath_oops
2021a1f3da82Smrg			do
2022a1f3da82Smrg				for cf_rpath_dir in \
2023a1f3da82Smrg					/usr/local \
2024a1f3da82Smrg					/usr/pkg \
2025a1f3da82Smrg					/opt/sfw
2026a1f3da82Smrg				do
2027a1f3da82Smrg					if test -f $cf_rpath_dir/lib/$cf_rpath_src
2028a1f3da82Smrg					then
2029a1f3da82Smrg						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
2030a1f3da82Smrg						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
2031a1f3da82Smrg						break
2032a1f3da82Smrg					fi
2033a1f3da82Smrg				done
2034a1f3da82Smrg			done
2035a1f3da82Smrg		fi
203620d2c4d2Smrg	fi
203720d2c4d2Smrg
203820d2c4d2Smrg	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
203920d2c4d2Smrg
204020d2c4d2Smrg	CF_RPATH_HACK_2(LDFLAGS)
204120d2c4d2Smrg	CF_RPATH_HACK_2(LIBS)
204220d2c4d2Smrg
204320d2c4d2Smrg	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2044e0a2b6dfSmrgelse
2045e0a2b6dfSmrg	AC_MSG_RESULT(no)
204620d2c4d2Smrgfi
204720d2c4d2SmrgAC_SUBST(EXTRA_LDFLAGS)
204820d2c4d2Smrg])dnl
204920d2c4d2Smrgdnl ---------------------------------------------------------------------------
205001037d57Smrgdnl CF_RPATH_HACK_2 version: 7 updated: 2015/04/12 15:39:00
205120d2c4d2Smrgdnl ---------------
205220d2c4d2Smrgdnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
205320d2c4d2Smrgdnl EXTRA_LDFLAGS for each -L option found.
205420d2c4d2Smrgdnl
205520d2c4d2Smrgdnl $cf_rpath_list contains a list of directories to ignore.
205620d2c4d2Smrgdnl
205720d2c4d2Smrgdnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
205820d2c4d2Smrgdnl      but LIBS often has misplaced -L options.
205920d2c4d2SmrgAC_DEFUN([CF_RPATH_HACK_2],
206020d2c4d2Smrg[
206120d2c4d2SmrgCF_VERBOSE(...checking $1 [$]$1)
206220d2c4d2Smrg
206320d2c4d2Smrgcf_rpath_dst=
206420d2c4d2Smrgfor cf_rpath_src in [$]$1
206520d2c4d2Smrgdo
206601037d57Smrg	case $cf_rpath_src in
206701037d57Smrg	(-L*)
206820d2c4d2Smrg
206920d2c4d2Smrg		# check if this refers to a directory which we will ignore
207020d2c4d2Smrg		cf_rpath_skip=no
207120d2c4d2Smrg		if test -n "$cf_rpath_list"
207220d2c4d2Smrg		then
207320d2c4d2Smrg			for cf_rpath_item in $cf_rpath_list
207420d2c4d2Smrg			do
207520d2c4d2Smrg				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
207620d2c4d2Smrg				then
207720d2c4d2Smrg					cf_rpath_skip=yes
207820d2c4d2Smrg					break
207920d2c4d2Smrg				fi
208020d2c4d2Smrg			done
208120d2c4d2Smrg		fi
208220d2c4d2Smrg
208320d2c4d2Smrg		if test "$cf_rpath_skip" = no
208420d2c4d2Smrg		then
208520d2c4d2Smrg			# transform the option
208620d2c4d2Smrg			if test "$LD_RPATH_OPT" = "-R " ; then
208720d2c4d2Smrg				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
208820d2c4d2Smrg			else
208920d2c4d2Smrg				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
209020d2c4d2Smrg			fi
209120d2c4d2Smrg
209220d2c4d2Smrg			# if we have not already added this, add it now
209320d2c4d2Smrg			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
209420d2c4d2Smrg			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
209520d2c4d2Smrg			then
209620d2c4d2Smrg				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
209720d2c4d2Smrg				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
209820d2c4d2Smrg			fi
209920d2c4d2Smrg		fi
210020d2c4d2Smrg		;;
210120d2c4d2Smrg	esac
210220d2c4d2Smrg	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
210320d2c4d2Smrgdone
210420d2c4d2Smrg$1=$cf_rpath_dst
210520d2c4d2Smrg
210620d2c4d2SmrgCF_VERBOSE(...checked $1 [$]$1)
210720d2c4d2SmrgAC_SUBST(EXTRA_LDFLAGS)
2108d522f475Smrg])dnl
2109d522f475Smrgdnl ---------------------------------------------------------------------------
2110d522f475Smrgdnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
2111d522f475Smrgdnl -----------
2112d522f475Smrgdnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
2113d522f475Smrgdnl programs need this test).
2114d522f475Smrgdnl
2115d522f475Smrgdnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
2116d522f475Smrgdnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
2117d522f475Smrgdnl winsize declaration is left alone - we may revisit this if Apple choose to
2118d522f475Smrgdnl break that part of the interface as well.
2119d522f475SmrgAC_DEFUN([CF_SIGWINCH],
2120d522f475Smrg[
2121d522f475SmrgAC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
2122d522f475Smrg	AC_TRY_COMPILE([
2123d522f475Smrg#include <sys/types.h>
2124d522f475Smrg#include <sys/signal.h>
2125d522f475Smrg],[int x = SIGWINCH],
2126d522f475Smrg	[cf_cv_define_sigwinch=yes],
2127d522f475Smrg	[AC_TRY_COMPILE([
2128d522f475Smrg#undef _XOPEN_SOURCE
2129d522f475Smrg#undef _POSIX_SOURCE
2130d522f475Smrg#undef _POSIX_C_SOURCE
2131d522f475Smrg#include <sys/types.h>
2132d522f475Smrg#include <sys/signal.h>
2133d522f475Smrg],[int x = SIGWINCH],
2134d522f475Smrg	[cf_cv_define_sigwinch=maybe],
2135d522f475Smrg	[cf_cv_define_sigwinch=no])
2136d522f475Smrg])
2137d522f475Smrg])
2138d522f475Smrg
2139d522f475Smrgif test "$cf_cv_define_sigwinch" = maybe ; then
2140d522f475SmrgAC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
2141d522f475Smrgcf_cv_fixup_sigwinch=unknown
2142d522f475Smrgcf_sigwinch=32
2143d522f475Smrgwhile test $cf_sigwinch != 1
2144d522f475Smrgdo
2145d522f475Smrg	AC_TRY_COMPILE([
2146d522f475Smrg#undef _XOPEN_SOURCE
2147d522f475Smrg#undef _POSIX_SOURCE
2148d522f475Smrg#undef _POSIX_C_SOURCE
2149d522f475Smrg#include <sys/types.h>
2150d522f475Smrg#include <sys/signal.h>
2151d522f475Smrg],[
2152d522f475Smrg#if SIGWINCH != $cf_sigwinch
2153d522f475Smrgmake an error
2154d522f475Smrg#endif
2155d522f475Smrgint x = SIGWINCH],
2156d522f475Smrg	[cf_cv_fixup_sigwinch=$cf_sigwinch
2157d522f475Smrg	 break])
2158d522f475Smrg
2159d522f475Smrgcf_sigwinch=`expr $cf_sigwinch - 1`
2160d522f475Smrgdone
2161d522f475Smrg])
2162d522f475Smrg
2163d522f475Smrg	if test "$cf_cv_fixup_sigwinch" != unknown ; then
2164d522f475Smrg		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
2165d522f475Smrg	fi
2166d522f475Smrgfi
2167d522f475Smrg])dnl
2168d522f475Smrgdnl ---------------------------------------------------------------------------
21690bd37d32Smrgdnl CF_SIG_ATOMIC_T version: 3 updated: 2012/10/04 20:12:20
2170d522f475Smrgdnl ---------------
2171d522f475Smrgdnl signal handler, but there are some gcc depedencies in that recommendation.
2172d522f475Smrgdnl Try anyway.
2173d522f475SmrgAC_DEFUN([CF_SIG_ATOMIC_T],
2174d522f475Smrg[
2175d522f475SmrgAC_MSG_CHECKING(for signal global datatype)
2176d522f475SmrgAC_CACHE_VAL(cf_cv_sig_atomic_t,[
2177d522f475Smrg	for cf_type in \
2178d522f475Smrg		"volatile sig_atomic_t" \
2179d522f475Smrg		"sig_atomic_t" \
2180d522f475Smrg		"int"
2181d522f475Smrg	do
2182d522f475Smrg	AC_TRY_COMPILE([
2183d522f475Smrg#include <sys/types.h>
2184d522f475Smrg#include <signal.h>
2185d522f475Smrg#include <stdio.h>
2186d522f475Smrg
2187d522f475Smrgextern $cf_type x;
2188d522f475Smrg$cf_type x;
2189d522f475Smrgstatic void handler(int sig)
2190d522f475Smrg{
2191d522f475Smrg	x = 5;
2192d522f475Smrg}],
2193d522f475Smrg		[signal(SIGINT, handler);
2194d522f475Smrg		 x = 1],
2195d522f475Smrg		[cf_cv_sig_atomic_t=$cf_type],
2196d522f475Smrg		[cf_cv_sig_atomic_t=no])
2197d522f475Smrg		test "$cf_cv_sig_atomic_t" != no && break
2198d522f475Smrg	done
2199d522f475Smrg	])
2200d522f475SmrgAC_MSG_RESULT($cf_cv_sig_atomic_t)
22010bd37d32Smrgtest "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
2202d522f475Smrg])dnl
2203d522f475Smrgdnl ---------------------------------------------------------------------------
22040bd37d32Smrgdnl CF_STRUCT_LASTLOG version: 2 updated: 2012/10/04 20:12:20
2205d522f475Smrgdnl -----------------
2206d522f475Smrgdnl Check for header defining struct lastlog, ensure that its .ll_time member
2207d522f475Smrgdnl is compatible with time().
2208d522f475SmrgAC_DEFUN([CF_STRUCT_LASTLOG],
2209d522f475Smrg[
2210d522f475SmrgAC_CHECK_HEADERS(lastlog.h)
2211d522f475SmrgAC_CACHE_CHECK(for struct lastlog,cf_cv_struct_lastlog,[
2212d522f475SmrgAC_TRY_RUN([
2213d522f475Smrg#include <sys/types.h>
2214d522f475Smrg#include <time.h>
2215d522f475Smrg#include <lastlog.h>
2216d522f475Smrg
2217d522f475Smrgint main()
2218d522f475Smrg{
2219d522f475Smrg	struct lastlog data;
2220d522f475Smrg	return (sizeof(data.ll_time) != sizeof(time_t));
2221d522f475Smrg}],[
2222d522f475Smrgcf_cv_struct_lastlog=yes],[
2223d522f475Smrgcf_cv_struct_lastlog=no],[
2224d522f475Smrgcf_cv_struct_lastlog=unknown])])
2225d522f475Smrg
22260bd37d32Smrgtest $cf_cv_struct_lastlog != no && AC_DEFINE(USE_STRUCT_LASTLOG,1,[Define to 1 if we have struct lastlog])
2227d522f475Smrg])dnl
2228d522f475Smrgdnl ---------------------------------------------------------------------------
22290bd37d32Smrgdnl CF_SVR4 version: 5 updated: 2012/10/04 05:24:07
2230d522f475Smrgdnl -------
2231d522f475Smrgdnl Check if this is an SVR4 system.  We need the definition for xterm
2232d522f475SmrgAC_DEFUN([CF_SVR4],
2233d522f475Smrg[
2234d522f475SmrgAC_CHECK_LIB(elf, elf_begin,[
2235d522f475SmrgAC_CACHE_CHECK(if this is an SVR4 system, cf_cv_svr4,[
2236d522f475SmrgAC_TRY_COMPILE([
22370bd37d32Smrg#if defined(__CYGWIN__)
22380bd37d32Smrgmake an error
22390bd37d32Smrg#endif
2240d522f475Smrg#include <elf.h>
2241d522f475Smrg#include <sys/termio.h>
2242d522f475Smrg],[
2243d522f475Smrgstatic struct termio d_tio;
2244d522f475Smrg	d_tio.c_cc[VINTR] = 0;
2245d522f475Smrg	d_tio.c_cc[VQUIT] = 0;
2246d522f475Smrg	d_tio.c_cc[VERASE] = 0;
2247d522f475Smrg	d_tio.c_cc[VKILL] = 0;
2248d522f475Smrg	d_tio.c_cc[VEOF] = 0;
2249d522f475Smrg	d_tio.c_cc[VEOL] = 0;
2250d522f475Smrg	d_tio.c_cc[VMIN] = 0;
2251d522f475Smrg	d_tio.c_cc[VTIME] = 0;
2252d522f475Smrg	d_tio.c_cc[VLNEXT] = 0;
2253d522f475Smrg],
2254d522f475Smrg[cf_cv_svr4=yes],
2255d522f475Smrg[cf_cv_svr4=no])
2256d522f475Smrg])
2257d522f475Smrg])
22580bd37d32Smrgtest "$cf_cv_svr4" = yes && AC_DEFINE(SVR4,1,[Define to 1 if this is an SVR4 system])
2259d522f475Smrg])dnl
2260d522f475Smrgdnl ---------------------------------------------------------------------------
22610bd37d32Smrgdnl CF_SYSV version: 15 updated: 2012/10/04 05:24:07
2262d522f475Smrgdnl -------
2263d522f475Smrgdnl Check if this is a SYSV platform, e.g., as used in <X11/Xos.h>, and whether
2264d522f475Smrgdnl defining it will be helpful.  The following features are used to check:
2265d522f475Smrgdnl
2266d522f475Smrgdnl a) bona-fide SVSV doesn't use const for sys_errlist[].  Since this is a
2267d522f475Smrgdnl legacy (pre-ANSI) feature, const should not apply.  Modern systems only
2268d522f475Smrgdnl declare strerror().  Xos.h declares the legacy form of str_errlist[], and
2269d522f475Smrgdnl a compile-time error will result from trying to assign to a const array.
2270d522f475Smrgdnl
2271d522f475Smrgdnl b) compile with headers that exist on SYSV hosts.
2272d522f475Smrgdnl
2273d522f475Smrgdnl c) compile with type definitions that differ on SYSV hosts from standard C.
2274d522f475SmrgAC_DEFUN([CF_SYSV],
2275d522f475Smrg[
2276d522f475SmrgAC_CHECK_HEADERS( \
2277d522f475Smrgtermios.h \
2278d522f475Smrgstdlib.h \
2279d522f475SmrgX11/Intrinsic.h \
2280d522f475Smrg)
2281d522f475Smrg
2282d522f475SmrgAC_REQUIRE([CF_SYS_ERRLIST])
2283d522f475Smrg
2284d522f475SmrgAC_CACHE_CHECK(if we should define SYSV,cf_cv_sysv,[
2285d522f475SmrgAC_TRY_COMPILE([
2286d522f475Smrg#undef  SYSV
2287d522f475Smrg#define SYSV 1			/* get Xos.h to declare sys_errlist[] */
2288d522f475Smrg#ifdef HAVE_STDLIB_H
2289d522f475Smrg#include <stdlib.h>		/* look for wchar_t */
2290d522f475Smrg#endif
2291d522f475Smrg#ifdef HAVE_X11_INTRINSIC_H
2292d522f475Smrg#include <X11/Intrinsic.h>	/* Intrinsic.h has other traps... */
2293d522f475Smrg#endif
22940bd37d32Smrg#ifdef HAVE_TERMIOS_H		/* needed for HPUX 10.20 */
22950bd37d32Smrg#include <termios.h>
22960bd37d32Smrg#define STRUCT_TERMIOS struct termios
22970bd37d32Smrg#else
22980bd37d32Smrg#define STRUCT_TERMIOS struct termio
22990bd37d32Smrg#endif
2300d522f475Smrg#include <curses.h>
2301d522f475Smrg#include <term.h>		/* eliminate most BSD hacks */
2302d522f475Smrg#include <errno.h>		/* declare sys_errlist on older systems */
2303d522f475Smrg#include <sys/termio.h>		/* eliminate most of the remaining ones */
2304d522f475Smrg],[
2305d522f475Smrgstatic STRUCT_TERMIOS d_tio;
2306d522f475Smrg	d_tio.c_cc[VINTR] = 0;
2307d522f475Smrg	d_tio.c_cc[VQUIT] = 0;
2308d522f475Smrg	d_tio.c_cc[VERASE] = 0;
2309d522f475Smrg	d_tio.c_cc[VKILL] = 0;
2310d522f475Smrg	d_tio.c_cc[VEOF] = 0;
2311d522f475Smrg	d_tio.c_cc[VEOL] = 0;
2312d522f475Smrg	d_tio.c_cc[VMIN] = 0;
2313d522f475Smrg	d_tio.c_cc[VTIME] = 0;
2314d522f475Smrg#if defined(HAVE_SYS_ERRLIST) && !defined(DECL_SYS_ERRLIST)
2315d522f475Smrgsys_errlist[0] = "";		/* Cygwin mis-declares this */
2316d522f475Smrg#endif
2317d522f475Smrg],
2318d522f475Smrg[cf_cv_sysv=yes],
2319d522f475Smrg[cf_cv_sysv=no])
2320d522f475Smrg])
23210bd37d32Smrgtest "$cf_cv_sysv" = yes && AC_DEFINE(SYSV,1,[Define to 1 if this is an SYSV system])
2322d522f475Smrg])dnl
2323d522f475Smrgdnl ---------------------------------------------------------------------------
23240bd37d32Smrgdnl CF_SYSV_UTMP version: 6 updated: 2012/10/04 20:12:20
2325d522f475Smrgdnl ------------
2326d522f475Smrgdnl Check if this is a SYSV flavor of UTMP
2327d522f475SmrgAC_DEFUN([CF_SYSV_UTMP],
2328d522f475Smrg[
2329d522f475SmrgAC_CACHE_CHECK(if $cf_cv_have_utmp is SYSV flavor,cf_cv_sysv_utmp,[
2330d522f475Smrgtest "$cf_cv_have_utmp" = "utmp" && cf_prefix="ut" || cf_prefix="utx"
2331d522f475SmrgAC_TRY_LINK([
2332d522f475Smrg#include <sys/types.h>
2333d522f475Smrg#include <${cf_cv_have_utmp}.h>],[
2334d522f475Smrgstruct $cf_cv_have_utmp x;
2335d522f475Smrg	set${cf_prefix}ent ();
2336d522f475Smrg	get${cf_prefix}id(&x);
2337d522f475Smrg	put${cf_prefix}line(&x);
2338d522f475Smrg	end${cf_prefix}ent();],
2339d522f475Smrg	[cf_cv_sysv_utmp=yes],
2340d522f475Smrg	[cf_cv_sysv_utmp=no])
2341d522f475Smrg])
23420bd37d32Smrgtest $cf_cv_sysv_utmp = yes && AC_DEFINE(USE_SYSV_UTMP,1,[Define to 1 if utmp is SYSV flavor])
2343d522f475Smrg])dnl
2344d522f475Smrgdnl ---------------------------------------------------------------------------
2345d522f475Smrgdnl CF_SYS_ERRLIST version: 6 updated: 2001/12/30 13:03:23
2346d522f475Smrgdnl --------------
2347d522f475Smrgdnl Check for declaration of sys_nerr and sys_errlist in one of stdio.h and
2348d522f475Smrgdnl errno.h.  Declaration of sys_errlist on BSD4.4 interferes with our
2349d522f475Smrgdnl declaration.  Reported by Keith Bostic.
2350d522f475SmrgAC_DEFUN([CF_SYS_ERRLIST],
2351d522f475Smrg[
2352d522f475Smrg    CF_CHECK_ERRNO(sys_nerr)
2353d522f475Smrg    CF_CHECK_ERRNO(sys_errlist)
2354d522f475Smrg])dnl
2355d522f475Smrgdnl ---------------------------------------------------------------------------
23560bd37d32Smrgdnl CF_TERMIO_C_ISPEED version: 3 updated: 2012/10/04 20:12:20
2357d522f475Smrgdnl ------------------
2358d522f475Smrgdnl Check for SGI's broken redefinition of baud rates introduced in IRIX 6.5
2359d522f475Smrgdnl (there doesn't appear to be a useful predefined symbol).
2360d522f475SmrgAC_DEFUN([CF_TERMIO_C_ISPEED],
2361d522f475Smrg[
2362d522f475SmrgAC_CACHE_CHECK(for IRIX 6.5 baud-rate redefinitions,cf_cv_termio_c_ispeed,[
2363d522f475SmrgAC_TRY_COMPILE([
2364d522f475Smrg#include <sys/types.h>
2365d522f475Smrg#include <sys/termio.h>],[
2366d522f475Smrgstruct termio foo;
2367d522f475Smrgfoo.c_ispeed = B38400;
2368d522f475Smrgfoo.c_ospeed = B9600;
2369d522f475Smrg],[cf_cv_termio_c_ispeed=yes
2370d522f475Smrg],[cf_cv_termio_c_ispeed=no])
2371d522f475Smrg])
23720bd37d32Smrgtest "$cf_cv_termio_c_ispeed" = yes && AC_DEFINE(HAVE_TERMIO_C_ISPEED,1,[define 1 if we have IRIX 6.5 baud-rate redefinitions])
2373d522f475Smrg])dnl
2374d522f475Smrgdnl ---------------------------------------------------------------------------
237501037d57Smrgdnl CF_TRIM_X_LIBS version: 3 updated: 2015/04/12 15:39:00
2376e0a2b6dfSmrgdnl --------------
2377e0a2b6dfSmrgdnl Trim extra base X libraries added as a workaround for inconsistent library
2378e0a2b6dfSmrgdnl dependencies returned by "new" pkg-config files.
2379e0a2b6dfSmrgAC_DEFUN([CF_TRIM_X_LIBS],[
2380e0a2b6dfSmrg	for cf_trim_lib in Xmu Xt X11
2381e0a2b6dfSmrg	do
2382e0a2b6dfSmrg		case "$LIBS" in
238301037d57Smrg		(*-l$cf_trim_lib\ *-l$cf_trim_lib*)
2384e0a2b6dfSmrg			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
2385e0a2b6dfSmrg			CF_VERBOSE(..trimmed $LIBS)
2386e0a2b6dfSmrg			;;
2387e0a2b6dfSmrg		esac
2388e0a2b6dfSmrg	done
2389e0a2b6dfSmrg])
2390e0a2b6dfSmrgdnl ---------------------------------------------------------------------------
2391e0a2b6dfSmrgdnl CF_TRY_PKG_CONFIG version: 5 updated: 2013/07/06 21:27:06
239220d2c4d2Smrgdnl -----------------
239320d2c4d2Smrgdnl This is a simple wrapper to use for pkg-config, for libraries which may be
239420d2c4d2Smrgdnl available in that form.
239520d2c4d2Smrgdnl
239620d2c4d2Smrgdnl $1 = package name
239720d2c4d2Smrgdnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
239820d2c4d2Smrgdnl $3 = logic to use if pkg-config does not have the package
239920d2c4d2SmrgAC_DEFUN([CF_TRY_PKG_CONFIG],[
240020d2c4d2SmrgAC_REQUIRE([CF_PKG_CONFIG])
240120d2c4d2Smrg
240220d2c4d2Smrgif test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
240320d2c4d2Smrg	CF_VERBOSE(found package $1)
240420d2c4d2Smrg	cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
240520d2c4d2Smrg	cf_pkgconfig_libs="`$PKG_CONFIG --libs   $1 2>/dev/null`"
240620d2c4d2Smrg	CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
240720d2c4d2Smrg	CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
240820d2c4d2Smrg	CF_ADD_CFLAGS($cf_pkgconfig_incs)
240920d2c4d2Smrg	CF_ADD_LIBS($cf_pkgconfig_libs)
241020d2c4d2Smrg	ifelse([$2],,:,[$2])
241120d2c4d2Smrgelse
2412e0a2b6dfSmrg	cf_pkgconfig_incs=
2413e0a2b6dfSmrg	cf_pkgconfig_libs=
241420d2c4d2Smrg	ifelse([$3],,:,[$3])
241520d2c4d2Smrgfi
241620d2c4d2Smrg])
241720d2c4d2Smrgdnl ---------------------------------------------------------------------------
24180bd37d32Smrgdnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
24190bd37d32Smrgdnl -------------------
24200bd37d32Smrgdnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
24210bd37d32Smrgdnl can define it successfully.
24220bd37d32SmrgAC_DEFUN([CF_TRY_XOPEN_SOURCE],[
24230bd37d32SmrgAC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
24240bd37d32Smrg	AC_TRY_COMPILE([
24250bd37d32Smrg#include <stdlib.h>
24260bd37d32Smrg#include <string.h>
24270bd37d32Smrg#include <sys/types.h>
24280bd37d32Smrg],[
24290bd37d32Smrg#ifndef _XOPEN_SOURCE
24300bd37d32Smrgmake an error
24310bd37d32Smrg#endif],
24320bd37d32Smrg	[cf_cv_xopen_source=no],
24330bd37d32Smrg	[cf_save="$CPPFLAGS"
24340bd37d32Smrg	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
24350bd37d32Smrg	 AC_TRY_COMPILE([
24360bd37d32Smrg#include <stdlib.h>
24370bd37d32Smrg#include <string.h>
24380bd37d32Smrg#include <sys/types.h>
24390bd37d32Smrg],[
24400bd37d32Smrg#ifdef _XOPEN_SOURCE
24410bd37d32Smrgmake an error
24420bd37d32Smrg#endif],
24430bd37d32Smrg	[cf_cv_xopen_source=no],
24440bd37d32Smrg	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
24450bd37d32Smrg	CPPFLAGS="$cf_save"
24460bd37d32Smrg	])
24470bd37d32Smrg])
24480bd37d32Smrg
24490bd37d32Smrgif test "$cf_cv_xopen_source" != no ; then
24500bd37d32Smrg	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
24510bd37d32Smrg	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
24520bd37d32Smrg	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
24530bd37d32Smrg	CF_ADD_CFLAGS($cf_temp_xopen_source)
24540bd37d32Smrgfi
24550bd37d32Smrg])
24560bd37d32Smrgdnl ---------------------------------------------------------------------------
245701037d57Smrgdnl CF_TTY_GROUP version: 9 updated: 2015/04/12 15:39:00
2458d522f475Smrgdnl ------------
2459d522f475Smrgdnl Check if the system has a tty-group defined.  This is used in xterm when
2460d522f475Smrgdnl setting pty ownership.
2461d522f475SmrgAC_DEFUN([CF_TTY_GROUP],
2462d522f475Smrg[
2463d522f475SmrgAC_MSG_CHECKING(for explicit tty group name)
2464d522f475SmrgAC_ARG_WITH(tty-group,
2465d522f475Smrg	[  --with-tty-group=XXX    use XXX for the tty-group],
2466d522f475Smrg	[cf_tty_group=$withval],
2467d522f475Smrg	[cf_tty_group=auto...])
2468d522f475Smrgtest -z "$cf_tty_group"    && cf_tty_group=auto...
2469d522f475Smrgtest "$cf_tty_group" = yes && cf_tty_group=auto...
2470d522f475SmrgAC_MSG_RESULT($cf_tty_group)
2471d522f475Smrg
2472d522f475Smrgif test "$cf_tty_group" = "auto..." ; then
2473d522f475SmrgAC_CACHE_CHECK(for tty group name,cf_cv_tty_group_name,[
2474d522f475Smrg
2475d522f475Smrg# If we are configuring as root, it is hard to get a clue about the tty group.
2476d522f475Smrg# But we'll guess based on how our connection is set up - assuming it is done
2477d522f475Smrg# properly.
2478d522f475Smrg
2479d522f475Smrgcf_uid=`id | sed -e 's/^[^=]*=//' -e 's/(.*$//'`
2480d522f475Smrg# )vi
2481d522f475Smrgif test "$cf_uid" != 0 ; then
2482d522f475Smrgcf_cv_tty_group_name=
2483d522f475Smrgcf_tty_name=`tty`
2484d522f475Smrgtest "$cf_tty_name" = "not a tty" && cf_tty_name=/dev/tty
2485d522f475Smrgtest -z "$cf_tty_name" && cf_tty_name=/dev/tty
2486d522f475Smrgif test -c "$cf_tty_name"
2487d522f475Smrgthen
2488d522f475Smrg	cf_option="-l -L"
2489d522f475Smrg
2490d522f475Smrg	# Expect listing to have fields like this:
2491d522f475Smrg	#-rwxrwxrwx   1 user      group       34293 Jul 18 16:29 pathname
2492d522f475Smrg	ls $cf_option $cf_tty_name >conftest.out
2493d522f475Smrg	read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
2494d522f475Smrg	if test -z "$cf_rest" ; then
2495d522f475Smrg		cf_option="$cf_option -g"
2496d522f475Smrg		ls $cf_option $cf_tty_name >conftest.out
2497d522f475Smrg		read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
2498d522f475Smrg	fi
2499d522f475Smrg	rm -f conftest.out
2500d522f475Smrg	cf_cv_tty_group_name=$cf_grp
2501d522f475Smrgfi
2502d522f475Smrgfi
2503d522f475Smrg
2504d522f475Smrg# If we cannot deduce the tty group, fall back on hardcoded cases
2505d522f475Smrg
2506d522f475Smrgif test -z "$cf_cv_tty_group_name"
2507d522f475Smrgthen
250801037d57Smrgcase $host_os in
250901037d57Smrg(osf*)
2510d522f475Smrg	cf_cv_tty_group_name="terminal"
2511d522f475Smrg	;;
251201037d57Smrg(*)
2513d522f475Smrg	cf_cv_tty_group_name="unknown"
2514d522f475Smrg	if ( egrep '^tty:' /etc/group 2>/dev/null 1>/dev/null ) then
2515d522f475Smrg		cf_cv_tty_group_name="tty"
2516d522f475Smrg	fi
2517d522f475Smrg	;;
2518d522f475Smrgesac
2519d522f475Smrgfi
2520d522f475Smrg])
2521d522f475Smrgcf_tty_group="$cf_cv_tty_group_name"
2522d522f475Smrgelse
2523d522f475Smrg	# if configure option, always do this
25240bd37d32Smrg	AC_DEFINE(USE_TTY_GROUP,1,[Define to 1 if we have a tty groupname])
2525d522f475Smrgfi
2526d522f475Smrg
25270bd37d32SmrgAC_DEFINE_UNQUOTED(TTY_GROUP_NAME,"$cf_tty_group",[Define to the name use for tty group])
2528d522f475Smrg
2529d522f475Smrg# This is only a double-check that the group-name we obtained above really
2530d522f475Smrg# does apply to the device.  We cannot perform this test if we are in batch
2531d522f475Smrg# mode, or if we are cross-compiling.
2532d522f475Smrg
2533d522f475SmrgAC_CACHE_CHECK(if we may use the $cf_tty_group group,cf_cv_tty_group,[
2534d522f475Smrgcf_tty_name=`tty`
2535d522f475Smrgif test "$cf_tty_name" != "not a tty"
2536d522f475Smrgthen
2537d522f475SmrgAC_TRY_RUN([
2538d522f475Smrg#include <unistd.h>
2539d522f475Smrg#include <sys/types.h>
2540d522f475Smrg#include <sys/stat.h>
2541d522f475Smrg#include <grp.h>
2542d522f475Smrgint main()
2543d522f475Smrg{
2544d522f475Smrg	struct stat sb;
2545d522f475Smrg	struct group *ttygrp = getgrnam(TTY_GROUP_NAME);
2546d522f475Smrg	char *name = ttyname(0);
2547d522f475Smrg
2548d522f475Smrg	endgrent();
2549d522f475Smrg	if (ttygrp != 0
2550d522f475Smrg	 && name != 0
2551d522f475Smrg	 && stat(name, &sb) == 0
2552d522f475Smrg	 && sb.st_gid != getgid()
2553d522f475Smrg	 && sb.st_gid == ttygrp->gr_gid) {
2554d522f475Smrg		${cf_cv_main_return:-return} (0);
2555d522f475Smrg	}
2556d522f475Smrg	${cf_cv_main_return:-return} (1);
2557d522f475Smrg}
2558d522f475Smrg	],
2559d522f475Smrg	[cf_cv_tty_group=yes],
2560d522f475Smrg	[cf_cv_tty_group=no],
2561d522f475Smrg	[cf_cv_tty_group=unknown])
2562d522f475Smrgelif test "$cross_compiling" = yes; then
2563d522f475Smrg	cf_cv_tty_group=unknown
2564d522f475Smrgelse
2565d522f475Smrg	cf_cv_tty_group=yes
2566d522f475Smrgfi
2567d522f475Smrg])
2568d522f475Smrg
2569d522f475Smrgif test $cf_cv_tty_group = no ; then
2570d522f475Smrg	AC_MSG_WARN(Cannot use $cf_tty_group group)
2571d522f475Smrgelse
2572d522f475Smrg	AC_DEFINE(USE_TTY_GROUP)
2573d522f475Smrgfi
2574d522f475Smrg])dnl
2575d522f475Smrgdnl ---------------------------------------------------------------------------
25760bd37d32Smrgdnl CF_TYPE_CC_T version: 2 updated: 2012/10/04 20:12:20
25770bd37d32Smrgdnl ------------
25780bd37d32Smrgdnl	Check for cc_t type, used in termio.
25790bd37d32SmrgAC_DEFUN([CF_TYPE_CC_T],
25800bd37d32Smrg[
25810bd37d32SmrgAC_MSG_CHECKING(for cc_t in <termios.h> or <termio.h>)
25820bd37d32SmrgAC_CACHE_VAL(cf_cv_type_cc_t,[
25830bd37d32Smrg	AC_TRY_COMPILE([
25840bd37d32Smrg#include <sys/types.h>
25850bd37d32Smrg#if defined(HAVE_TERMIOS_H)
25860bd37d32Smrg#include <termios.h>
25870bd37d32Smrg#else
25880bd37d32Smrg#include <termio.h>
25890bd37d32Smrg#include <sys/ioctl.h>
25900bd37d32Smrg#endif
25910bd37d32Smrg],
25920bd37d32Smrg		[cc_t x],
25930bd37d32Smrg		[cf_cv_type_cc_t=yes],
25940bd37d32Smrg		[cf_cv_type_cc_t=no])
25950bd37d32Smrg	])
25960bd37d32SmrgAC_MSG_RESULT($cf_cv_type_cc_t)
25970bd37d32Smrgtest $cf_cv_type_cc_t = no && AC_DEFINE(cc_t, unsigned char,[Define to cc_t type used in termio])
25980bd37d32Smrg])dnl
25990bd37d32Smrgdnl ---------------------------------------------------------------------------
26000bd37d32Smrgdnl CF_TYPE_FD_MASK version: 3 updated: 2012/10/04 06:57:36
2601d522f475Smrgdnl ---------------
2602d522f475Smrgdnl Check for the declaration of fd_mask, which is like fd_set, associated
2603d522f475Smrgdnl with select().  The check for fd_set should have pulled in this as well,
2604d522f475Smrgdnl but there is a special case for Mac OS X, possibly other BSD-derived
2605d522f475Smrgdnl platforms.
2606d522f475SmrgAC_DEFUN([CF_TYPE_FD_MASK],
2607d522f475Smrg[
2608d522f475SmrgAC_REQUIRE([CF_TYPE_FD_SET])
2609d522f475Smrg
2610d522f475SmrgAC_CACHE_CHECK(for declaration of fd_mask,cf_cv_type_fd_mask,[
2611d522f475Smrg    if test x$cf_cv_type_fd_set = xX11/Xpoll.h ; then
2612d522f475Smrg        AC_TRY_COMPILE([
2613d522f475Smrg#include <X11/Xpoll.h>],[fd_mask x],,
2614d522f475Smrg        [CF_MSG_LOG(if we must define CSRG_BASED)
2615d522f475Smrg# Xosdefs.h on Mac OS X may not define this (but it should).
2616d522f475Smrg            AC_TRY_COMPILE([
2617d522f475Smrg#define CSRG_BASED
2618d522f475Smrg#include <X11/Xpoll.h>],[fd_mask x],
2619d522f475Smrg        cf_cv_type_fd_mask=CSRG_BASED)])
2620d522f475Smrg    else
2621d522f475Smrg        cf_cv_type_fd_mask=$cf_cv_type_fd_set
2622d522f475Smrg    fi
2623d522f475Smrg])
2624d522f475Smrgif test x$cf_cv_type_fd_mask = xCSRG_BASED ; then
26250bd37d32Smrg    AC_DEFINE(CSRG_BASED,1,[Define to 1 if needed for declaring fd_mask()])
2626d522f475Smrgfi
2627d522f475Smrg])dnl
2628d522f475Smrgdnl ---------------------------------------------------------------------------
26290bd37d32Smrgdnl CF_TYPE_FD_SET version: 5 updated: 2012/10/04 20:12:20
2630d522f475Smrgdnl --------------
2631d522f475Smrgdnl Check for the declaration of fd_set.  Some platforms declare it in
2632d522f475Smrgdnl <sys/types.h>, and some in <sys/select.h>, which requires <sys/types.h>.
2633d522f475Smrgdnl Finally, if we are using this for an X application, Xpoll.h may include
2634d522f475Smrgdnl <sys/select.h>, so we don't want to do it twice.
2635d522f475SmrgAC_DEFUN([CF_TYPE_FD_SET],
2636d522f475Smrg[
2637d522f475SmrgAC_CHECK_HEADERS(X11/Xpoll.h)
2638d522f475Smrg
2639d522f475SmrgAC_CACHE_CHECK(for declaration of fd_set,cf_cv_type_fd_set,
2640d522f475Smrg	[CF_MSG_LOG(sys/types alone)
2641d522f475SmrgAC_TRY_COMPILE([
2642d522f475Smrg#include <sys/types.h>],
2643d522f475Smrg	[fd_set x],
2644d522f475Smrg	[cf_cv_type_fd_set=sys/types.h],
2645d522f475Smrg	[CF_MSG_LOG(X11/Xpoll.h)
2646d522f475SmrgAC_TRY_COMPILE([
2647d522f475Smrg#ifdef HAVE_X11_XPOLL_H
2648d522f475Smrg#include <X11/Xpoll.h>
2649d522f475Smrg#endif],
2650d522f475Smrg	[fd_set x],
2651d522f475Smrg	[cf_cv_type_fd_set=X11/Xpoll.h],
2652d522f475Smrg	[CF_MSG_LOG(sys/select.h)
2653d522f475SmrgAC_TRY_COMPILE([
2654d522f475Smrg#include <sys/types.h>
2655d522f475Smrg#include <sys/select.h>],
2656d522f475Smrg	[fd_set x],
2657d522f475Smrg	[cf_cv_type_fd_set=sys/select.h],
2658d522f475Smrg	[cf_cv_type_fd_set=unknown])])])])
2659d522f475Smrgif test $cf_cv_type_fd_set = sys/select.h ; then
26600bd37d32Smrg	AC_DEFINE(USE_SYS_SELECT_H,1,[Define to 1 to include sys/select.h to declare fd_set])
2661d522f475Smrgfi
2662d522f475Smrg])
2663d522f475Smrgdnl ---------------------------------------------------------------------------
2664e39b573cSmrgdnl CF_UNDO_CFLAGS version: 1 updated: 2011/07/02 09:27:51
2665e39b573cSmrgdnl --------------
2666e39b573cSmrgdnl Remove flags from $CFLAGS or similar shell variable using sed.
2667e39b573cSmrgdnl $1 = variable
2668e39b573cSmrgdnl $2 = message
2669e39b573cSmrgdnl $3 = pattern to remove
2670e39b573cSmrgAC_DEFUN([CF_UNDO_CFLAGS],
2671e39b573cSmrg[
2672e39b573cSmrg	CF_VERBOSE(removing $2 flags from $1)
2673e39b573cSmrg	$1=`echo "[$]$1" | sed -e 's/$3//'`
2674e39b573cSmrg	CF_VERBOSE(...result [$]$1)
2675e39b573cSmrg])dnl
2676e39b573cSmrgdnl ---------------------------------------------------------------------------
2677d522f475Smrgdnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
2678d522f475Smrgdnl --------
2679d522f475Smrgdnl Make an uppercase version of a variable
2680d522f475Smrgdnl $1=uppercase($2)
2681d522f475SmrgAC_DEFUN([CF_UPPER],
2682d522f475Smrg[
2683d522f475Smrg$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2684d522f475Smrg])dnl
2685d522f475Smrgdnl ---------------------------------------------------------------------------
26860bd37d32Smrgdnl CF_UTEMPTER version: 4 updated: 2012/10/04 20:12:20
2687d522f475Smrgdnl -----------
2688d522f475Smrgdnl Try to link with utempter library
2689d522f475SmrgAC_DEFUN([CF_UTEMPTER],
2690d522f475Smrg[
2691d522f475SmrgAC_CACHE_CHECK(if we can link with utempter library,cf_cv_have_utempter,[
2692d522f475Smrgcf_save_LIBS="$LIBS"
269320d2c4d2SmrgCF_ADD_LIB(utempter)
2694d522f475SmrgAC_TRY_LINK([
2695d522f475Smrg#include <utempter.h>
2696d522f475Smrg],[
2697d522f475Smrg	addToUtmp("/dev/tty", 0, 1);
2698d522f475Smrg	removeFromUtmp();
2699d522f475Smrg],[
2700d522f475Smrg	cf_cv_have_utempter=yes],[
2701d522f475Smrg	cf_cv_have_utempter=no])
2702d522f475SmrgLIBS="$cf_save_LIBS"
2703d522f475Smrg])
2704d522f475Smrgif test "$cf_cv_have_utempter" = yes ; then
27050bd37d32Smrg	AC_DEFINE(USE_UTEMPTER,1,[Define to 1 if we can/should link with utempter])
270620d2c4d2Smrg	CF_ADD_LIB(utempter)
2707d522f475Smrgfi
2708d522f475Smrg])dnl
2709d522f475Smrgdnl ---------------------------------------------------------------------------
27100bd37d32Smrgdnl CF_UTMP version: 10 updated: 2012/10/04 20:12:20
2711d522f475Smrgdnl -------
2712d522f475Smrgdnl Check for UTMP/UTMPX headers
2713d522f475SmrgAC_DEFUN([CF_UTMP],
2714d522f475Smrg[
2715d522f475SmrgAC_REQUIRE([CF_LASTLOG])
2716d522f475Smrg
2717d522f475SmrgAC_CACHE_CHECK(for utmp implementation,cf_cv_have_utmp,[
2718d522f475Smrg	cf_cv_have_utmp=no
2719d522f475Smrgfor cf_header in utmpx utmp ; do
2720d522f475Smrgcf_utmp_includes="
2721d522f475Smrg#include <sys/types.h>
2722d522f475Smrg#include <${cf_header}.h>
2723d522f475Smrg#define getutent getutxent
2724d522f475Smrg#ifdef USE_LASTLOG
2725d522f475Smrg#include <lastlog.h>	/* may conflict with utmpx.h on Linux */
2726d522f475Smrg#endif
2727d522f475Smrg"
2728d522f475Smrg	AC_TRY_COMPILE([$cf_utmp_includes],
2729d522f475Smrg	[struct $cf_header x;
2730d522f475Smrg	 char *name = x.ut_name; /* utmp.h and compatible definitions */
2731d522f475Smrg	],
2732d522f475Smrg	[cf_cv_have_utmp=$cf_header
2733d522f475Smrg	 break],
2734d522f475Smrg	[
2735d522f475Smrg	AC_TRY_COMPILE([$cf_utmp_includes],
2736d522f475Smrg	[struct $cf_header x;
2737d522f475Smrg	 char *name = x.ut_user; /* utmpx.h must declare this */
2738d522f475Smrg	],
2739d522f475Smrg	[cf_cv_have_utmp=$cf_header
2740d522f475Smrg	 break
2741d522f475Smrg	])])
2742d522f475Smrgdone
2743d522f475Smrg])
2744d522f475Smrg
2745d522f475Smrgif test $cf_cv_have_utmp != no ; then
27460bd37d32Smrg	AC_DEFINE(HAVE_UTMP,1,[Define to 1 if the utmp interface is available])
27470bd37d32Smrg	test $cf_cv_have_utmp = utmpx && AC_DEFINE(UTMPX_FOR_UTMP,1,[Define if we have utmpx interface])
2748d522f475Smrg	CF_UTMP_UT_HOST
2749d522f475Smrg	CF_UTMP_UT_SYSLEN
2750d522f475Smrg	CF_UTMP_UT_NAME
2751d522f475Smrg	CF_UTMP_UT_XSTATUS
2752d522f475Smrg	CF_UTMP_UT_XTIME
2753d522f475Smrg	CF_UTMP_UT_SESSION
2754d522f475Smrg	CF_SYSV_UTMP
2755d522f475Smrgfi
2756d522f475Smrg])dnl
2757d522f475Smrgdnl ---------------------------------------------------------------------------
2758d522f475Smrgdnl CF_UTMP_GROUP version: 1 updated: 2005/10/06 20:29:29
2759d522f475Smrgdnl -------------
2760d522f475Smrgdnl Find the utmp/utmpx file and determine its group to allow setgid programs
2761d522f475Smrgdnl to manipulate it, e.g., when there is no intermediary.
2762d522f475SmrgAC_DEFUN([CF_UTMP_GROUP],[
2763d522f475SmrgAC_REQUIRE([CF_UTMP])
2764d522f475Smrgif test $cf_cv_have_utmp != no ; then
2765d522f475SmrgAC_CACHE_CHECK(for utmp/utmpx group,cf_cv_utmp_group,[
2766d522f475Smrgfor cf_utmp_path in /var/adm /var/run
2767d522f475Smrgdo
2768d522f475Smrg	for cf_utmp_file in utmpx utmp
2769d522f475Smrg	do
2770d522f475Smrg		if test -f $cf_utmp_path/$cf_utmp_file
2771d522f475Smrg		then
2772d522f475Smrg			cf_cv_utmp_group=root
2773d522f475Smrg
2774d522f475Smrg			cf_option="-l -L"
2775d522f475Smrg
2776d522f475Smrg			# Expect listing to have fields like this:
2777d522f475Smrg			#-r--r--r--   1 user      group       34293 Jul 18 16:29 pathname
2778d522f475Smrg			ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
2779d522f475Smrg			read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
2780d522f475Smrg			if test -z "$cf_rest" ; then
2781d522f475Smrg				cf_option="$cf_option -g"
2782d522f475Smrg				ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
2783d522f475Smrg				read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
2784d522f475Smrg			fi
2785d522f475Smrg			rm -f conftest
2786d522f475Smrg
2787d522f475Smrg			# If we have a pathname, and the date fields look right, assume we've
2788d522f475Smrg			# captured the group as well.
2789d522f475Smrg			if test -n "$cf_rest" ; then
2790d522f475Smrg				cf_test=`echo "${cf_date2}${cf_date3}" | sed -e 's/[[0-9:]]//g'`
2791d522f475Smrg				if test -z "$cf_test" ; then
2792d522f475Smrg					cf_cv_utmp_group=$cf_grp;
2793d522f475Smrg				fi
2794d522f475Smrg			fi
2795d522f475Smrg			break
2796d522f475Smrg		fi
2797d522f475Smrg	done
2798d522f475Smrg	test -n "$cf_cv_utmp_group" && break
2799d522f475Smrgdone
2800d522f475Smrg])
2801d522f475Smrgelse
2802d522f475Smrg	AC_MSG_ERROR(cannot find utmp group)
2803d522f475Smrgfi
2804d522f475Smrg])dnl
2805d522f475Smrgdnl ---------------------------------------------------------------------------
28060bd37d32Smrgdnl CF_UTMP_UT_HOST version: 8 updated: 2012/10/04 20:12:20
2807d522f475Smrgdnl ---------------
2808d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_host member
2809d522f475SmrgAC_DEFUN([CF_UTMP_UT_HOST],
2810d522f475Smrg[
2811d522f475Smrgif test $cf_cv_have_utmp != no ; then
2812d522f475SmrgAC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_host is declared)
2813d522f475SmrgAC_CACHE_VAL(cf_cv_have_utmp_ut_host,[
2814d522f475Smrg	AC_TRY_COMPILE([
2815d522f475Smrg#include <sys/types.h>
2816d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2817d522f475Smrg	[struct $cf_cv_have_utmp x; char *y = &x.ut_host[0]],
2818d522f475Smrg	[cf_cv_have_utmp_ut_host=yes],
2819d522f475Smrg	[cf_cv_have_utmp_ut_host=no])
2820d522f475Smrg	])
2821d522f475SmrgAC_MSG_RESULT($cf_cv_have_utmp_ut_host)
28220bd37d32Smrgtest $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])
2823d522f475Smrgfi
2824d522f475Smrg])dnl
2825d522f475Smrgdnl ---------------------------------------------------------------------------
282601037d57Smrgdnl CF_UTMP_UT_NAME version: 6 updated: 2015/04/12 15:39:00
2827d522f475Smrgdnl ---------------
2828d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_name member
2829d522f475SmrgAC_DEFUN([CF_UTMP_UT_NAME],
2830d522f475Smrg[
2831d522f475Smrgif test $cf_cv_have_utmp != no ; then
2832d522f475SmrgAC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_name is declared,cf_cv_have_utmp_ut_name,[
2833d522f475Smrg	cf_cv_have_utmp_ut_name=no
2834d522f475Smrgcf_utmp_includes="
2835d522f475Smrg#include <sys/types.h>
2836d522f475Smrg#include <${cf_cv_have_utmp}.h>
2837d522f475Smrg#define getutent getutxent
2838d522f475Smrg#ifdef USE_LASTLOG
2839d522f475Smrg#include <lastlog.h>		/* may conflict with utmpx.h on Linux */
2840d522f475Smrg#endif
2841d522f475Smrg"
2842d522f475Smrgfor cf_header in ut_name ut_user ; do
2843d522f475Smrg	AC_TRY_COMPILE([$cf_utmp_includes],
2844d522f475Smrg	[struct $cf_cv_have_utmp x;
2845d522f475Smrg	 char *name = x.$cf_header;
2846d522f475Smrg	],
2847d522f475Smrg	[cf_cv_have_utmp_ut_name=$cf_header
2848d522f475Smrg	 break])
2849d522f475Smrgdone
2850d522f475Smrg])
2851d522f475Smrg
285201037d57Smrgcase $cf_cv_have_utmp_ut_name in
285301037d57Smrg(no)
2854d522f475Smrg	AC_MSG_ERROR(Cannot find declaration for ut.ut_name)
2855d522f475Smrg	;;
285601037d57Smrg(ut_user)
28570bd37d32Smrg	AC_DEFINE(ut_name,ut_user,[Define to rename UTMP/UTMPX struct ut_name member])
2858d522f475Smrg	;;
2859d522f475Smrgesac
2860d522f475Smrgfi
2861d522f475Smrg])dnl
2862d522f475Smrgdnl ---------------------------------------------------------------------------
28630bd37d32Smrgdnl CF_UTMP_UT_SESSION version: 6 updated: 2012/10/04 20:12:20
2864d522f475Smrgdnl ------------------
2865d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_session member
2866d522f475SmrgAC_DEFUN([CF_UTMP_UT_SESSION],
2867d522f475Smrg[
2868d522f475Smrgif test $cf_cv_have_utmp != no ; then
2869d522f475SmrgAC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_session is declared, cf_cv_have_utmp_ut_session,[
2870d522f475Smrg	AC_TRY_COMPILE([
2871d522f475Smrg#include <sys/types.h>
2872d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2873d522f475Smrg	[struct $cf_cv_have_utmp x; long y = x.ut_session],
2874d522f475Smrg	[cf_cv_have_utmp_ut_session=yes],
2875d522f475Smrg	[cf_cv_have_utmp_ut_session=no])
2876d522f475Smrg])
2877d522f475Smrgif test $cf_cv_have_utmp_ut_session != no ; then
28780bd37d32Smrg	AC_DEFINE(HAVE_UTMP_UT_SESSION,1,[Define to 1 if UTMP/UTMPX struct defines ut_session member])
2879d522f475Smrgfi
2880d522f475Smrgfi
2881d522f475Smrg])dnl
2882d522f475Smrgdnl ---------------------------------------------------------------------------
28830bd37d32Smrgdnl CF_UTMP_UT_SYSLEN version: 2 updated: 2012/10/04 20:12:20
2884d522f475Smrgdnl -----------------
2885d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_syslen member
2886d522f475SmrgAC_DEFUN([CF_UTMP_UT_SYSLEN],
2887d522f475Smrg[
2888d522f475Smrgif test $cf_cv_have_utmp != no ; then
2889d522f475SmrgAC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_syslen is declared)
2890d522f475SmrgAC_CACHE_VAL(cf_cv_have_utmp_ut_syslen,[
2891d522f475Smrg	AC_TRY_COMPILE([
2892d522f475Smrg#include <sys/types.h>
2893d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2894d522f475Smrg	[struct $cf_cv_have_utmp x; int y = x.ut_syslen],
2895d522f475Smrg	[cf_cv_have_utmp_ut_syslen=yes],
2896d522f475Smrg	[cf_cv_have_utmp_ut_syslen=no])
2897d522f475Smrg	])
2898d522f475SmrgAC_MSG_RESULT($cf_cv_have_utmp_ut_syslen)
28990bd37d32Smrgtest $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])
2900d522f475Smrgfi
2901d522f475Smrg])dnl
2902d522f475Smrgdnl ---------------------------------------------------------------------------
29030bd37d32Smrgdnl CF_UTMP_UT_XSTATUS version: 4 updated: 2012/10/04 20:12:20
2904d522f475Smrgdnl ------------------
2905d522f475Smrgdnl Check for known variants on the UTMP/UTMPX struct's exit-status as reported
2906d522f475Smrgdnl by various people:
2907d522f475Smrgdnl
2908d522f475Smrgdnl	ut_exit.__e_exit (HPUX 11 - David Ellement, also in glibc2)
2909d522f475Smrgdnl	ut_exit.e_exit (SVR4)
2910d522f475Smrgdnl	ut_exit.ut_e_exit (os390 - Greg Smith)
2911d522f475Smrgdnl	ut_exit.ut_exit (Tru64 4.0f - Jeremie Petit, 4.0e - Tomas Vanhala)
2912d522f475Smrgdnl
2913d522f475Smrgdnl Note: utmp_xstatus is not a conventional compatibility definition in the
2914d522f475Smrgdnl system header files.
2915d522f475SmrgAC_DEFUN([CF_UTMP_UT_XSTATUS],
2916d522f475Smrg[
2917d522f475Smrgif test $cf_cv_have_utmp != no ; then
2918d522f475SmrgAC_CACHE_CHECK(for exit-status in $cf_cv_have_utmp,cf_cv_have_utmp_ut_xstatus,[
2919d522f475Smrgfor cf_result in \
2920d522f475Smrg	ut_exit.__e_exit \
2921d522f475Smrg	ut_exit.e_exit \
2922d522f475Smrg	ut_exit.ut_e_exit \
2923d522f475Smrg	ut_exit.ut_exit
2924d522f475Smrgdo
2925d522f475SmrgAC_TRY_COMPILE([
2926d522f475Smrg#include <sys/types.h>
2927d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2928d522f475Smrg	[struct $cf_cv_have_utmp x; long y = x.$cf_result = 0],
2929d522f475Smrg	[cf_cv_have_utmp_ut_xstatus=$cf_result
2930d522f475Smrg	 break],
2931d522f475Smrg	[cf_cv_have_utmp_ut_xstatus=no])
2932d522f475Smrgdone
2933d522f475Smrg])
2934d522f475Smrgif test $cf_cv_have_utmp_ut_xstatus != no ; then
29350bd37d32Smrg	AC_DEFINE(HAVE_UTMP_UT_XSTATUS,1,[Define to 1 if UTMP/UTMPX has exit-status member])
29360bd37d32Smrg	AC_DEFINE_UNQUOTED(ut_xstatus,$cf_cv_have_utmp_ut_xstatus,[Define if needed to rename member ut_xstatus of UTMP/UTMPX])
2937d522f475Smrgfi
2938d522f475Smrgfi
2939d522f475Smrg])dnl
2940d522f475Smrgdnl ---------------------------------------------------------------------------
29410bd37d32Smrgdnl CF_UTMP_UT_XTIME version: 9 updated: 2012/10/04 20:12:20
2942d522f475Smrgdnl ----------------
2943d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_xtime member
2944d522f475SmrgAC_DEFUN([CF_UTMP_UT_XTIME],
2945d522f475Smrg[
2946d522f475Smrgif test $cf_cv_have_utmp != no ; then
2947d522f475SmrgAC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_xtime is declared, cf_cv_have_utmp_ut_xtime,[
2948d522f475Smrg	AC_TRY_COMPILE([
2949d522f475Smrg#include <sys/types.h>
2950d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2951d522f475Smrg	[struct $cf_cv_have_utmp x; long y = x.ut_xtime = 0],
2952d522f475Smrg	[cf_cv_have_utmp_ut_xtime=yes],
2953d522f475Smrg	[AC_TRY_COMPILE([
2954d522f475Smrg#include <sys/types.h>
2955d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2956d522f475Smrg	[struct $cf_cv_have_utmp x; long y = x.ut_tv.tv_sec],
2957d522f475Smrg	[cf_cv_have_utmp_ut_xtime=define],
2958d522f475Smrg	[cf_cv_have_utmp_ut_xtime=no])
2959d522f475Smrg	])
2960d522f475Smrg])
2961d522f475Smrgif test $cf_cv_have_utmp_ut_xtime != no ; then
29620bd37d32Smrg	AC_DEFINE(HAVE_UTMP_UT_XTIME,1,[Define to 1 if UTMP/UTMPX struct defines ut_xtime member])
2963d522f475Smrg	if test $cf_cv_have_utmp_ut_xtime = define ; then
29640bd37d32Smrg		AC_DEFINE(ut_xtime,ut_tv.tv_sec,[Define if needed to alternate name for utmpx.ut_xtime member])
2965d522f475Smrg	fi
2966d522f475Smrgfi
2967d522f475Smrgfi
2968d522f475Smrg])dnl
2969d522f475Smrgdnl ---------------------------------------------------------------------------
2970d522f475Smrgdnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
2971d522f475Smrgdnl ----------
2972d522f475Smrgdnl Use AC_VERBOSE w/o the warnings
2973d522f475SmrgAC_DEFUN([CF_VERBOSE],
2974d522f475Smrg[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
2975d522f475SmrgCF_MSG_LOG([$1])
2976d522f475Smrg])dnl
2977d522f475Smrgdnl ---------------------------------------------------------------------------
297801037d57Smrgdnl CF_WITH_APP_CLASS version: 3 updated: 2015/04/12 15:39:00
2979e39b573cSmrgdnl -----------------
2980e39b573cSmrgdnl Handle configure option "--with-app-class", setting the $APP_CLASS
2981e39b573cSmrgdnl variable, used for X resources.
2982e39b573cSmrgdnl
2983e39b573cSmrgdnl $1 = default value.
29840bd37d32SmrgAC_DEFUN([CF_WITH_APP_CLASS],[
2985e39b573cSmrgAC_MSG_CHECKING(for X applications class)
2986e39b573cSmrgAC_ARG_WITH(app-class,
2987e39b573cSmrg	[  --with-app-class=XXX    override X applications class (default $1)],
2988e39b573cSmrg	[APP_CLASS=$withval],
2989e39b573cSmrg	[APP_CLASS=$1])
2990e39b573cSmrg
299101037d57Smrgcase x$APP_CLASS in
299201037d57Smrg(*[[/@,%]]*)
2993e39b573cSmrg	AC_MSG_WARN(X applications class cannot contain punctuation)
2994e39b573cSmrg	APP_CLASS=$1
2995e39b573cSmrg	;;
299601037d57Smrg(x[[A-Z]]*)
2997e39b573cSmrg	;;
299801037d57Smrg(*)
2999e39b573cSmrg	AC_MSG_WARN([X applications class must start with capital, ignoring $APP_CLASS])
3000e39b573cSmrg	APP_CLASS=$1
3001e39b573cSmrg	;;
3002e39b573cSmrgesac
3003e39b573cSmrg
3004e39b573cSmrgAC_MSG_RESULT($APP_CLASS)
3005e39b573cSmrg
3006e39b573cSmrgAC_SUBST(APP_CLASS)
3007e39b573cSmrg])dnl
3008e39b573cSmrgdnl ---------------------------------------------------------------------------
300901037d57Smrgdnl CF_WITH_APP_DEFAULTS version: 6 updated: 2015/01/02 09:05:50
3010e39b573cSmrgdnl --------------------
3011e39b573cSmrgdnl Handle configure option "--with-app-defaults", setting these shell
3012e39b573cSmrgdnl variables:
30130bd37d32Smrgdnl
30140bd37d32Smrgdnl $APPSDIR is the option value, used for installing app-defaults files.
3015e39b573cSmrgdnl $no_appsdir is a "#" (comment) if "--without-app-defaults" is given.
30160bd37d32Smrgdnl
30170bd37d32Smrgdnl Most Linux's use this:
30180bd37d32Smrgdnl 	/usr/share/X11/app-defaults
30190bd37d32Smrgdnl Debian uses this:
30200bd37d32Smrgdnl 	/etc/X11/app-defaults
30210bd37d32Smrgdnl DragonFlyBSD ports uses this:
30220bd37d32Smrgdnl 	/usr/pkg/lib/X11/app-defaults
30230bd37d32Smrgdnl FreeBSD ports use these:
30240bd37d32Smrgdnl 	/usr/local/lib/X11/app-defaults
30250bd37d32Smrgdnl 	/usr/local/share/X11/app-defaults
30260bd37d32Smrgdnl Mandriva has these:
30270bd37d32Smrgdnl 	/usr/lib/X11/app-defaults
30280bd37d32Smrgdnl 	/usr/lib64/X11/app-defaults
30290bd37d32Smrgdnl NetBSD has these
30300bd37d32Smrgdnl 	/usr/X11R7/lib/X11/app-defaults
30310bd37d32Smrgdnl OpenSolaris uses
30320bd37d32Smrgdnl 	32-bit:
30330bd37d32Smrgdnl 	/usr/X11/etc/X11/app-defaults
30340bd37d32Smrgdnl 	/usr/X11/share/X11/app-defaults
30350bd37d32Smrgdnl 	/usr/X11/lib/X11/app-defaults
303601037d57Smrgdnl OSX uses
303701037d57Smrgdnl		/opt/local/share/X11/app-defaults (MacPorts)
303801037d57Smrgdnl		/opt/X11/share/X11/app-defaults (non-ports)
30390bd37d32Smrgdnl	64-bit:
30400bd37d32Smrgdnl 	/usr/X11/etc/X11/app-defaults
30410bd37d32Smrgdnl 	/usr/X11/share/X11/app-defaults (I mkdir'd this)
30420bd37d32Smrgdnl 	/usr/X11/lib/amd64/X11/app-defaults
30430bd37d32Smrgdnl Solaris10 uses (in this order):
30440bd37d32Smrgdnl 	/usr/openwin/lib/X11/app-defaults
30450bd37d32Smrgdnl 	/usr/X11/lib/X11/app-defaults
30460bd37d32SmrgAC_DEFUN([CF_WITH_APP_DEFAULTS],[
3047e39b573cSmrgAC_MSG_CHECKING(for directory to install resource files)
30480bd37d32SmrgAC_ARG_WITH(app-defaults,
30490bd37d32Smrg	[  --with-app-defaults=DIR directory in which to install resource files (EPREFIX/lib/X11/app-defaults)],
30500bd37d32Smrg	[APPSDIR=$withval],
30510bd37d32Smrg	[APPSDIR='${exec_prefix}/lib/X11/app-defaults'])
30520bd37d32Smrg
30530bd37d32Smrgif test "x[$]APPSDIR" = xauto
30540bd37d32Smrgthen
30550bd37d32Smrg	APPSDIR='${exec_prefix}/lib/X11/app-defaults'
30560bd37d32Smrg	for cf_path in \
305701037d57Smrg		/opt/local/share/X11/app-defaults \
305801037d57Smrg		/opt/X11/share/X11/app-defaults \
30590bd37d32Smrg		/usr/share/X11/app-defaults \
30600bd37d32Smrg		/usr/X11/share/X11/app-defaults \
30610bd37d32Smrg		/usr/X11/lib/X11/app-defaults \
30620bd37d32Smrg		/usr/lib/X11/app-defaults \
30630bd37d32Smrg		/etc/X11/app-defaults \
30640bd37d32Smrg		/usr/pkg/lib/X11/app-defaults \
30650bd37d32Smrg		/usr/X11R7/lib/X11/app-defaults \
30660bd37d32Smrg		/usr/X11R6/lib/X11/app-defaults \
30670bd37d32Smrg		/usr/X11R5/lib/X11/app-defaults \
30680bd37d32Smrg		/usr/X11R4/lib/X11/app-defaults \
30690bd37d32Smrg		/usr/local/lib/X11/app-defaults \
30700bd37d32Smrg		/usr/local/share/X11/app-defaults \
30710bd37d32Smrg		/usr/lib64/X11/app-defaults
30720bd37d32Smrg	do
30730bd37d32Smrg		if test -d "$cf_path" ; then
30740bd37d32Smrg			APPSDIR="$cf_path"
30750bd37d32Smrg			break
30760bd37d32Smrg		fi
30770bd37d32Smrg	done
30780bd37d32Smrgelse
30790bd37d32Smrg	cf_path=$APPSDIR
30800bd37d32Smrg	CF_PATH_SYNTAX(cf_path)
30810bd37d32Smrgfi
30820bd37d32Smrg
30830bd37d32SmrgAC_MSG_RESULT($APPSDIR)
30840bd37d32SmrgAC_SUBST(APPSDIR)
3085e39b573cSmrg
3086e39b573cSmrgno_appsdir=
30870bd37d32Smrgif test "$APPSDIR" = no
30880bd37d32Smrgthen
30890bd37d32Smrg	no_appsdir="#"
30900bd37d32Smrgelse
30910bd37d32Smrg	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(APPSDIR)"
30920bd37d32Smrgfi
3093e39b573cSmrgAC_SUBST(no_appsdir)
3094e39b573cSmrg])dnl
3095e39b573cSmrgdnl ---------------------------------------------------------------------------
30960bd37d32Smrgdnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
30970bd37d32Smrgdnl ----------------
30980bd37d32Smrgdnl Configure-option for dbmalloc.  The optional parameter is used to override
30990bd37d32Smrgdnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
31000bd37d32SmrgAC_DEFUN([CF_WITH_DBMALLOC],[
31010bd37d32SmrgCF_NO_LEAKS_OPTION(dbmalloc,
31020bd37d32Smrg	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
31030bd37d32Smrg	[USE_DBMALLOC])
31040bd37d32Smrg
31050bd37d32Smrgif test "$with_dbmalloc" = yes ; then
31060bd37d32Smrg	AC_CHECK_HEADER(dbmalloc.h,
31070bd37d32Smrg		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
31080bd37d32Smrgfi
31090bd37d32Smrg])dnl
31100bd37d32Smrgdnl ---------------------------------------------------------------------------
311101037d57Smrgdnl CF_WITH_DESKTOP_CATEGORY version: 5 updated: 2015/04/12 15:39:00
3112e39b573cSmrgdnl ------------------------
3113e39b573cSmrgdnl Taking into account the absence of standardization of desktop categories
3114e39b573cSmrgdnl take a look to see whether other applications on the current system are
3115e39b573cSmrgdnl assigned any/all of a set of suggested categories.
3116e39b573cSmrgdnl
3117e39b573cSmrgdnl $1 = program name
3118e39b573cSmrgdnl $2 = case-pattern to match comparable desktop files to obtain category
3119e39b573cSmrgdnl      This pattern may contain wildcards.
3120e39b573cSmrgdnl $3 = suggested categories, also a case-pattern but without wildcards,
31210bd37d32Smrgdnl      since it doubles as a default value for a shell case-statement.
31220bd37d32Smrgdnl $4 = categories to use if no match is found on the build-machine for the
31230bd37d32Smrgdnl      --with-desktop-category "auto" setting.
3124e39b573cSmrgdnl
3125e39b573cSmrgdnl The macro tells the configure script to substitute the $DESKTOP_CATEGORY
3126e39b573cSmrgdnl value.
3127e39b573cSmrgAC_DEFUN([CF_WITH_DESKTOP_CATEGORY],[
3128e39b573cSmrgAC_REQUIRE([CF_DISABLE_DESKTOP])
3129e39b573cSmrg
3130e39b573cSmrgif test -z "$desktop_utils"
3131e39b573cSmrgthen
3132e39b573cSmrg	AC_MSG_CHECKING(for requested desktop-category)
3133e39b573cSmrg	AC_ARG_WITH(desktop-category,
3134e39b573cSmrg		[  --with-desktop-category=XXX  one or more desktop catgories or auto],
3135e39b573cSmrg		[cf_desktop_want=$withval],
3136e39b573cSmrg		[cf_desktop_want=auto])
3137e39b573cSmrg	AC_MSG_RESULT($cf_desktop_want)
3138e39b573cSmrg
3139e39b573cSmrg	if test "$cf_desktop_want" = auto
3140e39b573cSmrg	then
3141e39b573cSmrg		rm -rf conftest*
3142e39b573cSmrg		cf_desktop_also=
3143e39b573cSmrg		for cf_desktop_dir in  \
3144e39b573cSmrg			/usr/share/app-install \
3145e39b573cSmrg			/usr/share/applications
3146e39b573cSmrg		do
3147e39b573cSmrg			if test -d $cf_desktop_dir
3148e39b573cSmrg			then
3149e39b573cSmrg				find $cf_desktop_dir -name '*.desktop' | \
3150e39b573cSmrg				while true
3151e39b573cSmrg				do
3152e39b573cSmrg					read cf_desktop_path
3153e39b573cSmrg					test -z "$cf_desktop_path" && break
3154e39b573cSmrg					cf_desktop_name=`basename $cf_desktop_path .desktop`
315501037d57Smrg					case $cf_desktop_name in
315601037d57Smrg					($1|*-$1|$2)
3157e39b573cSmrg						CF_VERBOSE(inspect $cf_desktop_path)
3158e39b573cSmrg						egrep '^Categories=' $cf_desktop_path | \
3159e39b573cSmrg							tr ';' '\n' | \
3160e39b573cSmrg							sed -e 's%^.*=%%' -e '/^$/d' >>conftest.1
3161e39b573cSmrg						;;
3162e39b573cSmrg					esac
3163e39b573cSmrg				done
3164e39b573cSmrg			fi
3165e39b573cSmrg		done
3166e39b573cSmrg		if test -s conftest.1
3167e39b573cSmrg		then
3168e39b573cSmrg			cf_desktop_last=
3169e39b573cSmrg			sort conftest.1 | \
3170e39b573cSmrg			while true
3171e39b573cSmrg			do
3172e39b573cSmrg				read cf_desktop_this
3173e39b573cSmrg				test -z "$cf_desktop_this" && break
317401037d57Smrg				case $cf_desktop_this in
317501037d57Smrg				(Qt*|GTK*|KDE*|GNOME*|*XFCE*|*Xfce*)
3176e39b573cSmrg					;;
317701037d57Smrg				($3)
3178e39b573cSmrg					test "x$cf_desktop_last" != "x$cf_desktop_this" && echo $cf_desktop_this >>conftest.2
3179e39b573cSmrg					;;
3180e39b573cSmrg				esac
3181e39b573cSmrg				cf_desktop_last=$cf_desktop_this
3182e39b573cSmrg			done
3183e39b573cSmrg			cf_desktop_want=`cat conftest.2 | tr '\n' ';'`
3184e39b573cSmrg		fi
31850bd37d32Smrg		if test -n "$cf_desktop_want"
31860bd37d32Smrg		then
31870bd37d32Smrg			if test "$cf_desktop_want" = auto
31880bd37d32Smrg			then
31890bd37d32Smrg				cf_desktop_want=
31900bd37d32Smrg			else
31910bd37d32Smrg				# do a sanity check on the semicolon-separated list, ignore on failure
31920bd37d32Smrg				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/[[^;]]//g'`
31930bd37d32Smrg				test -z "$cf_desktop_test" && cf_desktop_want=
31940bd37d32Smrg				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/^.*;$/./g'`
31950bd37d32Smrg				test -z "$cf_desktop_test" && cf_desktop_want=
31960bd37d32Smrg			fi
31970bd37d32Smrg		fi
31980bd37d32Smrg		if test -z "$cf_desktop_want"
31990bd37d32Smrg		then
32000bd37d32Smrg			cf_desktop_want="ifelse([$4],,ifelse([$3],,[Application;],[`echo "$3" | sed -e 's/\*//g' -e 's/|/;/g' -e 's/[[;]]*$/;/g'`]),[$4])"
32010bd37d32Smrg			CF_VERBOSE(no usable value found for desktop category, using $cf_desktop_want)
32020bd37d32Smrg		fi
3203e39b573cSmrg	fi
3204e39b573cSmrg	DESKTOP_CATEGORY=`echo "$cf_desktop_want" | sed -e 's/[[ ,]]/;/g'`
32050bd37d32Smrg	CF_VERBOSE(will use Categories=$DESKTOP_CATEGORY)
3206e39b573cSmrg	AC_SUBST(DESKTOP_CATEGORY)
3207e39b573cSmrgfi
3208e39b573cSmrg])
3209e39b573cSmrgdnl ---------------------------------------------------------------------------
32100bd37d32Smrgdnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
3211e39b573cSmrgdnl ---------------
32120bd37d32Smrgdnl Configure-option for dmalloc.  The optional parameter is used to override
32130bd37d32Smrgdnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
32140bd37d32SmrgAC_DEFUN([CF_WITH_DMALLOC],[
32150bd37d32SmrgCF_NO_LEAKS_OPTION(dmalloc,
32160bd37d32Smrg	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
32170bd37d32Smrg	[USE_DMALLOC])
32180bd37d32Smrg
32190bd37d32Smrgif test "$with_dmalloc" = yes ; then
32200bd37d32Smrg	AC_CHECK_HEADER(dmalloc.h,
32210bd37d32Smrg		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
32220bd37d32Smrgfi
32230bd37d32Smrg])dnl
32240bd37d32Smrgdnl ---------------------------------------------------------------------------
32250bd37d32Smrgdnl CF_WITH_ICONDIR version: 5 updated: 2012/07/22 09:18:02
32260bd37d32Smrgdnl ---------------
32270bd37d32Smrgdnl Handle configure option "--with-icondir", setting these shell variables:
32280bd37d32Smrgdnl
32290bd37d32Smrgdnl $ICONDIR is the option value, used for installing icon files.
3230e39b573cSmrgdnl $no_icondir is a "#" (comment) if "--without-icondir" is given.
3231e39b573cSmrgAC_DEFUN([CF_WITH_ICONDIR],[
3232e39b573cSmrgAC_MSG_CHECKING(for directory to install icons)
32330bd37d32SmrgAC_ARG_WITH(icondir,
32340bd37d32Smrg	[  --with-icondir=DIR      directory in which to install icons for desktop],
32350bd37d32Smrg	[ICONDIR=$withval],
32360bd37d32Smrg	[test -z "$ICONDIR" && ICONDIR=no])
32370bd37d32Smrg
32380bd37d32Smrgif test "x[$]ICONDIR" = xauto
32390bd37d32Smrgthen
32400bd37d32Smrg	ICONDIR='${datadir}/icons'
32410bd37d32Smrg	for cf_path in \
32420bd37d32Smrg		/usr/share/icons \
32430bd37d32Smrg		/usr/X11R6/share/icons
32440bd37d32Smrg	do
32450bd37d32Smrg		if test -d "$cf_path" ; then
32460bd37d32Smrg			ICONDIR="$cf_path"
32470bd37d32Smrg			break
32480bd37d32Smrg		fi
32490bd37d32Smrg	done
32500bd37d32Smrgelse
32510bd37d32Smrg	cf_path=$ICONDIR
32520bd37d32Smrg	CF_PATH_SYNTAX(cf_path)
32530bd37d32Smrgfi
32540bd37d32SmrgAC_MSG_RESULT($ICONDIR)
32550bd37d32SmrgAC_SUBST(ICONDIR)
3256e39b573cSmrg
3257e39b573cSmrgno_icondir=
32580bd37d32Smrgif test "$ICONDIR" = no
32590bd37d32Smrgthen
32600bd37d32Smrg	no_icondir="#"
32610bd37d32Smrgelse
32620bd37d32Smrg	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(ICONDIR)"
32630bd37d32Smrgfi
3264e39b573cSmrgAC_SUBST(no_icondir)
3265e39b573cSmrg])dnl
3266e39b573cSmrgdnl ---------------------------------------------------------------------------
326701037d57Smrgdnl CF_WITH_ICON_NAME version: 3 updated: 2015/04/12 15:39:00
32680bd37d32Smrgdnl -----------------
32690bd37d32Smrgdnl Allow a default icon-name to be overridden.
32700bd37d32Smrgdnl $1 = default icon name
32710bd37d32SmrgAC_DEFUN([CF_WITH_ICON_NAME],[
32720bd37d32SmrgAC_MSG_CHECKING(for the icon name)
32730bd37d32SmrgAC_ARG_WITH(icon-name,
32740bd37d32Smrg	[  --with-icon-name=XXXX   override icon name (default: $1)],
32750bd37d32Smrg	[ICON_NAME="$withval"],
32760bd37d32Smrg	[ICON_NAME=$1])
32770bd37d32Smrgcase "x$ICON_NAME" in
327801037d57Smrg(xyes|xno|x)
32790bd37d32Smrg	ICON_NAME=$1
32800bd37d32Smrg	;;
32810bd37d32Smrgesac
32820bd37d32SmrgAC_SUBST(ICON_NAME)
32830bd37d32SmrgAC_MSG_RESULT($ICON_NAME)
32840bd37d32Smrg])dnl
32850bd37d32Smrgdnl ---------------------------------------------------------------------------
328601037d57Smrgdnl CF_WITH_ICON_SYMLINK version: 2 updated: 2015/04/12 15:39:00
32870bd37d32Smrgdnl --------------------
32880bd37d32Smrgdnl Workaround for systems which are (mis)configured to map all icon references
32890bd37d32Smrgdnl for xterm into "xterm" name.  For instance, recent (2013) KDE ignores both
32900bd37d32Smrgdnl the name given in the .desktop file (xterm-color) and the application name
32910bd37d32Smrgdnl (xterm-dev).
32920bd37d32Smrgdnl
32930bd37d32Smrgdnl $1 = default icon name to use if symlink is wanted
32940bd37d32SmrgAC_DEFUN([CF_WITH_ICON_SYMLINK],[
32950bd37d32SmrgAC_MSG_CHECKING(for icon symlink to use)
32960bd37d32SmrgAC_ARG_WITH(icon-symlink,
32970bd37d32Smrg	[  --with-icon-symlink=XXX make symbolic link for icon name (default: $1)],
32980bd37d32Smrg	[ICON_SYMLINK="$withval"],
32990bd37d32Smrg	[ICON_SYMLINK=NONE])
33000bd37d32Smrgcase "x$ICON_SYMLINK" in
330101037d57Smrg(xyes)
33020bd37d32Smrg	ICON_SYMLINK=$1
33030bd37d32Smrg	;;
330401037d57Smrg(xno|x)
33050bd37d32Smrg	ICON_SYMLINK=NONE
33060bd37d32Smrg	;;
33070bd37d32Smrgesac
33080bd37d32SmrgAC_SUBST(ICON_SYMLINK)
33090bd37d32SmrgAC_MSG_RESULT($ICON_SYMLINK)
33100bd37d32Smrg])dnl
33110bd37d32Smrgdnl ---------------------------------------------------------------------------
331201037d57Smrgdnl CF_WITH_ICON_THEME version: 11 updated: 2015/04/12 15:39:00
33130bd37d32Smrgdnl ------------------
33140bd37d32Smrgdnl If asked, check for prerequisites and setup symbols to permit installing
33150bd37d32Smrgdnl one or more application icons in the Red Hat icon-theme directory
331601037d57Smrgdnl hierarchy.
33170bd37d32Smrgdnl
33180bd37d32Smrgdnl If the prerequisites are missing, give a warning and revert to the long-
33190bd37d32Smrgdnl standing pixmaps directory.
33200bd37d32Smrgdnl
33210bd37d32Smrgdnl Parameters:
33220bd37d32Smrgdnl
33230bd37d32Smrgdnl $1 = application icon.  This can be a list, and is not optional.
33240bd37d32Smrgdnl $2 = default theme (defaults to hicolor)
33250bd37d32Smrgdnl $3 = formats (defaults to list [.svg .png .xpm])
33260bd37d32Smrgdnl $4 = alternate icon if no theme is used (defaults to $1).
33270bd37d32Smrgdnl
33280bd37d32Smrgdnl Result:
33290bd37d32Smrgdnl ICON_NAME = basename of first item in $1
33300bd37d32Smrgdnl ICON_LIST = reprocessed $1
33310bd37d32Smrgdnl ICON_THEME = reprocessed $2
33320bd37d32Smrgdnl ICON_FORMAT = reprocessed $3
33330bd37d32SmrgAC_DEFUN([CF_WITH_ICON_THEME],
33340bd37d32Smrg[
33350bd37d32Smrgifelse([$1],,[
33360bd37d32Smrg	AC_MSG_ERROR([macro [CF_WITH_ICON_THEME] requires application-icon name])
33370bd37d32Smrg],[
33380bd37d32Smrg
33390bd37d32SmrgCF_WITH_PIXMAPDIR
33400bd37d32SmrgCF_WITH_ICONDIR
33410bd37d32Smrg
33420bd37d32SmrgAC_MSG_CHECKING(if icon theme should be used)
33430bd37d32SmrgAC_ARG_WITH(icon-theme,
33440bd37d32Smrg	[  --with-icon-theme=XXX   install icons into desktop theme (hicolor)],
33450bd37d32Smrg	[ICON_THEME=$withval],
33460bd37d32Smrg	[ICON_THEME=no])
33470bd37d32Smrg
334801037d57Smrgcase "x$ICON_THEME" in
334901037d57Smrg(xno)
33500bd37d32Smrg	;;
335101037d57Smrg(x|xyes)
33520bd37d32Smrg	ICON_THEME=ifelse([$2],,hicolor,$2)
33530bd37d32Smrg	;;
33540bd37d32Smrgesac
33550bd37d32SmrgAC_MSG_RESULT($ICON_THEME)
33560bd37d32Smrg
33570bd37d32Smrgif test "x$ICON_THEME" = xno
33580bd37d32Smrgthen
33590bd37d32Smrg	if test "x$ICONDIR" != xno
33600bd37d32Smrg	then
33610bd37d32Smrg		CF_VERBOSE(ignoring icondir without theme)
33620bd37d32Smrg		no_icondir="#"
33630bd37d32Smrg	fi
33640bd37d32Smrgelse
33650bd37d32Smrg	if test "x$ICONDIR" = xno
33660bd37d32Smrg	then
33670bd37d32Smrg		AC_MSG_ERROR(icondir must be set for icon theme)
33680bd37d32Smrg	fi
33690bd37d32Smrgfi
33700bd37d32Smrg
33710bd37d32Smrg: ${ICON_FORMAT:=ifelse([$3],,[".svg .png .xpm"],[$3])}
33720bd37d32Smrg
33730bd37d32Smrg# ICON_NAME=
33740bd37d32SmrgICON_LIST=
33750bd37d32Smrg
33760bd37d32Smrgifelse([$4],,[cf_icon_list=$1],[
33770bd37d32Smrgif test "x$ICON_THEME" != xno
33780bd37d32Smrgthen
33790bd37d32Smrg	cf_icon_list="$1"
33800bd37d32Smrgelse
33810bd37d32Smrg	cf_icon_list="$4"
33820bd37d32Smrgfi
33830bd37d32Smrg])
33840bd37d32Smrg
33850bd37d32SmrgAC_MSG_CHECKING([for icon(s) to install])
33860bd37d32Smrgfor cf_name in $cf_icon_list
33870bd37d32Smrgdo
33880bd37d32Smrg	CF_VERBOSE(using $ICON_FORMAT)
33890bd37d32Smrg	for cf_suffix in $ICON_FORMAT
33900bd37d32Smrg	do
33910bd37d32Smrg		cf_icon="${cf_name}${cf_suffix}"
33920bd37d32Smrg		cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
33930bd37d32Smrg		if test ! -f "${cf_left}"
33940bd37d32Smrg		then
33950bd37d32Smrg			if test "x$srcdir" != "x."
33960bd37d32Smrg			then
33970bd37d32Smrg				cf_icon="${srcdir}/${cf_left}"
33980bd37d32Smrg				cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
33990bd37d32Smrg				if test ! -f "${cf_left}"
34000bd37d32Smrg				then
34010bd37d32Smrg					continue
34020bd37d32Smrg				fi
34030bd37d32Smrg			else
34040bd37d32Smrg				continue
34050bd37d32Smrg			fi
34060bd37d32Smrg		fi
34070bd37d32Smrg		if test "x$ICON_THEME" != xno
34080bd37d32Smrg		then
34090bd37d32Smrg			cf_base=`basename $cf_left`
34100bd37d32Smrg			cf_trim=`echo "$cf_base" | sed -e 's/_[[0-9]][[0-9]]x[[0-9]][[0-9]]\././'`
341101037d57Smrg			case "x${cf_base}" in
341201037d57Smrg			(*:*)
34130bd37d32Smrg				cf_next=$cf_base
34140bd37d32Smrg				# user-defined mapping
34150bd37d32Smrg				;;
341601037d57Smrg			(*.png)
34170bd37d32Smrg				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'`
34180bd37d32Smrg				if test -z "$cf_size"
34190bd37d32Smrg				then
34200bd37d32Smrg					AC_MSG_WARN(cannot determine size of $cf_left)
34210bd37d32Smrg					continue
34220bd37d32Smrg				fi
34230bd37d32Smrg				cf_next="$cf_size/apps/$cf_trim"
34240bd37d32Smrg				;;
342501037d57Smrg			(*.svg)
34260bd37d32Smrg				cf_next="scalable/apps/$cf_trim"
34270bd37d32Smrg				;;
342801037d57Smrg			(*.xpm)
34290bd37d32Smrg				CF_VERBOSE(ignored XPM file in icon theme)
34300bd37d32Smrg				continue
34310bd37d32Smrg				;;
343201037d57Smrg			(*_[[0-9]][[0-9]]*x[[0-9]][[0-9]]*.*)
34330bd37d32Smrg				cf_size=`echo "$cf_left"|sed -e 's/^.*_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\..*$/\1/'`
34340bd37d32Smrg				cf_left=`echo "$cf_left"|sed -e 's/^\(.*\)_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\(\..*\)$/\1\3/'`
34350bd37d32Smrg				cf_next="$cf_size/apps/$cf_base"
34360bd37d32Smrg				;;
34370bd37d32Smrg			esac
34380bd37d32Smrg			CF_VERBOSE(adding $cf_next)
34390bd37d32Smrg			cf_icon="${cf_icon}:${cf_next}"
34400bd37d32Smrg		fi
34410bd37d32Smrg		test -n "$ICON_LIST" && ICON_LIST="$ICON_LIST "
34420bd37d32Smrg		ICON_LIST="$ICON_LIST${cf_icon}"
34430bd37d32Smrg		if test -z "$ICON_NAME"
34440bd37d32Smrg		then
34450bd37d32Smrg			ICON_NAME=`basename $cf_icon | sed -e 's/[[.:]].*//'`
34460bd37d32Smrg		fi
34470bd37d32Smrg	done
34480bd37d32Smrgdone
34490bd37d32Smrg
34500bd37d32Smrgif test -n "$verbose"
34510bd37d32Smrgthen
34520bd37d32Smrg	AC_MSG_CHECKING(result)
34530bd37d32Smrgfi
34540bd37d32SmrgAC_MSG_RESULT($ICON_LIST)
34550bd37d32Smrg
34560bd37d32Smrgif test -z "$ICON_LIST"
34570bd37d32Smrgthen
34580bd37d32Smrg	AC_MSG_ERROR(no icons found)
34590bd37d32Smrgfi
34600bd37d32Smrg])
34610bd37d32Smrg
34620bd37d32SmrgAC_MSG_CHECKING(for icon name)
34630bd37d32SmrgAC_MSG_RESULT($ICON_NAME)
34640bd37d32Smrg
34650bd37d32SmrgAC_SUBST(ICON_FORMAT)
34660bd37d32SmrgAC_SUBST(ICON_THEME)
34670bd37d32SmrgAC_SUBST(ICON_LIST)
34680bd37d32SmrgAC_SUBST(ICON_NAME)
34690bd37d32Smrg])dnl
34700bd37d32Smrgdnl ---------------------------------------------------------------------------
347101037d57Smrgdnl CF_WITH_IMAKE_CFLAGS version: 10 updated: 2015/04/12 15:39:00
3472d522f475Smrgdnl --------------------
3473d522f475Smrgdnl xterm and similar programs build more readily when propped up with imake's
3474d522f475Smrgdnl hand-tuned definitions.  If we do not use imake, provide fallbacks for the
3475d522f475Smrgdnl most common definitions that we're not likely to do by autoconf tests.
3476d522f475SmrgAC_DEFUN([CF_WITH_IMAKE_CFLAGS],[
3477d522f475SmrgAC_REQUIRE([CF_ENABLE_NARROWPROTO])
3478d522f475Smrg
3479d522f475SmrgAC_MSG_CHECKING(if we should use imake to help)
3480d522f475SmrgCF_ARG_DISABLE(imake,
3481d522f475Smrg	[  --disable-imake         disable use of imake for definitions],
3482d522f475Smrg	[enable_imake=no],
3483d522f475Smrg	[enable_imake=yes])
3484d522f475SmrgAC_MSG_RESULT($enable_imake)
3485d522f475Smrg
3486d522f475Smrgif test "$enable_imake" = yes ; then
348720d2c4d2Smrg	CF_IMAKE_CFLAGS(ifelse([$1],,,[$1]))
3488d522f475Smrgfi
3489d522f475Smrg
3490d522f475Smrgif test -n "$IMAKE" && test -n "$IMAKE_CFLAGS" ; then
3491d522f475Smrg	CF_ADD_CFLAGS($IMAKE_CFLAGS)
3492d522f475Smrgelse
3493d522f475Smrg	IMAKE_CFLAGS=
3494d522f475Smrg	IMAKE_LOADFLAGS=
3495d522f475Smrg	CF_VERBOSE(make fallback definitions)
3496d522f475Smrg
3497d522f475Smrg	# We prefer config.guess' values when we can get them, to avoid
3498d522f475Smrg	# inconsistent results with uname (AIX for instance).  However,
3499d522f475Smrg	# config.guess is not always consistent either.
3500d522f475Smrg	case $host_os in
350101037d57Smrg	(*[[0-9]].[[0-9]]*)
3502d522f475Smrg		UNAME_RELEASE="$host_os"
3503d522f475Smrg		;;
350401037d57Smrg	(*)
3505d522f475Smrg		UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
3506d522f475Smrg		;;
3507d522f475Smrg	esac
3508d522f475Smrg
3509d522f475Smrg	case .$UNAME_RELEASE in
351001037d57Smrg	(*[[0-9]].[[0-9]]*)
3511d522f475Smrg		OSMAJORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/\..*//'`
3512d522f475Smrg		OSMINORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/^[[^.]]*\.//' -e 's/\..*//' -e 's/[[^0-9]].*//' `
3513d522f475Smrg		test -z "$OSMAJORVERSION" && OSMAJORVERSION=1
3514d522f475Smrg		test -z "$OSMINORVERSION" && OSMINORVERSION=0
3515d522f475Smrg		IMAKE_CFLAGS="-DOSMAJORVERSION=$OSMAJORVERSION -DOSMINORVERSION=$OSMINORVERSION $IMAKE_CFLAGS"
3516d522f475Smrg		;;
3517d522f475Smrg	esac
3518d522f475Smrg
3519d522f475Smrg	# FUNCPROTO is standard with X11R6, but XFree86 drops it, leaving some
3520d522f475Smrg	# fallback/fragments for NeedPrototypes, etc.
3521d522f475Smrg	IMAKE_CFLAGS="-DFUNCPROTO=15 $IMAKE_CFLAGS"
3522d522f475Smrg
3523d522f475Smrg	# If this is not set properly, Xaw's scrollbars will not work
3524d522f475Smrg	if test "$enable_narrowproto" = yes ; then
3525d522f475Smrg		IMAKE_CFLAGS="-DNARROWPROTO=1 $IMAKE_CFLAGS"
3526d522f475Smrg	fi
3527d522f475Smrg
3528d522f475Smrg	# Other special definitions:
3529d522f475Smrg	case $host_os in
353001037d57Smrg	(aix*)
3531d522f475Smrg		# imake on AIX 5.1 defines AIXV3.  really.
3532d522f475Smrg		IMAKE_CFLAGS="-DAIXV3 -DAIXV4 $IMAKE_CFLAGS"
3533d522f475Smrg		;;
353401037d57Smrg	(irix[[56]].*)
3535d522f475Smrg		# these are needed to make SIGWINCH work in xterm
3536d522f475Smrg		IMAKE_CFLAGS="-DSYSV -DSVR4 $IMAKE_CFLAGS"
3537d522f475Smrg		;;
3538d522f475Smrg	esac
3539d522f475Smrg
3540d522f475Smrg	CF_ADD_CFLAGS($IMAKE_CFLAGS)
3541d522f475Smrg
3542d522f475Smrg	AC_SUBST(IMAKE_CFLAGS)
3543d522f475Smrg	AC_SUBST(IMAKE_LOADFLAGS)
3544d522f475Smrgfi
3545d522f475Smrg])dnl
3546d522f475Smrgdnl ---------------------------------------------------------------------------
354701037d57Smrgdnl CF_WITH_MAN2HTML version: 3 updated: 2015/04/12 15:39:00
354801037d57Smrgdnl ----------------
354901037d57Smrgdnl Check for man2html and groff.  Optionally prefer man2html over groff.
355001037d57Smrgdnl Generate a shell script which hides the differences between the two.
355101037d57Smrgdnl
355201037d57Smrgdnl We name that "man2html.tmp".
355301037d57Smrgdnl
355401037d57Smrgdnl The shell script can be removed later, e.g., using "make distclean".
355501037d57SmrgAC_DEFUN([CF_WITH_MAN2HTML],[
355601037d57SmrgAC_REQUIRE([CF_PROG_GROFF])
355701037d57Smrg
355801037d57SmrgAC_MSG_CHECKING(for program to convert manpage to html)
355901037d57SmrgAC_ARG_WITH(man2html,
356001037d57Smrg	[  --with-man2html=XXX     use XXX rather than groff],
356101037d57Smrg	[cf_man2html=$withval],
356201037d57Smrg	[cf_man2html=$GROFF_PATH])
356301037d57Smrg
356401037d57Smrgcf_with_groff=no
356501037d57Smrg
356601037d57Smrgcase $cf_man2html in
356701037d57Smrg(yes)
356801037d57Smrg	AC_MSG_RESULT(man2html)
356901037d57Smrg	AC_PATH_PROG(cf_man2html,man2html,no)
357001037d57Smrg	;;
357101037d57Smrg(no|groff|*/groff*)
357201037d57Smrg	cf_with_groff=yes
357301037d57Smrg	cf_man2html=$GROFF_PATH
357401037d57Smrg	AC_MSG_RESULT($cf_man2html)
357501037d57Smrg	;;
357601037d57Smrg(*)
357701037d57Smrg	AC_MSG_RESULT($cf_man2html)
357801037d57Smrg	;;
357901037d57Smrgesac
358001037d57Smrg
358101037d57SmrgMAN2HTML_TEMP="man2html.tmp"
358201037d57Smrg	cat >$MAN2HTML_TEMP <<CF_EOF
358301037d57Smrg#!/bin/sh
358401037d57Smrg# Temporary script generated by CF_WITH_MAN2HTML
358501037d57Smrg# Convert inputs to html, sending result to standard output.
358601037d57Smrg#
358701037d57Smrg# Parameters:
358801037d57Smrg# $1 = rootname of file to convert
358901037d57Smrg# $2 = suffix of file to convert, e.g., "1"
359001037d57Smrg# $3 = macros to use, e.g., "man"
359101037d57Smrg#
359201037d57SmrgROOT=\[$]1
359301037d57SmrgTYPE=\[$]2
359401037d57SmrgMACS=\[$]3
359501037d57Smrg
359601037d57Smrgunset LANG
359701037d57Smrgunset LC_ALL
359801037d57Smrgunset LC_CTYPE
359901037d57Smrgunset LANGUAGE
360001037d57SmrgGROFF_NO_SGR=stupid
360101037d57Smrgexport GROFF_NO_SGR
360201037d57Smrg
360301037d57SmrgCF_EOF
360401037d57Smrg
360501037d57Smrgif test "x$cf_with_groff" = xyes
360601037d57Smrgthen
360701037d57Smrg	MAN2HTML_NOTE="$GROFF_NOTE"
360801037d57Smrg	MAN2HTML_PATH="$GROFF_PATH"
360901037d57Smrg	cat >>$MAN2HTML_TEMP <<CF_EOF
361001037d57Smrg/bin/sh -c "tbl \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
361101037d57SmrgCF_EOF
361201037d57Smrgelse
361301037d57Smrg	MAN2HTML_NOTE=""
361401037d57Smrg	CF_PATH_SYNTAX(cf_man2html)
361501037d57Smrg	MAN2HTML_PATH="$cf_man2html"
361601037d57Smrg	AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
361701037d57Smrg
361801037d57Smrg	# for this example, expect 3 lines of content, the remainder is head/foot
361901037d57Smrg	cat >conftest.in <<CF_EOF
362001037d57Smrg.TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
362101037d57Smrg.SH SECTION
362201037d57SmrgMARKER
362301037d57SmrgCF_EOF
362401037d57Smrg
362501037d57Smrg	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C nroff -man conftest.in >conftest.out
362601037d57Smrg
362701037d57Smrg	cf_man2html_1st=`fgrep -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
362801037d57Smrg	cf_man2html_top=`expr $cf_man2html_1st - 2`
362901037d57Smrg	cf_man2html_bot=`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`
363001037d57Smrg	cf_man2html_bot=`expr $cf_man2html_bot - 2 - $cf_man2html_top`
363101037d57Smrg	cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
363201037d57Smrg
363301037d57Smrg	AC_MSG_RESULT($cf_man2html_top_bot)
363401037d57Smrg
363501037d57Smrg	AC_MSG_CHECKING(for pagesize to use)
363601037d57Smrg	for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
363701037d57Smrg	do
363801037d57Smrg	cat >>conftest.in <<CF_EOF
363901037d57Smrg.nf
364001037d57Smrg0
364101037d57Smrg1
364201037d57Smrg2
364301037d57Smrg3
364401037d57Smrg4
364501037d57Smrg5
364601037d57Smrg6
364701037d57Smrg7
364801037d57Smrg8
364901037d57Smrg9
365001037d57SmrgCF_EOF
365101037d57Smrg	done
365201037d57Smrg
365301037d57Smrg	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C nroff -man conftest.in >conftest.out
365401037d57Smrg	cf_man2html_page=`fgrep -n HEAD1 conftest.out |tail -n 1 |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
365501037d57Smrg	test -z "$cf_man2html_page" && cf_man2html_page=99999
365601037d57Smrg	test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
365701037d57Smrg
365801037d57Smrg	rm -rf conftest*
365901037d57Smrg	AC_MSG_RESULT($cf_man2html_page)
366001037d57Smrg
366101037d57Smrg	cat >>$MAN2HTML_TEMP <<CF_EOF
366201037d57Smrg: \${MAN2HTML_PATH=$MAN2HTML_PATH}
366301037d57SmrgMAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title="\$ROOT\(\$TYPE\)" -compress -pgsize $cf_man2html_page"
366401037d57Smrgcase \${TYPE} in
366501037d57Smrg(ms)
366601037d57Smrg	tbl \${ROOT}.\${TYPE} | nroff -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
366701037d57Smrg	;;
366801037d57Smrg(*)
366901037d57Smrg	tbl \${ROOT}.\${TYPE} | nroff -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
367001037d57Smrg	;;
367101037d57Smrgesac
367201037d57SmrgCF_EOF
367301037d57Smrgfi
367401037d57Smrg
367501037d57Smrgchmod 700 $MAN2HTML_TEMP
367601037d57Smrg
367701037d57SmrgAC_SUBST(MAN2HTML_NOTE)
367801037d57SmrgAC_SUBST(MAN2HTML_PATH)
367901037d57SmrgAC_SUBST(MAN2HTML_TEMP)
368001037d57Smrg])dnl
368101037d57Smrgdnl ---------------------------------------------------------------------------
368201037d57Smrgdnl CF_WITH_PCRE version: 11 updated: 2015/04/12 15:39:00
3683d522f475Smrgdnl ------------
3684d522f475Smrgdnl Add PCRE (Perl-compatible regular expressions) to the build if it is
3685d522f475Smrgdnl available and the user requests it.  Assume the application will otherwise
3686d522f475Smrgdnl use the POSIX interface.
3687d522f475Smrgdnl
3688d522f475Smrgdnl TODO allow $withval to specify package location
3689d522f475SmrgAC_DEFUN([CF_WITH_PCRE],
3690d522f475Smrg[
369120d2c4d2SmrgAC_REQUIRE([CF_PKG_CONFIG])
369220d2c4d2Smrg
3693d522f475SmrgAC_MSG_CHECKING(if you want to use PCRE for regular-expressions)
3694d522f475SmrgAC_ARG_WITH(pcre,
3695d522f475Smrg	[  --with-pcre             use PCRE for regular-expressions])
3696d522f475Smrgtest -z "$with_pcre" && with_pcre=no
3697d522f475SmrgAC_MSG_RESULT($with_pcre)
3698d522f475Smrg
3699d522f475Smrgif test "$with_pcre" != no ; then
370020d2c4d2Smrg	CF_TRY_PKG_CONFIG(libpcre,,[
370120d2c4d2Smrg		AC_CHECK_LIB(pcre,pcre_compile,,
370220d2c4d2Smrg			AC_MSG_ERROR(Cannot find PCRE library))])
370320d2c4d2Smrg
37040bd37d32Smrg		AC_DEFINE(HAVE_LIB_PCRE,1,[Define to 1 if we can/should compile with the PCRE library])
370520d2c4d2Smrg
370601037d57Smrg		case $LIBS in
370701037d57Smrg		(*pcreposix*)
370820d2c4d2Smrg			;;
370901037d57Smrg		(*)
371020d2c4d2Smrg			AC_CHECK_LIB(pcreposix,pcreposix_regcomp,
37110bd37d32Smrg				[AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we should include pcreposix.h])
371220d2c4d2Smrg				 CF_ADD_LIB(pcreposix)],
371320d2c4d2Smrg				[AC_CHECK_LIB(pcreposix,regcomp,[
37140bd37d32Smrg					AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we should include pcreposix.h])
371520d2c4d2Smrg					CF_ADD_LIB(pcreposix)],
371620d2c4d2Smrg					AC_MSG_ERROR(Cannot find PCRE POSIX library)]))
371720d2c4d2Smrg			;;
371820d2c4d2Smrg		esac
3719d522f475Smrgfi
3720d522f475Smrg])dnl
3721d522f475Smrgdnl ---------------------------------------------------------------------------
37220bd37d32Smrgdnl CF_WITH_PIXMAPDIR version: 3 updated: 2012/07/22 09:18:02
37230bd37d32Smrgdnl -----------------
37240bd37d32Smrgdnl Handle configure option "--with-pixmapdir", setting these shell variables:
37250bd37d32Smrgdnl
37260bd37d32Smrgdnl $PIXMAPDIR is the option value, used for installing pixmap files.
37270bd37d32Smrgdnl $no_pixmapdir is a "#" (comment) if "--without-pixmapdir" is given.
37280bd37d32SmrgAC_DEFUN([CF_WITH_PIXMAPDIR],[
37290bd37d32SmrgAC_MSG_CHECKING(for directory to install pixmaps)
37300bd37d32SmrgAC_ARG_WITH(pixmapdir,
37310bd37d32Smrg	[  --with-pixmapdir=DIR    directory in which to install pixmaps (DATADIR/pixmaps)],
37320bd37d32Smrg	[PIXMAPDIR=$withval],
37330bd37d32Smrg	[test -z "$PIXMAPDIR" && PIXMAPDIR='${datadir}/pixmaps'])
37340bd37d32Smrg
37350bd37d32Smrgif test "x[$]PIXMAPDIR" = xauto
37360bd37d32Smrgthen
37370bd37d32Smrg	PIXMAPDIR='${datadir}/pixmaps'
37380bd37d32Smrg	for cf_path in \
37390bd37d32Smrg		/usr/share/pixmaps \
37400bd37d32Smrg		/usr/X11R6/share/pixmaps
37410bd37d32Smrg	do
37420bd37d32Smrg		if test -d "$cf_path" ; then
37430bd37d32Smrg			PIXMAPDIR="$cf_path"
37440bd37d32Smrg			break
37450bd37d32Smrg		fi
37460bd37d32Smrg	done
37470bd37d32Smrgelse
37480bd37d32Smrg	cf_path=$PIXMAPDIR
37490bd37d32Smrg	CF_PATH_SYNTAX(cf_path)
37500bd37d32Smrgfi
37510bd37d32SmrgAC_MSG_RESULT($PIXMAPDIR)
37520bd37d32SmrgAC_SUBST(PIXMAPDIR)
37530bd37d32Smrg
37540bd37d32Smrgno_pixmapdir=
37550bd37d32Smrgif test "$PIXMAPDIR" = no
37560bd37d32Smrgthen
37570bd37d32Smrg	no_pixmapdir="#"
37580bd37d32Smrgelse
37590bd37d32Smrg	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(PIXMAPDIR)"
37600bd37d32Smrgfi
37610bd37d32SmrgAC_SUBST(no_pixmapdir)
37620bd37d32Smrg])dnl
37630bd37d32Smrgdnl ---------------------------------------------------------------------------
37640bd37d32Smrgdnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
37650bd37d32Smrgdnl ----------------
37660bd37d32SmrgAC_DEFUN([CF_WITH_VALGRIND],[
37670bd37d32SmrgCF_NO_LEAKS_OPTION(valgrind,
37680bd37d32Smrg	[  --with-valgrind         test: use valgrind],
37690bd37d32Smrg	[USE_VALGRIND])
37700bd37d32Smrg])dnl
37710bd37d32Smrgdnl ---------------------------------------------------------------------------
37720bd37d32Smrgdnl CF_WITH_XPM version: 3 updated: 2012/10/04 06:57:36
37730bd37d32Smrgdnl -----------
37740bd37d32Smrgdnl Test for Xpm library, update compiler/loader flags if it is wanted and
37750bd37d32Smrgdnl found.
37760bd37d32Smrgdnl
37770bd37d32Smrgdnl Also sets ICON_SUFFIX
37780bd37d32SmrgAC_DEFUN([CF_WITH_XPM],
37790bd37d32Smrg[
37800bd37d32SmrgICON_SUFFIX=.xbm
37810bd37d32Smrg
37820bd37d32Smrgcf_save_cppflags="${CPPFLAGS}"
37830bd37d32Smrgcf_save_ldflags="${LDFLAGS}"
37840bd37d32Smrg
37850bd37d32SmrgAC_MSG_CHECKING(if you want to use the Xpm library for colored icon)
37860bd37d32SmrgAC_ARG_WITH(xpm,
37870bd37d32Smrg[  --with-xpm=DIR          use Xpm library for colored icon, may specify path],
37880bd37d32Smrg	[cf_Xpm_library="$withval"],
37890bd37d32Smrg	[cf_Xpm_library=yes])
37900bd37d32SmrgAC_MSG_RESULT($cf_Xpm_library)
37910bd37d32Smrg
37920bd37d32Smrgif test "$cf_Xpm_library" != no ; then
37930bd37d32Smrg    if test "$cf_Xpm_library" != yes ; then
37940bd37d32Smrg	CPPFLAGS="$CPPFLAGS -I$withval/include"
37950bd37d32Smrg	LDFLAGS="$LDFLAGS -L$withval/lib"
37960bd37d32Smrg    fi
37970bd37d32Smrg    AC_CHECK_HEADER(X11/xpm.h,[
37980bd37d32Smrg	AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData,[
37990bd37d32Smrg	    AC_DEFINE(HAVE_LIBXPM,1,[Define to 1 if we should use Xpm library])
38000bd37d32Smrg	    ICON_SUFFIX=.xpm
38010bd37d32Smrg	    LIBS="-lXpm $LIBS"],
38020bd37d32Smrg	    [CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"],
38030bd37d32Smrg	    [-lX11 $X_LIBS])],
38040bd37d32Smrg	[CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"])
38050bd37d32Smrgfi
38060bd37d32Smrg
38070bd37d32SmrgAC_SUBST(ICON_SUFFIX)
38080bd37d32Smrg])dnl
38090bd37d32Smrgdnl ---------------------------------------------------------------------------
381001037d57Smrgdnl CF_XBOOL_RESULT version: 3 updated: 2015/04/12 15:39:00
38110bd37d32Smrgdnl ---------------
38120bd37d32Smrgdnl Translate an autoconf boolean yes/no into X11's booleans, e.g., True/False.
38130bd37d32Smrgdnl Allow for more than two values, e.g., "maybe", still using the same leading
38140bd37d32Smrgdnl capital convention.
38150bd37d32Smrgdnl
38160bd37d32Smrgdnl $1 = symbol to define
38170bd37d32Smrgdnl $2 = symbol holding value
38180bd37d32Smrgdnl $3 = description
38190bd37d32Smrgdefine([CF_XBOOL_RESULT],[
38200bd37d32SmrgAC_MSG_RESULT([$]$2)
382101037d57Smrgcase [$]$2 in
382201037d57Smrg(yes)
38230bd37d32Smrg	$2=true
38240bd37d32Smrg	;;
382501037d57Smrg(no)
38260bd37d32Smrg	$2=false
38270bd37d32Smrg	;;
38280bd37d32Smrgesac
38290bd37d32Smrgcf_xbool1=`echo "[$]$2"|sed -e 's/^\(.\).*/\1/'`
38300bd37d32SmrgCF_UPPER(cf_xbool1,$cf_xbool1)
38310bd37d32Smrgcf_xbool2=`echo "[$]$2"|sed -e 's/^.//'`
38320bd37d32Smrg$2=${cf_xbool1}${cf_xbool2}
38330bd37d32SmrgAC_DEFINE_UNQUOTED($1,[$]$2,$3)
38340bd37d32SmrgAC_SUBST($2)
38350bd37d32Smrg])
38360bd37d32Smrgdnl ---------------------------------------------------------------------------
383701037d57Smrgdnl CF_XINERAMA version: 2 updated: 2015/02/15 15:18:41
383801037d57Smrgdnl -----------
383901037d57SmrgAC_DEFUN([CF_XINERAMA],[
384001037d57SmrgCF_TRY_PKG_CONFIG(xinerama,[
384101037d57Smrg	AC_DEFINE(HAVE_X11_EXTENSIONS_XINERAMA_H)],[
384201037d57Smrg	AC_CHECK_LIB(Xinerama,XineramaQueryScreens,
384301037d57Smrg		[CF_ADD_LIB(Xinerama)
384401037d57Smrg		 AC_CHECK_HEADERS( \
384501037d57Smrg			X11/extensions/Xinerama.h \
384601037d57Smrg			)
384701037d57Smrg		])
384801037d57Smrg	])
384901037d57Smrg])dnl
385001037d57Smrgdnl ---------------------------------------------------------------------------
38510bd37d32Smrgdnl CF_XKB_BELL_EXT version: 4 updated: 2012/10/04 20:12:20
3852d522f475Smrgdnl ---------------
3853d522f475Smrgdnl Check for XKB bell extension
3854d522f475SmrgAC_DEFUN([CF_XKB_BELL_EXT],[
3855d522f475SmrgAC_CACHE_CHECK(for XKB Bell extension, cf_cv_xkb_bell_ext,[
3856d522f475SmrgAC_TRY_LINK([
3857956cc18dSsnj#include <X11/Intrinsic.h>
3858d522f475Smrg#include <X11/XKBlib.h>		/* has the prototype */
3859d522f475Smrg#include <X11/extensions/XKBbells.h>	/* has the XkbBI_xxx definitions */
3860d522f475Smrg],[
3861956cc18dSsnj	int x = (XkbBI_Info |XkbBI_MinorError |XkbBI_MajorError |XkbBI_TerminalBell |XkbBI_MarginBell);
3862956cc18dSsnj	Atom y;
3863956cc18dSsnj	XkbBell((Display *)0, (Widget)0, 0, y);
3864d522f475Smrg],[cf_cv_xkb_bell_ext=yes],[cf_cv_xkb_bell_ext=no])
3865d522f475Smrg])
38660bd37d32Smrgtest "$cf_cv_xkb_bell_ext" = yes && AC_DEFINE(HAVE_XKB_BELL_EXT,1,[Define 1 if we have XKB Bell extension])
38670bd37d32Smrg])
38680bd37d32Smrgdnl ---------------------------------------------------------------------------
38690bd37d32Smrgdnl CF_XKB_KEYCODE_TO_KEYSYM version: 2 updated: 2012/09/28 20:23:33
38700bd37d32Smrgdnl ------------------------
38710bd37d32Smrgdnl Some older vendor-unix systems made a practice of delivering fragments of
38720bd37d32Smrgdnl Xkb, requiring test-compiles.
38730bd37d32SmrgAC_DEFUN([CF_XKB_KEYCODE_TO_KEYSYM],[
38740bd37d32SmrgAC_CACHE_CHECK(if we can use XkbKeycodeToKeysym, cf_cv_xkb_keycode_to_keysym,[
38750bd37d32SmrgAC_TRY_COMPILE([
38760bd37d32Smrg#include <X11/Xlib.h>
38770bd37d32Smrg#include <X11/XKBlib.h>
38780bd37d32Smrg],[
38790bd37d32Smrg    KeySym keysym = XkbKeycodeToKeysym((Display *)0, 0, 0, 0);
38800bd37d32Smrg],[
38810bd37d32Smrgcf_cv_xkb_keycode_to_keysym=yes
38820bd37d32Smrg],[
38830bd37d32Smrgcf_cv_xkb_keycode_to_keysym=no
38840bd37d32Smrg])
38850bd37d32Smrg])
38860bd37d32Smrg
38870bd37d32Smrgif test $cf_cv_xkb_keycode_to_keysym = yes
38880bd37d32Smrgthen
38890bd37d32Smrg	AC_CHECK_FUNCS(XkbKeycodeToKeysym)
38900bd37d32Smrgfi
38910bd37d32Smrg])
38920bd37d32Smrgdnl ---------------------------------------------------------------------------
38930bd37d32Smrgdnl CF_XKB_QUERY_EXTENSION version: 2 updated: 2012/09/28 20:23:46
38940bd37d32Smrgdnl ----------------------
38950bd37d32Smrgdnl see ifdef in scrollbar.c - iron out here
38960bd37d32SmrgAC_DEFUN([CF_XKB_QUERY_EXTENSION],[
38970bd37d32SmrgAC_CACHE_CHECK(if we can use XkbQueryExtension, cf_cv_xkb_query_extension,[
38980bd37d32SmrgAC_TRY_COMPILE([
38990bd37d32Smrg#include <X11/Xlib.h>
39000bd37d32Smrg#include <X11/extensions/XKB.h>
39010bd37d32Smrg#include <X11/XKBlib.h>
39020bd37d32Smrg],[
39030bd37d32Smrg	int xkbmajor = XkbMajorVersion;
39040bd37d32Smrg	int xkbminor = XkbMinorVersion;
39050bd37d32Smrg	int xkbopcode, xkbevent, xkberror;
39060bd37d32Smrg
39070bd37d32Smrg	if (XkbLibraryVersion(&xkbmajor, &xkbminor)
39080bd37d32Smrg	    && XkbQueryExtension((Display *)0,
39090bd37d32Smrg				 &xkbopcode,
39100bd37d32Smrg				 &xkbevent,
39110bd37d32Smrg				 &xkberror,
39120bd37d32Smrg				 &xkbmajor,
39130bd37d32Smrg				 &xkbminor))
39140bd37d32Smrg		 return 0;
39150bd37d32Smrg],[
39160bd37d32Smrgcf_cv_xkb_query_extension=yes
39170bd37d32Smrg],[
39180bd37d32Smrgcf_cv_xkb_query_extension=no
39190bd37d32Smrg])
39200bd37d32Smrg])
39210bd37d32Smrg
39220bd37d32Smrgif test $cf_cv_xkb_query_extension = yes
39230bd37d32Smrgthen
39240bd37d32Smrg	AC_CHECK_FUNCS(XkbQueryExtension)
39250bd37d32Smrgfi
3926d522f475Smrg])
3927d522f475Smrgdnl ---------------------------------------------------------------------------
392801037d57Smrgdnl CF_XOPEN_SOURCE version: 49 updated: 2015/04/12 15:39:00
3929d522f475Smrgdnl ---------------
3930d522f475Smrgdnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3931d522f475Smrgdnl or adapt to the vendor's definitions to get equivalent functionality,
3932d522f475Smrgdnl without losing the common non-POSIX features.
3933d522f475Smrgdnl
3934d522f475Smrgdnl Parameters:
3935d522f475Smrgdnl	$1 is the nominal value for _XOPEN_SOURCE
3936d522f475Smrgdnl	$2 is the nominal value for _POSIX_C_SOURCE
3937d522f475SmrgAC_DEFUN([CF_XOPEN_SOURCE],[
39380bd37d32SmrgAC_REQUIRE([AC_CANONICAL_HOST])
3939d522f475Smrg
394020d2c4d2Smrgcf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
394120d2c4d2Smrgcf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
394220d2c4d2Smrgcf_xopen_source=
3943d522f475Smrg
394401037d57Smrgcase $host_os in
394501037d57Smrg(aix[[4-7]]*)
394620d2c4d2Smrg	cf_xopen_source="-D_ALL_SOURCE"
394720d2c4d2Smrg	;;
394801037d57Smrg(cygwin|msys)
3949e39b573cSmrg	cf_XOPEN_SOURCE=600
3950e39b573cSmrg	;;
395101037d57Smrg(darwin[[0-8]].*)
395220d2c4d2Smrg	cf_xopen_source="-D_APPLE_C_SOURCE"
395320d2c4d2Smrg	;;
395401037d57Smrg(darwin*)
395520d2c4d2Smrg	cf_xopen_source="-D_DARWIN_C_SOURCE"
39560bd37d32Smrg	cf_XOPEN_SOURCE=
3957d522f475Smrg	;;
395801037d57Smrg(freebsd*|dragonfly*)
3959d522f475Smrg	# 5.x headers associate
3960d522f475Smrg	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
3961d522f475Smrg	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
3962d522f475Smrg	cf_POSIX_C_SOURCE=200112L
3963d522f475Smrg	cf_XOPEN_SOURCE=600
396420d2c4d2Smrg	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
396520d2c4d2Smrg	;;
396601037d57Smrg(hpux11*)
396720d2c4d2Smrg	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3968d522f475Smrg	;;
396901037d57Smrg(hpux*)
397020d2c4d2Smrg	cf_xopen_source="-D_HPUX_SOURCE"
3971d522f475Smrg	;;
397201037d57Smrg(irix[[56]].*)
397320d2c4d2Smrg	cf_xopen_source="-D_SGI_SOURCE"
39740bd37d32Smrg	cf_XOPEN_SOURCE=
3975d522f475Smrg	;;
397601037d57Smrg(linux*|gnu*|mint*|k*bsd*-gnu)
3977d522f475Smrg	CF_GNU_SOURCE
3978d522f475Smrg	;;
397901037d57Smrg(minix*)
398001037d57Smrg	cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
398101037d57Smrg	;;
398201037d57Smrg(mirbsd*)
39830bd37d32Smrg	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
39840bd37d32Smrg	cf_XOPEN_SOURCE=
39850bd37d32Smrg	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3986d522f475Smrg	;;
398701037d57Smrg(netbsd*)
39880bd37d32Smrg	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
39890bd37d32Smrg	;;
399001037d57Smrg(openbsd[[4-9]]*)
39910bd37d32Smrg	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
39920bd37d32Smrg	cf_xopen_source="-D_BSD_SOURCE"
39930bd37d32Smrg	cf_XOPEN_SOURCE=600
3994d522f475Smrg	;;
399501037d57Smrg(openbsd*)
3996d522f475Smrg	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3997d522f475Smrg	;;
399801037d57Smrg(osf[[45]]*)
399920d2c4d2Smrg	cf_xopen_source="-D_OSF_SOURCE"
4000d522f475Smrg	;;
400101037d57Smrg(nto-qnx*)
400220d2c4d2Smrg	cf_xopen_source="-D_QNX_SOURCE"
4003d522f475Smrg	;;
400401037d57Smrg(sco*)
4005d522f475Smrg	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
4006d522f475Smrg	;;
400701037d57Smrg(solaris2.*)
400820d2c4d2Smrg	cf_xopen_source="-D__EXTENSIONS__"
4009894e0ac8Smrg	cf_cv_xopen_source=broken
4010d522f475Smrg	;;
401101037d57Smrg(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
401201037d57Smrg	cf_XOPEN_SOURCE=
401301037d57Smrg	cf_POSIX_C_SOURCE=
401401037d57Smrg	;;
401501037d57Smrg(*)
40160bd37d32Smrg	CF_TRY_XOPEN_SOURCE
4017d522f475Smrg	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
4018d522f475Smrg	;;
4019d522f475Smrgesac
402020d2c4d2Smrg
402120d2c4d2Smrgif test -n "$cf_xopen_source" ; then
402201037d57Smrg	CF_ADD_CFLAGS($cf_xopen_source,true)
402320d2c4d2Smrgfi
40240bd37d32Smrg
40250bd37d32Smrgdnl In anything but the default case, we may have system-specific setting
40260bd37d32Smrgdnl which is still not guaranteed to provide all of the entrypoints that
40270bd37d32Smrgdnl _XOPEN_SOURCE would yield.
40280bd37d32Smrgif test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
40290bd37d32Smrg	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
40300bd37d32Smrg	AC_TRY_COMPILE([#include <stdlib.h>],[
40310bd37d32Smrg#ifndef _XOPEN_SOURCE
40320bd37d32Smrgmake an error
40330bd37d32Smrg#endif],
40340bd37d32Smrg	[cf_XOPEN_SOURCE_set=yes],
40350bd37d32Smrg	[cf_XOPEN_SOURCE_set=no])
40360bd37d32Smrg	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
40370bd37d32Smrg	if test $cf_XOPEN_SOURCE_set = yes
40380bd37d32Smrg	then
40390bd37d32Smrg		AC_TRY_COMPILE([#include <stdlib.h>],[
40400bd37d32Smrg#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
40410bd37d32Smrgmake an error
40420bd37d32Smrg#endif],
40430bd37d32Smrg		[cf_XOPEN_SOURCE_set_ok=yes],
40440bd37d32Smrg		[cf_XOPEN_SOURCE_set_ok=no])
40450bd37d32Smrg		if test $cf_XOPEN_SOURCE_set_ok = no
40460bd37d32Smrg		then
40470bd37d32Smrg			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
40480bd37d32Smrg		fi
40490bd37d32Smrg	else
40500bd37d32Smrg		CF_TRY_XOPEN_SOURCE
40510bd37d32Smrg	fi
40520bd37d32Smrgfi
4053d522f475Smrg])
4054d522f475Smrgdnl ---------------------------------------------------------------------------
405501037d57Smrgdnl CF_X_ATHENA version: 23 updated: 2015/04/12 15:39:00
4056d522f475Smrgdnl -----------
4057d522f475Smrgdnl Check for Xaw (Athena) libraries
4058d522f475Smrgdnl
4059d522f475Smrgdnl Sets $cf_x_athena according to the flavor of Xaw which is used.
4060d522f475SmrgAC_DEFUN([CF_X_ATHENA],
406120d2c4d2Smrg[
40626879286fSmrgcf_x_athena=${cf_x_athena:-Xaw}
4063d522f475Smrg
4064d522f475SmrgAC_MSG_CHECKING(if you want to link with Xaw 3d library)
4065d522f475Smrgwithval=
4066d522f475SmrgAC_ARG_WITH(Xaw3d,
4067d522f475Smrg	[  --with-Xaw3d            link with Xaw 3d library])
4068d522f475Smrgif test "$withval" = yes ; then
4069d522f475Smrg	cf_x_athena=Xaw3d
4070d522f475Smrg	AC_MSG_RESULT(yes)
4071d522f475Smrgelse
4072d522f475Smrg	AC_MSG_RESULT(no)
4073d522f475Smrgfi
4074d522f475Smrg
407501037d57SmrgAC_MSG_CHECKING(if you want to link with Xaw 3d xft library)
407601037d57Smrgwithval=
407701037d57SmrgAC_ARG_WITH(Xaw3dxft,
407801037d57Smrg	[  --with-Xaw3dxft         link with Xaw 3d xft library])
407901037d57Smrgif test "$withval" = yes ; then
408001037d57Smrg	cf_x_athena=Xaw3dxft
408101037d57Smrg	AC_MSG_RESULT(yes)
408201037d57Smrgelse
408301037d57Smrg	AC_MSG_RESULT(no)
408401037d57Smrgfi
408501037d57Smrg
4086d522f475SmrgAC_MSG_CHECKING(if you want to link with neXT Athena library)
4087d522f475Smrgwithval=
4088d522f475SmrgAC_ARG_WITH(neXtaw,
4089d522f475Smrg	[  --with-neXtaw           link with neXT Athena library])
4090d522f475Smrgif test "$withval" = yes ; then
4091d522f475Smrg	cf_x_athena=neXtaw
4092d522f475Smrg	AC_MSG_RESULT(yes)
4093d522f475Smrgelse
4094d522f475Smrg	AC_MSG_RESULT(no)
4095d522f475Smrgfi
4096d522f475Smrg
4097d522f475SmrgAC_MSG_CHECKING(if you want to link with Athena-Plus library)
4098d522f475Smrgwithval=
4099d522f475SmrgAC_ARG_WITH(XawPlus,
4100d522f475Smrg	[  --with-XawPlus          link with Athena-Plus library])
4101d522f475Smrgif test "$withval" = yes ; then
4102d522f475Smrg	cf_x_athena=XawPlus
4103d522f475Smrg	AC_MSG_RESULT(yes)
4104d522f475Smrgelse
4105d522f475Smrg	AC_MSG_RESULT(no)
4106d522f475Smrgfi
4107d522f475Smrg
4108d522f475Smrgcf_x_athena_lib=""
4109d522f475Smrg
411020d2c4d2Smrgif test "$PKG_CONFIG" != none ; then
411120d2c4d2Smrg	cf_athena_list=
411220d2c4d2Smrg	test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
411320d2c4d2Smrg	for cf_athena_pkg in \
411420d2c4d2Smrg		$cf_athena_list \
411520d2c4d2Smrg		${cf_x_athena} \
411620d2c4d2Smrg		${cf_x_athena}-devel \
411720d2c4d2Smrg		lib${cf_x_athena} \
411820d2c4d2Smrg		lib${cf_x_athena}-devel
411920d2c4d2Smrg	do
412020d2c4d2Smrg		CF_TRY_PKG_CONFIG($cf_athena_pkg,[
412120d2c4d2Smrg			cf_x_athena_lib="$cf_pkgconfig_libs"
412220d2c4d2Smrg			CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
412320d2c4d2Smrg			AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
41246879286fSmrg
4125e0a2b6dfSmrg			CF_TRIM_X_LIBS
4126e0a2b6dfSmrg
41276879286fSmrgAC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
41286879286fSmrgAC_TRY_LINK([
41296879286fSmrg#include <X11/Xmu/CharSet.h>
41306879286fSmrg],[
41316879286fSmrgint check = XmuCompareISOLatin1("big", "small")
41326879286fSmrg],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
41336879286fSmrg
41346879286fSmrg			if test "$cf_cv_xaw_compat" = no
41356879286fSmrg			then
41366879286fSmrg				# workaround for broken ".pc" files...
413701037d57Smrg				case "$cf_x_athena_lib" in
413801037d57Smrg				(*-lXmu*)
41396879286fSmrg					;;
414001037d57Smrg				(*)
41416879286fSmrg					CF_VERBOSE(work around broken package)
4142e0a2b6dfSmrg					cf_save_xmu="$LIBS"
4143e0a2b6dfSmrg					cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
4144e0a2b6dfSmrg					CF_TRY_PKG_CONFIG(xmu,[
4145e0a2b6dfSmrg							LIBS="$cf_save_xmu"
4146e0a2b6dfSmrg							CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
4147e0a2b6dfSmrg						],[
4148e0a2b6dfSmrg							CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
4149e0a2b6dfSmrg						])
4150e0a2b6dfSmrg					CF_TRIM_X_LIBS
41516879286fSmrg					;;
41526879286fSmrg				esac
41536879286fSmrg			fi
41546879286fSmrg
415520d2c4d2Smrg			break])
415620d2c4d2Smrg	done
415720d2c4d2Smrgfi
415820d2c4d2Smrg
415920d2c4d2Smrgif test -z "$cf_x_athena_lib" ; then
416020d2c4d2Smrg	CF_X_EXT
416120d2c4d2Smrg	CF_X_TOOLKIT
416220d2c4d2Smrg	CF_X_ATHENA_CPPFLAGS($cf_x_athena)
416320d2c4d2Smrg	CF_X_ATHENA_LIBS($cf_x_athena)
416420d2c4d2Smrgfi
4165d522f475Smrg])dnl
4166d522f475Smrgdnl ---------------------------------------------------------------------------
416720d2c4d2Smrgdnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
4168d522f475Smrgdnl --------------------
4169d522f475Smrgdnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
4170d522f475Smrgdnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
4171d522f475SmrgAC_DEFUN([CF_X_ATHENA_CPPFLAGS],
4172d522f475Smrg[
417320d2c4d2Smrgcf_x_athena_root=ifelse([$1],,Xaw,[$1])
417420d2c4d2Smrgcf_x_athena_inc=""
4175d522f475Smrg
4176d522f475Smrgfor cf_path in default \
4177d522f475Smrg	/usr/contrib/X11R6 \
4178d522f475Smrg	/usr/contrib/X11R5 \
4179d522f475Smrg	/usr/lib/X11R5 \
4180d522f475Smrg	/usr/local
4181d522f475Smrgdo
418220d2c4d2Smrg	if test -z "$cf_x_athena_inc" ; then
4183d522f475Smrg		cf_save="$CPPFLAGS"
4184d522f475Smrg		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
4185d522f475Smrg		if test $cf_path != default ; then
4186956cc18dSsnj			CPPFLAGS="$cf_save -I$cf_path/include"
4187d522f475Smrg			AC_MSG_CHECKING(for $cf_test in $cf_path)
4188d522f475Smrg		else
4189d522f475Smrg			AC_MSG_CHECKING(for $cf_test)
4190d522f475Smrg		fi
4191d522f475Smrg		AC_TRY_COMPILE([
4192d522f475Smrg#include <X11/Intrinsic.h>
4193d522f475Smrg#include <$cf_test>],[],
4194d522f475Smrg			[cf_result=yes],
4195d522f475Smrg			[cf_result=no])
4196d522f475Smrg		AC_MSG_RESULT($cf_result)
4197d522f475Smrg		if test "$cf_result" = yes ; then
419820d2c4d2Smrg			cf_x_athena_inc=$cf_path
4199d522f475Smrg			break
4200d522f475Smrg		else
4201d522f475Smrg			CPPFLAGS="$cf_save"
4202d522f475Smrg		fi
4203d522f475Smrg	fi
4204d522f475Smrgdone
4205d522f475Smrg
420620d2c4d2Smrgif test -z "$cf_x_athena_inc" ; then
4207d522f475Smrg	AC_MSG_WARN(
4208d522f475Smrg[Unable to successfully find Athena header files with test program])
420920d2c4d2Smrgelif test "$cf_x_athena_inc" != default ; then
421020d2c4d2Smrg	CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
4211d522f475Smrgfi
4212d522f475Smrg])
4213d522f475Smrgdnl ---------------------------------------------------------------------------
42140bd37d32Smrgdnl CF_X_ATHENA_LIBS version: 12 updated: 2011/07/17 19:55:02
4215d522f475Smrgdnl ----------------
4216d522f475Smrgdnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
4217d522f475Smrgdnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
4218d522f475SmrgAC_DEFUN([CF_X_ATHENA_LIBS],
4219d522f475Smrg[AC_REQUIRE([CF_X_TOOLKIT])
422020d2c4d2Smrgcf_x_athena_root=ifelse([$1],,Xaw,[$1])
4221d522f475Smrgcf_x_athena_lib=""
4222d522f475Smrg
4223d522f475Smrgfor cf_path in default \
4224d522f475Smrg	/usr/contrib/X11R6 \
4225d522f475Smrg	/usr/contrib/X11R5 \
4226d522f475Smrg	/usr/lib/X11R5 \
4227d522f475Smrg	/usr/local
4228d522f475Smrgdo
4229d522f475Smrg	for cf_lib in \
42300bd37d32Smrg		${cf_x_athena_root} \
42310bd37d32Smrg		${cf_x_athena_root}7 \
42320bd37d32Smrg		${cf_x_athena_root}6
42330bd37d32Smrg	do
42340bd37d32Smrg	for cf_libs in \
42350bd37d32Smrg		"-l$cf_lib -lXmu" \
42360bd37d32Smrg		"-l$cf_lib -lXpm -lXmu" \
42370bd37d32Smrg		"-l${cf_lib}_s -lXmu_s"
4238d522f475Smrg	do
4239d522f475Smrg		if test -z "$cf_x_athena_lib" ; then
4240d522f475Smrg			cf_save="$LIBS"
4241d522f475Smrg			cf_test=XawSimpleMenuAddGlobalActions
4242d522f475Smrg			if test $cf_path != default ; then
42430bd37d32Smrg				CF_ADD_LIBS(-L$cf_path/lib $cf_libs)
42440bd37d32Smrg				AC_MSG_CHECKING(for $cf_libs in $cf_path)
4245d522f475Smrg			else
42460bd37d32Smrg				CF_ADD_LIBS($cf_libs)
42470bd37d32Smrg				AC_MSG_CHECKING(for $cf_test in $cf_libs)
4248d522f475Smrg			fi
4249a1f3da82Smrg			AC_TRY_LINK([
4250a1f3da82Smrg#include <X11/Intrinsic.h>
4251a1f3da82Smrg#include <X11/$cf_x_athena_root/SimpleMenu.h>
4252a1f3da82Smrg],[
4253a1f3da82Smrg$cf_test((XtAppContext) 0)],
4254d522f475Smrg				[cf_result=yes],
4255d522f475Smrg				[cf_result=no])
4256d522f475Smrg			AC_MSG_RESULT($cf_result)
4257d522f475Smrg			if test "$cf_result" = yes ; then
42580bd37d32Smrg				cf_x_athena_lib="$cf_libs"
4259d522f475Smrg				break
4260d522f475Smrg			fi
4261d522f475Smrg			LIBS="$cf_save"
4262d522f475Smrg		fi
42630bd37d32Smrg	done # cf_libs
42640bd37d32Smrg		test -n "$cf_x_athena_lib" && break
42650bd37d32Smrg	done # cf_lib
4266d522f475Smrgdone
4267d522f475Smrg
4268d522f475Smrgif test -z "$cf_x_athena_lib" ; then
4269d522f475Smrg	AC_MSG_ERROR(
4270d522f475Smrg[Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
4271d522f475Smrgfi
4272d522f475Smrg
4273d522f475SmrgCF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
4274d522f475SmrgAC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
4275d522f475Smrg])
4276d522f475Smrgdnl ---------------------------------------------------------------------------
427720d2c4d2Smrgdnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
427820d2c4d2Smrgdnl --------
427920d2c4d2SmrgAC_DEFUN([CF_X_EXT],[
428020d2c4d2SmrgCF_TRY_PKG_CONFIG(Xext,,[
428120d2c4d2Smrg	AC_CHECK_LIB(Xext,XextCreateExtension,
428220d2c4d2Smrg		[CF_ADD_LIB(Xext)])])
428320d2c4d2Smrg])dnl
428420d2c4d2Smrgdnl ---------------------------------------------------------------------------
428501037d57Smrgdnl CF_X_FONTCONFIG version: 6 updated: 2015/04/12 15:39:00
42866879286fSmrgdnl ---------------
42876879286fSmrgdnl Check for fontconfig library, a dependency of the X FreeType library.
42886879286fSmrgAC_DEFUN([CF_X_FONTCONFIG],
42896879286fSmrg[
42906879286fSmrgAC_REQUIRE([CF_X_FREETYPE])
42916879286fSmrg
4292e39b573cSmrgif test "$cf_cv_found_freetype" = yes ; then
42936879286fSmrgAC_CACHE_CHECK(for usable Xft/fontconfig package,cf_cv_xft_compat,[
42946879286fSmrgAC_TRY_LINK([
42956879286fSmrg#include <X11/Xft/Xft.h>
42966879286fSmrg],[
42976879286fSmrg	XftPattern *pat;
42986879286fSmrg	XftPatternBuild(pat,
42996879286fSmrg					XFT_FAMILY, XftTypeString, "mono",
43006879286fSmrg					(void *) 0);
43016879286fSmrg],[cf_cv_xft_compat=yes],[cf_cv_xft_compat=no])
43026879286fSmrg])
43036879286fSmrg
43046879286fSmrgif test "$cf_cv_xft_compat" = no
43056879286fSmrgthen
43066879286fSmrg	# workaround for broken ".pc" files used for Xft.
430701037d57Smrg	case "$cf_cv_x_freetype_libs" in
430801037d57Smrg	(*-lfontconfig*)
43096879286fSmrg		;;
431001037d57Smrg	(*)
43116879286fSmrg		CF_VERBOSE(work around broken package)
4312e0a2b6dfSmrg		cf_save_fontconfig="$LIBS"
4313e0a2b6dfSmrg		CF_TRY_PKG_CONFIG(fontconfig,[
4314e0a2b6dfSmrg				CF_ADD_CFLAGS($cf_pkgconfig_incs)
4315e0a2b6dfSmrg				LIBS="$cf_save_fontconfig"
4316e0a2b6dfSmrg				CF_ADD_LIB_AFTER(-lXft,$cf_pkgconfig_libs)
4317e0a2b6dfSmrg			],[
4318e0a2b6dfSmrg				CF_ADD_LIB_AFTER(-lXft,-lfontconfig)
4319e0a2b6dfSmrg			])
43206879286fSmrg		;;
43216879286fSmrg	esac
43226879286fSmrgfi
4323e39b573cSmrgfi
43246879286fSmrg])dnl
43256879286fSmrgdnl ---------------------------------------------------------------------------
432601037d57Smrgdnl CF_X_FREETYPE version: 27 updated: 2015/04/12 15:39:00
4327d522f475Smrgdnl -------------
4328d522f475Smrgdnl Check for X FreeType headers and libraries (XFree86 4.x, etc).
4329d522f475Smrgdnl
4330d522f475Smrgdnl First check for the appropriate config program, since the developers for
4331d522f475Smrgdnl these libraries change their configuration (and config program) more or
4332d522f475Smrgdnl less randomly.  If we cannot find the config program, do not bother trying
4333d522f475Smrgdnl to guess the latest variation of include/lib directories.
4334d522f475Smrgdnl
4335d522f475Smrgdnl If either or both of these configure-script options are not given, rely on
4336d522f475Smrgdnl the output of the config program to provide the cflags/libs options:
4337d522f475Smrgdnl	--with-freetype-cflags
4338d522f475Smrgdnl	--with-freetype-libs
4339d522f475SmrgAC_DEFUN([CF_X_FREETYPE],
4340d522f475Smrg[
4341956cc18dSsnjAC_REQUIRE([CF_PKG_CONFIG])
4342956cc18dSsnj
43430bd37d32Smrgcf_cv_x_freetype_incs=no
43440bd37d32Smrgcf_cv_x_freetype_libs=no
4345d522f475Smrgcf_extra_freetype_libs=
4346956cc18dSsnjFREETYPE_CONFIG=none
4347d522f475SmrgFREETYPE_PARAMS=
4348d522f475Smrg
43490bd37d32SmrgAC_MSG_CHECKING(for FreeType configuration script)
43500bd37d32SmrgAC_ARG_WITH(freetype-config,
43510bd37d32Smrg	[  --with-freetype-config  configure script to use for FreeType],
43520bd37d32Smrg	[cf_cv_x_freetype_cfgs="$withval"],
43530bd37d32Smrg	[cf_cv_x_freetype_cfgs=auto])
43540bd37d32Smrgtest -z $cf_cv_x_freetype_cfgs && cf_cv_x_freetype_cfgs=auto
43550bd37d32Smrgtest $cf_cv_x_freetype_cfgs = no && cf_cv_x_freetype_cfgs=none
43560bd37d32SmrgAC_MSG_RESULT($cf_cv_x_freetype_cfgs)
43570bd37d32Smrg
43580bd37d32Smrgcase $cf_cv_x_freetype_cfgs in
435901037d57Smrg(none)
43600bd37d32Smrg	AC_MSG_CHECKING(if you specified -D/-I options for FreeType)
43610bd37d32Smrg	AC_ARG_WITH(freetype-cflags,
43620bd37d32Smrg		[  --with-freetype-cflags  -D/-I options for compiling with FreeType],
43630bd37d32Smrg		[cf_cv_x_freetype_incs="$with_freetype_cflags"],
43640bd37d32Smrg		[cf_cv_x_freetype_incs=no])
43650bd37d32Smrg	AC_MSG_RESULT($cf_cv_x_freetype_incs)
43660bd37d32Smrg
43670bd37d32Smrg	AC_MSG_CHECKING(if you specified -L/-l options for FreeType)
43680bd37d32Smrg	AC_ARG_WITH(freetype-libs,
43690bd37d32Smrg		[  --with-freetype-libs    -L/-l options to link FreeType],
43700bd37d32Smrg		[cf_cv_x_freetype_libs="$with_freetype_libs"],
43710bd37d32Smrg		[cf_cv_x_freetype_libs=no])
43720bd37d32Smrg	AC_MSG_RESULT($cf_cv_x_freetype_libs)
43730bd37d32Smrg	;;
437401037d57Smrg(auto)
43750bd37d32Smrg	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
43760bd37d32Smrg		FREETYPE_CONFIG=$PKG_CONFIG
43770bd37d32Smrg		FREETYPE_PARAMS=xft
43780bd37d32Smrg	else
43790bd37d32Smrg		AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, none)
43800bd37d32Smrg		if test "$FREETYPE_CONFIG" != none; then
43810bd37d32Smrg			FREETYPE_CONFIG=$FREETYPE_CONFIG
43820bd37d32Smrg			cf_extra_freetype_libs="-lXft"
43830bd37d32Smrg		else
43840bd37d32Smrg			AC_PATH_PROG(FREETYPE_OLD_CONFIG, xft-config, none)
43850bd37d32Smrg			if test "$FREETYPE_OLD_CONFIG" != none; then
43860bd37d32Smrg				FREETYPE_CONFIG=$FREETYPE_OLD_CONFIG
43870bd37d32Smrg			fi
43880bd37d32Smrg		fi
43890bd37d32Smrg	fi
43900bd37d32Smrg	;;
439101037d57Smrg(pkg*)
43920bd37d32Smrg	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
43930bd37d32Smrg		FREETYPE_CONFIG=$cf_cv_x_freetype_cfgs
43940bd37d32Smrg		FREETYPE_PARAMS=xft
43950bd37d32Smrg	else
43960bd37d32Smrg		AC_MSG_WARN(cannot find pkg-config for Xft)
43970bd37d32Smrg	fi
43980bd37d32Smrg	;;
439901037d57Smrg(*)
44000bd37d32Smrg	AC_PATH_PROG(FREETYPE_XFT_CONFIG, $cf_cv_x_freetype_cfgs, none)
4401d522f475Smrg	if test "$FREETYPE_XFT_CONFIG" != none; then
4402d522f475Smrg		FREETYPE_CONFIG=$FREETYPE_XFT_CONFIG
4403d522f475Smrg	else
44040bd37d32Smrg		AC_MSG_WARN(cannot find config script for Xft)
4405d522f475Smrg	fi
44060bd37d32Smrg	;;
44070bd37d32Smrgesac
4408d522f475Smrg
4409956cc18dSsnjif test "$FREETYPE_CONFIG" != none ; then
44100bd37d32Smrg	AC_MSG_CHECKING(for FreeType config)
44110bd37d32Smrg	AC_MSG_RESULT($FREETYPE_CONFIG $FREETYPE_PARAMS)
4412d522f475Smrg
4413956cc18dSsnj	if test "$cf_cv_x_freetype_incs" = no ; then
4414956cc18dSsnj		AC_MSG_CHECKING(for $FREETYPE_CONFIG cflags)
4415956cc18dSsnj		cf_cv_x_freetype_incs="`$FREETYPE_CONFIG $FREETYPE_PARAMS --cflags 2>/dev/null`"
4416956cc18dSsnj		AC_MSG_RESULT($cf_cv_x_freetype_incs)
4417956cc18dSsnj	fi
4418d522f475Smrg
4419956cc18dSsnj	if test "$cf_cv_x_freetype_libs" = no ; then
4420956cc18dSsnj		AC_MSG_CHECKING(for $FREETYPE_CONFIG libs)
4421956cc18dSsnj		cf_cv_x_freetype_libs="$cf_extra_freetype_libs `$FREETYPE_CONFIG $FREETYPE_PARAMS --libs 2>/dev/null`"
4422956cc18dSsnj		AC_MSG_RESULT($cf_cv_x_freetype_libs)
4423956cc18dSsnj	fi
4424d522f475Smrgfi
4425d522f475Smrg
4426d522f475Smrgif test "$cf_cv_x_freetype_incs" = no ; then
4427d522f475Smrg	cf_cv_x_freetype_incs=
4428d522f475Smrgfi
4429d522f475Smrg
4430d522f475Smrgif test "$cf_cv_x_freetype_libs" = no ; then
4431d522f475Smrg	cf_cv_x_freetype_libs=-lXft
4432d522f475Smrgfi
4433d522f475Smrg
4434d522f475SmrgAC_MSG_CHECKING(if we can link with FreeType libraries)
4435d522f475Smrg
4436d522f475Smrgcf_save_LIBS="$LIBS"
4437d522f475Smrgcf_save_INCS="$CPPFLAGS"
4438d522f475Smrg
443920d2c4d2SmrgCF_ADD_LIBS($cf_cv_x_freetype_libs)
4440956cc18dSsnjCPPFLAGS="$CPPFLAGS $cf_cv_x_freetype_incs"
4441d522f475Smrg
4442d522f475SmrgAC_TRY_LINK([
4443d522f475Smrg#include <X11/Xlib.h>
4444d522f475Smrg#include <X11/extensions/Xrender.h>
4445d522f475Smrg#include <X11/Xft/Xft.h>],[
4446d522f475Smrg	XftPattern  *pat = XftNameParse ("name");],
4447d522f475Smrg	[cf_cv_found_freetype=yes],
4448d522f475Smrg	[cf_cv_found_freetype=no])
4449d522f475SmrgAC_MSG_RESULT($cf_cv_found_freetype)
4450d522f475Smrg
4451d522f475SmrgLIBS="$cf_save_LIBS"
4452d522f475SmrgCPPFLAGS="$cf_save_INCS"
4453d522f475Smrg
4454d522f475Smrgif test "$cf_cv_found_freetype" = yes ; then
445520d2c4d2Smrg	CF_ADD_LIBS($cf_cv_x_freetype_libs)
4456d522f475Smrg	CF_ADD_CFLAGS($cf_cv_x_freetype_incs)
44570bd37d32Smrg	AC_DEFINE(XRENDERFONT,1,[Define to 1 if we can/should link with FreeType libraries])
4458d522f475Smrg
4459d522f475SmrgAC_CHECK_FUNCS( \
4460d522f475Smrg	XftDrawCharSpec \
4461d522f475Smrg	XftDrawSetClip \
4462d522f475Smrg	XftDrawSetClipRectangles \
4463d522f475Smrg)
4464d522f475Smrg
4465d522f475Smrgelse
4466d522f475Smrg	AC_MSG_WARN(No libraries found for FreeType)
4467d522f475Smrg	CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
4468d522f475Smrgfi
4469d522f475Smrg
4470d522f475Smrg# FIXME: revisit this if needed
4471d522f475SmrgAC_SUBST(HAVE_TYPE_FCCHAR32)
4472d522f475SmrgAC_SUBST(HAVE_TYPE_XFTCHARSPEC)
4473d522f475Smrg])
4474d522f475Smrgdnl ---------------------------------------------------------------------------
447501037d57Smrgdnl CF_X_TOOLKIT version: 23 updated: 2015/04/12 15:39:00
4476d522f475Smrgdnl ------------
4477d522f475Smrgdnl Check for X Toolkit libraries
4478d522f475SmrgAC_DEFUN([CF_X_TOOLKIT],
4479d522f475Smrg[
4480d522f475SmrgAC_REQUIRE([AC_PATH_XTRA])
4481d522f475SmrgAC_REQUIRE([CF_CHECK_CACHE])
4482d522f475Smrg
448301037d57Smrg# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
448401037d57Smrg# in some cases has installed dummy files in the former, other cases replaced
448501037d57Smrg# it with a link to the new location).  This complicates the configure script.
448601037d57Smrg# Check for that pitfall, and recover using pkg-config
448701037d57Smrg#
448801037d57Smrg# If none of these are set, the configuration is almost certainly broken.
448901037d57Smrgif test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
449001037d57Smrgthen
449101037d57Smrg	CF_TRY_PKG_CONFIG(x11,,[AC_MSG_WARN(unable to find X11 library)])
449201037d57Smrg	CF_TRY_PKG_CONFIG(ice,,[AC_MSG_WARN(unable to find ICE library)])
449301037d57Smrg	CF_TRY_PKG_CONFIG(sm,,[AC_MSG_WARN(unable to find SM library)])
449401037d57Smrg	CF_TRY_PKG_CONFIG(xt,,[AC_MSG_WARN(unable to find Xt library)])
449501037d57Smrgfi
449601037d57Smrg
4497d522f475Smrgcf_have_X_LIBS=no
4498d522f475Smrg
449920d2c4d2SmrgCF_TRY_PKG_CONFIG(xt,[
450020d2c4d2Smrg
450101037d57Smrg	case "x$LIBS" in
450201037d57Smrg	(*-lX11*)
45036879286fSmrg		;;
450401037d57Smrg	(*)
45056879286fSmrg# we have an "xt" package, but it may omit Xt's dependency on X11
45066879286fSmrgAC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
45076879286fSmrgAC_TRY_LINK([
45086879286fSmrg#include <X11/Xlib.h>
45096879286fSmrg],[
45106879286fSmrg	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
45116879286fSmrg	int rc2 = XClearWindow((Display*) 0, (Window) 0);
45126879286fSmrg	int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
45136879286fSmrg	int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
45146879286fSmrg],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
45156879286fSmrg		if test "$cf_cv_xt_x11_compat" = no
45166879286fSmrg		then
45176879286fSmrg			CF_VERBOSE(work around broken X11 dependency)
45186879286fSmrg			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.
45196879286fSmrg			CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
45206879286fSmrg		fi
452120d2c4d2Smrg		;;
452220d2c4d2Smrg	esac
452320d2c4d2Smrg
45246879286fSmrgAC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
45256879286fSmrgAC_TRY_LINK([
45266879286fSmrg#include <X11/Shell.h>
45276879286fSmrg],[int num = IceConnectionNumber(0)
45286879286fSmrg],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
45296879286fSmrg
45306879286fSmrg	if test "$cf_cv_xt_ice_compat" = no
45316879286fSmrg	then
45326879286fSmrg		# workaround for broken ".pc" files used for X Toolkit.
453301037d57Smrg		case "x$X_PRE_LIBS" in
453401037d57Smrg		(*-lICE*)
453501037d57Smrg			case "x$LIBS" in
453601037d57Smrg			(*-lICE*)
45376879286fSmrg				;;
453801037d57Smrg			(*)
45396879286fSmrg				CF_VERBOSE(work around broken ICE dependency)
45406879286fSmrg				CF_TRY_PKG_CONFIG(ice,
45416879286fSmrg					[CF_TRY_PKG_CONFIG(sm)],
45426879286fSmrg					[CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
45436879286fSmrg				;;
45446879286fSmrg			esac
45456879286fSmrg			;;
45466879286fSmrg		esac
45476879286fSmrg	fi
45486879286fSmrg
454920d2c4d2Smrg	cf_have_X_LIBS=yes
455020d2c4d2Smrg],[
455120d2c4d2Smrg
455220d2c4d2Smrg	LDFLAGS="$X_LIBS $LDFLAGS"
455320d2c4d2Smrg	CF_CHECK_CFLAGS($X_CFLAGS)
4554d522f475Smrg
455520d2c4d2Smrg	AC_CHECK_FUNC(XOpenDisplay,,[
455620d2c4d2Smrg	AC_CHECK_LIB(X11,XOpenDisplay,
455720d2c4d2Smrg		[CF_ADD_LIB(X11)],,
455820d2c4d2Smrg		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
4559d522f475Smrg
456020d2c4d2Smrg	AC_CHECK_FUNC(XtAppInitialize,,[
456120d2c4d2Smrg	AC_CHECK_LIB(Xt, XtAppInitialize,
45620bd37d32Smrg		[AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
456320d2c4d2Smrg		 cf_have_X_LIBS=Xt
456420d2c4d2Smrg		 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
456520d2c4d2Smrg		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
456620d2c4d2Smrg])
4567d522f475Smrg
4568d522f475Smrgif test $cf_have_X_LIBS = no ; then
4569d522f475Smrg	AC_MSG_WARN(
4570d522f475Smrg[Unable to successfully link X Toolkit library (-lXt) with
4571d522f475Smrgtest program.  You will have to check and add the proper libraries by hand
4572d522f475Smrgto makefile.])
4573d522f475Smrgfi
4574d522f475Smrg])dnl
45750bd37d32Smrgdnl ---------------------------------------------------------------------------
45760bd37d32Smrgdnl CF__GRANTPT_BODY version: 4 updated: 2012/05/07 19:39:45
45770bd37d32Smrgdnl ----------------
45780bd37d32Smrgdnl Body for workability check of grantpt.
45790bd37d32Smrgdefine([CF__GRANTPT_BODY],[
45800bd37d32Smrg	int code = 0;
45810bd37d32Smrg	int rc;
45820bd37d32Smrg	int pty;
45830bd37d32Smrg	int tty;
45840bd37d32Smrg	char *slave;
45850bd37d32Smrg	struct termios tio;
45860bd37d32Smrg
45870bd37d32Smrg	signal(SIGALRM, my_timeout);
45880bd37d32Smrg
45890bd37d32Smrg	if (alarm(2) == 9)
45900bd37d32Smrg		failed(9);
45910bd37d32Smrg	else if ((pty = posix_openpt(O_RDWR)) < 0)
45920bd37d32Smrg		failed(1);
45930bd37d32Smrg	else if ((rc = grantpt(pty)) < 0)
45940bd37d32Smrg		failed(2);
45950bd37d32Smrg	else if ((rc = unlockpt(pty)) < 0)
45960bd37d32Smrg		failed(3);
45970bd37d32Smrg	else if ((slave = ptsname(pty)) == 0)
45980bd37d32Smrg		failed(4);
45990bd37d32Smrg#if (CONFTEST == 3) || defined(CONFTEST_isatty)
46000bd37d32Smrg	else if (!isatty(pty))
46010bd37d32Smrg		failed(4);
46020bd37d32Smrg#endif
46030bd37d32Smrg#if CONFTEST >= 4
46040bd37d32Smrg    else if ((rc = tcgetattr(pty, &tio)) < 0)
46050bd37d32Smrg		failed(20);
46060bd37d32Smrg    else if ((rc = tcsetattr(pty, TCSAFLUSH, &tio)) < 0)
46070bd37d32Smrg		failed(21);
46080bd37d32Smrg#endif
46090bd37d32Smrg	/* BSD posix_openpt does not treat pty as a terminal until slave is opened.
46100bd37d32Smrg	 * Linux does treat it that way.
46110bd37d32Smrg	 */
46120bd37d32Smrg	else if ((tty = open(slave, O_RDWR)) < 0)
46130bd37d32Smrg		failed(5);
46140bd37d32Smrg#ifdef CONFTEST
46150bd37d32Smrg#ifdef I_PUSH
46160bd37d32Smrg#if (CONFTEST == 0) || defined(CONFTEST_ptem)
46170bd37d32Smrg    else if ((rc = ioctl(tty, I_PUSH, "ptem")) < 0)
46180bd37d32Smrg		failed(10);
46190bd37d32Smrg#endif
46200bd37d32Smrg#if (CONFTEST == 1) || defined(CONFTEST_ldterm)
46210bd37d32Smrg    else if ((rc = ioctl(tty, I_PUSH, "ldterm")) < 0)
46220bd37d32Smrg		failed(11);
46230bd37d32Smrg#endif
46240bd37d32Smrg#if (CONFTEST == 2) || defined(CONFTEST_ttcompat)
46250bd37d32Smrg    else if ((rc = ioctl(tty, I_PUSH, "ttcompat")) < 0)
46260bd37d32Smrg		failed(12);
46270bd37d32Smrg#endif
46280bd37d32Smrg#endif /* I_PUSH */
46290bd37d32Smrg#if CONFTEST >= 5
46300bd37d32Smrg    else if ((rc = tcgetattr(tty, &tio)) < 0)
46310bd37d32Smrg		failed(30);
46320bd37d32Smrg    else if ((rc = tcsetattr(tty, TCSAFLUSH, &tio)) < 0)
46330bd37d32Smrg		failed(31);
46340bd37d32Smrg#endif
46350bd37d32Smrg#endif /* CONFTEST */
46360bd37d32Smrg
46370bd37d32Smrg	${cf_cv_main_return:-return}(code);
46380bd37d32Smrg])
46390bd37d32Smrgdnl ---------------------------------------------------------------------------
46400bd37d32Smrgdnl CF__GRANTPT_HEAD version: 3 updated: 2012/01/29 17:13:14
46410bd37d32Smrgdnl ----------------
46420bd37d32Smrgdnl Headers for workability check of grantpt.
46430bd37d32Smrgdefine([CF__GRANTPT_HEAD],[
46440bd37d32Smrg#include <stdlib.h>
46450bd37d32Smrg#include <termios.h>
46460bd37d32Smrg#include <unistd.h>
46470bd37d32Smrg#include <signal.h>
46480bd37d32Smrg#include <fcntl.h>
46490bd37d32Smrg#include <errno.h>
46500bd37d32Smrg
46510bd37d32Smrg#ifndef HAVE_POSIX_OPENPT
46520bd37d32Smrg#undef posix_openpt
46530bd37d32Smrg#define posix_openpt(mode) open("/dev/ptmx", mode)
46540bd37d32Smrg#endif
46550bd37d32Smrg
46560bd37d32Smrg#ifdef HAVE_STROPTS_H
46570bd37d32Smrg#include <stropts.h>
46580bd37d32Smrg#endif
46590bd37d32Smrg
46600bd37d32Smrgstatic void failed(int code)
46610bd37d32Smrg{
46620bd37d32Smrg	perror("conftest");
46630bd37d32Smrg	exit(code);
46640bd37d32Smrg}
46650bd37d32Smrg
46660bd37d32Smrgstatic void my_timeout(int sig)
46670bd37d32Smrg{
46680bd37d32Smrg	exit(99);
46690bd37d32Smrg}
46700bd37d32Smrg])
4671