aclocal.m4 revision 2e4f8982
12e4f8982Smrgdnl $XTermId: aclocal.m4,v 1.412 2016/05/28 18:42:52 tom Exp $
2d522f475Smrgdnl
3d522f475Smrgdnl ---------------------------------------------------------------------------
4d522f475Smrgdnl
52e4f8982Smrgdnl Copyright 1997-2015,2016 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 ---------------------------------------------------------------------------
382e4f8982Smrgdnl AM_LANGINFO_CODESET version: 4 updated: 2015/04/18 08:56:57
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[
492e4f8982SmrgAC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
502e4f8982Smrg	[AC_TRY_LINK([#include <langinfo.h>],
512e4f8982Smrg	[char* cs = nl_langinfo(CODESET);],
522e4f8982Smrg	am_cv_langinfo_codeset=yes,
532e4f8982Smrg	am_cv_langinfo_codeset=no)
542e4f8982Smrg	])
552e4f8982Smrg	if test $am_cv_langinfo_codeset = yes; then
562e4f8982Smrg		AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
572e4f8982Smrg		[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
582e4f8982Smrg	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 ---------------------------------------------------------------------------
2342e4f8982Smrgdnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
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)
2472e4f8982Smrg	if test "$enableval" != "$5" ; then
24820d2c4d2Smrgifelse([$3],,[    :]dnl
24920d2c4d2Smrg,[    $3]) ifelse([$4],,,[
2502e4f8982Smrg	else
2512e4f8982Smrg		$4])
2522e4f8982Smrg	fi],[enableval=$5 ifelse([$4],,,[
2532e4f8982Smrg	$4
254d522f475Smrg])dnl
2552e4f8982Smrg])])dnl
256d522f475Smrgdnl ---------------------------------------------------------------------------
2572e4f8982Smrgdnl CF_CC_ENV_FLAGS version: 3 updated: 2016/05/21 18:10:17
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.
2622e4f8982Smrgdnl
2632e4f8982Smrgdnl Caveat: this also disallows blanks in the pathname for the compiler, but
2642e4f8982Smrgdnl the nuisance of having inconsistent settings for compiler and preprocessor
2652e4f8982Smrgdnl outweighs that limitation.
2660bd37d32SmrgAC_DEFUN([CF_CC_ENV_FLAGS],
2670bd37d32Smrg[
2680bd37d32Smrg# This should have been defined by AC_PROG_CC
2690bd37d32Smrg: ${CC:=cc}
2700bd37d32Smrg
2710bd37d32SmrgAC_MSG_CHECKING(\$CC variable)
27201037d57Smrgcase "$CC" in
2732e4f8982Smrg(*[[\ \	]]-*)
2740bd37d32Smrg	AC_MSG_RESULT(broken)
2750bd37d32Smrg	AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
2760bd37d32Smrg	# humor him...
2772e4f8982Smrg	cf_flags=`echo "$CC" | sed -e 's/^[[^ 	]]*[[ 	]][[ 	]]*//'`
2780bd37d32Smrg	CC=`echo "$CC" | sed -e 's/[[ 	]].*//'`
2790bd37d32Smrg	CF_ADD_CFLAGS($cf_flags)
2802e4f8982Smrg	CF_VERBOSE(resulting CC: '$CC')
2812e4f8982Smrg	CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
2822e4f8982Smrg	CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
2830bd37d32Smrg	;;
28401037d57Smrg(*)
2850bd37d32Smrg	AC_MSG_RESULT(ok)
2860bd37d32Smrg	;;
2870bd37d32Smrgesac
2880bd37d32Smrg])dnl
2890bd37d32Smrgdnl ---------------------------------------------------------------------------
2900bd37d32Smrgdnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
291d522f475Smrgdnl --------------
292d522f475Smrgdnl Check if we're accidentally using a cache from a different machine.
293d522f475Smrgdnl Derive the system name, as a check for reusing the autoconf cache.
294d522f475Smrgdnl
295d522f475Smrgdnl If we've packaged config.guess and config.sub, run that (since it does a
296d522f475Smrgdnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
297d522f475Smrgdnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
298d522f475Smrgdnl which is useful in cross-compiles.
299d522f475Smrgdnl
300d522f475Smrgdnl Note: we would use $ac_config_sub, but that is one of the places where
301d522f475Smrgdnl autoconf 2.5x broke compatibility with autoconf 2.13
302d522f475SmrgAC_DEFUN([CF_CHECK_CACHE],
303d522f475Smrg[
304d522f475Smrgif test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
305d522f475Smrg	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
306d522f475Smrg	system_name="$host_os"
307d522f475Smrgelse
308d522f475Smrg	system_name="`(uname -s -r) 2>/dev/null`"
309d522f475Smrg	if test -z "$system_name" ; then
310d522f475Smrg		system_name="`(hostname) 2>/dev/null`"
311d522f475Smrg	fi
312d522f475Smrgfi
3130bd37d32Smrgtest -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
314d522f475SmrgAC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
315d522f475Smrg
316d522f475Smrgtest -z "$system_name" && system_name="$cf_cv_system_name"
317d522f475Smrgtest -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
318d522f475Smrg
319d522f475Smrgif test ".$system_name" != ".$cf_cv_system_name" ; then
320d522f475Smrg	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
321d522f475Smrg	AC_MSG_ERROR("Please remove config.cache and try again.")
322d522f475Smrgfi
323d522f475Smrg])dnl
324d522f475Smrgdnl ---------------------------------------------------------------------------
32501037d57Smrgdnl CF_CHECK_CFLAGS version: 3 updated: 2014/07/22 05:32:57
326d522f475Smrgdnl ---------------
327d522f475Smrgdnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
328d522f475Smrgdnl a build-configuration such as imake.  These have the pitfall that they
329d522f475Smrgdnl often contain compiler-specific options which we cannot use, mixed with
330d522f475Smrgdnl preprocessor options that we usually can.
331d522f475SmrgAC_DEFUN([CF_CHECK_CFLAGS],
332d522f475Smrg[
333d522f475SmrgCF_VERBOSE(checking additions to CFLAGS)
334d522f475Smrgcf_check_cflags="$CFLAGS"
335d522f475Smrgcf_check_cppflags="$CPPFLAGS"
336d522f475SmrgCF_ADD_CFLAGS($1,yes)
33701037d57Smrgif test "x$cf_check_cflags" != "x$CFLAGS" ; then
338d522f475SmrgAC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
339d522f475Smrg	[CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
34001037d57Smrg	 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
341d522f475Smrg		 CF_VERBOSE(but keeping change to \$CPPFLAGS)
342d522f475Smrg	 fi
343d522f475Smrg	 CFLAGS="$cf_check_flags"])
344d522f475Smrgfi
345d522f475Smrg])dnl
346d522f475Smrgdnl ---------------------------------------------------------------------------
3472e4f8982Smrgdnl CF_CHECK_ERRNO version: 12 updated: 2015/04/18 08:56:57
348d522f475Smrgdnl --------------
349d522f475Smrgdnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
350d522f475Smrgdnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
351d522f475Smrgdnl ourselves.
352d522f475Smrgdnl
353d522f475Smrgdnl $1 = the name to check
3542eaa94a1Schristosdnl $2 = the assumed type
355d522f475SmrgAC_DEFUN([CF_CHECK_ERRNO],
356d522f475Smrg[
357d522f475SmrgAC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
3582e4f8982Smrg	AC_TRY_COMPILE([
359d522f475Smrg#ifdef HAVE_STDLIB_H
360d522f475Smrg#include <stdlib.h>
361d522f475Smrg#endif
362d522f475Smrg#include <stdio.h>
363d522f475Smrg#include <sys/types.h>
364d522f475Smrg#include <errno.h> ],
3652e4f8982Smrg	ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1,
3662e4f8982Smrg	[cf_cv_dcl_$1=yes],
3672e4f8982Smrg	[cf_cv_dcl_$1=no])
368d522f475Smrg])
369d522f475Smrg
370d522f475Smrgif test "$cf_cv_dcl_$1" = no ; then
3712e4f8982Smrg	CF_UPPER(cf_result,decl_$1)
3722e4f8982Smrg	AC_DEFINE_UNQUOTED($cf_result)
373d522f475Smrgfi
374d522f475Smrg
375d522f475Smrg# It's possible (for near-UNIX clones) that the data doesn't exist
37620d2c4d2SmrgCF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
377d522f475Smrg])dnl
378d522f475Smrgdnl ---------------------------------------------------------------------------
3792e4f8982Smrgdnl CF_CHECK_EXTERN_DATA version: 4 updated: 2015/04/18 08:56:57
380d522f475Smrgdnl --------------------
381d522f475Smrgdnl Check for existence of external data in the current set of libraries.  If
382d522f475Smrgdnl we can modify it, it's real enough.
383d522f475Smrgdnl $1 = the name to check
384d522f475Smrgdnl $2 = its type
385d522f475SmrgAC_DEFUN([CF_CHECK_EXTERN_DATA],
386d522f475Smrg[
387d522f475SmrgAC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
3882e4f8982Smrg	AC_TRY_LINK([
389d522f475Smrg#undef $1
390d522f475Smrgextern $2 $1;
391d522f475Smrg],
3922e4f8982Smrg	[$1 = 2],
3932e4f8982Smrg	[cf_cv_have_$1=yes],
3942e4f8982Smrg	[cf_cv_have_$1=no])
395d522f475Smrg])
396d522f475Smrg
397d522f475Smrgif test "$cf_cv_have_$1" = yes ; then
3982e4f8982Smrg	CF_UPPER(cf_result,have_$1)
3992e4f8982Smrg	AC_DEFINE_UNQUOTED($cf_result)
400d522f475Smrgfi
401d522f475Smrg
402d522f475Smrg])dnl
403d522f475Smrgdnl ---------------------------------------------------------------------------
404e0a2b6dfSmrgdnl CF_CLANG_COMPILER version: 2 updated: 2013/11/19 19:23:35
4050bd37d32Smrgdnl -----------------
4060bd37d32Smrgdnl Check if the given compiler is really clang.  clang's C driver defines
4070bd37d32Smrgdnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
4080bd37d32Smrgdnl not ignore some gcc options.
4090bd37d32Smrgdnl
4100bd37d32Smrgdnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
4110bd37d32Smrgdnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
4120bd37d32Smrgdnl the wrappers for gcc and g++ warnings.
4130bd37d32Smrgdnl
4140bd37d32Smrgdnl $1 = GCC (default) or GXX
415e0a2b6dfSmrgdnl $2 = CLANG_COMPILER (default)
4160bd37d32Smrgdnl $3 = CFLAGS (default) or CXXFLAGS
4170bd37d32SmrgAC_DEFUN([CF_CLANG_COMPILER],[
4180bd37d32Smrgifelse([$2],,CLANG_COMPILER,[$2])=no
4190bd37d32Smrg
4200bd37d32Smrgif test "$ifelse([$1],,[$1],GCC)" = yes ; then
4210bd37d32Smrg	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
4220bd37d32Smrg	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
4230bd37d32Smrg	ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
4240bd37d32Smrg	AC_TRY_COMPILE([],[
4250bd37d32Smrg#ifdef __clang__
4260bd37d32Smrg#else
4270bd37d32Smrgmake an error
4280bd37d32Smrg#endif
4290bd37d32Smrg],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
4300bd37d32Smrgcf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
4310bd37d32Smrg],[])
4320bd37d32Smrg	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
4330bd37d32Smrg	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
4340bd37d32Smrgfi
4350bd37d32Smrg])
4360bd37d32Smrgdnl ---------------------------------------------------------------------------
437e39b573cSmrgdnl CF_DISABLE_DESKTOP version: 2 updated: 2011/04/22 05:17:37
438e39b573cSmrgdnl ------------------
439e39b573cSmrgdnl Handle a configure option "--disable-desktop", which sets a shell
440e39b573cSmrgdnl variable $desktop_utils to a "#" if the feature is not wanted, or to an
441e39b573cSmrgdnl empty string if enabled.  The variable is used to substitute in front of
442e39b573cSmrgdnl corresponding makefile-rules.
443e39b573cSmrgdnl
444e39b573cSmrgdnl It also tells the configure script to substitute the environment variable
445e39b573cSmrgdnl $DESKTOP_FLAGS, which can be used by external scripts to customize the
446e39b573cSmrgdnl invocation of desktop-file-util.
447e39b573cSmrgdnl
448e39b573cSmrgdnl $1 = program name
449e39b573cSmrgAC_DEFUN([CF_DISABLE_DESKTOP],[
450e39b573cSmrg# Comment-out the install-desktop rule if the desktop-utils are not found.
451e39b573cSmrgAC_MSG_CHECKING(if you want to install desktop files)
452e39b573cSmrgCF_ARG_OPTION(desktop,
453e39b573cSmrg	[  --disable-desktop       disable install of $1 desktop files],
454e39b573cSmrg	[enable_desktop=$enableval],
455e39b573cSmrg	[enable_desktop=$enableval],yes)
456e39b573cSmrgAC_MSG_RESULT($enable_desktop)
457e39b573cSmrg
458e39b573cSmrgdesktop_utils=
459e39b573cSmrgif test "$enable_desktop" = yes ; then
460e39b573cSmrgAC_CHECK_PROG(desktop_utils,desktop-file-install,yes,no)
461e39b573cSmrgfi
462e39b573cSmrg
463e39b573cSmrgtest "$desktop_utils" = yes && desktop_utils= || desktop_utils="#"
464e39b573cSmrgAC_SUBST(DESKTOP_FLAGS)
465e39b573cSmrg])
466e39b573cSmrgdnl ---------------------------------------------------------------------------
4672e4f8982Smrgdnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
468d522f475Smrgdnl ---------------
469d522f475Smrgdnl You can always use "make -n" to see the actual options, but it's hard to
470d522f475Smrgdnl pick out/analyze warning messages when the compile-line is long.
471d522f475Smrgdnl
472d522f475Smrgdnl Sets:
473d522f475Smrgdnl	ECHO_LT - symbol to control if libtool is verbose
474d522f475Smrgdnl	ECHO_LD - symbol to prefix "cc -o" lines
475d522f475Smrgdnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
476d522f475Smrgdnl	SHOW_CC - symbol to put before explicit "cc -c" lines
477d522f475Smrgdnl	ECHO_CC - symbol to put before any "cc" line
478d522f475Smrgdnl
479d522f475SmrgAC_DEFUN([CF_DISABLE_ECHO],[
480d522f475SmrgAC_MSG_CHECKING(if you want to see long compiling messages)
481d522f475SmrgCF_ARG_DISABLE(echo,
4820bd37d32Smrg	[  --disable-echo          do not display "compiling" commands],
483d522f475Smrg	[
4842e4f8982Smrg	ECHO_LT='--silent'
4852e4f8982Smrg	ECHO_LD='@echo linking [$]@;'
4862e4f8982Smrg	RULE_CC='@echo compiling [$]<'
4872e4f8982Smrg	SHOW_CC='@echo compiling [$]@'
4882e4f8982Smrg	ECHO_CC='@'
489d522f475Smrg],[
4902e4f8982Smrg	ECHO_LT=''
4912e4f8982Smrg	ECHO_LD=''
4922e4f8982Smrg	RULE_CC=''
4932e4f8982Smrg	SHOW_CC=''
4942e4f8982Smrg	ECHO_CC=''
495d522f475Smrg])
496d522f475SmrgAC_MSG_RESULT($enableval)
497d522f475SmrgAC_SUBST(ECHO_LT)
498d522f475SmrgAC_SUBST(ECHO_LD)
499d522f475SmrgAC_SUBST(RULE_CC)
500d522f475SmrgAC_SUBST(SHOW_CC)
501d522f475SmrgAC_SUBST(ECHO_CC)
502d522f475Smrg])dnl
503d522f475Smrgdnl ---------------------------------------------------------------------------
5040bd37d32Smrgdnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
5050bd37d32Smrgdnl ----------------
5060bd37d32Smrgdnl Combine no-leak checks with the libraries or tools that are used for the
5070bd37d32Smrgdnl checks.
5080bd37d32SmrgAC_DEFUN([CF_DISABLE_LEAKS],[
5090bd37d32Smrg
5100bd37d32SmrgAC_REQUIRE([CF_WITH_DMALLOC])
5110bd37d32SmrgAC_REQUIRE([CF_WITH_DBMALLOC])
5120bd37d32SmrgAC_REQUIRE([CF_WITH_VALGRIND])
5130bd37d32Smrg
5140bd37d32SmrgAC_MSG_CHECKING(if you want to perform memory-leak testing)
5150bd37d32SmrgAC_ARG_ENABLE(leaks,
5160bd37d32Smrg	[  --disable-leaks         test: free permanent memory, analyze leaks],
5170bd37d32Smrg	[if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
5180bd37d32Smrg	: ${with_no_leaks:=no})
5190bd37d32SmrgAC_MSG_RESULT($with_no_leaks)
5200bd37d32Smrg
5210bd37d32Smrgif test "$with_no_leaks" = yes ; then
5220bd37d32Smrg	AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
5230bd37d32Smrg	AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
5240bd37d32Smrgfi
5250bd37d32Smrg])dnl
5260bd37d32Smrgdnl ---------------------------------------------------------------------------
527a1f3da82Smrgdnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
52820d2c4d2Smrgdnl ---------------------
52920d2c4d2Smrgdnl The rpath-hack makes it simpler to build programs, particularly with the
53020d2c4d2Smrgdnl *BSD ports which may have essential libraries in unusual places.  But it
53120d2c4d2Smrgdnl can interfere with building an executable for the base system.  Use this
53220d2c4d2Smrgdnl option in that case.
53320d2c4d2SmrgAC_DEFUN([CF_DISABLE_RPATH_HACK],
53420d2c4d2Smrg[
535a1f3da82SmrgAC_MSG_CHECKING(if rpath-hack should be disabled)
53620d2c4d2SmrgCF_ARG_DISABLE(rpath-hack,
53720d2c4d2Smrg	[  --disable-rpath-hack    don't add rpath options for additional libraries],
53820d2c4d2Smrg	[cf_disable_rpath_hack=yes],
53920d2c4d2Smrg	[cf_disable_rpath_hack=no])
54020d2c4d2SmrgAC_MSG_RESULT($cf_disable_rpath_hack)
54120d2c4d2Smrgif test "$cf_disable_rpath_hack" = no ; then
54220d2c4d2Smrg	CF_RPATH_HACK
54320d2c4d2Smrgfi
54420d2c4d2Smrg])
54520d2c4d2Smrgdnl ---------------------------------------------------------------------------
54601037d57Smrgdnl CF_ENABLE_NARROWPROTO version: 5 updated: 2015/04/12 15:39:00
547d522f475Smrgdnl ---------------------
548d522f475Smrgdnl If this is not set properly, Xaw's scrollbars will not work.
549d522f475Smrgdnl The so-called "modular" configuration for X.org omits most of the
550d522f475Smrgdnl configure checks that would be needed to provide compatibility with
551d522f475Smrgdnl older X builds.  This one breaks things noticeably.
552d522f475SmrgAC_DEFUN([CF_ENABLE_NARROWPROTO],
553d522f475Smrg[
554d522f475SmrgAC_MSG_CHECKING(if you want narrow prototypes for X libraries)
555d522f475Smrg
55601037d57Smrgcase `$ac_config_guess` in
55701037d57Smrg(*freebsd*|*gnu*|*irix5*|*irix6*|*linux-gnu*|*netbsd*|*openbsd*|*qnx*|*sco*|*sgi*)
558d522f475Smrg	cf_default_narrowproto=yes
559d522f475Smrg	;;
56001037d57Smrg(*)
561d522f475Smrg	cf_default_narrowproto=no
562d522f475Smrg	;;
563d522f475Smrgesac
564d522f475Smrg
565d522f475SmrgCF_ARG_OPTION(narrowproto,
566d522f475Smrg	[  --enable-narrowproto    enable narrow prototypes for X libraries],
567d522f475Smrg	[enable_narrowproto=$enableval],
568d522f475Smrg	[enable_narrowproto=$cf_default_narrowproto],
569d522f475Smrg	[$cf_default_narrowproto])
570d522f475SmrgAC_MSG_RESULT($enable_narrowproto)
571d522f475Smrg])
572d522f475Smrgdnl ---------------------------------------------------------------------------
573d522f475Smrgdnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
574d522f475Smrgdnl --------
575d522f475Smrgdnl Check if 'errno' is declared in <errno.h>
576d522f475SmrgAC_DEFUN([CF_ERRNO],
577d522f475Smrg[
578d522f475SmrgCF_CHECK_ERRNO(errno)
579d522f475Smrg])dnl
580d522f475Smrgdnl ---------------------------------------------------------------------------
58101037d57Smrgdnl CF_FUNC_GRANTPT version: 11 updated: 2015/04/12 15:39:00
582d522f475Smrgdnl ---------------
5830bd37d32Smrgdnl Check for grantpt versus openpty, as well as functions that "should" be
5840bd37d32Smrgdnl available if grantpt is available.
5850bd37d32SmrgAC_DEFUN([CF_FUNC_GRANTPT],[
5860bd37d32Smrg
5870bd37d32SmrgAC_CHECK_HEADERS( \
5880bd37d32Smrgstropts.h \
5890bd37d32Smrg)
5900bd37d32Smrg
5910bd37d32Smrgcf_func_grantpt="grantpt ptsname"
59201037d57Smrgcase $host_os in
59301037d57Smrg(darwin[[0-9]].*)
5940bd37d32Smrg	;;
59501037d57Smrg(*)
5960bd37d32Smrg	cf_func_grantpt="$cf_func_grantpt posix_openpt"
5970bd37d32Smrg	;;
5980bd37d32Smrgesac
5990bd37d32Smrg
6000bd37d32SmrgAC_CHECK_FUNCS($cf_func_grantpt)
6010bd37d32Smrg
6020bd37d32Smrgcf_grantpt_opts=
6030bd37d32Smrgif test "x$ac_cv_func_grantpt" = "xyes" ; then
6040bd37d32Smrg	AC_MSG_CHECKING(if grantpt really works)
6050bd37d32Smrg	AC_TRY_LINK(CF__GRANTPT_HEAD,CF__GRANTPT_BODY,[
6060bd37d32Smrg	AC_TRY_RUN(CF__GRANTPT_HEAD
6070bd37d32Smrgint main(void)
6080bd37d32Smrg{
6090bd37d32SmrgCF__GRANTPT_BODY
610d522f475Smrg}
6110bd37d32Smrg,
6120bd37d32Smrg,ac_cv_func_grantpt=no
6130bd37d32Smrg,ac_cv_func_grantpt=maybe)
6140bd37d32Smrg	],ac_cv_func_grantpt=no)
6150bd37d32Smrg	AC_MSG_RESULT($ac_cv_func_grantpt)
6160bd37d32Smrg
6170bd37d32Smrg	if test "x$ac_cv_func_grantpt" != "xno" ; then
6180bd37d32Smrg
6190bd37d32Smrg		if test "x$ac_cv_func_grantpt" = "xyes" ; then
6200bd37d32Smrg			AC_MSG_CHECKING(for pty features)
6210bd37d32Smrgdnl if we have no stropts.h, skip the checks for streams modules
6220bd37d32Smrg			if test "x$ac_cv_header_stropts_h" = xyes
6230bd37d32Smrg			then
6240bd37d32Smrg				cf_pty_this=0
6250bd37d32Smrg			else
6260bd37d32Smrg				cf_pty_this=3
6270bd37d32Smrg			fi
6280bd37d32Smrg
6290bd37d32Smrg			cf_pty_defines=
6300bd37d32Smrg			while test $cf_pty_this != 6
6310bd37d32Smrg			do
6320bd37d32Smrg
6330bd37d32Smrg				cf_pty_feature=
6340bd37d32Smrg				cf_pty_next=`expr $cf_pty_this + 1`
6350bd37d32Smrg				CF_MSG_LOG(pty feature test $cf_pty_next:5)
6360bd37d32Smrg				AC_TRY_RUN(#define CONFTEST $cf_pty_this
6370bd37d32Smrg$cf_pty_defines
6380bd37d32SmrgCF__GRANTPT_HEAD
6390bd37d32Smrgint main(void)
6400bd37d32Smrg{
6410bd37d32SmrgCF__GRANTPT_BODY
6420bd37d32Smrg}
6430bd37d32Smrg,
6440bd37d32Smrg[
64501037d57Smrg				case $cf_pty_next in
64601037d57Smrg				(1) # - streams
6470bd37d32Smrg					cf_pty_feature=ptem
6480bd37d32Smrg					;;
64901037d57Smrg				(2) # - streams
6500bd37d32Smrg					cf_pty_feature=ldterm
6510bd37d32Smrg					;;
65201037d57Smrg				(3) # - streams
6530bd37d32Smrg					cf_pty_feature=ttcompat
6540bd37d32Smrg					;;
65501037d57Smrg				(4)
6560bd37d32Smrg					cf_pty_feature=pty_isatty
6570bd37d32Smrg					;;
65801037d57Smrg				(5)
6590bd37d32Smrg					cf_pty_feature=pty_tcsetattr
6600bd37d32Smrg					;;
66101037d57Smrg				(6)
6620bd37d32Smrg					cf_pty_feature=tty_tcsetattr
6630bd37d32Smrg					;;
6640bd37d32Smrg				esac
6650bd37d32Smrg],[
66601037d57Smrg				case $cf_pty_next in
66701037d57Smrg				(1|2|3)
6680bd37d32Smrg					CF_MSG_LOG(skipping remaining streams features $cf_pty_this..2)
6690bd37d32Smrg					cf_pty_next=3
6700bd37d32Smrg					;;
6710bd37d32Smrg				esac
6720bd37d32Smrg])
6730bd37d32Smrg				if test -n "$cf_pty_feature"
6740bd37d32Smrg				then
6750bd37d32Smrg					cf_pty_defines="$cf_pty_defines
6760bd37d32Smrg#define CONFTEST_$cf_pty_feature 1
6770bd37d32Smrg"
6780bd37d32Smrg					cf_grantpt_opts="$cf_grantpt_opts $cf_pty_feature"
6790bd37d32Smrg				fi
6800bd37d32Smrg
6810bd37d32Smrg				cf_pty_this=$cf_pty_next
6820bd37d32Smrg			done
6830bd37d32Smrg			AC_MSG_RESULT($cf_grantpt_opts)
6840bd37d32Smrg			cf_grantpt_opts=`echo "$cf_grantpt_opts" | sed -e 's/ isatty//'`
6850bd37d32Smrg		fi
686d522f475Smrg	fi
6870bd37d32Smrgfi
6880bd37d32Smrg
6890bd37d32Smrgdnl If we found grantpt, but no features, e.g., for streams or if we are not
6900bd37d32Smrgdnl able to use tcsetattr, then give openpty a try.  In particular, Darwin 10.7
6910bd37d32Smrgdnl has a more functional openpty than posix_openpt.
6920bd37d32Smrgdnl
6930bd37d32Smrgdnl There is no configure run-test for openpty, since older implementations do
6940bd37d32Smrgdnl not always run properly as a non-root user.  For that reason, we also allow
6950bd37d32Smrgdnl the configure script to suppress this check entirely with $disable_openpty.
6960bd37d32Smrgif test "x$disable_openpty" != "xyes" || test -z "$cf_grantpt_opts" ; then
6970bd37d32Smrg	AC_CHECK_LIB(util, openpty, [cf_have_openpty=yes],[cf_have_openpty=no])
6980bd37d32Smrg	if test "$cf_have_openpty" = yes ; then
6990bd37d32Smrg		ac_cv_func_grantpt=no
7000bd37d32Smrg		LIBS="-lutil $LIBS"
7010bd37d32Smrg		AC_DEFINE(HAVE_OPENPTY,1,[Define to 1 if you have the openpty function])
7020bd37d32Smrg		AC_CHECK_HEADERS( \
7030bd37d32Smrg			util.h \
7040bd37d32Smrg			libutil.h \
7050bd37d32Smrg			pty.h \
7060bd37d32Smrg		)
7070bd37d32Smrg	fi
7080bd37d32Smrgfi
7090bd37d32Smrg
7100bd37d32Smrgdnl If we did not settle on using openpty, fill in the definitions for grantpt.
7110bd37d32Smrgif test "x$ac_cv_func_grantpt" != xno
7120bd37d32Smrgthen
7130bd37d32Smrg	CF_VERBOSE(will rely upon grantpt)
7140bd37d32Smrg	AC_DEFINE(HAVE_WORKING_GRANTPT,1,[Define to 1 if the grantpt function seems to work])
7150bd37d32Smrg	for cf_feature in $cf_grantpt_opts
7160bd37d32Smrg	do
7170bd37d32Smrg		cf_feature=`echo "$cf_feature" | sed -e 's/ //g'`
7180bd37d32Smrg		CF_UPPER(cf_FEATURE,$cf_feature)
7190bd37d32Smrg		AC_DEFINE_UNQUOTED(HAVE_GRANTPT_$cf_FEATURE)
7200bd37d32Smrg	done
7210bd37d32Smrgelif test "x$cf_have_openpty" = xno
7220bd37d32Smrgthen
7230bd37d32Smrg	CF_VERBOSE(will rely upon BSD-pseudoterminals)
7240bd37d32Smrgelse
7250bd37d32Smrg	CF_VERBOSE(will rely upon openpty)
7260bd37d32Smrgfi
7270bd37d32Smrg])dnl
728d522f475Smrgdnl ---------------------------------------------------------------------------
7292e4f8982Smrgdnl CF_FUNC_TGETENT version: 21 updated: 2015/09/12 14:59:46
730d522f475Smrgdnl ---------------
731d522f475Smrgdnl Check for tgetent function in termcap library.  If we cannot find this,
732d522f475Smrgdnl we'll use the $LINES and $COLUMNS environment variables to pass screen
733d522f475Smrgdnl size information to subprocesses.  (We cannot use terminfo's compatibility
734d522f475Smrgdnl function, since it cannot provide the termcap-format data).
735d522f475Smrgdnl
736d522f475Smrgdnl If the --disable-full-tgetent option is given, we'll settle for the first
737d522f475Smrgdnl tgetent function we find.  Since the search list in that case does not
738d522f475Smrgdnl include the termcap library, that allows us to default to terminfo.
739d522f475SmrgAC_DEFUN([CF_FUNC_TGETENT],
740d522f475Smrg[
741d522f475Smrg# compute a reasonable value for $TERM to give tgetent(), since we may be
742d522f475Smrg# running in 'screen', which sets $TERMCAP to a specific entry that is not
743d522f475Smrg# necessarily in /etc/termcap - unsetenv is not portable, so we cannot simply
744d522f475Smrg# discard $TERMCAP.
745d522f475Smrgcf_TERMVAR=vt100
746e39b573cSmrgif test -n "$TERMCAP"
747e39b573cSmrgthen
748e39b573cSmrg	cf_TERMCAP=`echo "$TERMCAP" | tr '\n' ' ' | sed -e 's/^..|//' -e 's/|.*//'`
74901037d57Smrg	case "$cf_TERMCAP" in
75001037d57Smrg	(screen*.*)
751e39b573cSmrg		;;
75201037d57Smrg	(*)
753e39b573cSmrg		cf_TERMVAR="$cf_TERMCAP"
754e39b573cSmrg		;;
755e39b573cSmrg	esac
756e39b573cSmrgfi
757d522f475Smrgtest -z "$cf_TERMVAR" && cf_TERMVAR=vt100
758d522f475Smrg
759d522f475SmrgAC_MSG_CHECKING(if we want full tgetent function)
760d522f475SmrgCF_ARG_DISABLE(full-tgetent,
761d522f475Smrg	[  --disable-full-tgetent  disable check for full tgetent function],
762d522f475Smrg	cf_full_tgetent=no,
763d522f475Smrg	cf_full_tgetent=yes,yes)
764d522f475SmrgAC_MSG_RESULT($cf_full_tgetent)
765d522f475Smrg
766d522f475Smrgif test "$cf_full_tgetent" = yes ; then
767d522f475Smrg	cf_test_message="full tgetent"
768d522f475Smrgelse
769d522f475Smrg	cf_test_message="tgetent"
770d522f475Smrgfi
771d522f475Smrg
772d522f475SmrgAC_CACHE_CHECK(for $cf_test_message function,cf_cv_lib_tgetent,[
773d522f475Smrgcf_save_LIBS="$LIBS"
774d522f475Smrgcf_cv_lib_tgetent=no
775d522f475Smrgif test "$cf_full_tgetent" = yes ; then
7760bd37d32Smrg	cf_TERMLIB="otermcap termcap termlib ncurses curses"
777d522f475Smrg	cf_TERMTST="buffer[[0]] == 0"
778d522f475Smrgelse
779d522f475Smrg	cf_TERMLIB="termlib ncurses curses"
780d522f475Smrg	cf_TERMTST="0"
781d522f475Smrgfi
782d522f475Smrgfor cf_termlib in '' $cf_TERMLIB ; do
783d522f475Smrg	LIBS="$cf_save_LIBS"
7842e4f8982Smrg	test -n "$cf_termlib" && { CF_ADD_LIB($cf_termlib) }
785d522f475Smrg	AC_TRY_RUN([
786d522f475Smrg/* terminfo implementations ignore the buffer argument, making it useless for
787d522f475Smrg * the xterm application, which uses this information to make a new TERMCAP
788d522f475Smrg * environment variable.
789d522f475Smrg */
790d522f475Smrgint main()
791d522f475Smrg{
792d522f475Smrg	char buffer[1024];
793d522f475Smrg	buffer[0] = 0;
794d522f475Smrg	tgetent(buffer, "$cf_TERMVAR");
795d522f475Smrg	${cf_cv_main_return:-return} ($cf_TERMTST); }],
796d522f475Smrg	[echo "yes, there is a termcap/tgetent in $cf_termlib" 1>&AC_FD_CC
797d522f475Smrg	 if test -n "$cf_termlib" ; then
798d522f475Smrg	 	cf_cv_lib_tgetent="-l$cf_termlib"
799d522f475Smrg	 else
800d522f475Smrg	 	cf_cv_lib_tgetent=yes
801d522f475Smrg	 fi
802d522f475Smrg	 break],
803d522f475Smrg	[echo "no, there is no termcap/tgetent in $cf_termlib" 1>&AC_FD_CC],
804d522f475Smrg	[echo "cross-compiling, cannot verify if a termcap/tgetent is present in $cf_termlib" 1>&AC_FD_CC])
805d522f475Smrgdone
806d522f475SmrgLIBS="$cf_save_LIBS"
807d522f475Smrg])
808d522f475Smrg
809d522f475Smrg# If we found a working tgetent(), set LIBS and check for termcap.h.
810d522f475Smrg# (LIBS cannot be set inside AC_CACHE_CHECK; the commands there should
811d522f475Smrg# not have side effects other than setting the cache variable, because
812d522f475Smrg# they are not executed when a cached value exists.)
813e39b573cSmrgif test "x$cf_cv_lib_tgetent" != xno ; then
8142e4f8982Smrg	test "x$cf_cv_lib_tgetent" != xyes && { CF_ADD_LIBS($cf_cv_lib_tgetent) }
8150bd37d32Smrg	AC_DEFINE(USE_TERMCAP,1,[Define 1 to indicate that working tgetent is found])
81620d2c4d2Smrg	if test "$cf_full_tgetent" = no ; then
81720d2c4d2Smrg		AC_TRY_COMPILE([
818d522f475Smrg#include <termcap.h>],[
819d522f475Smrg#ifdef NCURSES_VERSION
820d522f475Smrgmake an error
821d522f475Smrg#endif],[AC_DEFINE(HAVE_TERMCAP_H)])
82220d2c4d2Smrg	else
82320d2c4d2Smrg		AC_CHECK_HEADERS(termcap.h)
82420d2c4d2Smrg	fi
825d522f475Smrgelse
826d522f475Smrg        # If we didn't find a tgetent() that supports the buffer
827d522f475Smrg        # argument, look again to see whether we can find even
828d522f475Smrg        # a crippled one.  A crippled tgetent() is still useful to
829d522f475Smrg        # validate values for the TERM environment variable given to
830d522f475Smrg        # child processes.
831d522f475Smrg	AC_CACHE_CHECK(for partial tgetent function,cf_cv_lib_part_tgetent,[
832d522f475Smrg	cf_cv_lib_part_tgetent=no
833d522f475Smrg	for cf_termlib in $cf_TERMLIB ; do
834d522f475Smrg		LIBS="$cf_save_LIBS -l$cf_termlib"
835d522f475Smrg		AC_TRY_LINK([],[tgetent(0, "$cf_TERMVAR")],
836d522f475Smrg			[echo "there is a terminfo/tgetent in $cf_termlib" 1>&AC_FD_CC
837d522f475Smrg			 cf_cv_lib_part_tgetent="-l$cf_termlib"
838d522f475Smrg			 break])
839d522f475Smrg	done
840d522f475Smrg	LIBS="$cf_save_LIBS"
841d522f475Smrg	])
842d522f475Smrg
843d522f475Smrg	if test "$cf_cv_lib_part_tgetent" != no ; then
84420d2c4d2Smrg		CF_ADD_LIBS($cf_cv_lib_part_tgetent)
845d522f475Smrg		AC_CHECK_HEADERS(termcap.h)
846d522f475Smrg
847d522f475Smrg                # If this is linking against ncurses, we'll trigger the
848d522f475Smrg                # ifdef in resize.c that turns the termcap stuff back off.
8490bd37d32Smrg		AC_DEFINE(USE_TERMINFO,1,[Define to 1 to indicate that terminfo provides the tgetent interface])
850d522f475Smrg	fi
851d522f475Smrgfi
852d522f475Smrg])dnl
853d522f475Smrgdnl ---------------------------------------------------------------------------
85401037d57Smrgdnl CF_GCC_ATTRIBUTES version: 17 updated: 2015/04/12 15:39:00
855d522f475Smrgdnl -----------------
856d522f475Smrgdnl Test for availability of useful gcc __attribute__ directives to quiet
857d522f475Smrgdnl compiler warnings.  Though useful, not all are supported -- and contrary
858d522f475Smrgdnl to documentation, unrecognized directives cause older compilers to barf.
859d522f475SmrgAC_DEFUN([CF_GCC_ATTRIBUTES],
860d522f475Smrg[
861d522f475Smrgif test "$GCC" = yes
862d522f475Smrgthen
863d522f475Smrgcat > conftest.i <<EOF
864d522f475Smrg#ifndef GCC_PRINTF
865d522f475Smrg#define GCC_PRINTF 0
866d522f475Smrg#endif
867d522f475Smrg#ifndef GCC_SCANF
868d522f475Smrg#define GCC_SCANF 0
869d522f475Smrg#endif
870d522f475Smrg#ifndef GCC_NORETURN
871d522f475Smrg#define GCC_NORETURN /* nothing */
872d522f475Smrg#endif
873d522f475Smrg#ifndef GCC_UNUSED
874d522f475Smrg#define GCC_UNUSED /* nothing */
875d522f475Smrg#endif
876d522f475SmrgEOF
877d522f475Smrgif test "$GCC" = yes
878d522f475Smrgthen
879d522f475Smrg	AC_CHECKING([for $CC __attribute__ directives])
880d522f475Smrgcat > conftest.$ac_ext <<EOF
8816879286fSmrg#line __oline__ "${as_me:-configure}"
882d522f475Smrg#include "confdefs.h"
883d522f475Smrg#include "conftest.h"
884d522f475Smrg#include "conftest.i"
885d522f475Smrg#if	GCC_PRINTF
886d522f475Smrg#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
887d522f475Smrg#else
888d522f475Smrg#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
889d522f475Smrg#endif
890d522f475Smrg#if	GCC_SCANF
891d522f475Smrg#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
892d522f475Smrg#else
893d522f475Smrg#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
894d522f475Smrg#endif
895d522f475Smrgextern void wow(char *,...) GCC_SCANFLIKE(1,2);
896d522f475Smrgextern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
897d522f475Smrgextern void foo(void) GCC_NORETURN;
898d522f475Smrgint main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
899d522f475SmrgEOF
90020d2c4d2Smrg	cf_printf_attribute=no
90120d2c4d2Smrg	cf_scanf_attribute=no
902d522f475Smrg	for cf_attribute in scanf printf unused noreturn
903d522f475Smrg	do
904d522f475Smrg		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
905d522f475Smrg		cf_directive="__attribute__(($cf_attribute))"
906d522f475Smrg		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
90720d2c4d2Smrg
90801037d57Smrg		case $cf_attribute in
90901037d57Smrg		(printf)
91020d2c4d2Smrg			cf_printf_attribute=yes
91120d2c4d2Smrg			cat >conftest.h <<EOF
912d522f475Smrg#define GCC_$cf_ATTRIBUTE 1
913d522f475SmrgEOF
914d522f475Smrg			;;
91501037d57Smrg		(scanf)
91620d2c4d2Smrg			cf_scanf_attribute=yes
91720d2c4d2Smrg			cat >conftest.h <<EOF
91820d2c4d2Smrg#define GCC_$cf_ATTRIBUTE 1
91920d2c4d2SmrgEOF
92020d2c4d2Smrg			;;
92101037d57Smrg		(*)
92220d2c4d2Smrg			cat >conftest.h <<EOF
923d522f475Smrg#define GCC_$cf_ATTRIBUTE $cf_directive
924d522f475SmrgEOF
925d522f475Smrg			;;
926d522f475Smrg		esac
92720d2c4d2Smrg
928d522f475Smrg		if AC_TRY_EVAL(ac_compile); then
929d522f475Smrg			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
930d522f475Smrg			cat conftest.h >>confdefs.h
93101037d57Smrg			case $cf_attribute in
93201037d57Smrg			(noreturn)
9330bd37d32Smrg				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
9340bd37d32Smrg				;;
93501037d57Smrg			(printf)
9360bd37d32Smrg				cf_value='/* nothing */'
9370bd37d32Smrg				if test "$cf_printf_attribute" != no ; then
9380bd37d32Smrg					cf_value='__attribute__((format(printf,fmt,var)))'
9390bd37d32Smrg					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
94020d2c4d2Smrg				fi
9410bd37d32Smrg				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
94220d2c4d2Smrg				;;
94301037d57Smrg			(scanf)
9440bd37d32Smrg				cf_value='/* nothing */'
9450bd37d32Smrg				if test "$cf_scanf_attribute" != no ; then
9460bd37d32Smrg					cf_value='__attribute__((format(scanf,fmt,var)))'
9470bd37d32Smrg					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
94820d2c4d2Smrg				fi
9490bd37d32Smrg				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
9500bd37d32Smrg				;;
95101037d57Smrg			(unused)
9520bd37d32Smrg				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
95320d2c4d2Smrg				;;
95420d2c4d2Smrg			esac
955d522f475Smrg		fi
956d522f475Smrg	done
957d522f475Smrgelse
958d522f475Smrg	fgrep define conftest.i >>confdefs.h
959d522f475Smrgfi
960d522f475Smrgrm -rf conftest*
961d522f475Smrgfi
962d522f475Smrg])dnl
963d522f475Smrgdnl ---------------------------------------------------------------------------
9640bd37d32Smrgdnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
965d522f475Smrgdnl --------------
966d522f475Smrgdnl Find version of gcc
967d522f475SmrgAC_DEFUN([CF_GCC_VERSION],[
968d522f475SmrgAC_REQUIRE([AC_PROG_CC])
969d522f475SmrgGCC_VERSION=none
970d522f475Smrgif test "$GCC" = yes ; then
971d522f475Smrg	AC_MSG_CHECKING(version of $CC)
9720bd37d32Smrg	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.]].*//'`"
973d522f475Smrg	test -z "$GCC_VERSION" && GCC_VERSION=unknown
974d522f475Smrg	AC_MSG_RESULT($GCC_VERSION)
975d522f475Smrgfi
976d522f475Smrg])dnl
977d522f475Smrgdnl ---------------------------------------------------------------------------
97801037d57Smrgdnl CF_GCC_WARNINGS version: 32 updated: 2015/04/12 15:39:00
979d522f475Smrgdnl ---------------
980d522f475Smrgdnl Check if the compiler supports useful warning options.  There's a few that
981d522f475Smrgdnl we don't use, simply because they're too noisy:
982d522f475Smrgdnl
983d522f475Smrgdnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
984d522f475Smrgdnl	-Wredundant-decls (system headers make this too noisy)
985d522f475Smrgdnl	-Wtraditional (combines too many unrelated messages, only a few useful)
986d522f475Smrgdnl	-Wwrite-strings (too noisy, but should review occasionally).  This
987d522f475Smrgdnl		is enabled for ncurses using "--enable-const".
988d522f475Smrgdnl	-pedantic
989d522f475Smrgdnl
990d522f475Smrgdnl Parameter:
991d522f475Smrgdnl	$1 is an optional list of gcc warning flags that a particular
992d522f475Smrgdnl		application might want to use, e.g., "no-unused" for
993d522f475Smrgdnl		-Wno-unused
994d522f475Smrgdnl Special:
995d522f475Smrgdnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
996d522f475Smrgdnl
997d522f475SmrgAC_DEFUN([CF_GCC_WARNINGS],
998d522f475Smrg[
999d522f475SmrgAC_REQUIRE([CF_GCC_VERSION])
1000d522f475SmrgCF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
10010bd37d32SmrgCF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
1002d522f475Smrg
1003d522f475Smrgcat > conftest.$ac_ext <<EOF
10046879286fSmrg#line __oline__ "${as_me:-configure}"
1005d522f475Smrgint main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1006d522f475SmrgEOF
1007d522f475Smrg
1008d522f475Smrgif test "$INTEL_COMPILER" = yes
1009d522f475Smrgthen
1010d522f475Smrg# The "-wdXXX" options suppress warnings:
1011d522f475Smrg# remark #1419: external declaration in primary source file
1012d522f475Smrg# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1013d522f475Smrg# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1014d522f475Smrg# remark #193: zero used for undefined preprocessing identifier
1015d522f475Smrg# remark #593: variable "curs_sb_left_arrow" was set but never used
1016d522f475Smrg# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1017d522f475Smrg# remark #869: parameter "tw" was never referenced
1018d522f475Smrg# remark #981: operands are evaluated in unspecified order
1019956cc18dSsnj# warning #279: controlling expression is constant
1020d522f475Smrg
1021d522f475Smrg	AC_CHECKING([for $CC warning options])
1022d522f475Smrg	cf_save_CFLAGS="$CFLAGS"
1023d522f475Smrg	EXTRA_CFLAGS="-Wall"
1024d522f475Smrg	for cf_opt in \
1025d522f475Smrg		wd1419 \
1026d522f475Smrg		wd1683 \
1027d522f475Smrg		wd1684 \
1028d522f475Smrg		wd193 \
1029d522f475Smrg		wd593 \
1030956cc18dSsnj		wd279 \
1031d522f475Smrg		wd810 \
1032d522f475Smrg		wd869 \
1033d522f475Smrg		wd981
1034d522f475Smrg	do
1035d522f475Smrg		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1036d522f475Smrg		if AC_TRY_EVAL(ac_compile); then
1037d522f475Smrg			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1038d522f475Smrg			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1039d522f475Smrg		fi
1040d522f475Smrg	done
1041d522f475Smrg	CFLAGS="$cf_save_CFLAGS"
1042d522f475Smrg
1043d522f475Smrgelif test "$GCC" = yes
1044d522f475Smrgthen
1045d522f475Smrg	AC_CHECKING([for $CC warning options])
1046d522f475Smrg	cf_save_CFLAGS="$CFLAGS"
104720d2c4d2Smrg	EXTRA_CFLAGS=
1048d522f475Smrg	cf_warn_CONST=""
1049d522f475Smrg	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1050e0a2b6dfSmrg	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
1051e0a2b6dfSmrg	test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
105220d2c4d2Smrg	for cf_opt in W Wall \
1053d522f475Smrg		Wbad-function-cast \
1054d522f475Smrg		Wcast-align \
1055d522f475Smrg		Wcast-qual \
1056e0a2b6dfSmrg		Wdeclaration-after-statement \
1057e0a2b6dfSmrg		Wextra \
1058d522f475Smrg		Winline \
1059d522f475Smrg		Wmissing-declarations \
1060d522f475Smrg		Wmissing-prototypes \
1061d522f475Smrg		Wnested-externs \
1062d522f475Smrg		Wpointer-arith \
1063d522f475Smrg		Wshadow \
1064d522f475Smrg		Wstrict-prototypes \
1065e0a2b6dfSmrg		Wundef $cf_gcc_warnings $cf_warn_CONST $1
1066d522f475Smrg	do
1067d522f475Smrg		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1068d522f475Smrg		if AC_TRY_EVAL(ac_compile); then
1069d522f475Smrg			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
107001037d57Smrg			case $cf_opt in
107101037d57Smrg			(Wcast-qual)
1072d522f475Smrg				CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1073d522f475Smrg				;;
107401037d57Smrg			(Winline)
1075d522f475Smrg				case $GCC_VERSION in
107601037d57Smrg				([[34]].*)
1077d522f475Smrg					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1078d522f475Smrg					continue;;
1079d522f475Smrg				esac
1080d522f475Smrg				;;
108101037d57Smrg			(Wpointer-arith)
10820bd37d32Smrg				case $GCC_VERSION in
108301037d57Smrg				([[12]].*)
10840bd37d32Smrg					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
10850bd37d32Smrg					continue;;
10860bd37d32Smrg				esac
10870bd37d32Smrg				;;
1088d522f475Smrg			esac
1089d522f475Smrg			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1090d522f475Smrg		fi
1091d522f475Smrg	done
1092d522f475Smrg	CFLAGS="$cf_save_CFLAGS"
1093d522f475Smrgfi
10946879286fSmrgrm -rf conftest*
1095d522f475Smrg
1096d522f475SmrgAC_SUBST(EXTRA_CFLAGS)
1097d522f475Smrg])dnl
1098d522f475Smrgdnl ---------------------------------------------------------------------------
1099d522f475Smrgdnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1100d522f475Smrgdnl -------------
1101d522f475Smrgdnl Check if we must define _GNU_SOURCE to get a reasonable value for
1102d522f475Smrgdnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1103d522f475Smrgdnl (or misfeature) of glibc2, which breaks portability of many applications,
1104d522f475Smrgdnl since it is interwoven with GNU extensions.
1105d522f475Smrgdnl
1106d522f475Smrgdnl Well, yes we could work around it...
1107d522f475SmrgAC_DEFUN([CF_GNU_SOURCE],
1108d522f475Smrg[
1109d522f475SmrgAC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1110d522f475SmrgAC_TRY_COMPILE([#include <sys/types.h>],[
1111d522f475Smrg#ifndef _XOPEN_SOURCE
1112d522f475Smrgmake an error
1113d522f475Smrg#endif],
1114d522f475Smrg	[cf_cv_gnu_source=no],
1115d522f475Smrg	[cf_save="$CPPFLAGS"
1116d522f475Smrg	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1117d522f475Smrg	 AC_TRY_COMPILE([#include <sys/types.h>],[
1118d522f475Smrg#ifdef _XOPEN_SOURCE
1119d522f475Smrgmake an error
1120d522f475Smrg#endif],
1121d522f475Smrg	[cf_cv_gnu_source=no],
1122d522f475Smrg	[cf_cv_gnu_source=yes])
1123d522f475Smrg	CPPFLAGS="$cf_save"
1124d522f475Smrg	])
1125d522f475Smrg])
1126d522f475Smrgtest "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1127d522f475Smrg])dnl
1128d522f475Smrgdnl ---------------------------------------------------------------------------
1129d522f475Smrgdnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1130d522f475Smrgdnl ---------------
1131d522f475Smrgdnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1132d522f475SmrgAC_DEFUN([CF_HELP_MESSAGE],
1133d522f475Smrg[AC_DIVERT_HELP([$1])dnl
1134d522f475Smrg])dnl
1135d522f475Smrgdnl ---------------------------------------------------------------------------
113601037d57Smrgdnl CF_IMAKE_CFLAGS version: 32 updated: 2015/04/12 15:39:00
1137d522f475Smrgdnl ---------------
1138d522f475Smrgdnl Use imake to obtain compiler flags.  We could, in principle, write tests to
1139d522f475Smrgdnl get these, but if imake is properly configured there is no point in doing
1140d522f475Smrgdnl this.
1141d522f475Smrgdnl
1142d522f475Smrgdnl Parameters (used in constructing a sample Imakefile):
1143d522f475Smrgdnl	$1 = optional value to append to $IMAKE_CFLAGS
1144d522f475Smrgdnl	$2 = optional value to append to $IMAKE_LOADFLAGS
1145d522f475SmrgAC_DEFUN([CF_IMAKE_CFLAGS],
1146d522f475Smrg[
1147d522f475SmrgAC_PATH_PROGS(IMAKE,xmkmf imake)
1148d522f475Smrg
1149d522f475Smrgif test -n "$IMAKE" ; then
1150d522f475Smrg
115101037d57Smrgcase $IMAKE in
115201037d57Smrg(*/imake)
115301037d57Smrg	cf_imake_opts="-DUseInstalled=YES"
1154d522f475Smrg	;;
115501037d57Smrg(*/util/xmkmf)
1156d522f475Smrg	# A single parameter tells xmkmf where the config-files are:
115701037d57Smrg	cf_imake_opts="`echo $IMAKE|sed -e s,/config/util/xmkmf,,`"
1158d522f475Smrg	;;
115901037d57Smrg(*)
1160d522f475Smrg	cf_imake_opts=
1161d522f475Smrg	;;
1162d522f475Smrgesac
1163d522f475Smrg
1164d522f475Smrg# If it's installed properly, imake (or its wrapper, xmkmf) will point to the
1165d522f475Smrg# config directory.
1166d522f475Smrgif mkdir conftestdir; then
1167d522f475Smrg	CDPATH=; export CDPATH
1168d522f475Smrg	cf_makefile=`cd $srcdir;pwd`/Imakefile
1169d522f475Smrg	cd conftestdir
1170d522f475Smrg
1171d522f475Smrg	cat >fix_cflags.sed <<'CF_EOF'
1172d522f475Smrgs/\\//g
1173d522f475Smrgs/[[ 	]][[ 	]]*/ /g
1174d522f475Smrgs/"//g
1175d522f475Smrg:pack
1176d522f475Smrgs/\(=[[^ ]][[^ ]]*\) \([[^-]]\)/\1	\2/g
1177d522f475Smrgt pack
1178d522f475Smrgs/\(-D[[a-zA-Z0-9_]][[a-zA-Z0-9_]]*\)=\([[^\'0-9 ]][[^ ]]*\)/\1='\\"\2\\"'/g
1179d522f475Smrgs/^IMAKE[[ ]]/IMAKE_CFLAGS="/
1180d522f475Smrgs/	/ /g
1181d522f475Smrgs/$/"/
1182d522f475SmrgCF_EOF
1183d522f475Smrg
1184d522f475Smrg	cat >fix_lflags.sed <<'CF_EOF'
1185d522f475Smrgs/^IMAKE[[ 	]]*/IMAKE_LOADFLAGS="/
1186d522f475Smrgs/$/"/
1187d522f475SmrgCF_EOF
1188d522f475Smrg
1189d522f475Smrg	echo >./Imakefile
1190d522f475Smrg	test -f $cf_makefile && cat $cf_makefile >>./Imakefile
1191d522f475Smrg
1192d522f475Smrg	cat >> ./Imakefile <<'CF_EOF'
1193d522f475Smrgfindstddefs:
119420d2c4d2Smrg	@echo IMAKE ${ALLDEFINES}ifelse([$1],,,[ $1])       | sed -f fix_cflags.sed
119520d2c4d2Smrg	@echo IMAKE ${EXTRA_LOAD_FLAGS}ifelse([$2],,,[ $2]) | sed -f fix_lflags.sed
1196d522f475SmrgCF_EOF
1197d522f475Smrg
1198d522f475Smrg	if ( $IMAKE $cf_imake_opts 1>/dev/null 2>&AC_FD_CC && test -f Makefile)
1199d522f475Smrg	then
1200d522f475Smrg		CF_VERBOSE(Using $IMAKE $cf_imake_opts)
1201d522f475Smrg	else
1202d522f475Smrg		# sometimes imake doesn't have the config path compiled in.  Find it.
1203d522f475Smrg		cf_config=
1204d522f475Smrg		for cf_libpath in $X_LIBS $LIBS ; do
120501037d57Smrg			case $cf_libpath in
120601037d57Smrg			(-L*)
1207d522f475Smrg				cf_libpath=`echo .$cf_libpath | sed -e 's/^...//'`
1208d522f475Smrg				cf_libpath=$cf_libpath/X11/config
1209d522f475Smrg				if test -d $cf_libpath ; then
1210d522f475Smrg					cf_config=$cf_libpath
1211d522f475Smrg					break
1212d522f475Smrg				fi
1213d522f475Smrg				;;
1214d522f475Smrg			esac
1215d522f475Smrg		done
1216d522f475Smrg		if test -z "$cf_config" ; then
1217d522f475Smrg			AC_MSG_WARN(Could not find imake config-directory)
1218d522f475Smrg		else
1219d522f475Smrg			cf_imake_opts="$cf_imake_opts -I$cf_config"
1220d522f475Smrg			if ( $IMAKE -v $cf_imake_opts 2>&AC_FD_CC)
1221d522f475Smrg			then
1222d522f475Smrg				CF_VERBOSE(Using $IMAKE $cf_config)
1223d522f475Smrg			else
1224d522f475Smrg				AC_MSG_WARN(Cannot run $IMAKE)
1225d522f475Smrg			fi
1226d522f475Smrg		fi
1227d522f475Smrg	fi
1228d522f475Smrg
1229d522f475Smrg	# GNU make sometimes prints "make[1]: Entering...", which
1230d522f475Smrg	# would confuse us.
1231d522f475Smrg	eval `make findstddefs 2>/dev/null | grep -v make`
1232d522f475Smrg
1233d522f475Smrg	cd ..
1234d522f475Smrg	rm -rf conftestdir
1235d522f475Smrg
1236d522f475Smrg	# We use ${ALLDEFINES} rather than ${STD_DEFINES} because the former
1237d522f475Smrg	# declares XTFUNCPROTO there.  However, some vendors (e.g., SGI) have
1238d522f475Smrg	# modified it to support site.cf, adding a kludge for the /usr/include
1239d522f475Smrg	# directory.  Try to filter that out, otherwise gcc won't find its
1240d522f475Smrg	# headers.
1241d522f475Smrg	if test -n "$GCC" ; then
1242d522f475Smrg	    if test -n "$IMAKE_CFLAGS" ; then
1243d522f475Smrg		cf_nostdinc=""
1244d522f475Smrg		cf_std_incl=""
1245d522f475Smrg		cf_cpp_opts=""
1246d522f475Smrg		for cf_opt in $IMAKE_CFLAGS
1247d522f475Smrg		do
1248d522f475Smrg		    case "$cf_opt" in
124901037d57Smrg		    (-nostdinc)
1250d522f475Smrg			cf_nostdinc="$cf_opt"
1251d522f475Smrg			;;
125201037d57Smrg		    (-I/usr/include)
1253d522f475Smrg			cf_std_incl="$cf_opt"
1254d522f475Smrg			;;
125501037d57Smrg		    (*)
1256d522f475Smrg			cf_cpp_opts="$cf_cpp_opts $cf_opt"
1257d522f475Smrg			;;
1258d522f475Smrg		    esac
1259d522f475Smrg		done
1260d522f475Smrg		if test -z "$cf_nostdinc" ; then
1261d522f475Smrg		    IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl"
1262d522f475Smrg		elif test -z "$cf_std_incl" ; then
1263d522f475Smrg		    IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc"
1264d522f475Smrg		else
1265d522f475Smrg		    CF_VERBOSE(suppressed \"$cf_nostdinc\" and \"$cf_std_incl\")
1266d522f475Smrg		    IMAKE_CFLAGS="$cf_cpp_opts"
1267d522f475Smrg		fi
1268d522f475Smrg	    fi
1269d522f475Smrg	fi
1270d522f475Smrgfi
1271d522f475Smrg
1272d522f475Smrg# Some imake configurations define PROJECTROOT with an empty value.  Remove
1273d522f475Smrg# the empty definition.
1274d522f475Smrgcase $IMAKE_CFLAGS in
127501037d57Smrg(*-DPROJECTROOT=/*)
1276d522f475Smrg	;;
127701037d57Smrg(*)
1278d522f475Smrg	IMAKE_CFLAGS=`echo "$IMAKE_CFLAGS" |sed -e "s,-DPROJECTROOT=[[ 	]], ,"`
1279d522f475Smrg	;;
1280d522f475Smrgesac
1281d522f475Smrg
1282d522f475Smrgfi
1283d522f475Smrg
1284d522f475SmrgCF_VERBOSE(IMAKE_CFLAGS $IMAKE_CFLAGS)
1285d522f475SmrgCF_VERBOSE(IMAKE_LOADFLAGS $IMAKE_LOADFLAGS)
1286d522f475Smrg
1287d522f475SmrgAC_SUBST(IMAKE_CFLAGS)
1288d522f475SmrgAC_SUBST(IMAKE_LOADFLAGS)
1289d522f475Smrg])dnl
1290d522f475Smrgdnl ---------------------------------------------------------------------------
1291d522f475Smrgdnl CF_INPUT_METHOD version: 3 updated: 2000/04/11 23:46:57
1292d522f475Smrgdnl ---------------
1293d522f475Smrgdnl Check if the X libraries support input-method
1294d522f475SmrgAC_DEFUN([CF_INPUT_METHOD],
1295d522f475Smrg[
1296d522f475SmrgAC_CACHE_CHECK([if X libraries support input-method],cf_cv_input_method,[
1297d522f475SmrgAC_TRY_LINK([
1298d522f475Smrg#include <X11/IntrinsicP.h>
1299d522f475Smrg#include <X11/Xatom.h>
1300d522f475Smrg#include <X11/Xutil.h>
1301d522f475Smrg#include <X11/Xmu/Atoms.h>
1302d522f475Smrg#include <X11/Xmu/Converters.h>
1303d522f475Smrg#include <X11/Xaw/XawImP.h>
1304d522f475Smrg],[
1305d522f475Smrg{
1306d522f475Smrg	XIM xim;
1307d522f475Smrg	XIMStyles *xim_styles = 0;
1308d522f475Smrg	XIMStyle input_style;
1309d522f475Smrg	Widget w = 0;
1310d522f475Smrg
1311d522f475Smrg	XSetLocaleModifiers("@im=none");
1312d522f475Smrg	xim = XOpenIM(XtDisplay(w), NULL, NULL, NULL);
1313d522f475Smrg	XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);
1314d522f475Smrg	XCloseIM(xim);
1315d522f475Smrg	input_style = (XIMPreeditNothing | XIMStatusNothing);
1316d522f475Smrg}
1317d522f475Smrg],
1318d522f475Smrg[cf_cv_input_method=yes],
1319d522f475Smrg[cf_cv_input_method=no])])
1320d522f475Smrg])dnl
1321d522f475Smrgdnl ---------------------------------------------------------------------------
132201037d57Smrgdnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00
1323d522f475Smrgdnl -----------------
1324d522f475Smrgdnl Check if the given compiler is really the Intel compiler for Linux.  It
1325d522f475Smrgdnl tries to imitate gcc, but does not return an error when it finds a mismatch
1326d522f475Smrgdnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1327d522f475Smrgdnl
1328d522f475Smrgdnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1329d522f475Smrgdnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1330d522f475Smrgdnl the wrappers for gcc and g++ warnings.
1331d522f475Smrgdnl
1332d522f475Smrgdnl $1 = GCC (default) or GXX
1333d522f475Smrgdnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1334d522f475Smrgdnl $3 = CFLAGS (default) or CXXFLAGS
1335d522f475SmrgAC_DEFUN([CF_INTEL_COMPILER],[
13360bd37d32SmrgAC_REQUIRE([AC_CANONICAL_HOST])
133720d2c4d2Smrgifelse([$2],,INTEL_COMPILER,[$2])=no
1338d522f475Smrg
133920d2c4d2Smrgif test "$ifelse([$1],,[$1],GCC)" = yes ; then
1340d522f475Smrg	case $host_os in
134101037d57Smrg	(linux*|gnu*)
134220d2c4d2Smrg		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
134320d2c4d2Smrg		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
134420d2c4d2Smrg		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1345d522f475Smrg		AC_TRY_COMPILE([],[
1346d522f475Smrg#ifdef __INTEL_COMPILER
1347d522f475Smrg#else
1348d522f475Smrgmake an error
1349d522f475Smrg#endif
135020d2c4d2Smrg],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1351894e0ac8Smrgcf_save_CFLAGS="$cf_save_CFLAGS -we147"
1352d522f475Smrg],[])
135320d2c4d2Smrg		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
135420d2c4d2Smrg		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1355d522f475Smrg		;;
1356d522f475Smrg	esac
1357d522f475Smrgfi
1358d522f475Smrg])dnl
1359d522f475Smrgdnl ---------------------------------------------------------------------------
13600bd37d32Smrgdnl CF_LASTLOG version: 5 updated: 2012/10/04 20:12:20
1361d522f475Smrgdnl ----------
1362d522f475Smrgdnl Check for header defining _PATH_LASTLOG, or failing that, see if the lastlog
1363d522f475Smrgdnl file exists.
1364d522f475SmrgAC_DEFUN([CF_LASTLOG],
1365d522f475Smrg[
1366d522f475SmrgAC_CHECK_HEADERS(lastlog.h paths.h)
1367d522f475SmrgAC_CACHE_CHECK(for lastlog path,cf_cv_path_lastlog,[
1368d522f475SmrgAC_TRY_COMPILE([
1369d522f475Smrg#include <sys/types.h>
1370d522f475Smrg#ifdef HAVE_LASTLOG_H
1371d522f475Smrg#include <lastlog.h>
1372d522f475Smrg#else
1373d522f475Smrg#ifdef HAVE_PATHS_H
1374d522f475Smrg#include <paths.h>
1375d522f475Smrg#endif
1376d522f475Smrg#endif],[char *path = _PATH_LASTLOG],
1377d522f475Smrg	[cf_cv_path_lastlog="_PATH_LASTLOG"],
1378d522f475Smrg	[if test -f /usr/adm/lastlog ; then
1379d522f475Smrg	 	cf_cv_path_lastlog=/usr/adm/lastlog
1380d522f475Smrg	else
1381d522f475Smrg		cf_cv_path_lastlog=no
1382d522f475Smrg	fi])
1383d522f475Smrg])
13840bd37d32Smrgtest $cf_cv_path_lastlog != no && AC_DEFINE(USE_LASTLOG,1,[Define to 1 if we can define lastlog pathname])
1385d522f475Smrg])dnl
1386d522f475Smrgdnl ---------------------------------------------------------------------------
13872e4f8982Smrgdnl CF_LD_RPATH_OPT version: 7 updated: 2016/02/20 18:01:19
138820d2c4d2Smrgdnl ---------------
138920d2c4d2Smrgdnl For the given system and compiler, find the compiler flags to pass to the
139020d2c4d2Smrgdnl loader to use the "rpath" feature.
139120d2c4d2SmrgAC_DEFUN([CF_LD_RPATH_OPT],
139220d2c4d2Smrg[
139320d2c4d2SmrgAC_REQUIRE([CF_CHECK_CACHE])
139420d2c4d2Smrg
139520d2c4d2SmrgLD_RPATH_OPT=
139620d2c4d2SmrgAC_MSG_CHECKING(for an rpath option)
139701037d57Smrgcase $cf_cv_system_name in
139801037d57Smrg(irix*)
139920d2c4d2Smrg	if test "$GCC" = yes; then
140020d2c4d2Smrg		LD_RPATH_OPT="-Wl,-rpath,"
140120d2c4d2Smrg	else
140220d2c4d2Smrg		LD_RPATH_OPT="-rpath "
140320d2c4d2Smrg	fi
140420d2c4d2Smrg	;;
14052e4f8982Smrg(linux*|gnu*|k*bsd*-gnu|freebsd*)
140620d2c4d2Smrg	LD_RPATH_OPT="-Wl,-rpath,"
140720d2c4d2Smrg	;;
140801037d57Smrg(openbsd[[2-9]].*|mirbsd*)
140920d2c4d2Smrg	LD_RPATH_OPT="-Wl,-rpath,"
141020d2c4d2Smrg	;;
14112e4f8982Smrg(dragonfly*)
141220d2c4d2Smrg	LD_RPATH_OPT="-rpath "
141320d2c4d2Smrg	;;
141401037d57Smrg(netbsd*)
141520d2c4d2Smrg	LD_RPATH_OPT="-Wl,-rpath,"
141620d2c4d2Smrg	;;
141701037d57Smrg(osf*|mls+*)
141820d2c4d2Smrg	LD_RPATH_OPT="-rpath "
141920d2c4d2Smrg	;;
142001037d57Smrg(solaris2*)
142120d2c4d2Smrg	LD_RPATH_OPT="-R"
142220d2c4d2Smrg	;;
142301037d57Smrg(*)
142420d2c4d2Smrg	;;
142520d2c4d2Smrgesac
142620d2c4d2SmrgAC_MSG_RESULT($LD_RPATH_OPT)
142720d2c4d2Smrg
142801037d57Smrgcase "x$LD_RPATH_OPT" in
142901037d57Smrg(x-R*)
143020d2c4d2Smrg	AC_MSG_CHECKING(if we need a space after rpath option)
143120d2c4d2Smrg	cf_save_LIBS="$LIBS"
143220d2c4d2Smrg	CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
143320d2c4d2Smrg	AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
143420d2c4d2Smrg	LIBS="$cf_save_LIBS"
143520d2c4d2Smrg	AC_MSG_RESULT($cf_rpath_space)
143620d2c4d2Smrg	test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
143720d2c4d2Smrg	;;
143820d2c4d2Smrgesac
143920d2c4d2Smrg])dnl
144020d2c4d2Smrgdnl ---------------------------------------------------------------------------
14416879286fSmrgdnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
144220d2c4d2Smrgdnl ------------
144320d2c4d2Smrgdnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
144420d2c4d2Smrgdnl a monocase filesystem.
144520d2c4d2SmrgAC_DEFUN([CF_MAKE_TAGS],[
144620d2c4d2SmrgAC_REQUIRE([CF_MIXEDCASE_FILENAMES])
144720d2c4d2Smrg
144820d2c4d2SmrgAC_CHECK_PROGS(CTAGS, exctags ctags)
144920d2c4d2SmrgAC_CHECK_PROGS(ETAGS, exetags etags)
145020d2c4d2Smrg
14516879286fSmrgAC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
145220d2c4d2Smrg
145320d2c4d2Smrgif test "$cf_cv_mixedcase" = yes ; then
14546879286fSmrg	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
145520d2c4d2Smrgelse
145620d2c4d2Smrg	MAKE_UPPER_TAGS=no
145720d2c4d2Smrgfi
145820d2c4d2Smrg
145920d2c4d2Smrgif test "$MAKE_UPPER_TAGS" = yes ; then
146020d2c4d2Smrg	MAKE_UPPER_TAGS=
146120d2c4d2Smrgelse
146220d2c4d2Smrg	MAKE_UPPER_TAGS="#"
146320d2c4d2Smrgfi
146420d2c4d2Smrg
146520d2c4d2Smrgif test "$MAKE_LOWER_TAGS" = yes ; then
146620d2c4d2Smrg	MAKE_LOWER_TAGS=
146720d2c4d2Smrgelse
146820d2c4d2Smrg	MAKE_LOWER_TAGS="#"
146920d2c4d2Smrgfi
147020d2c4d2Smrg
147120d2c4d2SmrgAC_SUBST(CTAGS)
147220d2c4d2SmrgAC_SUBST(ETAGS)
147320d2c4d2Smrg
147420d2c4d2SmrgAC_SUBST(MAKE_UPPER_TAGS)
147520d2c4d2SmrgAC_SUBST(MAKE_LOWER_TAGS)
147620d2c4d2Smrg])dnl
147720d2c4d2Smrgdnl ---------------------------------------------------------------------------
1478894e0ac8Smrgdnl CF_MATH_LIB version: 8 updated: 2010/05/29 16:31:02
1479894e0ac8Smrgdnl -----------
1480894e0ac8Smrgdnl Checks for libraries.  At least one UNIX system, Apple Macintosh
1481894e0ac8Smrgdnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
1482894e0ac8Smrgdnl AC_CHECK_LIB(m,sin), because that fails for C++.
1483894e0ac8SmrgAC_DEFUN([CF_MATH_LIB],
1484894e0ac8Smrg[
1485894e0ac8SmrgAC_CACHE_CHECK(if -lm needed for math functions,
1486894e0ac8Smrg	cf_cv_need_libm,[
1487894e0ac8Smrg	AC_TRY_LINK([
1488894e0ac8Smrg	#include <stdio.h>
1489894e0ac8Smrg	#include <math.h>
1490894e0ac8Smrg	],
1491894e0ac8Smrg	[double x = rand(); printf("result = %g\n", ]ifelse([$2],,sin(x),$2)[)],
1492894e0ac8Smrg	[cf_cv_need_libm=no],
1493894e0ac8Smrg	[cf_cv_need_libm=yes])])
1494894e0ac8Smrgif test "$cf_cv_need_libm" = yes
1495894e0ac8Smrgthen
1496894e0ac8Smrgifelse($1,,[
1497894e0ac8Smrg	CF_ADD_LIB(m)
1498894e0ac8Smrg],[$1=-lm])
1499894e0ac8Smrgfi
1500894e0ac8Smrg])
1501894e0ac8Smrgdnl ---------------------------------------------------------------------------
150201037d57Smrgdnl CF_MIXEDCASE_FILENAMES version: 7 updated: 2015/04/12 15:39:00
150320d2c4d2Smrgdnl ----------------------
150420d2c4d2Smrgdnl Check if the file-system supports mixed-case filenames.  If we're able to
150520d2c4d2Smrgdnl create a lowercase name and see it as uppercase, it doesn't support that.
150620d2c4d2SmrgAC_DEFUN([CF_MIXEDCASE_FILENAMES],
150720d2c4d2Smrg[
150820d2c4d2SmrgAC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
150920d2c4d2Smrgif test "$cross_compiling" = yes ; then
151001037d57Smrg	case $target_alias in
151101037d57Smrg	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
151220d2c4d2Smrg		cf_cv_mixedcase=no
151320d2c4d2Smrg		;;
151401037d57Smrg	(*)
151520d2c4d2Smrg		cf_cv_mixedcase=yes
151620d2c4d2Smrg		;;
151720d2c4d2Smrg	esac
151820d2c4d2Smrgelse
151920d2c4d2Smrg	rm -f conftest CONFTEST
152020d2c4d2Smrg	echo test >conftest
152120d2c4d2Smrg	if test -f CONFTEST ; then
152220d2c4d2Smrg		cf_cv_mixedcase=no
152320d2c4d2Smrg	else
152420d2c4d2Smrg		cf_cv_mixedcase=yes
152520d2c4d2Smrg	fi
152620d2c4d2Smrg	rm -f conftest CONFTEST
152720d2c4d2Smrgfi
152820d2c4d2Smrg])
15290bd37d32Smrgtest "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
153020d2c4d2Smrg])dnl
153120d2c4d2Smrgdnl ---------------------------------------------------------------------------
15326879286fSmrgdnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1533d522f475Smrgdnl ----------
1534d522f475Smrgdnl Write a debug message to config.log, along with the line number in the
1535d522f475Smrgdnl configure script.
1536d522f475SmrgAC_DEFUN([CF_MSG_LOG],[
15376879286fSmrgecho "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1538d522f475Smrg])dnl
1539d522f475Smrgdnl ---------------------------------------------------------------------------
154001037d57Smrgdnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
15410bd37d32Smrgdnl ------------------
15420bd37d32Smrgdnl see CF_WITH_NO_LEAKS
15430bd37d32SmrgAC_DEFUN([CF_NO_LEAKS_OPTION],[
15440bd37d32SmrgAC_MSG_CHECKING(if you want to use $1 for testing)
15450bd37d32SmrgAC_ARG_WITH($1,
15460bd37d32Smrg	[$2],
15470bd37d32Smrg	[AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
15480bd37d32Smrg	 $4
15490bd37d32Smrg])
15500bd37d32Smrg	: ${with_cflags:=-g}
15510bd37d32Smrg	: ${with_no_leaks:=yes}
15520bd37d32Smrg	 with_$1=yes],
15530bd37d32Smrg	[with_$1=])
15540bd37d32SmrgAC_MSG_RESULT(${with_$1:-no})
15550bd37d32Smrg
155601037d57Smrgcase .$with_cflags in
155701037d57Smrg(.*-g*)
155801037d57Smrg	case .$CFLAGS in
155901037d57Smrg	(.*-g*)
15600bd37d32Smrg		;;
156101037d57Smrg	(*)
15620bd37d32Smrg		CF_ADD_CFLAGS([-g])
15630bd37d32Smrg		;;
15640bd37d32Smrg	esac
15650bd37d32Smrg	;;
15660bd37d32Smrgesac
15670bd37d32Smrg])dnl
15680bd37d32Smrgdnl ---------------------------------------------------------------------------
156901037d57Smrgdnl CF_PATHSEP version: 7 updated: 2015/04/12 15:39:00
1570956cc18dSsnjdnl ----------
15710bd37d32Smrgdnl Provide a value for the $PATH and similar separator (or amend the value
15720bd37d32Smrgdnl as provided in autoconf 2.5x).
1573956cc18dSsnjAC_DEFUN([CF_PATHSEP],
1574956cc18dSsnj[
15750bd37d32Smrg	AC_MSG_CHECKING(for PATH separator)
1576956cc18dSsnj	case $cf_cv_system_name in
157701037d57Smrg	(os2*)	PATH_SEPARATOR=';'  ;;
157801037d57Smrg	(*)	${PATH_SEPARATOR:=':'}  ;;
1579956cc18dSsnj	esac
158020d2c4d2Smrgifelse([$1],,,[$1=$PATH_SEPARATOR])
1581956cc18dSsnj	AC_SUBST(PATH_SEPARATOR)
15820bd37d32Smrg	AC_MSG_RESULT($PATH_SEPARATOR)
1583956cc18dSsnj])dnl
1584956cc18dSsnjdnl ---------------------------------------------------------------------------
15850bd37d32Smrgdnl CF_PATH_PROG version: 9 updated: 2012/10/04 20:12:20
1586d522f475Smrgdnl ------------
1587d522f475Smrgdnl Check for a given program, defining corresponding symbol.
1588d522f475Smrgdnl	$1 = environment variable, which is suffixed by "_PATH" in the #define.
1589d522f475Smrgdnl	$2 = program name to find.
1590d522f475Smrgdnl	$3 = optional list of additional program names to test.
1591d522f475Smrgdnl
1592d522f475Smrgdnl If there is more than one token in the result, #define the remaining tokens
1593d522f475Smrgdnl to $1_ARGS.  We need this for 'install' in particular.
1594d522f475Smrgdnl
1595d522f475Smrgdnl FIXME: we should allow this to be overridden by environment variables
1596d522f475Smrgdnl
1597d522f475SmrgAC_DEFUN([CF_PATH_PROG],[
1598956cc18dSsnjAC_REQUIRE([CF_PATHSEP])
1599d522f475Smrgtest -z "[$]$1" && $1=$2
1600d522f475SmrgAC_PATH_PROGS($1,[$]$1 $2 $3,[$]$1)
1601d522f475Smrg
1602d522f475Smrgcf_path_prog=""
1603d522f475Smrgcf_path_args=""
16046879286fSmrgIFS="${IFS:- 	}"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
1605d522f475Smrgfor cf_temp in $ac_cv_path_$1
1606d522f475Smrgdo
1607d522f475Smrg	if test -z "$cf_path_prog" ; then
1608d522f475Smrg		if test "$with_full_paths" = yes ; then
1609d522f475Smrg			CF_PATH_SYNTAX(cf_temp,break)
1610d522f475Smrg			cf_path_prog="$cf_temp"
1611d522f475Smrg		else
1612d522f475Smrg			cf_path_prog="`basename $cf_temp`"
1613d522f475Smrg		fi
1614d522f475Smrg	elif test -z "$cf_path_args" ; then
1615d522f475Smrg		cf_path_args="$cf_temp"
1616d522f475Smrg	else
1617d522f475Smrg		cf_path_args="$cf_path_args $cf_temp"
1618d522f475Smrg	fi
1619d522f475Smrgdone
1620d522f475SmrgIFS="$cf_save_ifs"
1621d522f475Smrg
1622d522f475Smrgif test -n "$cf_path_prog" ; then
1623d522f475Smrg	CF_MSG_LOG(defining path for ${cf_path_prog})
16240bd37d32Smrg	AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog",Define to pathname $1)
16250bd37d32Smrg	test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args",Define to provide args for $1)
1626d522f475Smrgfi
1627d522f475Smrg])dnl
1628d522f475Smrgdnl ---------------------------------------------------------------------------
16292e4f8982Smrgdnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
1630d522f475Smrgdnl --------------
1631d522f475Smrgdnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1632d522f475Smrgdnl begins with one of the prefix/exec_prefix variables, and then again if the
1633d522f475Smrgdnl result begins with 'NONE'.  This is necessary to work around autoconf's
1634d522f475Smrgdnl delayed evaluation of those symbols.
1635d522f475SmrgAC_DEFUN([CF_PATH_SYNTAX],[
1636d522f475Smrgif test "x$prefix" != xNONE; then
16372e4f8982Smrg	cf_path_syntax="$prefix"
1638d522f475Smrgelse
16392e4f8982Smrg	cf_path_syntax="$ac_default_prefix"
1640d522f475Smrgfi
1641d522f475Smrg
164201037d57Smrgcase ".[$]$1" in
164301037d57Smrg(.\[$]\(*\)*|.\'*\'*)
16442e4f8982Smrg	;;
164501037d57Smrg(..|./*|.\\*)
16462e4f8982Smrg	;;
164701037d57Smrg(.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
16482e4f8982Smrg	;;
164901037d57Smrg(.\[$]{*prefix}*|.\[$]{*dir}*)
16502e4f8982Smrg	eval $1="[$]$1"
16512e4f8982Smrg	case ".[$]$1" in
16522e4f8982Smrg	(.NONE/*)
16532e4f8982Smrg		$1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
16542e4f8982Smrg		;;
16552e4f8982Smrg	esac
16562e4f8982Smrg	;;
165701037d57Smrg(.no|.NONE/*)
16582e4f8982Smrg	$1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
16592e4f8982Smrg	;;
166001037d57Smrg(*)
16612e4f8982Smrg	ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
16622e4f8982Smrg	;;
1663d522f475Smrgesac
1664d522f475Smrg])dnl
1665d522f475Smrgdnl ---------------------------------------------------------------------------
16662e4f8982Smrgdnl CF_PKG_CONFIG version: 10 updated: 2015/04/26 18:06:58
1667956cc18dSsnjdnl -------------
1668956cc18dSsnjdnl Check for the package-config program, unless disabled by command-line.
1669956cc18dSsnjAC_DEFUN([CF_PKG_CONFIG],
1670956cc18dSsnj[
1671956cc18dSsnjAC_MSG_CHECKING(if you want to use pkg-config)
1672956cc18dSsnjAC_ARG_WITH(pkg-config,
1673956cc18dSsnj	[  --with-pkg-config{=path} enable/disable use of pkg-config],
1674956cc18dSsnj	[cf_pkg_config=$withval],
1675956cc18dSsnj	[cf_pkg_config=yes])
1676956cc18dSsnjAC_MSG_RESULT($cf_pkg_config)
1677956cc18dSsnj
167801037d57Smrgcase $cf_pkg_config in
167901037d57Smrg(no)
1680956cc18dSsnj	PKG_CONFIG=none
1681956cc18dSsnj	;;
168201037d57Smrg(yes)
1683e39b573cSmrg	CF_ACVERSION_CHECK(2.52,
1684e39b573cSmrg		[AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
1685e39b573cSmrg		[AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
1686956cc18dSsnj	;;
168701037d57Smrg(*)
1688956cc18dSsnj	PKG_CONFIG=$withval
1689956cc18dSsnj	;;
1690956cc18dSsnjesac
1691956cc18dSsnj
1692956cc18dSsnjtest -z "$PKG_CONFIG" && PKG_CONFIG=none
1693956cc18dSsnjif test "$PKG_CONFIG" != none ; then
1694956cc18dSsnj	CF_PATH_SYNTAX(PKG_CONFIG)
16952e4f8982Smrgelif test "x$cf_pkg_config" != xno ; then
169601037d57Smrg	AC_MSG_WARN(pkg-config is not installed)
1697956cc18dSsnjfi
1698956cc18dSsnj
1699956cc18dSsnjAC_SUBST(PKG_CONFIG)
1700956cc18dSsnj])dnl
1701956cc18dSsnjdnl ---------------------------------------------------------------------------
170201037d57Smrgdnl CF_POSIX_C_SOURCE version: 9 updated: 2015/04/12 15:39:00
1703d522f475Smrgdnl -----------------
1704d522f475Smrgdnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1705d522f475Smrgdnl
1706d522f475Smrgdnl	POSIX.1-1990				_POSIX_SOURCE
1707d522f475Smrgdnl	POSIX.1-1990 and			_POSIX_SOURCE and
1708d522f475Smrgdnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
1709d522f475Smrgdnl		Bindings Option
1710d522f475Smrgdnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
1711d522f475Smrgdnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
1712d522f475Smrgdnl	X/Open 2000				_POSIX_C_SOURCE=200112L
1713d522f475Smrgdnl
1714d522f475Smrgdnl Parameters:
1715d522f475Smrgdnl	$1 is the nominal value for _POSIX_C_SOURCE
1716d522f475SmrgAC_DEFUN([CF_POSIX_C_SOURCE],
1717d522f475Smrg[
171820d2c4d2Smrgcf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1719d522f475Smrg
1720d522f475Smrgcf_save_CFLAGS="$CFLAGS"
1721d522f475Smrgcf_save_CPPFLAGS="$CPPFLAGS"
1722d522f475Smrg
1723d522f475SmrgCF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1724d522f475SmrgCF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1725d522f475Smrg
1726d522f475SmrgAC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1727d522f475Smrg	CF_MSG_LOG(if the symbol is already defined go no further)
1728d522f475Smrg	AC_TRY_COMPILE([#include <sys/types.h>],[
1729d522f475Smrg#ifndef _POSIX_C_SOURCE
1730d522f475Smrgmake an error
1731d522f475Smrg#endif],
1732d522f475Smrg	[cf_cv_posix_c_source=no],
1733d522f475Smrg	[cf_want_posix_source=no
173401037d57Smrg	 case .$cf_POSIX_C_SOURCE in
173501037d57Smrg	 (.[[12]]??*)
1736d522f475Smrg		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1737d522f475Smrg		;;
173801037d57Smrg	 (.2)
1739d522f475Smrg		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1740d522f475Smrg		cf_want_posix_source=yes
1741d522f475Smrg		;;
174201037d57Smrg	 (.*)
1743d522f475Smrg		cf_want_posix_source=yes
1744d522f475Smrg		;;
1745d522f475Smrg	 esac
1746d522f475Smrg	 if test "$cf_want_posix_source" = yes ; then
1747d522f475Smrg		AC_TRY_COMPILE([#include <sys/types.h>],[
1748d522f475Smrg#ifdef _POSIX_SOURCE
1749d522f475Smrgmake an error
1750d522f475Smrg#endif],[],
1751d522f475Smrg		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1752d522f475Smrg	 fi
1753d522f475Smrg	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1754d522f475Smrg	 CFLAGS="$cf_trim_CFLAGS"
1755d522f475Smrg	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1756d522f475Smrg	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1757d522f475Smrg	 AC_TRY_COMPILE([#include <sys/types.h>],[
1758d522f475Smrg#ifndef _POSIX_C_SOURCE
1759d522f475Smrgmake an error
1760d522f475Smrg#endif],,
1761d522f475Smrg	 [cf_cv_posix_c_source=no])
1762d522f475Smrg	 CFLAGS="$cf_save_CFLAGS"
1763d522f475Smrg	 CPPFLAGS="$cf_save_CPPFLAGS"
1764d522f475Smrg	])
1765d522f475Smrg])
1766d522f475Smrg
1767d522f475Smrgif test "$cf_cv_posix_c_source" != no ; then
1768d522f475Smrg	CFLAGS="$cf_trim_CFLAGS"
1769d522f475Smrg	CPPFLAGS="$cf_trim_CPPFLAGS"
177020d2c4d2Smrg	CF_ADD_CFLAGS($cf_cv_posix_c_source)
1771d522f475Smrgfi
1772d522f475Smrg
1773d522f475Smrg])dnl
1774d522f475Smrgdnl ---------------------------------------------------------------------------
17750bd37d32Smrgdnl CF_POSIX_SAVED_IDS version: 8 updated: 2012/10/04 20:12:20
1776d522f475Smrgdnl ------------------
1777d522f475Smrgdnl
1778d522f475Smrgdnl Check first if saved-ids are always supported.  Some systems
1779d522f475Smrgdnl may require runtime checks.
1780d522f475SmrgAC_DEFUN([CF_POSIX_SAVED_IDS],
1781d522f475Smrg[
1782d522f475SmrgAC_CHECK_HEADERS( \
1783d522f475Smrgsys/param.h \
1784d522f475Smrg)
1785d522f475Smrg
1786d522f475SmrgAC_CACHE_CHECK(if POSIX saved-ids are supported,cf_cv_posix_saved_ids,[
1787d522f475SmrgAC_TRY_LINK(
1788d522f475Smrg[
1789d522f475Smrg#include <unistd.h>
1790d522f475Smrg#ifdef HAVE_SYS_PARAM_H
1791d522f475Smrg#include <sys/param.h>		/* this may define "BSD" */
1792d522f475Smrg#endif
1793d522f475Smrg],[
1794d522f475Smrg#if defined(_POSIX_SAVED_IDS) && (_POSIX_SAVED_IDS > 0)
1795d522f475Smrg	void *p = (void *) seteuid;
1796d522f475Smrg	int x = seteuid(geteuid());
1797d522f475Smrg#elif defined(BSD) && (BSD >= 199103)
1798d522f475Smrg/* The BSD's may implement the runtime check - and it fails.
1799d522f475Smrg * However, saved-ids work almost like POSIX (close enough for most uses).
1800d522f475Smrg */
1801d522f475Smrg#else
1802d522f475Smrgmake an error
1803d522f475Smrg#endif
1804d522f475Smrg],[cf_cv_posix_saved_ids=yes
1805d522f475Smrg],[
1806d522f475SmrgAC_TRY_RUN([
1807d522f475Smrg#ifdef HAVE_STDLIB_H
1808d522f475Smrg#include <stdlib.h>
1809d522f475Smrg#endif
1810d522f475Smrg#include <unistd.h>
1811d522f475Smrgint main()
1812d522f475Smrg{
1813d522f475Smrg	void *p = (void *) seteuid;
1814d522f475Smrg	long code = sysconf(_SC_SAVED_IDS);
1815d522f475Smrg	${cf_cv_main_return:-return}  ((code > 0) ? 0 : 1);
1816d522f475Smrg}],
1817d522f475Smrg	cf_cv_posix_saved_ids=yes,
1818d522f475Smrg	cf_cv_posix_saved_ids=no,
1819d522f475Smrg	cf_cv_posix_saved_ids=unknown)
1820d522f475Smrg])
1821d522f475Smrg])
1822d522f475Smrg
18230bd37d32Smrgtest "$cf_cv_posix_saved_ids" = yes && AC_DEFINE(HAVE_POSIX_SAVED_IDS,1,[Define to 1 if POSIX saved-ids are supported])
1824d522f475Smrg])
1825d522f475Smrgdnl ---------------------------------------------------------------------------
18260bd37d32Smrgdnl CF_POSIX_WAIT version: 3 updated: 2012/10/04 20:12:20
1827d522f475Smrgdnl -------------
1828d522f475Smrgdnl Check for POSIX wait support
1829d522f475SmrgAC_DEFUN([CF_POSIX_WAIT],
1830d522f475Smrg[
1831d522f475SmrgAC_REQUIRE([AC_HEADER_SYS_WAIT])
1832d522f475SmrgAC_CACHE_CHECK(for POSIX wait functions,cf_cv_posix_wait,[
1833d522f475SmrgAC_TRY_LINK([
1834d522f475Smrg#include <stdlib.h>
1835d522f475Smrg#include <stdio.h>
1836d522f475Smrg#include <sys/types.h>
1837d522f475Smrg#ifdef HAVE_SYS_WAIT_H
1838d522f475Smrg#include <sys/wait.h>
1839d522f475Smrg#endif
1840d522f475Smrg],[
1841d522f475Smrg	int stat_loc;
1842d522f475Smrg	pid_t pid = waitpid(-1, &stat_loc, WNOHANG|WUNTRACED);
1843d522f475Smrg	pid_t pid2 = wait(&stat_loc);
1844d522f475Smrg],
1845d522f475Smrg[cf_cv_posix_wait=yes],
1846d522f475Smrg[cf_cv_posix_wait=no])
1847d522f475Smrg])
18480bd37d32Smrgtest "$cf_cv_posix_wait" = yes && AC_DEFINE(USE_POSIX_WAIT,1,[Define to 1 if we have POSIX wait functions])
1849d522f475Smrg])dnl
1850d522f475Smrgdnl ---------------------------------------------------------------------------
1851d522f475Smrgdnl CF_PROCFS_CWD version: 2 updated: 2007/03/12 20:39:04
1852d522f475Smrgdnl -------------
1853d522f475Smrgdnl Find /proc tree (may be in a different place) which implements the "cwd"
1854d522f475Smrgdnl link.
1855d522f475SmrgAC_DEFUN([CF_PROCFS_CWD],[
1856d522f475SmrgAC_CACHE_CHECK(for proc tree with cwd-support,cf_cv_procfs_cwd,[
1857d522f475Smrgcf_cv_procfs_cwd=no
1858d522f475Smrgfor cf_path in /proc /compat/linux/proc /usr/compat/linux/proc
1859d522f475Smrgdo
1860d522f475Smrg	if test -d $cf_path && \
1861d522f475Smrg	   test -d $cf_path/$$ && \
1862d522f475Smrg	   ( test -d $cf_path/$$/cwd || \
1863d522f475Smrg	     test -L $cf_path/$$/cwd ); then
1864d522f475Smrg		cf_cv_procfs_cwd=$cf_path
1865d522f475Smrg		break
1866d522f475Smrg	fi
1867d522f475Smrgdone
1868d522f475Smrg])
1869d522f475Smrg])dnl
1870d522f475Smrgdnl ---------------------------------------------------------------------------
187101037d57Smrgdnl CF_PROG_CC version: 4 updated: 2014/07/12 18:57:58
18720bd37d32Smrgdnl ----------
18730bd37d32Smrgdnl standard check for CC, plus followup sanity checks
18740bd37d32Smrgdnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
18750bd37d32SmrgAC_DEFUN([CF_PROG_CC],[
18760bd37d32Smrgifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
18770bd37d32SmrgCF_GCC_VERSION
18780bd37d32SmrgCF_ACVERSION_CHECK(2.52,
18790bd37d32Smrg	[AC_PROG_CC_STDC],
18800bd37d32Smrg	[CF_ANSI_CC_REQD])
188101037d57SmrgCF_CC_ENV_FLAGS
1882d522f475Smrg])dnl
1883d522f475Smrgdnl ---------------------------------------------------------------------------
18842e4f8982Smrgdnl CF_PROG_GROFF version: 2 updated: 2015/07/04 11:16:27
18850bd37d32Smrgdnl -------------
18860bd37d32Smrgdnl Check if groff is available, for cases (such as html output) where nroff
18870bd37d32Smrgdnl is not enough.
18880bd37d32SmrgAC_DEFUN([CF_PROG_GROFF],[
18890bd37d32SmrgAC_PATH_PROG(GROFF_PATH,groff,no)
18902e4f8982SmrgAC_PATH_PROG(NROFF_PATH,nroff,no)
18910bd37d32Smrgif test "x$GROFF_PATH" = xno
18920bd37d32Smrgthen
18930bd37d32Smrg	NROFF_NOTE=
18940bd37d32Smrg	GROFF_NOTE="#"
18950bd37d32Smrgelse
18960bd37d32Smrg	NROFF_NOTE="#"
18970bd37d32Smrg	GROFF_NOTE=
18980bd37d32Smrgfi
18990bd37d32SmrgAC_SUBST(GROFF_NOTE)
19000bd37d32SmrgAC_SUBST(NROFF_NOTE)
1901d522f475Smrg])dnl
1902d522f475Smrgdnl ---------------------------------------------------------------------------
19032e4f8982Smrgdnl CF_PROG_LINT version: 3 updated: 2016/05/22 15:25:54
19042e4f8982Smrgdnl ------------
19052e4f8982SmrgAC_DEFUN([CF_PROG_LINT],
19062e4f8982Smrg[
19072e4f8982SmrgAC_CHECK_PROGS(LINT, lint cppcheck splint)
19082e4f8982SmrgAC_SUBST(LINT_OPTS)
19092e4f8982Smrg])dnl
19102e4f8982Smrgdnl ---------------------------------------------------------------------------
19112e4f8982Smrgdnl CF_REGEX version: 12 updated: 2015/04/18 08:56:57
1912d522f475Smrgdnl --------
1913d522f475Smrgdnl Attempt to determine if we've got one of the flavors of regular-expression
1914d522f475Smrgdnl code that we can support.
1915d522f475SmrgAC_DEFUN([CF_REGEX],
1916d522f475Smrg[
191720d2c4d2Smrg
191820d2c4d2Smrgcf_regex_func=no
191920d2c4d2Smrg
19206879286fSmrgcf_regex_libs="regex re"
192101037d57Smrgcase $host_os in
192201037d57Smrg(mingw*)
19230bd37d32Smrg	cf_regex_libs="gnurx $cf_regex_libs"
19246879286fSmrg	;;
19256879286fSmrgesac
19266879286fSmrg
192720d2c4d2SmrgAC_CHECK_FUNC(regcomp,[cf_regex_func=regcomp],[
19286879286fSmrg	for cf_regex_lib in $cf_regex_libs
192920d2c4d2Smrg	do
193020d2c4d2Smrg		AC_CHECK_LIB($cf_regex_lib,regcomp,[
193120d2c4d2Smrg				CF_ADD_LIB($cf_regex_lib)
193220d2c4d2Smrg				cf_regex_func=regcomp
193320d2c4d2Smrg				break])
193420d2c4d2Smrg	done
193520d2c4d2Smrg])
193620d2c4d2Smrg
193720d2c4d2Smrgif test "$cf_regex_func" = no ; then
193820d2c4d2Smrg	AC_CHECK_FUNC(compile,[cf_regex_func=compile],[
193920d2c4d2Smrg		AC_CHECK_LIB(gen,compile,[
194020d2c4d2Smrg				CF_ADD_LIB(gen)
194120d2c4d2Smrg				cf_regex_func=compile])])
194220d2c4d2Smrgfi
194320d2c4d2Smrg
194420d2c4d2Smrgif test "$cf_regex_func" = no ; then
194520d2c4d2Smrg	AC_MSG_WARN(cannot find regular expression library)
194620d2c4d2Smrgfi
194720d2c4d2Smrg
194820d2c4d2SmrgAC_CACHE_CHECK(for regular-expression headers,cf_cv_regex_hdrs,[
194920d2c4d2Smrg
195020d2c4d2Smrgcf_cv_regex_hdrs=no
195101037d57Smrgcase $cf_regex_func in
195201037d57Smrg(compile)
195320d2c4d2Smrg	for cf_regex_hdr in regexp.h regexpr.h
195420d2c4d2Smrg	do
195520d2c4d2Smrg		AC_TRY_LINK([#include <$cf_regex_hdr>],[
195620d2c4d2Smrg			char *p = compile("", "", "", 0);
1957d522f475Smrg			int x = step("", "");
195820d2c4d2Smrg		],[
195920d2c4d2Smrg			cf_cv_regex_hdrs=$cf_regex_hdr
196020d2c4d2Smrg			break
196120d2c4d2Smrg		])
196220d2c4d2Smrg	done
196320d2c4d2Smrg	;;
196401037d57Smrg(*)
196520d2c4d2Smrg	for cf_regex_hdr in regex.h
196620d2c4d2Smrg	do
196720d2c4d2Smrg		AC_TRY_LINK([#include <sys/types.h>
196820d2c4d2Smrg#include <$cf_regex_hdr>],[
196920d2c4d2Smrg			regex_t *p;
197020d2c4d2Smrg			int x = regcomp(p, "", 0);
197120d2c4d2Smrg			int y = regexec(p, "", 0, 0, 0);
197220d2c4d2Smrg			regfree(p);
197320d2c4d2Smrg		],[
197420d2c4d2Smrg			cf_cv_regex_hdrs=$cf_regex_hdr
197520d2c4d2Smrg			break
197620d2c4d2Smrg		])
197720d2c4d2Smrg	done
197820d2c4d2Smrg	;;
197920d2c4d2Smrgesac
198020d2c4d2Smrg
1981d522f475Smrg])
198220d2c4d2Smrg
198301037d57Smrgcase $cf_cv_regex_hdrs in
19842e4f8982Smrg	(no)		AC_MSG_WARN(no regular expression header found) ;;
19852e4f8982Smrg	(regex.h)	AC_DEFINE(HAVE_REGEX_H_FUNCS,1,[Define to 1 to include regex.h for regular expressions]) ;;
19862e4f8982Smrg	(regexp.h)	AC_DEFINE(HAVE_REGEXP_H_FUNCS,1,[Define to 1 to include regexp.h for regular expressions]) ;;
19872e4f8982Smrg	(regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS,1,[Define to 1 to include regexpr.h for regular expressions]) ;;
1988d522f475Smrgesac
1989d522f475Smrg])dnl
1990d522f475Smrgdnl ---------------------------------------------------------------------------
199120d2c4d2Smrgdnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
1992d522f475Smrgdnl ----------------
1993d522f475Smrgdnl Remove all -U and -D options that refer to the given symbol from a list
1994d522f475Smrgdnl of C compiler options.  This works around the problem that not all
1995d522f475Smrgdnl compilers process -U and -D options from left-to-right, so a -U option
1996d522f475Smrgdnl cannot be used to cancel the effect of a preceding -D option.
1997d522f475Smrgdnl
1998d522f475Smrgdnl $1 = target (which could be the same as the source variable)
1999d522f475Smrgdnl $2 = source (including '$')
2000d522f475Smrgdnl $3 = symbol to remove
2001d522f475Smrgdefine([CF_REMOVE_DEFINE],
2002d522f475Smrg[
2003d522f475Smrg$1=`echo "$2" | \
200420d2c4d2Smrg	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
200520d2c4d2Smrg		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
200620d2c4d2Smrg])dnl
200720d2c4d2Smrgdnl ---------------------------------------------------------------------------
2008e0a2b6dfSmrgdnl CF_RPATH_HACK version: 11 updated: 2013/09/01 13:02:00
200920d2c4d2Smrgdnl -------------
201020d2c4d2SmrgAC_DEFUN([CF_RPATH_HACK],
201120d2c4d2Smrg[
201220d2c4d2SmrgAC_REQUIRE([CF_LD_RPATH_OPT])
201320d2c4d2SmrgAC_MSG_CHECKING(for updated LDFLAGS)
201420d2c4d2Smrgif test -n "$LD_RPATH_OPT" ; then
201520d2c4d2Smrg	AC_MSG_RESULT(maybe)
201620d2c4d2Smrg
201720d2c4d2Smrg	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
201820d2c4d2Smrg	cf_rpath_list="/usr/lib /lib"
201920d2c4d2Smrg	if test "$cf_ldd_prog" != no
202020d2c4d2Smrg	then
2021a1f3da82Smrg		cf_rpath_oops=
2022a1f3da82Smrg
202320d2c4d2SmrgAC_TRY_LINK([#include <stdio.h>],
202420d2c4d2Smrg		[printf("Hello");],
2025e0a2b6dfSmrg		[cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
2026e0a2b6dfSmrg		 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
2027a1f3da82Smrg
2028a1f3da82Smrg		# If we passed the link-test, but get a "not found" on a given library,
2029a1f3da82Smrg		# this could be due to inept reconfiguration of gcc to make it only
2030a1f3da82Smrg		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
2031a1f3da82Smrg		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
2032a1f3da82Smrg		# /usr/local libraries.
2033a1f3da82Smrg		if test -n "$cf_rpath_oops"
2034a1f3da82Smrg		then
2035a1f3da82Smrg			for cf_rpath_src in $cf_rpath_oops
2036a1f3da82Smrg			do
2037a1f3da82Smrg				for cf_rpath_dir in \
2038a1f3da82Smrg					/usr/local \
2039a1f3da82Smrg					/usr/pkg \
2040a1f3da82Smrg					/opt/sfw
2041a1f3da82Smrg				do
2042a1f3da82Smrg					if test -f $cf_rpath_dir/lib/$cf_rpath_src
2043a1f3da82Smrg					then
2044a1f3da82Smrg						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
2045a1f3da82Smrg						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
2046a1f3da82Smrg						break
2047a1f3da82Smrg					fi
2048a1f3da82Smrg				done
2049a1f3da82Smrg			done
2050a1f3da82Smrg		fi
205120d2c4d2Smrg	fi
205220d2c4d2Smrg
205320d2c4d2Smrg	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
205420d2c4d2Smrg
205520d2c4d2Smrg	CF_RPATH_HACK_2(LDFLAGS)
205620d2c4d2Smrg	CF_RPATH_HACK_2(LIBS)
205720d2c4d2Smrg
205820d2c4d2Smrg	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2059e0a2b6dfSmrgelse
2060e0a2b6dfSmrg	AC_MSG_RESULT(no)
206120d2c4d2Smrgfi
206220d2c4d2SmrgAC_SUBST(EXTRA_LDFLAGS)
206320d2c4d2Smrg])dnl
206420d2c4d2Smrgdnl ---------------------------------------------------------------------------
206501037d57Smrgdnl CF_RPATH_HACK_2 version: 7 updated: 2015/04/12 15:39:00
206620d2c4d2Smrgdnl ---------------
206720d2c4d2Smrgdnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
206820d2c4d2Smrgdnl EXTRA_LDFLAGS for each -L option found.
206920d2c4d2Smrgdnl
207020d2c4d2Smrgdnl $cf_rpath_list contains a list of directories to ignore.
207120d2c4d2Smrgdnl
207220d2c4d2Smrgdnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
207320d2c4d2Smrgdnl      but LIBS often has misplaced -L options.
207420d2c4d2SmrgAC_DEFUN([CF_RPATH_HACK_2],
207520d2c4d2Smrg[
207620d2c4d2SmrgCF_VERBOSE(...checking $1 [$]$1)
207720d2c4d2Smrg
207820d2c4d2Smrgcf_rpath_dst=
207920d2c4d2Smrgfor cf_rpath_src in [$]$1
208020d2c4d2Smrgdo
208101037d57Smrg	case $cf_rpath_src in
208201037d57Smrg	(-L*)
208320d2c4d2Smrg
208420d2c4d2Smrg		# check if this refers to a directory which we will ignore
208520d2c4d2Smrg		cf_rpath_skip=no
208620d2c4d2Smrg		if test -n "$cf_rpath_list"
208720d2c4d2Smrg		then
208820d2c4d2Smrg			for cf_rpath_item in $cf_rpath_list
208920d2c4d2Smrg			do
209020d2c4d2Smrg				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
209120d2c4d2Smrg				then
209220d2c4d2Smrg					cf_rpath_skip=yes
209320d2c4d2Smrg					break
209420d2c4d2Smrg				fi
209520d2c4d2Smrg			done
209620d2c4d2Smrg		fi
209720d2c4d2Smrg
209820d2c4d2Smrg		if test "$cf_rpath_skip" = no
209920d2c4d2Smrg		then
210020d2c4d2Smrg			# transform the option
210120d2c4d2Smrg			if test "$LD_RPATH_OPT" = "-R " ; then
210220d2c4d2Smrg				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
210320d2c4d2Smrg			else
210420d2c4d2Smrg				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
210520d2c4d2Smrg			fi
210620d2c4d2Smrg
210720d2c4d2Smrg			# if we have not already added this, add it now
210820d2c4d2Smrg			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
210920d2c4d2Smrg			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
211020d2c4d2Smrg			then
211120d2c4d2Smrg				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
211220d2c4d2Smrg				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
211320d2c4d2Smrg			fi
211420d2c4d2Smrg		fi
211520d2c4d2Smrg		;;
211620d2c4d2Smrg	esac
211720d2c4d2Smrg	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
211820d2c4d2Smrgdone
211920d2c4d2Smrg$1=$cf_rpath_dst
212020d2c4d2Smrg
212120d2c4d2SmrgCF_VERBOSE(...checked $1 [$]$1)
212220d2c4d2SmrgAC_SUBST(EXTRA_LDFLAGS)
2123d522f475Smrg])dnl
2124d522f475Smrgdnl ---------------------------------------------------------------------------
2125d522f475Smrgdnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
2126d522f475Smrgdnl -----------
2127d522f475Smrgdnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
2128d522f475Smrgdnl programs need this test).
2129d522f475Smrgdnl
2130d522f475Smrgdnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
2131d522f475Smrgdnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
2132d522f475Smrgdnl winsize declaration is left alone - we may revisit this if Apple choose to
2133d522f475Smrgdnl break that part of the interface as well.
2134d522f475SmrgAC_DEFUN([CF_SIGWINCH],
2135d522f475Smrg[
2136d522f475SmrgAC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
2137d522f475Smrg	AC_TRY_COMPILE([
2138d522f475Smrg#include <sys/types.h>
2139d522f475Smrg#include <sys/signal.h>
2140d522f475Smrg],[int x = SIGWINCH],
2141d522f475Smrg	[cf_cv_define_sigwinch=yes],
2142d522f475Smrg	[AC_TRY_COMPILE([
2143d522f475Smrg#undef _XOPEN_SOURCE
2144d522f475Smrg#undef _POSIX_SOURCE
2145d522f475Smrg#undef _POSIX_C_SOURCE
2146d522f475Smrg#include <sys/types.h>
2147d522f475Smrg#include <sys/signal.h>
2148d522f475Smrg],[int x = SIGWINCH],
2149d522f475Smrg	[cf_cv_define_sigwinch=maybe],
2150d522f475Smrg	[cf_cv_define_sigwinch=no])
2151d522f475Smrg])
2152d522f475Smrg])
2153d522f475Smrg
2154d522f475Smrgif test "$cf_cv_define_sigwinch" = maybe ; then
2155d522f475SmrgAC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
2156d522f475Smrgcf_cv_fixup_sigwinch=unknown
2157d522f475Smrgcf_sigwinch=32
2158d522f475Smrgwhile test $cf_sigwinch != 1
2159d522f475Smrgdo
2160d522f475Smrg	AC_TRY_COMPILE([
2161d522f475Smrg#undef _XOPEN_SOURCE
2162d522f475Smrg#undef _POSIX_SOURCE
2163d522f475Smrg#undef _POSIX_C_SOURCE
2164d522f475Smrg#include <sys/types.h>
2165d522f475Smrg#include <sys/signal.h>
2166d522f475Smrg],[
2167d522f475Smrg#if SIGWINCH != $cf_sigwinch
2168d522f475Smrgmake an error
2169d522f475Smrg#endif
2170d522f475Smrgint x = SIGWINCH],
2171d522f475Smrg	[cf_cv_fixup_sigwinch=$cf_sigwinch
2172d522f475Smrg	 break])
2173d522f475Smrg
2174d522f475Smrgcf_sigwinch=`expr $cf_sigwinch - 1`
2175d522f475Smrgdone
2176d522f475Smrg])
2177d522f475Smrg
2178d522f475Smrg	if test "$cf_cv_fixup_sigwinch" != unknown ; then
2179d522f475Smrg		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
2180d522f475Smrg	fi
2181d522f475Smrgfi
2182d522f475Smrg])dnl
2183d522f475Smrgdnl ---------------------------------------------------------------------------
21840bd37d32Smrgdnl CF_SIG_ATOMIC_T version: 3 updated: 2012/10/04 20:12:20
2185d522f475Smrgdnl ---------------
2186d522f475Smrgdnl signal handler, but there are some gcc depedencies in that recommendation.
2187d522f475Smrgdnl Try anyway.
2188d522f475SmrgAC_DEFUN([CF_SIG_ATOMIC_T],
2189d522f475Smrg[
2190d522f475SmrgAC_MSG_CHECKING(for signal global datatype)
2191d522f475SmrgAC_CACHE_VAL(cf_cv_sig_atomic_t,[
2192d522f475Smrg	for cf_type in \
2193d522f475Smrg		"volatile sig_atomic_t" \
2194d522f475Smrg		"sig_atomic_t" \
2195d522f475Smrg		"int"
2196d522f475Smrg	do
2197d522f475Smrg	AC_TRY_COMPILE([
2198d522f475Smrg#include <sys/types.h>
2199d522f475Smrg#include <signal.h>
2200d522f475Smrg#include <stdio.h>
2201d522f475Smrg
2202d522f475Smrgextern $cf_type x;
2203d522f475Smrg$cf_type x;
2204d522f475Smrgstatic void handler(int sig)
2205d522f475Smrg{
2206d522f475Smrg	x = 5;
2207d522f475Smrg}],
2208d522f475Smrg		[signal(SIGINT, handler);
2209d522f475Smrg		 x = 1],
2210d522f475Smrg		[cf_cv_sig_atomic_t=$cf_type],
2211d522f475Smrg		[cf_cv_sig_atomic_t=no])
2212d522f475Smrg		test "$cf_cv_sig_atomic_t" != no && break
2213d522f475Smrg	done
2214d522f475Smrg	])
2215d522f475SmrgAC_MSG_RESULT($cf_cv_sig_atomic_t)
22160bd37d32Smrgtest "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
2217d522f475Smrg])dnl
2218d522f475Smrgdnl ---------------------------------------------------------------------------
22190bd37d32Smrgdnl CF_STRUCT_LASTLOG version: 2 updated: 2012/10/04 20:12:20
2220d522f475Smrgdnl -----------------
2221d522f475Smrgdnl Check for header defining struct lastlog, ensure that its .ll_time member
2222d522f475Smrgdnl is compatible with time().
2223d522f475SmrgAC_DEFUN([CF_STRUCT_LASTLOG],
2224d522f475Smrg[
2225d522f475SmrgAC_CHECK_HEADERS(lastlog.h)
2226d522f475SmrgAC_CACHE_CHECK(for struct lastlog,cf_cv_struct_lastlog,[
2227d522f475SmrgAC_TRY_RUN([
2228d522f475Smrg#include <sys/types.h>
2229d522f475Smrg#include <time.h>
2230d522f475Smrg#include <lastlog.h>
2231d522f475Smrg
2232d522f475Smrgint main()
2233d522f475Smrg{
2234d522f475Smrg	struct lastlog data;
2235d522f475Smrg	return (sizeof(data.ll_time) != sizeof(time_t));
2236d522f475Smrg}],[
2237d522f475Smrgcf_cv_struct_lastlog=yes],[
2238d522f475Smrgcf_cv_struct_lastlog=no],[
2239d522f475Smrgcf_cv_struct_lastlog=unknown])])
2240d522f475Smrg
22410bd37d32Smrgtest $cf_cv_struct_lastlog != no && AC_DEFINE(USE_STRUCT_LASTLOG,1,[Define to 1 if we have struct lastlog])
2242d522f475Smrg])dnl
2243d522f475Smrgdnl ---------------------------------------------------------------------------
22440bd37d32Smrgdnl CF_SVR4 version: 5 updated: 2012/10/04 05:24:07
2245d522f475Smrgdnl -------
2246d522f475Smrgdnl Check if this is an SVR4 system.  We need the definition for xterm
2247d522f475SmrgAC_DEFUN([CF_SVR4],
2248d522f475Smrg[
2249d522f475SmrgAC_CHECK_LIB(elf, elf_begin,[
2250d522f475SmrgAC_CACHE_CHECK(if this is an SVR4 system, cf_cv_svr4,[
2251d522f475SmrgAC_TRY_COMPILE([
22520bd37d32Smrg#if defined(__CYGWIN__)
22530bd37d32Smrgmake an error
22540bd37d32Smrg#endif
2255d522f475Smrg#include <elf.h>
2256d522f475Smrg#include <sys/termio.h>
2257d522f475Smrg],[
2258d522f475Smrgstatic struct termio d_tio;
2259d522f475Smrg	d_tio.c_cc[VINTR] = 0;
2260d522f475Smrg	d_tio.c_cc[VQUIT] = 0;
2261d522f475Smrg	d_tio.c_cc[VERASE] = 0;
2262d522f475Smrg	d_tio.c_cc[VKILL] = 0;
2263d522f475Smrg	d_tio.c_cc[VEOF] = 0;
2264d522f475Smrg	d_tio.c_cc[VEOL] = 0;
2265d522f475Smrg	d_tio.c_cc[VMIN] = 0;
2266d522f475Smrg	d_tio.c_cc[VTIME] = 0;
2267d522f475Smrg	d_tio.c_cc[VLNEXT] = 0;
2268d522f475Smrg],
2269d522f475Smrg[cf_cv_svr4=yes],
2270d522f475Smrg[cf_cv_svr4=no])
2271d522f475Smrg])
2272d522f475Smrg])
22730bd37d32Smrgtest "$cf_cv_svr4" = yes && AC_DEFINE(SVR4,1,[Define to 1 if this is an SVR4 system])
2274d522f475Smrg])dnl
2275d522f475Smrgdnl ---------------------------------------------------------------------------
22760bd37d32Smrgdnl CF_SYSV version: 15 updated: 2012/10/04 05:24:07
2277d522f475Smrgdnl -------
2278d522f475Smrgdnl Check if this is a SYSV platform, e.g., as used in <X11/Xos.h>, and whether
2279d522f475Smrgdnl defining it will be helpful.  The following features are used to check:
2280d522f475Smrgdnl
2281d522f475Smrgdnl a) bona-fide SVSV doesn't use const for sys_errlist[].  Since this is a
2282d522f475Smrgdnl legacy (pre-ANSI) feature, const should not apply.  Modern systems only
2283d522f475Smrgdnl declare strerror().  Xos.h declares the legacy form of str_errlist[], and
2284d522f475Smrgdnl a compile-time error will result from trying to assign to a const array.
2285d522f475Smrgdnl
2286d522f475Smrgdnl b) compile with headers that exist on SYSV hosts.
2287d522f475Smrgdnl
2288d522f475Smrgdnl c) compile with type definitions that differ on SYSV hosts from standard C.
2289d522f475SmrgAC_DEFUN([CF_SYSV],
2290d522f475Smrg[
2291d522f475SmrgAC_CHECK_HEADERS( \
2292d522f475Smrgtermios.h \
2293d522f475Smrgstdlib.h \
2294d522f475SmrgX11/Intrinsic.h \
2295d522f475Smrg)
2296d522f475Smrg
2297d522f475SmrgAC_REQUIRE([CF_SYS_ERRLIST])
2298d522f475Smrg
2299d522f475SmrgAC_CACHE_CHECK(if we should define SYSV,cf_cv_sysv,[
2300d522f475SmrgAC_TRY_COMPILE([
2301d522f475Smrg#undef  SYSV
2302d522f475Smrg#define SYSV 1			/* get Xos.h to declare sys_errlist[] */
2303d522f475Smrg#ifdef HAVE_STDLIB_H
2304d522f475Smrg#include <stdlib.h>		/* look for wchar_t */
2305d522f475Smrg#endif
2306d522f475Smrg#ifdef HAVE_X11_INTRINSIC_H
2307d522f475Smrg#include <X11/Intrinsic.h>	/* Intrinsic.h has other traps... */
2308d522f475Smrg#endif
23090bd37d32Smrg#ifdef HAVE_TERMIOS_H		/* needed for HPUX 10.20 */
23100bd37d32Smrg#include <termios.h>
23110bd37d32Smrg#define STRUCT_TERMIOS struct termios
23120bd37d32Smrg#else
23130bd37d32Smrg#define STRUCT_TERMIOS struct termio
23140bd37d32Smrg#endif
2315d522f475Smrg#include <curses.h>
2316d522f475Smrg#include <term.h>		/* eliminate most BSD hacks */
2317d522f475Smrg#include <errno.h>		/* declare sys_errlist on older systems */
2318d522f475Smrg#include <sys/termio.h>		/* eliminate most of the remaining ones */
2319d522f475Smrg],[
2320d522f475Smrgstatic STRUCT_TERMIOS d_tio;
2321d522f475Smrg	d_tio.c_cc[VINTR] = 0;
2322d522f475Smrg	d_tio.c_cc[VQUIT] = 0;
2323d522f475Smrg	d_tio.c_cc[VERASE] = 0;
2324d522f475Smrg	d_tio.c_cc[VKILL] = 0;
2325d522f475Smrg	d_tio.c_cc[VEOF] = 0;
2326d522f475Smrg	d_tio.c_cc[VEOL] = 0;
2327d522f475Smrg	d_tio.c_cc[VMIN] = 0;
2328d522f475Smrg	d_tio.c_cc[VTIME] = 0;
2329d522f475Smrg#if defined(HAVE_SYS_ERRLIST) && !defined(DECL_SYS_ERRLIST)
2330d522f475Smrgsys_errlist[0] = "";		/* Cygwin mis-declares this */
2331d522f475Smrg#endif
2332d522f475Smrg],
2333d522f475Smrg[cf_cv_sysv=yes],
2334d522f475Smrg[cf_cv_sysv=no])
2335d522f475Smrg])
23360bd37d32Smrgtest "$cf_cv_sysv" = yes && AC_DEFINE(SYSV,1,[Define to 1 if this is an SYSV system])
2337d522f475Smrg])dnl
2338d522f475Smrgdnl ---------------------------------------------------------------------------
23390bd37d32Smrgdnl CF_SYSV_UTMP version: 6 updated: 2012/10/04 20:12:20
2340d522f475Smrgdnl ------------
2341d522f475Smrgdnl Check if this is a SYSV flavor of UTMP
2342d522f475SmrgAC_DEFUN([CF_SYSV_UTMP],
2343d522f475Smrg[
2344d522f475SmrgAC_CACHE_CHECK(if $cf_cv_have_utmp is SYSV flavor,cf_cv_sysv_utmp,[
2345d522f475Smrgtest "$cf_cv_have_utmp" = "utmp" && cf_prefix="ut" || cf_prefix="utx"
2346d522f475SmrgAC_TRY_LINK([
2347d522f475Smrg#include <sys/types.h>
2348d522f475Smrg#include <${cf_cv_have_utmp}.h>],[
2349d522f475Smrgstruct $cf_cv_have_utmp x;
2350d522f475Smrg	set${cf_prefix}ent ();
2351d522f475Smrg	get${cf_prefix}id(&x);
2352d522f475Smrg	put${cf_prefix}line(&x);
2353d522f475Smrg	end${cf_prefix}ent();],
2354d522f475Smrg	[cf_cv_sysv_utmp=yes],
2355d522f475Smrg	[cf_cv_sysv_utmp=no])
2356d522f475Smrg])
23570bd37d32Smrgtest $cf_cv_sysv_utmp = yes && AC_DEFINE(USE_SYSV_UTMP,1,[Define to 1 if utmp is SYSV flavor])
2358d522f475Smrg])dnl
2359d522f475Smrgdnl ---------------------------------------------------------------------------
2360d522f475Smrgdnl CF_SYS_ERRLIST version: 6 updated: 2001/12/30 13:03:23
2361d522f475Smrgdnl --------------
2362d522f475Smrgdnl Check for declaration of sys_nerr and sys_errlist in one of stdio.h and
2363d522f475Smrgdnl errno.h.  Declaration of sys_errlist on BSD4.4 interferes with our
2364d522f475Smrgdnl declaration.  Reported by Keith Bostic.
2365d522f475SmrgAC_DEFUN([CF_SYS_ERRLIST],
2366d522f475Smrg[
2367d522f475Smrg    CF_CHECK_ERRNO(sys_nerr)
2368d522f475Smrg    CF_CHECK_ERRNO(sys_errlist)
2369d522f475Smrg])dnl
2370d522f475Smrgdnl ---------------------------------------------------------------------------
23710bd37d32Smrgdnl CF_TERMIO_C_ISPEED version: 3 updated: 2012/10/04 20:12:20
2372d522f475Smrgdnl ------------------
2373d522f475Smrgdnl Check for SGI's broken redefinition of baud rates introduced in IRIX 6.5
2374d522f475Smrgdnl (there doesn't appear to be a useful predefined symbol).
2375d522f475SmrgAC_DEFUN([CF_TERMIO_C_ISPEED],
2376d522f475Smrg[
2377d522f475SmrgAC_CACHE_CHECK(for IRIX 6.5 baud-rate redefinitions,cf_cv_termio_c_ispeed,[
2378d522f475SmrgAC_TRY_COMPILE([
2379d522f475Smrg#include <sys/types.h>
2380d522f475Smrg#include <sys/termio.h>],[
2381d522f475Smrgstruct termio foo;
2382d522f475Smrgfoo.c_ispeed = B38400;
2383d522f475Smrgfoo.c_ospeed = B9600;
2384d522f475Smrg],[cf_cv_termio_c_ispeed=yes
2385d522f475Smrg],[cf_cv_termio_c_ispeed=no])
2386d522f475Smrg])
23870bd37d32Smrgtest "$cf_cv_termio_c_ispeed" = yes && AC_DEFINE(HAVE_TERMIO_C_ISPEED,1,[define 1 if we have IRIX 6.5 baud-rate redefinitions])
2388d522f475Smrg])dnl
2389d522f475Smrgdnl ---------------------------------------------------------------------------
239001037d57Smrgdnl CF_TRIM_X_LIBS version: 3 updated: 2015/04/12 15:39:00
2391e0a2b6dfSmrgdnl --------------
2392e0a2b6dfSmrgdnl Trim extra base X libraries added as a workaround for inconsistent library
2393e0a2b6dfSmrgdnl dependencies returned by "new" pkg-config files.
2394e0a2b6dfSmrgAC_DEFUN([CF_TRIM_X_LIBS],[
2395e0a2b6dfSmrg	for cf_trim_lib in Xmu Xt X11
2396e0a2b6dfSmrg	do
2397e0a2b6dfSmrg		case "$LIBS" in
239801037d57Smrg		(*-l$cf_trim_lib\ *-l$cf_trim_lib*)
2399e0a2b6dfSmrg			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
2400e0a2b6dfSmrg			CF_VERBOSE(..trimmed $LIBS)
2401e0a2b6dfSmrg			;;
2402e0a2b6dfSmrg		esac
2403e0a2b6dfSmrg	done
2404e0a2b6dfSmrg])
2405e0a2b6dfSmrgdnl ---------------------------------------------------------------------------
2406e0a2b6dfSmrgdnl CF_TRY_PKG_CONFIG version: 5 updated: 2013/07/06 21:27:06
240720d2c4d2Smrgdnl -----------------
240820d2c4d2Smrgdnl This is a simple wrapper to use for pkg-config, for libraries which may be
240920d2c4d2Smrgdnl available in that form.
241020d2c4d2Smrgdnl
241120d2c4d2Smrgdnl $1 = package name
241220d2c4d2Smrgdnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
241320d2c4d2Smrgdnl $3 = logic to use if pkg-config does not have the package
241420d2c4d2SmrgAC_DEFUN([CF_TRY_PKG_CONFIG],[
241520d2c4d2SmrgAC_REQUIRE([CF_PKG_CONFIG])
241620d2c4d2Smrg
241720d2c4d2Smrgif test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
241820d2c4d2Smrg	CF_VERBOSE(found package $1)
241920d2c4d2Smrg	cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
242020d2c4d2Smrg	cf_pkgconfig_libs="`$PKG_CONFIG --libs   $1 2>/dev/null`"
242120d2c4d2Smrg	CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
242220d2c4d2Smrg	CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
242320d2c4d2Smrg	CF_ADD_CFLAGS($cf_pkgconfig_incs)
242420d2c4d2Smrg	CF_ADD_LIBS($cf_pkgconfig_libs)
242520d2c4d2Smrg	ifelse([$2],,:,[$2])
242620d2c4d2Smrgelse
2427e0a2b6dfSmrg	cf_pkgconfig_incs=
2428e0a2b6dfSmrg	cf_pkgconfig_libs=
242920d2c4d2Smrg	ifelse([$3],,:,[$3])
243020d2c4d2Smrgfi
243120d2c4d2Smrg])
243220d2c4d2Smrgdnl ---------------------------------------------------------------------------
24330bd37d32Smrgdnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
24340bd37d32Smrgdnl -------------------
24350bd37d32Smrgdnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
24360bd37d32Smrgdnl can define it successfully.
24370bd37d32SmrgAC_DEFUN([CF_TRY_XOPEN_SOURCE],[
24380bd37d32SmrgAC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
24390bd37d32Smrg	AC_TRY_COMPILE([
24400bd37d32Smrg#include <stdlib.h>
24410bd37d32Smrg#include <string.h>
24420bd37d32Smrg#include <sys/types.h>
24430bd37d32Smrg],[
24440bd37d32Smrg#ifndef _XOPEN_SOURCE
24450bd37d32Smrgmake an error
24460bd37d32Smrg#endif],
24470bd37d32Smrg	[cf_cv_xopen_source=no],
24480bd37d32Smrg	[cf_save="$CPPFLAGS"
24490bd37d32Smrg	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
24500bd37d32Smrg	 AC_TRY_COMPILE([
24510bd37d32Smrg#include <stdlib.h>
24520bd37d32Smrg#include <string.h>
24530bd37d32Smrg#include <sys/types.h>
24540bd37d32Smrg],[
24550bd37d32Smrg#ifdef _XOPEN_SOURCE
24560bd37d32Smrgmake an error
24570bd37d32Smrg#endif],
24580bd37d32Smrg	[cf_cv_xopen_source=no],
24590bd37d32Smrg	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
24600bd37d32Smrg	CPPFLAGS="$cf_save"
24610bd37d32Smrg	])
24620bd37d32Smrg])
24630bd37d32Smrg
24640bd37d32Smrgif test "$cf_cv_xopen_source" != no ; then
24650bd37d32Smrg	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
24660bd37d32Smrg	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
24670bd37d32Smrg	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
24680bd37d32Smrg	CF_ADD_CFLAGS($cf_temp_xopen_source)
24690bd37d32Smrgfi
24700bd37d32Smrg])
24710bd37d32Smrgdnl ---------------------------------------------------------------------------
247201037d57Smrgdnl CF_TTY_GROUP version: 9 updated: 2015/04/12 15:39:00
2473d522f475Smrgdnl ------------
2474d522f475Smrgdnl Check if the system has a tty-group defined.  This is used in xterm when
2475d522f475Smrgdnl setting pty ownership.
2476d522f475SmrgAC_DEFUN([CF_TTY_GROUP],
2477d522f475Smrg[
2478d522f475SmrgAC_MSG_CHECKING(for explicit tty group name)
2479d522f475SmrgAC_ARG_WITH(tty-group,
2480d522f475Smrg	[  --with-tty-group=XXX    use XXX for the tty-group],
2481d522f475Smrg	[cf_tty_group=$withval],
2482d522f475Smrg	[cf_tty_group=auto...])
2483d522f475Smrgtest -z "$cf_tty_group"    && cf_tty_group=auto...
2484d522f475Smrgtest "$cf_tty_group" = yes && cf_tty_group=auto...
2485d522f475SmrgAC_MSG_RESULT($cf_tty_group)
2486d522f475Smrg
2487d522f475Smrgif test "$cf_tty_group" = "auto..." ; then
2488d522f475SmrgAC_CACHE_CHECK(for tty group name,cf_cv_tty_group_name,[
2489d522f475Smrg
2490d522f475Smrg# If we are configuring as root, it is hard to get a clue about the tty group.
2491d522f475Smrg# But we'll guess based on how our connection is set up - assuming it is done
2492d522f475Smrg# properly.
2493d522f475Smrg
2494d522f475Smrgcf_uid=`id | sed -e 's/^[^=]*=//' -e 's/(.*$//'`
2495d522f475Smrg# )vi
2496d522f475Smrgif test "$cf_uid" != 0 ; then
2497d522f475Smrgcf_cv_tty_group_name=
2498d522f475Smrgcf_tty_name=`tty`
2499d522f475Smrgtest "$cf_tty_name" = "not a tty" && cf_tty_name=/dev/tty
2500d522f475Smrgtest -z "$cf_tty_name" && cf_tty_name=/dev/tty
2501d522f475Smrgif test -c "$cf_tty_name"
2502d522f475Smrgthen
2503d522f475Smrg	cf_option="-l -L"
2504d522f475Smrg
2505d522f475Smrg	# Expect listing to have fields like this:
2506d522f475Smrg	#-rwxrwxrwx   1 user      group       34293 Jul 18 16:29 pathname
2507d522f475Smrg	ls $cf_option $cf_tty_name >conftest.out
2508d522f475Smrg	read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
2509d522f475Smrg	if test -z "$cf_rest" ; then
2510d522f475Smrg		cf_option="$cf_option -g"
2511d522f475Smrg		ls $cf_option $cf_tty_name >conftest.out
2512d522f475Smrg		read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
2513d522f475Smrg	fi
2514d522f475Smrg	rm -f conftest.out
2515d522f475Smrg	cf_cv_tty_group_name=$cf_grp
2516d522f475Smrgfi
2517d522f475Smrgfi
2518d522f475Smrg
2519d522f475Smrg# If we cannot deduce the tty group, fall back on hardcoded cases
2520d522f475Smrg
2521d522f475Smrgif test -z "$cf_cv_tty_group_name"
2522d522f475Smrgthen
252301037d57Smrgcase $host_os in
252401037d57Smrg(osf*)
2525d522f475Smrg	cf_cv_tty_group_name="terminal"
2526d522f475Smrg	;;
252701037d57Smrg(*)
2528d522f475Smrg	cf_cv_tty_group_name="unknown"
2529d522f475Smrg	if ( egrep '^tty:' /etc/group 2>/dev/null 1>/dev/null ) then
2530d522f475Smrg		cf_cv_tty_group_name="tty"
2531d522f475Smrg	fi
2532d522f475Smrg	;;
2533d522f475Smrgesac
2534d522f475Smrgfi
2535d522f475Smrg])
2536d522f475Smrgcf_tty_group="$cf_cv_tty_group_name"
2537d522f475Smrgelse
2538d522f475Smrg	# if configure option, always do this
25390bd37d32Smrg	AC_DEFINE(USE_TTY_GROUP,1,[Define to 1 if we have a tty groupname])
2540d522f475Smrgfi
2541d522f475Smrg
25420bd37d32SmrgAC_DEFINE_UNQUOTED(TTY_GROUP_NAME,"$cf_tty_group",[Define to the name use for tty group])
2543d522f475Smrg
2544d522f475Smrg# This is only a double-check that the group-name we obtained above really
2545d522f475Smrg# does apply to the device.  We cannot perform this test if we are in batch
2546d522f475Smrg# mode, or if we are cross-compiling.
2547d522f475Smrg
2548d522f475SmrgAC_CACHE_CHECK(if we may use the $cf_tty_group group,cf_cv_tty_group,[
2549d522f475Smrgcf_tty_name=`tty`
2550d522f475Smrgif test "$cf_tty_name" != "not a tty"
2551d522f475Smrgthen
2552d522f475SmrgAC_TRY_RUN([
2553d522f475Smrg#include <unistd.h>
2554d522f475Smrg#include <sys/types.h>
2555d522f475Smrg#include <sys/stat.h>
2556d522f475Smrg#include <grp.h>
2557d522f475Smrgint main()
2558d522f475Smrg{
2559d522f475Smrg	struct stat sb;
2560d522f475Smrg	struct group *ttygrp = getgrnam(TTY_GROUP_NAME);
2561d522f475Smrg	char *name = ttyname(0);
2562d522f475Smrg
2563d522f475Smrg	endgrent();
2564d522f475Smrg	if (ttygrp != 0
2565d522f475Smrg	 && name != 0
2566d522f475Smrg	 && stat(name, &sb) == 0
2567d522f475Smrg	 && sb.st_gid != getgid()
2568d522f475Smrg	 && sb.st_gid == ttygrp->gr_gid) {
2569d522f475Smrg		${cf_cv_main_return:-return} (0);
2570d522f475Smrg	}
2571d522f475Smrg	${cf_cv_main_return:-return} (1);
2572d522f475Smrg}
2573d522f475Smrg	],
2574d522f475Smrg	[cf_cv_tty_group=yes],
2575d522f475Smrg	[cf_cv_tty_group=no],
2576d522f475Smrg	[cf_cv_tty_group=unknown])
2577d522f475Smrgelif test "$cross_compiling" = yes; then
2578d522f475Smrg	cf_cv_tty_group=unknown
2579d522f475Smrgelse
2580d522f475Smrg	cf_cv_tty_group=yes
2581d522f475Smrgfi
2582d522f475Smrg])
2583d522f475Smrg
2584d522f475Smrgif test $cf_cv_tty_group = no ; then
2585d522f475Smrg	AC_MSG_WARN(Cannot use $cf_tty_group group)
2586d522f475Smrgelse
2587d522f475Smrg	AC_DEFINE(USE_TTY_GROUP)
2588d522f475Smrgfi
2589d522f475Smrg])dnl
2590d522f475Smrgdnl ---------------------------------------------------------------------------
25910bd37d32Smrgdnl CF_TYPE_CC_T version: 2 updated: 2012/10/04 20:12:20
25920bd37d32Smrgdnl ------------
25930bd37d32Smrgdnl	Check for cc_t type, used in termio.
25940bd37d32SmrgAC_DEFUN([CF_TYPE_CC_T],
25950bd37d32Smrg[
25960bd37d32SmrgAC_MSG_CHECKING(for cc_t in <termios.h> or <termio.h>)
25970bd37d32SmrgAC_CACHE_VAL(cf_cv_type_cc_t,[
25980bd37d32Smrg	AC_TRY_COMPILE([
25990bd37d32Smrg#include <sys/types.h>
26000bd37d32Smrg#if defined(HAVE_TERMIOS_H)
26010bd37d32Smrg#include <termios.h>
26020bd37d32Smrg#else
26030bd37d32Smrg#include <termio.h>
26040bd37d32Smrg#include <sys/ioctl.h>
26050bd37d32Smrg#endif
26060bd37d32Smrg],
26070bd37d32Smrg		[cc_t x],
26080bd37d32Smrg		[cf_cv_type_cc_t=yes],
26090bd37d32Smrg		[cf_cv_type_cc_t=no])
26100bd37d32Smrg	])
26110bd37d32SmrgAC_MSG_RESULT($cf_cv_type_cc_t)
26120bd37d32Smrgtest $cf_cv_type_cc_t = no && AC_DEFINE(cc_t, unsigned char,[Define to cc_t type used in termio])
26130bd37d32Smrg])dnl
26140bd37d32Smrgdnl ---------------------------------------------------------------------------
26150bd37d32Smrgdnl CF_TYPE_FD_MASK version: 3 updated: 2012/10/04 06:57:36
2616d522f475Smrgdnl ---------------
2617d522f475Smrgdnl Check for the declaration of fd_mask, which is like fd_set, associated
2618d522f475Smrgdnl with select().  The check for fd_set should have pulled in this as well,
2619d522f475Smrgdnl but there is a special case for Mac OS X, possibly other BSD-derived
2620d522f475Smrgdnl platforms.
2621d522f475SmrgAC_DEFUN([CF_TYPE_FD_MASK],
2622d522f475Smrg[
2623d522f475SmrgAC_REQUIRE([CF_TYPE_FD_SET])
2624d522f475Smrg
2625d522f475SmrgAC_CACHE_CHECK(for declaration of fd_mask,cf_cv_type_fd_mask,[
2626d522f475Smrg    if test x$cf_cv_type_fd_set = xX11/Xpoll.h ; then
2627d522f475Smrg        AC_TRY_COMPILE([
2628d522f475Smrg#include <X11/Xpoll.h>],[fd_mask x],,
2629d522f475Smrg        [CF_MSG_LOG(if we must define CSRG_BASED)
2630d522f475Smrg# Xosdefs.h on Mac OS X may not define this (but it should).
2631d522f475Smrg            AC_TRY_COMPILE([
2632d522f475Smrg#define CSRG_BASED
2633d522f475Smrg#include <X11/Xpoll.h>],[fd_mask x],
2634d522f475Smrg        cf_cv_type_fd_mask=CSRG_BASED)])
2635d522f475Smrg    else
2636d522f475Smrg        cf_cv_type_fd_mask=$cf_cv_type_fd_set
2637d522f475Smrg    fi
2638d522f475Smrg])
2639d522f475Smrgif test x$cf_cv_type_fd_mask = xCSRG_BASED ; then
26400bd37d32Smrg    AC_DEFINE(CSRG_BASED,1,[Define to 1 if needed for declaring fd_mask()])
2641d522f475Smrgfi
2642d522f475Smrg])dnl
2643d522f475Smrgdnl ---------------------------------------------------------------------------
26440bd37d32Smrgdnl CF_TYPE_FD_SET version: 5 updated: 2012/10/04 20:12:20
2645d522f475Smrgdnl --------------
2646d522f475Smrgdnl Check for the declaration of fd_set.  Some platforms declare it in
2647d522f475Smrgdnl <sys/types.h>, and some in <sys/select.h>, which requires <sys/types.h>.
2648d522f475Smrgdnl Finally, if we are using this for an X application, Xpoll.h may include
2649d522f475Smrgdnl <sys/select.h>, so we don't want to do it twice.
2650d522f475SmrgAC_DEFUN([CF_TYPE_FD_SET],
2651d522f475Smrg[
2652d522f475SmrgAC_CHECK_HEADERS(X11/Xpoll.h)
2653d522f475Smrg
2654d522f475SmrgAC_CACHE_CHECK(for declaration of fd_set,cf_cv_type_fd_set,
2655d522f475Smrg	[CF_MSG_LOG(sys/types alone)
2656d522f475SmrgAC_TRY_COMPILE([
2657d522f475Smrg#include <sys/types.h>],
2658d522f475Smrg	[fd_set x],
2659d522f475Smrg	[cf_cv_type_fd_set=sys/types.h],
2660d522f475Smrg	[CF_MSG_LOG(X11/Xpoll.h)
2661d522f475SmrgAC_TRY_COMPILE([
2662d522f475Smrg#ifdef HAVE_X11_XPOLL_H
2663d522f475Smrg#include <X11/Xpoll.h>
2664d522f475Smrg#endif],
2665d522f475Smrg	[fd_set x],
2666d522f475Smrg	[cf_cv_type_fd_set=X11/Xpoll.h],
2667d522f475Smrg	[CF_MSG_LOG(sys/select.h)
2668d522f475SmrgAC_TRY_COMPILE([
2669d522f475Smrg#include <sys/types.h>
2670d522f475Smrg#include <sys/select.h>],
2671d522f475Smrg	[fd_set x],
2672d522f475Smrg	[cf_cv_type_fd_set=sys/select.h],
2673d522f475Smrg	[cf_cv_type_fd_set=unknown])])])])
2674d522f475Smrgif test $cf_cv_type_fd_set = sys/select.h ; then
26750bd37d32Smrg	AC_DEFINE(USE_SYS_SELECT_H,1,[Define to 1 to include sys/select.h to declare fd_set])
2676d522f475Smrgfi
2677d522f475Smrg])
2678d522f475Smrgdnl ---------------------------------------------------------------------------
2679e39b573cSmrgdnl CF_UNDO_CFLAGS version: 1 updated: 2011/07/02 09:27:51
2680e39b573cSmrgdnl --------------
2681e39b573cSmrgdnl Remove flags from $CFLAGS or similar shell variable using sed.
2682e39b573cSmrgdnl $1 = variable
2683e39b573cSmrgdnl $2 = message
2684e39b573cSmrgdnl $3 = pattern to remove
2685e39b573cSmrgAC_DEFUN([CF_UNDO_CFLAGS],
2686e39b573cSmrg[
2687e39b573cSmrg	CF_VERBOSE(removing $2 flags from $1)
2688e39b573cSmrg	$1=`echo "[$]$1" | sed -e 's/$3//'`
2689e39b573cSmrg	CF_VERBOSE(...result [$]$1)
2690e39b573cSmrg])dnl
2691e39b573cSmrgdnl ---------------------------------------------------------------------------
2692d522f475Smrgdnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
2693d522f475Smrgdnl --------
2694d522f475Smrgdnl Make an uppercase version of a variable
2695d522f475Smrgdnl $1=uppercase($2)
2696d522f475SmrgAC_DEFUN([CF_UPPER],
2697d522f475Smrg[
2698d522f475Smrg$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2699d522f475Smrg])dnl
2700d522f475Smrgdnl ---------------------------------------------------------------------------
27010bd37d32Smrgdnl CF_UTEMPTER version: 4 updated: 2012/10/04 20:12:20
2702d522f475Smrgdnl -----------
2703d522f475Smrgdnl Try to link with utempter library
2704d522f475SmrgAC_DEFUN([CF_UTEMPTER],
2705d522f475Smrg[
2706d522f475SmrgAC_CACHE_CHECK(if we can link with utempter library,cf_cv_have_utempter,[
2707d522f475Smrgcf_save_LIBS="$LIBS"
270820d2c4d2SmrgCF_ADD_LIB(utempter)
2709d522f475SmrgAC_TRY_LINK([
2710d522f475Smrg#include <utempter.h>
2711d522f475Smrg],[
2712d522f475Smrg	addToUtmp("/dev/tty", 0, 1);
2713d522f475Smrg	removeFromUtmp();
2714d522f475Smrg],[
2715d522f475Smrg	cf_cv_have_utempter=yes],[
2716d522f475Smrg	cf_cv_have_utempter=no])
2717d522f475SmrgLIBS="$cf_save_LIBS"
2718d522f475Smrg])
2719d522f475Smrgif test "$cf_cv_have_utempter" = yes ; then
27200bd37d32Smrg	AC_DEFINE(USE_UTEMPTER,1,[Define to 1 if we can/should link with utempter])
272120d2c4d2Smrg	CF_ADD_LIB(utempter)
2722d522f475Smrgfi
2723d522f475Smrg])dnl
2724d522f475Smrgdnl ---------------------------------------------------------------------------
27250bd37d32Smrgdnl CF_UTMP version: 10 updated: 2012/10/04 20:12:20
2726d522f475Smrgdnl -------
2727d522f475Smrgdnl Check for UTMP/UTMPX headers
2728d522f475SmrgAC_DEFUN([CF_UTMP],
2729d522f475Smrg[
2730d522f475SmrgAC_REQUIRE([CF_LASTLOG])
2731d522f475Smrg
2732d522f475SmrgAC_CACHE_CHECK(for utmp implementation,cf_cv_have_utmp,[
2733d522f475Smrg	cf_cv_have_utmp=no
2734d522f475Smrgfor cf_header in utmpx utmp ; do
2735d522f475Smrgcf_utmp_includes="
2736d522f475Smrg#include <sys/types.h>
2737d522f475Smrg#include <${cf_header}.h>
2738d522f475Smrg#define getutent getutxent
2739d522f475Smrg#ifdef USE_LASTLOG
2740d522f475Smrg#include <lastlog.h>	/* may conflict with utmpx.h on Linux */
2741d522f475Smrg#endif
2742d522f475Smrg"
2743d522f475Smrg	AC_TRY_COMPILE([$cf_utmp_includes],
2744d522f475Smrg	[struct $cf_header x;
2745d522f475Smrg	 char *name = x.ut_name; /* utmp.h and compatible definitions */
2746d522f475Smrg	],
2747d522f475Smrg	[cf_cv_have_utmp=$cf_header
2748d522f475Smrg	 break],
2749d522f475Smrg	[
2750d522f475Smrg	AC_TRY_COMPILE([$cf_utmp_includes],
2751d522f475Smrg	[struct $cf_header x;
2752d522f475Smrg	 char *name = x.ut_user; /* utmpx.h must declare this */
2753d522f475Smrg	],
2754d522f475Smrg	[cf_cv_have_utmp=$cf_header
2755d522f475Smrg	 break
2756d522f475Smrg	])])
2757d522f475Smrgdone
2758d522f475Smrg])
2759d522f475Smrg
2760d522f475Smrgif test $cf_cv_have_utmp != no ; then
27610bd37d32Smrg	AC_DEFINE(HAVE_UTMP,1,[Define to 1 if the utmp interface is available])
27620bd37d32Smrg	test $cf_cv_have_utmp = utmpx && AC_DEFINE(UTMPX_FOR_UTMP,1,[Define if we have utmpx interface])
2763d522f475Smrg	CF_UTMP_UT_HOST
2764d522f475Smrg	CF_UTMP_UT_SYSLEN
2765d522f475Smrg	CF_UTMP_UT_NAME
2766d522f475Smrg	CF_UTMP_UT_XSTATUS
2767d522f475Smrg	CF_UTMP_UT_XTIME
2768d522f475Smrg	CF_UTMP_UT_SESSION
2769d522f475Smrg	CF_SYSV_UTMP
2770d522f475Smrgfi
2771d522f475Smrg])dnl
2772d522f475Smrgdnl ---------------------------------------------------------------------------
2773d522f475Smrgdnl CF_UTMP_GROUP version: 1 updated: 2005/10/06 20:29:29
2774d522f475Smrgdnl -------------
2775d522f475Smrgdnl Find the utmp/utmpx file and determine its group to allow setgid programs
2776d522f475Smrgdnl to manipulate it, e.g., when there is no intermediary.
2777d522f475SmrgAC_DEFUN([CF_UTMP_GROUP],[
2778d522f475SmrgAC_REQUIRE([CF_UTMP])
2779d522f475Smrgif test $cf_cv_have_utmp != no ; then
2780d522f475SmrgAC_CACHE_CHECK(for utmp/utmpx group,cf_cv_utmp_group,[
2781d522f475Smrgfor cf_utmp_path in /var/adm /var/run
2782d522f475Smrgdo
2783d522f475Smrg	for cf_utmp_file in utmpx utmp
2784d522f475Smrg	do
2785d522f475Smrg		if test -f $cf_utmp_path/$cf_utmp_file
2786d522f475Smrg		then
2787d522f475Smrg			cf_cv_utmp_group=root
2788d522f475Smrg
2789d522f475Smrg			cf_option="-l -L"
2790d522f475Smrg
2791d522f475Smrg			# Expect listing to have fields like this:
2792d522f475Smrg			#-r--r--r--   1 user      group       34293 Jul 18 16:29 pathname
2793d522f475Smrg			ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
2794d522f475Smrg			read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
2795d522f475Smrg			if test -z "$cf_rest" ; then
2796d522f475Smrg				cf_option="$cf_option -g"
2797d522f475Smrg				ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
2798d522f475Smrg				read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
2799d522f475Smrg			fi
2800d522f475Smrg			rm -f conftest
2801d522f475Smrg
2802d522f475Smrg			# If we have a pathname, and the date fields look right, assume we've
2803d522f475Smrg			# captured the group as well.
2804d522f475Smrg			if test -n "$cf_rest" ; then
2805d522f475Smrg				cf_test=`echo "${cf_date2}${cf_date3}" | sed -e 's/[[0-9:]]//g'`
2806d522f475Smrg				if test -z "$cf_test" ; then
2807d522f475Smrg					cf_cv_utmp_group=$cf_grp;
2808d522f475Smrg				fi
2809d522f475Smrg			fi
2810d522f475Smrg			break
2811d522f475Smrg		fi
2812d522f475Smrg	done
2813d522f475Smrg	test -n "$cf_cv_utmp_group" && break
2814d522f475Smrgdone
2815d522f475Smrg])
2816d522f475Smrgelse
2817d522f475Smrg	AC_MSG_ERROR(cannot find utmp group)
2818d522f475Smrgfi
2819d522f475Smrg])dnl
2820d522f475Smrgdnl ---------------------------------------------------------------------------
28210bd37d32Smrgdnl CF_UTMP_UT_HOST version: 8 updated: 2012/10/04 20:12:20
2822d522f475Smrgdnl ---------------
2823d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_host member
2824d522f475SmrgAC_DEFUN([CF_UTMP_UT_HOST],
2825d522f475Smrg[
2826d522f475Smrgif test $cf_cv_have_utmp != no ; then
2827d522f475SmrgAC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_host is declared)
2828d522f475SmrgAC_CACHE_VAL(cf_cv_have_utmp_ut_host,[
2829d522f475Smrg	AC_TRY_COMPILE([
2830d522f475Smrg#include <sys/types.h>
2831d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2832d522f475Smrg	[struct $cf_cv_have_utmp x; char *y = &x.ut_host[0]],
2833d522f475Smrg	[cf_cv_have_utmp_ut_host=yes],
2834d522f475Smrg	[cf_cv_have_utmp_ut_host=no])
2835d522f475Smrg	])
2836d522f475SmrgAC_MSG_RESULT($cf_cv_have_utmp_ut_host)
28370bd37d32Smrgtest $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])
2838d522f475Smrgfi
2839d522f475Smrg])dnl
2840d522f475Smrgdnl ---------------------------------------------------------------------------
284101037d57Smrgdnl CF_UTMP_UT_NAME version: 6 updated: 2015/04/12 15:39:00
2842d522f475Smrgdnl ---------------
2843d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_name member
2844d522f475SmrgAC_DEFUN([CF_UTMP_UT_NAME],
2845d522f475Smrg[
2846d522f475Smrgif test $cf_cv_have_utmp != no ; then
2847d522f475SmrgAC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_name is declared,cf_cv_have_utmp_ut_name,[
2848d522f475Smrg	cf_cv_have_utmp_ut_name=no
2849d522f475Smrgcf_utmp_includes="
2850d522f475Smrg#include <sys/types.h>
2851d522f475Smrg#include <${cf_cv_have_utmp}.h>
2852d522f475Smrg#define getutent getutxent
2853d522f475Smrg#ifdef USE_LASTLOG
2854d522f475Smrg#include <lastlog.h>		/* may conflict with utmpx.h on Linux */
2855d522f475Smrg#endif
2856d522f475Smrg"
2857d522f475Smrgfor cf_header in ut_name ut_user ; do
2858d522f475Smrg	AC_TRY_COMPILE([$cf_utmp_includes],
2859d522f475Smrg	[struct $cf_cv_have_utmp x;
2860d522f475Smrg	 char *name = x.$cf_header;
2861d522f475Smrg	],
2862d522f475Smrg	[cf_cv_have_utmp_ut_name=$cf_header
2863d522f475Smrg	 break])
2864d522f475Smrgdone
2865d522f475Smrg])
2866d522f475Smrg
286701037d57Smrgcase $cf_cv_have_utmp_ut_name in
286801037d57Smrg(no)
2869d522f475Smrg	AC_MSG_ERROR(Cannot find declaration for ut.ut_name)
2870d522f475Smrg	;;
287101037d57Smrg(ut_user)
28720bd37d32Smrg	AC_DEFINE(ut_name,ut_user,[Define to rename UTMP/UTMPX struct ut_name member])
2873d522f475Smrg	;;
2874d522f475Smrgesac
2875d522f475Smrgfi
2876d522f475Smrg])dnl
2877d522f475Smrgdnl ---------------------------------------------------------------------------
28780bd37d32Smrgdnl CF_UTMP_UT_SESSION version: 6 updated: 2012/10/04 20:12:20
2879d522f475Smrgdnl ------------------
2880d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_session member
2881d522f475SmrgAC_DEFUN([CF_UTMP_UT_SESSION],
2882d522f475Smrg[
2883d522f475Smrgif test $cf_cv_have_utmp != no ; then
2884d522f475SmrgAC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_session is declared, cf_cv_have_utmp_ut_session,[
2885d522f475Smrg	AC_TRY_COMPILE([
2886d522f475Smrg#include <sys/types.h>
2887d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2888d522f475Smrg	[struct $cf_cv_have_utmp x; long y = x.ut_session],
2889d522f475Smrg	[cf_cv_have_utmp_ut_session=yes],
2890d522f475Smrg	[cf_cv_have_utmp_ut_session=no])
2891d522f475Smrg])
2892d522f475Smrgif test $cf_cv_have_utmp_ut_session != no ; then
28930bd37d32Smrg	AC_DEFINE(HAVE_UTMP_UT_SESSION,1,[Define to 1 if UTMP/UTMPX struct defines ut_session member])
2894d522f475Smrgfi
2895d522f475Smrgfi
2896d522f475Smrg])dnl
2897d522f475Smrgdnl ---------------------------------------------------------------------------
28980bd37d32Smrgdnl CF_UTMP_UT_SYSLEN version: 2 updated: 2012/10/04 20:12:20
2899d522f475Smrgdnl -----------------
2900d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_syslen member
2901d522f475SmrgAC_DEFUN([CF_UTMP_UT_SYSLEN],
2902d522f475Smrg[
2903d522f475Smrgif test $cf_cv_have_utmp != no ; then
2904d522f475SmrgAC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_syslen is declared)
2905d522f475SmrgAC_CACHE_VAL(cf_cv_have_utmp_ut_syslen,[
2906d522f475Smrg	AC_TRY_COMPILE([
2907d522f475Smrg#include <sys/types.h>
2908d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2909d522f475Smrg	[struct $cf_cv_have_utmp x; int y = x.ut_syslen],
2910d522f475Smrg	[cf_cv_have_utmp_ut_syslen=yes],
2911d522f475Smrg	[cf_cv_have_utmp_ut_syslen=no])
2912d522f475Smrg	])
2913d522f475SmrgAC_MSG_RESULT($cf_cv_have_utmp_ut_syslen)
29140bd37d32Smrgtest $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])
2915d522f475Smrgfi
2916d522f475Smrg])dnl
2917d522f475Smrgdnl ---------------------------------------------------------------------------
29180bd37d32Smrgdnl CF_UTMP_UT_XSTATUS version: 4 updated: 2012/10/04 20:12:20
2919d522f475Smrgdnl ------------------
2920d522f475Smrgdnl Check for known variants on the UTMP/UTMPX struct's exit-status as reported
2921d522f475Smrgdnl by various people:
2922d522f475Smrgdnl
2923d522f475Smrgdnl	ut_exit.__e_exit (HPUX 11 - David Ellement, also in glibc2)
2924d522f475Smrgdnl	ut_exit.e_exit (SVR4)
2925d522f475Smrgdnl	ut_exit.ut_e_exit (os390 - Greg Smith)
2926d522f475Smrgdnl	ut_exit.ut_exit (Tru64 4.0f - Jeremie Petit, 4.0e - Tomas Vanhala)
2927d522f475Smrgdnl
2928d522f475Smrgdnl Note: utmp_xstatus is not a conventional compatibility definition in the
2929d522f475Smrgdnl system header files.
2930d522f475SmrgAC_DEFUN([CF_UTMP_UT_XSTATUS],
2931d522f475Smrg[
2932d522f475Smrgif test $cf_cv_have_utmp != no ; then
2933d522f475SmrgAC_CACHE_CHECK(for exit-status in $cf_cv_have_utmp,cf_cv_have_utmp_ut_xstatus,[
2934d522f475Smrgfor cf_result in \
2935d522f475Smrg	ut_exit.__e_exit \
2936d522f475Smrg	ut_exit.e_exit \
2937d522f475Smrg	ut_exit.ut_e_exit \
2938d522f475Smrg	ut_exit.ut_exit
2939d522f475Smrgdo
2940d522f475SmrgAC_TRY_COMPILE([
2941d522f475Smrg#include <sys/types.h>
2942d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2943d522f475Smrg	[struct $cf_cv_have_utmp x; long y = x.$cf_result = 0],
2944d522f475Smrg	[cf_cv_have_utmp_ut_xstatus=$cf_result
2945d522f475Smrg	 break],
2946d522f475Smrg	[cf_cv_have_utmp_ut_xstatus=no])
2947d522f475Smrgdone
2948d522f475Smrg])
2949d522f475Smrgif test $cf_cv_have_utmp_ut_xstatus != no ; then
29500bd37d32Smrg	AC_DEFINE(HAVE_UTMP_UT_XSTATUS,1,[Define to 1 if UTMP/UTMPX has exit-status member])
29510bd37d32Smrg	AC_DEFINE_UNQUOTED(ut_xstatus,$cf_cv_have_utmp_ut_xstatus,[Define if needed to rename member ut_xstatus of UTMP/UTMPX])
2952d522f475Smrgfi
2953d522f475Smrgfi
2954d522f475Smrg])dnl
2955d522f475Smrgdnl ---------------------------------------------------------------------------
29560bd37d32Smrgdnl CF_UTMP_UT_XTIME version: 9 updated: 2012/10/04 20:12:20
2957d522f475Smrgdnl ----------------
2958d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_xtime member
2959d522f475SmrgAC_DEFUN([CF_UTMP_UT_XTIME],
2960d522f475Smrg[
2961d522f475Smrgif test $cf_cv_have_utmp != no ; then
2962d522f475SmrgAC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_xtime is declared, cf_cv_have_utmp_ut_xtime,[
2963d522f475Smrg	AC_TRY_COMPILE([
2964d522f475Smrg#include <sys/types.h>
2965d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2966d522f475Smrg	[struct $cf_cv_have_utmp x; long y = x.ut_xtime = 0],
2967d522f475Smrg	[cf_cv_have_utmp_ut_xtime=yes],
2968d522f475Smrg	[AC_TRY_COMPILE([
2969d522f475Smrg#include <sys/types.h>
2970d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2971d522f475Smrg	[struct $cf_cv_have_utmp x; long y = x.ut_tv.tv_sec],
2972d522f475Smrg	[cf_cv_have_utmp_ut_xtime=define],
2973d522f475Smrg	[cf_cv_have_utmp_ut_xtime=no])
2974d522f475Smrg	])
2975d522f475Smrg])
2976d522f475Smrgif test $cf_cv_have_utmp_ut_xtime != no ; then
29770bd37d32Smrg	AC_DEFINE(HAVE_UTMP_UT_XTIME,1,[Define to 1 if UTMP/UTMPX struct defines ut_xtime member])
2978d522f475Smrg	if test $cf_cv_have_utmp_ut_xtime = define ; then
29790bd37d32Smrg		AC_DEFINE(ut_xtime,ut_tv.tv_sec,[Define if needed to alternate name for utmpx.ut_xtime member])
2980d522f475Smrg	fi
2981d522f475Smrgfi
2982d522f475Smrgfi
2983d522f475Smrg])dnl
2984d522f475Smrgdnl ---------------------------------------------------------------------------
2985d522f475Smrgdnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
2986d522f475Smrgdnl ----------
2987d522f475Smrgdnl Use AC_VERBOSE w/o the warnings
2988d522f475SmrgAC_DEFUN([CF_VERBOSE],
2989d522f475Smrg[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
2990d522f475SmrgCF_MSG_LOG([$1])
2991d522f475Smrg])dnl
2992d522f475Smrgdnl ---------------------------------------------------------------------------
299301037d57Smrgdnl CF_WITH_APP_CLASS version: 3 updated: 2015/04/12 15:39:00
2994e39b573cSmrgdnl -----------------
2995e39b573cSmrgdnl Handle configure option "--with-app-class", setting the $APP_CLASS
2996e39b573cSmrgdnl variable, used for X resources.
2997e39b573cSmrgdnl
2998e39b573cSmrgdnl $1 = default value.
29990bd37d32SmrgAC_DEFUN([CF_WITH_APP_CLASS],[
3000e39b573cSmrgAC_MSG_CHECKING(for X applications class)
3001e39b573cSmrgAC_ARG_WITH(app-class,
3002e39b573cSmrg	[  --with-app-class=XXX    override X applications class (default $1)],
3003e39b573cSmrg	[APP_CLASS=$withval],
3004e39b573cSmrg	[APP_CLASS=$1])
3005e39b573cSmrg
300601037d57Smrgcase x$APP_CLASS in
300701037d57Smrg(*[[/@,%]]*)
3008e39b573cSmrg	AC_MSG_WARN(X applications class cannot contain punctuation)
3009e39b573cSmrg	APP_CLASS=$1
3010e39b573cSmrg	;;
301101037d57Smrg(x[[A-Z]]*)
3012e39b573cSmrg	;;
301301037d57Smrg(*)
3014e39b573cSmrg	AC_MSG_WARN([X applications class must start with capital, ignoring $APP_CLASS])
3015e39b573cSmrg	APP_CLASS=$1
3016e39b573cSmrg	;;
3017e39b573cSmrgesac
3018e39b573cSmrg
3019e39b573cSmrgAC_MSG_RESULT($APP_CLASS)
3020e39b573cSmrg
3021e39b573cSmrgAC_SUBST(APP_CLASS)
3022e39b573cSmrg])dnl
3023e39b573cSmrgdnl ---------------------------------------------------------------------------
302401037d57Smrgdnl CF_WITH_APP_DEFAULTS version: 6 updated: 2015/01/02 09:05:50
3025e39b573cSmrgdnl --------------------
3026e39b573cSmrgdnl Handle configure option "--with-app-defaults", setting these shell
3027e39b573cSmrgdnl variables:
30280bd37d32Smrgdnl
30290bd37d32Smrgdnl $APPSDIR is the option value, used for installing app-defaults files.
3030e39b573cSmrgdnl $no_appsdir is a "#" (comment) if "--without-app-defaults" is given.
30310bd37d32Smrgdnl
30320bd37d32Smrgdnl Most Linux's use this:
30330bd37d32Smrgdnl 	/usr/share/X11/app-defaults
30340bd37d32Smrgdnl Debian uses this:
30350bd37d32Smrgdnl 	/etc/X11/app-defaults
30360bd37d32Smrgdnl DragonFlyBSD ports uses this:
30370bd37d32Smrgdnl 	/usr/pkg/lib/X11/app-defaults
30380bd37d32Smrgdnl FreeBSD ports use these:
30390bd37d32Smrgdnl 	/usr/local/lib/X11/app-defaults
30400bd37d32Smrgdnl 	/usr/local/share/X11/app-defaults
30410bd37d32Smrgdnl Mandriva has these:
30420bd37d32Smrgdnl 	/usr/lib/X11/app-defaults
30430bd37d32Smrgdnl 	/usr/lib64/X11/app-defaults
30440bd37d32Smrgdnl NetBSD has these
30450bd37d32Smrgdnl 	/usr/X11R7/lib/X11/app-defaults
30460bd37d32Smrgdnl OpenSolaris uses
30470bd37d32Smrgdnl 	32-bit:
30480bd37d32Smrgdnl 	/usr/X11/etc/X11/app-defaults
30490bd37d32Smrgdnl 	/usr/X11/share/X11/app-defaults
30500bd37d32Smrgdnl 	/usr/X11/lib/X11/app-defaults
305101037d57Smrgdnl OSX uses
305201037d57Smrgdnl		/opt/local/share/X11/app-defaults (MacPorts)
305301037d57Smrgdnl		/opt/X11/share/X11/app-defaults (non-ports)
30540bd37d32Smrgdnl	64-bit:
30550bd37d32Smrgdnl 	/usr/X11/etc/X11/app-defaults
30560bd37d32Smrgdnl 	/usr/X11/share/X11/app-defaults (I mkdir'd this)
30570bd37d32Smrgdnl 	/usr/X11/lib/amd64/X11/app-defaults
30580bd37d32Smrgdnl Solaris10 uses (in this order):
30590bd37d32Smrgdnl 	/usr/openwin/lib/X11/app-defaults
30600bd37d32Smrgdnl 	/usr/X11/lib/X11/app-defaults
30610bd37d32SmrgAC_DEFUN([CF_WITH_APP_DEFAULTS],[
3062e39b573cSmrgAC_MSG_CHECKING(for directory to install resource files)
30630bd37d32SmrgAC_ARG_WITH(app-defaults,
30640bd37d32Smrg	[  --with-app-defaults=DIR directory in which to install resource files (EPREFIX/lib/X11/app-defaults)],
30650bd37d32Smrg	[APPSDIR=$withval],
30660bd37d32Smrg	[APPSDIR='${exec_prefix}/lib/X11/app-defaults'])
30670bd37d32Smrg
30680bd37d32Smrgif test "x[$]APPSDIR" = xauto
30690bd37d32Smrgthen
30700bd37d32Smrg	APPSDIR='${exec_prefix}/lib/X11/app-defaults'
30710bd37d32Smrg	for cf_path in \
307201037d57Smrg		/opt/local/share/X11/app-defaults \
307301037d57Smrg		/opt/X11/share/X11/app-defaults \
30740bd37d32Smrg		/usr/share/X11/app-defaults \
30750bd37d32Smrg		/usr/X11/share/X11/app-defaults \
30760bd37d32Smrg		/usr/X11/lib/X11/app-defaults \
30770bd37d32Smrg		/usr/lib/X11/app-defaults \
30780bd37d32Smrg		/etc/X11/app-defaults \
30790bd37d32Smrg		/usr/pkg/lib/X11/app-defaults \
30800bd37d32Smrg		/usr/X11R7/lib/X11/app-defaults \
30810bd37d32Smrg		/usr/X11R6/lib/X11/app-defaults \
30820bd37d32Smrg		/usr/X11R5/lib/X11/app-defaults \
30830bd37d32Smrg		/usr/X11R4/lib/X11/app-defaults \
30840bd37d32Smrg		/usr/local/lib/X11/app-defaults \
30850bd37d32Smrg		/usr/local/share/X11/app-defaults \
30860bd37d32Smrg		/usr/lib64/X11/app-defaults
30870bd37d32Smrg	do
30880bd37d32Smrg		if test -d "$cf_path" ; then
30890bd37d32Smrg			APPSDIR="$cf_path"
30900bd37d32Smrg			break
30910bd37d32Smrg		fi
30920bd37d32Smrg	done
30930bd37d32Smrgelse
30940bd37d32Smrg	cf_path=$APPSDIR
30950bd37d32Smrg	CF_PATH_SYNTAX(cf_path)
30960bd37d32Smrgfi
30970bd37d32Smrg
30980bd37d32SmrgAC_MSG_RESULT($APPSDIR)
30990bd37d32SmrgAC_SUBST(APPSDIR)
3100e39b573cSmrg
3101e39b573cSmrgno_appsdir=
31020bd37d32Smrgif test "$APPSDIR" = no
31030bd37d32Smrgthen
31040bd37d32Smrg	no_appsdir="#"
31050bd37d32Smrgelse
31060bd37d32Smrg	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(APPSDIR)"
31070bd37d32Smrgfi
3108e39b573cSmrgAC_SUBST(no_appsdir)
3109e39b573cSmrg])dnl
3110e39b573cSmrgdnl ---------------------------------------------------------------------------
31110bd37d32Smrgdnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
31120bd37d32Smrgdnl ----------------
31130bd37d32Smrgdnl Configure-option for dbmalloc.  The optional parameter is used to override
31140bd37d32Smrgdnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
31150bd37d32SmrgAC_DEFUN([CF_WITH_DBMALLOC],[
31160bd37d32SmrgCF_NO_LEAKS_OPTION(dbmalloc,
31170bd37d32Smrg	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
31180bd37d32Smrg	[USE_DBMALLOC])
31190bd37d32Smrg
31200bd37d32Smrgif test "$with_dbmalloc" = yes ; then
31210bd37d32Smrg	AC_CHECK_HEADER(dbmalloc.h,
31220bd37d32Smrg		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
31230bd37d32Smrgfi
31240bd37d32Smrg])dnl
31250bd37d32Smrgdnl ---------------------------------------------------------------------------
312601037d57Smrgdnl CF_WITH_DESKTOP_CATEGORY version: 5 updated: 2015/04/12 15:39:00
3127e39b573cSmrgdnl ------------------------
3128e39b573cSmrgdnl Taking into account the absence of standardization of desktop categories
3129e39b573cSmrgdnl take a look to see whether other applications on the current system are
3130e39b573cSmrgdnl assigned any/all of a set of suggested categories.
3131e39b573cSmrgdnl
3132e39b573cSmrgdnl $1 = program name
3133e39b573cSmrgdnl $2 = case-pattern to match comparable desktop files to obtain category
3134e39b573cSmrgdnl      This pattern may contain wildcards.
3135e39b573cSmrgdnl $3 = suggested categories, also a case-pattern but without wildcards,
31360bd37d32Smrgdnl      since it doubles as a default value for a shell case-statement.
31370bd37d32Smrgdnl $4 = categories to use if no match is found on the build-machine for the
31380bd37d32Smrgdnl      --with-desktop-category "auto" setting.
3139e39b573cSmrgdnl
3140e39b573cSmrgdnl The macro tells the configure script to substitute the $DESKTOP_CATEGORY
3141e39b573cSmrgdnl value.
3142e39b573cSmrgAC_DEFUN([CF_WITH_DESKTOP_CATEGORY],[
3143e39b573cSmrgAC_REQUIRE([CF_DISABLE_DESKTOP])
3144e39b573cSmrg
3145e39b573cSmrgif test -z "$desktop_utils"
3146e39b573cSmrgthen
3147e39b573cSmrg	AC_MSG_CHECKING(for requested desktop-category)
3148e39b573cSmrg	AC_ARG_WITH(desktop-category,
3149e39b573cSmrg		[  --with-desktop-category=XXX  one or more desktop catgories or auto],
3150e39b573cSmrg		[cf_desktop_want=$withval],
3151e39b573cSmrg		[cf_desktop_want=auto])
3152e39b573cSmrg	AC_MSG_RESULT($cf_desktop_want)
3153e39b573cSmrg
3154e39b573cSmrg	if test "$cf_desktop_want" = auto
3155e39b573cSmrg	then
3156e39b573cSmrg		rm -rf conftest*
3157e39b573cSmrg		cf_desktop_also=
3158e39b573cSmrg		for cf_desktop_dir in  \
3159e39b573cSmrg			/usr/share/app-install \
3160e39b573cSmrg			/usr/share/applications
3161e39b573cSmrg		do
3162e39b573cSmrg			if test -d $cf_desktop_dir
3163e39b573cSmrg			then
3164e39b573cSmrg				find $cf_desktop_dir -name '*.desktop' | \
3165e39b573cSmrg				while true
3166e39b573cSmrg				do
3167e39b573cSmrg					read cf_desktop_path
3168e39b573cSmrg					test -z "$cf_desktop_path" && break
3169e39b573cSmrg					cf_desktop_name=`basename $cf_desktop_path .desktop`
317001037d57Smrg					case $cf_desktop_name in
317101037d57Smrg					($1|*-$1|$2)
3172e39b573cSmrg						CF_VERBOSE(inspect $cf_desktop_path)
3173e39b573cSmrg						egrep '^Categories=' $cf_desktop_path | \
3174e39b573cSmrg							tr ';' '\n' | \
3175e39b573cSmrg							sed -e 's%^.*=%%' -e '/^$/d' >>conftest.1
3176e39b573cSmrg						;;
3177e39b573cSmrg					esac
3178e39b573cSmrg				done
3179e39b573cSmrg			fi
3180e39b573cSmrg		done
3181e39b573cSmrg		if test -s conftest.1
3182e39b573cSmrg		then
3183e39b573cSmrg			cf_desktop_last=
3184e39b573cSmrg			sort conftest.1 | \
3185e39b573cSmrg			while true
3186e39b573cSmrg			do
3187e39b573cSmrg				read cf_desktop_this
3188e39b573cSmrg				test -z "$cf_desktop_this" && break
318901037d57Smrg				case $cf_desktop_this in
319001037d57Smrg				(Qt*|GTK*|KDE*|GNOME*|*XFCE*|*Xfce*)
3191e39b573cSmrg					;;
319201037d57Smrg				($3)
3193e39b573cSmrg					test "x$cf_desktop_last" != "x$cf_desktop_this" && echo $cf_desktop_this >>conftest.2
3194e39b573cSmrg					;;
3195e39b573cSmrg				esac
3196e39b573cSmrg				cf_desktop_last=$cf_desktop_this
3197e39b573cSmrg			done
3198e39b573cSmrg			cf_desktop_want=`cat conftest.2 | tr '\n' ';'`
3199e39b573cSmrg		fi
32000bd37d32Smrg		if test -n "$cf_desktop_want"
32010bd37d32Smrg		then
32020bd37d32Smrg			if test "$cf_desktop_want" = auto
32030bd37d32Smrg			then
32040bd37d32Smrg				cf_desktop_want=
32050bd37d32Smrg			else
32060bd37d32Smrg				# do a sanity check on the semicolon-separated list, ignore on failure
32070bd37d32Smrg				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/[[^;]]//g'`
32080bd37d32Smrg				test -z "$cf_desktop_test" && cf_desktop_want=
32090bd37d32Smrg				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/^.*;$/./g'`
32100bd37d32Smrg				test -z "$cf_desktop_test" && cf_desktop_want=
32110bd37d32Smrg			fi
32120bd37d32Smrg		fi
32130bd37d32Smrg		if test -z "$cf_desktop_want"
32140bd37d32Smrg		then
32150bd37d32Smrg			cf_desktop_want="ifelse([$4],,ifelse([$3],,[Application;],[`echo "$3" | sed -e 's/\*//g' -e 's/|/;/g' -e 's/[[;]]*$/;/g'`]),[$4])"
32160bd37d32Smrg			CF_VERBOSE(no usable value found for desktop category, using $cf_desktop_want)
32170bd37d32Smrg		fi
3218e39b573cSmrg	fi
3219e39b573cSmrg	DESKTOP_CATEGORY=`echo "$cf_desktop_want" | sed -e 's/[[ ,]]/;/g'`
32200bd37d32Smrg	CF_VERBOSE(will use Categories=$DESKTOP_CATEGORY)
3221e39b573cSmrg	AC_SUBST(DESKTOP_CATEGORY)
3222e39b573cSmrgfi
3223e39b573cSmrg])
3224e39b573cSmrgdnl ---------------------------------------------------------------------------
32250bd37d32Smrgdnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
3226e39b573cSmrgdnl ---------------
32270bd37d32Smrgdnl Configure-option for dmalloc.  The optional parameter is used to override
32280bd37d32Smrgdnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
32290bd37d32SmrgAC_DEFUN([CF_WITH_DMALLOC],[
32300bd37d32SmrgCF_NO_LEAKS_OPTION(dmalloc,
32310bd37d32Smrg	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
32320bd37d32Smrg	[USE_DMALLOC])
32330bd37d32Smrg
32340bd37d32Smrgif test "$with_dmalloc" = yes ; then
32350bd37d32Smrg	AC_CHECK_HEADER(dmalloc.h,
32360bd37d32Smrg		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
32370bd37d32Smrgfi
32380bd37d32Smrg])dnl
32390bd37d32Smrgdnl ---------------------------------------------------------------------------
32400bd37d32Smrgdnl CF_WITH_ICONDIR version: 5 updated: 2012/07/22 09:18:02
32410bd37d32Smrgdnl ---------------
32420bd37d32Smrgdnl Handle configure option "--with-icondir", setting these shell variables:
32430bd37d32Smrgdnl
32440bd37d32Smrgdnl $ICONDIR is the option value, used for installing icon files.
3245e39b573cSmrgdnl $no_icondir is a "#" (comment) if "--without-icondir" is given.
3246e39b573cSmrgAC_DEFUN([CF_WITH_ICONDIR],[
3247e39b573cSmrgAC_MSG_CHECKING(for directory to install icons)
32480bd37d32SmrgAC_ARG_WITH(icondir,
32490bd37d32Smrg	[  --with-icondir=DIR      directory in which to install icons for desktop],
32500bd37d32Smrg	[ICONDIR=$withval],
32510bd37d32Smrg	[test -z "$ICONDIR" && ICONDIR=no])
32520bd37d32Smrg
32530bd37d32Smrgif test "x[$]ICONDIR" = xauto
32540bd37d32Smrgthen
32550bd37d32Smrg	ICONDIR='${datadir}/icons'
32560bd37d32Smrg	for cf_path in \
32570bd37d32Smrg		/usr/share/icons \
32580bd37d32Smrg		/usr/X11R6/share/icons
32590bd37d32Smrg	do
32600bd37d32Smrg		if test -d "$cf_path" ; then
32610bd37d32Smrg			ICONDIR="$cf_path"
32620bd37d32Smrg			break
32630bd37d32Smrg		fi
32640bd37d32Smrg	done
32650bd37d32Smrgelse
32660bd37d32Smrg	cf_path=$ICONDIR
32670bd37d32Smrg	CF_PATH_SYNTAX(cf_path)
32680bd37d32Smrgfi
32690bd37d32SmrgAC_MSG_RESULT($ICONDIR)
32700bd37d32SmrgAC_SUBST(ICONDIR)
3271e39b573cSmrg
3272e39b573cSmrgno_icondir=
32730bd37d32Smrgif test "$ICONDIR" = no
32740bd37d32Smrgthen
32750bd37d32Smrg	no_icondir="#"
32760bd37d32Smrgelse
32770bd37d32Smrg	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(ICONDIR)"
32780bd37d32Smrgfi
3279e39b573cSmrgAC_SUBST(no_icondir)
3280e39b573cSmrg])dnl
3281e39b573cSmrgdnl ---------------------------------------------------------------------------
328201037d57Smrgdnl CF_WITH_ICON_NAME version: 3 updated: 2015/04/12 15:39:00
32830bd37d32Smrgdnl -----------------
32840bd37d32Smrgdnl Allow a default icon-name to be overridden.
32850bd37d32Smrgdnl $1 = default icon name
32860bd37d32SmrgAC_DEFUN([CF_WITH_ICON_NAME],[
32870bd37d32SmrgAC_MSG_CHECKING(for the icon name)
32880bd37d32SmrgAC_ARG_WITH(icon-name,
32890bd37d32Smrg	[  --with-icon-name=XXXX   override icon name (default: $1)],
32900bd37d32Smrg	[ICON_NAME="$withval"],
32910bd37d32Smrg	[ICON_NAME=$1])
32920bd37d32Smrgcase "x$ICON_NAME" in
329301037d57Smrg(xyes|xno|x)
32940bd37d32Smrg	ICON_NAME=$1
32950bd37d32Smrg	;;
32960bd37d32Smrgesac
32970bd37d32SmrgAC_SUBST(ICON_NAME)
32980bd37d32SmrgAC_MSG_RESULT($ICON_NAME)
32990bd37d32Smrg])dnl
33000bd37d32Smrgdnl ---------------------------------------------------------------------------
330101037d57Smrgdnl CF_WITH_ICON_SYMLINK version: 2 updated: 2015/04/12 15:39:00
33020bd37d32Smrgdnl --------------------
33030bd37d32Smrgdnl Workaround for systems which are (mis)configured to map all icon references
33040bd37d32Smrgdnl for xterm into "xterm" name.  For instance, recent (2013) KDE ignores both
33050bd37d32Smrgdnl the name given in the .desktop file (xterm-color) and the application name
33060bd37d32Smrgdnl (xterm-dev).
33070bd37d32Smrgdnl
33080bd37d32Smrgdnl $1 = default icon name to use if symlink is wanted
33090bd37d32SmrgAC_DEFUN([CF_WITH_ICON_SYMLINK],[
33100bd37d32SmrgAC_MSG_CHECKING(for icon symlink to use)
33110bd37d32SmrgAC_ARG_WITH(icon-symlink,
33120bd37d32Smrg	[  --with-icon-symlink=XXX make symbolic link for icon name (default: $1)],
33130bd37d32Smrg	[ICON_SYMLINK="$withval"],
33140bd37d32Smrg	[ICON_SYMLINK=NONE])
33150bd37d32Smrgcase "x$ICON_SYMLINK" in
331601037d57Smrg(xyes)
33170bd37d32Smrg	ICON_SYMLINK=$1
33180bd37d32Smrg	;;
331901037d57Smrg(xno|x)
33200bd37d32Smrg	ICON_SYMLINK=NONE
33210bd37d32Smrg	;;
33220bd37d32Smrgesac
33230bd37d32SmrgAC_SUBST(ICON_SYMLINK)
33240bd37d32SmrgAC_MSG_RESULT($ICON_SYMLINK)
33250bd37d32Smrg])dnl
33260bd37d32Smrgdnl ---------------------------------------------------------------------------
332701037d57Smrgdnl CF_WITH_ICON_THEME version: 11 updated: 2015/04/12 15:39:00
33280bd37d32Smrgdnl ------------------
33290bd37d32Smrgdnl If asked, check for prerequisites and setup symbols to permit installing
33300bd37d32Smrgdnl one or more application icons in the Red Hat icon-theme directory
333101037d57Smrgdnl hierarchy.
33320bd37d32Smrgdnl
33330bd37d32Smrgdnl If the prerequisites are missing, give a warning and revert to the long-
33340bd37d32Smrgdnl standing pixmaps directory.
33350bd37d32Smrgdnl
33360bd37d32Smrgdnl Parameters:
33370bd37d32Smrgdnl
33380bd37d32Smrgdnl $1 = application icon.  This can be a list, and is not optional.
33390bd37d32Smrgdnl $2 = default theme (defaults to hicolor)
33400bd37d32Smrgdnl $3 = formats (defaults to list [.svg .png .xpm])
33410bd37d32Smrgdnl $4 = alternate icon if no theme is used (defaults to $1).
33420bd37d32Smrgdnl
33430bd37d32Smrgdnl Result:
33440bd37d32Smrgdnl ICON_NAME = basename of first item in $1
33450bd37d32Smrgdnl ICON_LIST = reprocessed $1
33460bd37d32Smrgdnl ICON_THEME = reprocessed $2
33470bd37d32Smrgdnl ICON_FORMAT = reprocessed $3
33480bd37d32SmrgAC_DEFUN([CF_WITH_ICON_THEME],
33490bd37d32Smrg[
33500bd37d32Smrgifelse([$1],,[
33510bd37d32Smrg	AC_MSG_ERROR([macro [CF_WITH_ICON_THEME] requires application-icon name])
33520bd37d32Smrg],[
33530bd37d32Smrg
33540bd37d32SmrgCF_WITH_PIXMAPDIR
33550bd37d32SmrgCF_WITH_ICONDIR
33560bd37d32Smrg
33570bd37d32SmrgAC_MSG_CHECKING(if icon theme should be used)
33580bd37d32SmrgAC_ARG_WITH(icon-theme,
33590bd37d32Smrg	[  --with-icon-theme=XXX   install icons into desktop theme (hicolor)],
33600bd37d32Smrg	[ICON_THEME=$withval],
33610bd37d32Smrg	[ICON_THEME=no])
33620bd37d32Smrg
336301037d57Smrgcase "x$ICON_THEME" in
336401037d57Smrg(xno)
33650bd37d32Smrg	;;
336601037d57Smrg(x|xyes)
33670bd37d32Smrg	ICON_THEME=ifelse([$2],,hicolor,$2)
33680bd37d32Smrg	;;
33690bd37d32Smrgesac
33700bd37d32SmrgAC_MSG_RESULT($ICON_THEME)
33710bd37d32Smrg
33720bd37d32Smrgif test "x$ICON_THEME" = xno
33730bd37d32Smrgthen
33740bd37d32Smrg	if test "x$ICONDIR" != xno
33750bd37d32Smrg	then
33760bd37d32Smrg		CF_VERBOSE(ignoring icondir without theme)
33770bd37d32Smrg		no_icondir="#"
33780bd37d32Smrg	fi
33790bd37d32Smrgelse
33800bd37d32Smrg	if test "x$ICONDIR" = xno
33810bd37d32Smrg	then
33820bd37d32Smrg		AC_MSG_ERROR(icondir must be set for icon theme)
33830bd37d32Smrg	fi
33840bd37d32Smrgfi
33850bd37d32Smrg
33860bd37d32Smrg: ${ICON_FORMAT:=ifelse([$3],,[".svg .png .xpm"],[$3])}
33870bd37d32Smrg
33880bd37d32Smrg# ICON_NAME=
33890bd37d32SmrgICON_LIST=
33900bd37d32Smrg
33910bd37d32Smrgifelse([$4],,[cf_icon_list=$1],[
33920bd37d32Smrgif test "x$ICON_THEME" != xno
33930bd37d32Smrgthen
33940bd37d32Smrg	cf_icon_list="$1"
33950bd37d32Smrgelse
33960bd37d32Smrg	cf_icon_list="$4"
33970bd37d32Smrgfi
33980bd37d32Smrg])
33990bd37d32Smrg
34000bd37d32SmrgAC_MSG_CHECKING([for icon(s) to install])
34010bd37d32Smrgfor cf_name in $cf_icon_list
34020bd37d32Smrgdo
34030bd37d32Smrg	CF_VERBOSE(using $ICON_FORMAT)
34040bd37d32Smrg	for cf_suffix in $ICON_FORMAT
34050bd37d32Smrg	do
34060bd37d32Smrg		cf_icon="${cf_name}${cf_suffix}"
34070bd37d32Smrg		cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
34080bd37d32Smrg		if test ! -f "${cf_left}"
34090bd37d32Smrg		then
34100bd37d32Smrg			if test "x$srcdir" != "x."
34110bd37d32Smrg			then
34120bd37d32Smrg				cf_icon="${srcdir}/${cf_left}"
34130bd37d32Smrg				cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
34140bd37d32Smrg				if test ! -f "${cf_left}"
34150bd37d32Smrg				then
34160bd37d32Smrg					continue
34170bd37d32Smrg				fi
34180bd37d32Smrg			else
34190bd37d32Smrg				continue
34200bd37d32Smrg			fi
34210bd37d32Smrg		fi
34220bd37d32Smrg		if test "x$ICON_THEME" != xno
34230bd37d32Smrg		then
34240bd37d32Smrg			cf_base=`basename $cf_left`
34250bd37d32Smrg			cf_trim=`echo "$cf_base" | sed -e 's/_[[0-9]][[0-9]]x[[0-9]][[0-9]]\././'`
342601037d57Smrg			case "x${cf_base}" in
342701037d57Smrg			(*:*)
34280bd37d32Smrg				cf_next=$cf_base
34290bd37d32Smrg				# user-defined mapping
34300bd37d32Smrg				;;
343101037d57Smrg			(*.png)
34320bd37d32Smrg				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'`
34330bd37d32Smrg				if test -z "$cf_size"
34340bd37d32Smrg				then
34350bd37d32Smrg					AC_MSG_WARN(cannot determine size of $cf_left)
34360bd37d32Smrg					continue
34370bd37d32Smrg				fi
34380bd37d32Smrg				cf_next="$cf_size/apps/$cf_trim"
34390bd37d32Smrg				;;
344001037d57Smrg			(*.svg)
34410bd37d32Smrg				cf_next="scalable/apps/$cf_trim"
34420bd37d32Smrg				;;
344301037d57Smrg			(*.xpm)
34440bd37d32Smrg				CF_VERBOSE(ignored XPM file in icon theme)
34450bd37d32Smrg				continue
34460bd37d32Smrg				;;
344701037d57Smrg			(*_[[0-9]][[0-9]]*x[[0-9]][[0-9]]*.*)
34480bd37d32Smrg				cf_size=`echo "$cf_left"|sed -e 's/^.*_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\..*$/\1/'`
34490bd37d32Smrg				cf_left=`echo "$cf_left"|sed -e 's/^\(.*\)_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\(\..*\)$/\1\3/'`
34500bd37d32Smrg				cf_next="$cf_size/apps/$cf_base"
34510bd37d32Smrg				;;
34520bd37d32Smrg			esac
34530bd37d32Smrg			CF_VERBOSE(adding $cf_next)
34540bd37d32Smrg			cf_icon="${cf_icon}:${cf_next}"
34550bd37d32Smrg		fi
34560bd37d32Smrg		test -n "$ICON_LIST" && ICON_LIST="$ICON_LIST "
34570bd37d32Smrg		ICON_LIST="$ICON_LIST${cf_icon}"
34580bd37d32Smrg		if test -z "$ICON_NAME"
34590bd37d32Smrg		then
34600bd37d32Smrg			ICON_NAME=`basename $cf_icon | sed -e 's/[[.:]].*//'`
34610bd37d32Smrg		fi
34620bd37d32Smrg	done
34630bd37d32Smrgdone
34640bd37d32Smrg
34650bd37d32Smrgif test -n "$verbose"
34660bd37d32Smrgthen
34670bd37d32Smrg	AC_MSG_CHECKING(result)
34680bd37d32Smrgfi
34690bd37d32SmrgAC_MSG_RESULT($ICON_LIST)
34700bd37d32Smrg
34710bd37d32Smrgif test -z "$ICON_LIST"
34720bd37d32Smrgthen
34730bd37d32Smrg	AC_MSG_ERROR(no icons found)
34740bd37d32Smrgfi
34750bd37d32Smrg])
34760bd37d32Smrg
34770bd37d32SmrgAC_MSG_CHECKING(for icon name)
34780bd37d32SmrgAC_MSG_RESULT($ICON_NAME)
34790bd37d32Smrg
34800bd37d32SmrgAC_SUBST(ICON_FORMAT)
34810bd37d32SmrgAC_SUBST(ICON_THEME)
34820bd37d32SmrgAC_SUBST(ICON_LIST)
34830bd37d32SmrgAC_SUBST(ICON_NAME)
34840bd37d32Smrg])dnl
34850bd37d32Smrgdnl ---------------------------------------------------------------------------
348601037d57Smrgdnl CF_WITH_IMAKE_CFLAGS version: 10 updated: 2015/04/12 15:39:00
3487d522f475Smrgdnl --------------------
3488d522f475Smrgdnl xterm and similar programs build more readily when propped up with imake's
3489d522f475Smrgdnl hand-tuned definitions.  If we do not use imake, provide fallbacks for the
3490d522f475Smrgdnl most common definitions that we're not likely to do by autoconf tests.
3491d522f475SmrgAC_DEFUN([CF_WITH_IMAKE_CFLAGS],[
3492d522f475SmrgAC_REQUIRE([CF_ENABLE_NARROWPROTO])
3493d522f475Smrg
3494d522f475SmrgAC_MSG_CHECKING(if we should use imake to help)
3495d522f475SmrgCF_ARG_DISABLE(imake,
3496d522f475Smrg	[  --disable-imake         disable use of imake for definitions],
3497d522f475Smrg	[enable_imake=no],
3498d522f475Smrg	[enable_imake=yes])
3499d522f475SmrgAC_MSG_RESULT($enable_imake)
3500d522f475Smrg
3501d522f475Smrgif test "$enable_imake" = yes ; then
350220d2c4d2Smrg	CF_IMAKE_CFLAGS(ifelse([$1],,,[$1]))
3503d522f475Smrgfi
3504d522f475Smrg
3505d522f475Smrgif test -n "$IMAKE" && test -n "$IMAKE_CFLAGS" ; then
3506d522f475Smrg	CF_ADD_CFLAGS($IMAKE_CFLAGS)
3507d522f475Smrgelse
3508d522f475Smrg	IMAKE_CFLAGS=
3509d522f475Smrg	IMAKE_LOADFLAGS=
3510d522f475Smrg	CF_VERBOSE(make fallback definitions)
3511d522f475Smrg
3512d522f475Smrg	# We prefer config.guess' values when we can get them, to avoid
3513d522f475Smrg	# inconsistent results with uname (AIX for instance).  However,
3514d522f475Smrg	# config.guess is not always consistent either.
3515d522f475Smrg	case $host_os in
351601037d57Smrg	(*[[0-9]].[[0-9]]*)
3517d522f475Smrg		UNAME_RELEASE="$host_os"
3518d522f475Smrg		;;
351901037d57Smrg	(*)
3520d522f475Smrg		UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
3521d522f475Smrg		;;
3522d522f475Smrg	esac
3523d522f475Smrg
3524d522f475Smrg	case .$UNAME_RELEASE in
352501037d57Smrg	(*[[0-9]].[[0-9]]*)
3526d522f475Smrg		OSMAJORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/\..*//'`
3527d522f475Smrg		OSMINORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/^[[^.]]*\.//' -e 's/\..*//' -e 's/[[^0-9]].*//' `
3528d522f475Smrg		test -z "$OSMAJORVERSION" && OSMAJORVERSION=1
3529d522f475Smrg		test -z "$OSMINORVERSION" && OSMINORVERSION=0
3530d522f475Smrg		IMAKE_CFLAGS="-DOSMAJORVERSION=$OSMAJORVERSION -DOSMINORVERSION=$OSMINORVERSION $IMAKE_CFLAGS"
3531d522f475Smrg		;;
3532d522f475Smrg	esac
3533d522f475Smrg
3534d522f475Smrg	# FUNCPROTO is standard with X11R6, but XFree86 drops it, leaving some
3535d522f475Smrg	# fallback/fragments for NeedPrototypes, etc.
3536d522f475Smrg	IMAKE_CFLAGS="-DFUNCPROTO=15 $IMAKE_CFLAGS"
3537d522f475Smrg
3538d522f475Smrg	# If this is not set properly, Xaw's scrollbars will not work
3539d522f475Smrg	if test "$enable_narrowproto" = yes ; then
3540d522f475Smrg		IMAKE_CFLAGS="-DNARROWPROTO=1 $IMAKE_CFLAGS"
3541d522f475Smrg	fi
3542d522f475Smrg
3543d522f475Smrg	# Other special definitions:
3544d522f475Smrg	case $host_os in
354501037d57Smrg	(aix*)
3546d522f475Smrg		# imake on AIX 5.1 defines AIXV3.  really.
3547d522f475Smrg		IMAKE_CFLAGS="-DAIXV3 -DAIXV4 $IMAKE_CFLAGS"
3548d522f475Smrg		;;
354901037d57Smrg	(irix[[56]].*)
3550d522f475Smrg		# these are needed to make SIGWINCH work in xterm
3551d522f475Smrg		IMAKE_CFLAGS="-DSYSV -DSVR4 $IMAKE_CFLAGS"
3552d522f475Smrg		;;
3553d522f475Smrg	esac
3554d522f475Smrg
3555d522f475Smrg	CF_ADD_CFLAGS($IMAKE_CFLAGS)
3556d522f475Smrg
3557d522f475Smrg	AC_SUBST(IMAKE_CFLAGS)
3558d522f475Smrg	AC_SUBST(IMAKE_LOADFLAGS)
3559d522f475Smrgfi
3560d522f475Smrg])dnl
3561d522f475Smrgdnl ---------------------------------------------------------------------------
35622e4f8982Smrgdnl CF_WITH_MAN2HTML version: 5 updated: 2015/08/20 04:51:36
356301037d57Smrgdnl ----------------
356401037d57Smrgdnl Check for man2html and groff.  Optionally prefer man2html over groff.
356501037d57Smrgdnl Generate a shell script which hides the differences between the two.
356601037d57Smrgdnl
356701037d57Smrgdnl We name that "man2html.tmp".
356801037d57Smrgdnl
356901037d57Smrgdnl The shell script can be removed later, e.g., using "make distclean".
357001037d57SmrgAC_DEFUN([CF_WITH_MAN2HTML],[
357101037d57SmrgAC_REQUIRE([CF_PROG_GROFF])
357201037d57Smrg
357301037d57SmrgAC_MSG_CHECKING(for program to convert manpage to html)
357401037d57SmrgAC_ARG_WITH(man2html,
357501037d57Smrg	[  --with-man2html=XXX     use XXX rather than groff],
357601037d57Smrg	[cf_man2html=$withval],
357701037d57Smrg	[cf_man2html=$GROFF_PATH])
357801037d57Smrg
357901037d57Smrgcf_with_groff=no
358001037d57Smrg
358101037d57Smrgcase $cf_man2html in
358201037d57Smrg(yes)
358301037d57Smrg	AC_MSG_RESULT(man2html)
358401037d57Smrg	AC_PATH_PROG(cf_man2html,man2html,no)
358501037d57Smrg	;;
358601037d57Smrg(no|groff|*/groff*)
358701037d57Smrg	cf_with_groff=yes
358801037d57Smrg	cf_man2html=$GROFF_PATH
358901037d57Smrg	AC_MSG_RESULT($cf_man2html)
359001037d57Smrg	;;
359101037d57Smrg(*)
359201037d57Smrg	AC_MSG_RESULT($cf_man2html)
359301037d57Smrg	;;
359401037d57Smrgesac
359501037d57Smrg
359601037d57SmrgMAN2HTML_TEMP="man2html.tmp"
359701037d57Smrg	cat >$MAN2HTML_TEMP <<CF_EOF
35982e4f8982Smrg#!$SHELL
359901037d57Smrg# Temporary script generated by CF_WITH_MAN2HTML
360001037d57Smrg# Convert inputs to html, sending result to standard output.
360101037d57Smrg#
360201037d57Smrg# Parameters:
36032e4f8982Smrg# \${1} = rootname of file to convert
36042e4f8982Smrg# \${2} = suffix of file to convert, e.g., "1"
36052e4f8982Smrg# \${3} = macros to use, e.g., "man"
360601037d57Smrg#
360701037d57SmrgROOT=\[$]1
360801037d57SmrgTYPE=\[$]2
360901037d57SmrgMACS=\[$]3
361001037d57Smrg
361101037d57Smrgunset LANG
361201037d57Smrgunset LC_ALL
361301037d57Smrgunset LC_CTYPE
361401037d57Smrgunset LANGUAGE
361501037d57SmrgGROFF_NO_SGR=stupid
361601037d57Smrgexport GROFF_NO_SGR
361701037d57Smrg
361801037d57SmrgCF_EOF
361901037d57Smrg
362001037d57Smrgif test "x$cf_with_groff" = xyes
362101037d57Smrgthen
362201037d57Smrg	MAN2HTML_NOTE="$GROFF_NOTE"
362301037d57Smrg	MAN2HTML_PATH="$GROFF_PATH"
362401037d57Smrg	cat >>$MAN2HTML_TEMP <<CF_EOF
36252e4f8982Smrg$SHELL -c "tbl \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
362601037d57SmrgCF_EOF
362701037d57Smrgelse
362801037d57Smrg	MAN2HTML_NOTE=""
362901037d57Smrg	CF_PATH_SYNTAX(cf_man2html)
363001037d57Smrg	MAN2HTML_PATH="$cf_man2html"
363101037d57Smrg	AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
363201037d57Smrg
363301037d57Smrg	# for this example, expect 3 lines of content, the remainder is head/foot
363401037d57Smrg	cat >conftest.in <<CF_EOF
363501037d57Smrg.TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
363601037d57Smrg.SH SECTION
363701037d57SmrgMARKER
363801037d57SmrgCF_EOF
363901037d57Smrg
364001037d57Smrg	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C nroff -man conftest.in >conftest.out
364101037d57Smrg
364201037d57Smrg	cf_man2html_1st=`fgrep -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
364301037d57Smrg	cf_man2html_top=`expr $cf_man2html_1st - 2`
364401037d57Smrg	cf_man2html_bot=`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`
364501037d57Smrg	cf_man2html_bot=`expr $cf_man2html_bot - 2 - $cf_man2html_top`
364601037d57Smrg	cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
364701037d57Smrg
364801037d57Smrg	AC_MSG_RESULT($cf_man2html_top_bot)
364901037d57Smrg
365001037d57Smrg	AC_MSG_CHECKING(for pagesize to use)
365101037d57Smrg	for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
365201037d57Smrg	do
365301037d57Smrg	cat >>conftest.in <<CF_EOF
365401037d57Smrg.nf
365501037d57Smrg0
365601037d57Smrg1
365701037d57Smrg2
365801037d57Smrg3
365901037d57Smrg4
366001037d57Smrg5
366101037d57Smrg6
366201037d57Smrg7
366301037d57Smrg8
366401037d57Smrg9
366501037d57SmrgCF_EOF
366601037d57Smrg	done
366701037d57Smrg
366801037d57Smrg	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C nroff -man conftest.in >conftest.out
366901037d57Smrg	cf_man2html_page=`fgrep -n HEAD1 conftest.out |tail -n 1 |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
367001037d57Smrg	test -z "$cf_man2html_page" && cf_man2html_page=99999
367101037d57Smrg	test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
367201037d57Smrg
367301037d57Smrg	rm -rf conftest*
367401037d57Smrg	AC_MSG_RESULT($cf_man2html_page)
367501037d57Smrg
367601037d57Smrg	cat >>$MAN2HTML_TEMP <<CF_EOF
367701037d57Smrg: \${MAN2HTML_PATH=$MAN2HTML_PATH}
367801037d57SmrgMAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title="\$ROOT\(\$TYPE\)" -compress -pgsize $cf_man2html_page"
367901037d57Smrgcase \${TYPE} in
368001037d57Smrg(ms)
368101037d57Smrg	tbl \${ROOT}.\${TYPE} | nroff -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
368201037d57Smrg	;;
368301037d57Smrg(*)
368401037d57Smrg	tbl \${ROOT}.\${TYPE} | nroff -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
368501037d57Smrg	;;
368601037d57Smrgesac
368701037d57SmrgCF_EOF
368801037d57Smrgfi
368901037d57Smrg
369001037d57Smrgchmod 700 $MAN2HTML_TEMP
369101037d57Smrg
369201037d57SmrgAC_SUBST(MAN2HTML_NOTE)
369301037d57SmrgAC_SUBST(MAN2HTML_PATH)
369401037d57SmrgAC_SUBST(MAN2HTML_TEMP)
369501037d57Smrg])dnl
369601037d57Smrgdnl ---------------------------------------------------------------------------
369701037d57Smrgdnl CF_WITH_PCRE version: 11 updated: 2015/04/12 15:39:00
3698d522f475Smrgdnl ------------
3699d522f475Smrgdnl Add PCRE (Perl-compatible regular expressions) to the build if it is
3700d522f475Smrgdnl available and the user requests it.  Assume the application will otherwise
3701d522f475Smrgdnl use the POSIX interface.
3702d522f475Smrgdnl
3703d522f475Smrgdnl TODO allow $withval to specify package location
3704d522f475SmrgAC_DEFUN([CF_WITH_PCRE],
3705d522f475Smrg[
370620d2c4d2SmrgAC_REQUIRE([CF_PKG_CONFIG])
370720d2c4d2Smrg
3708d522f475SmrgAC_MSG_CHECKING(if you want to use PCRE for regular-expressions)
3709d522f475SmrgAC_ARG_WITH(pcre,
3710d522f475Smrg	[  --with-pcre             use PCRE for regular-expressions])
3711d522f475Smrgtest -z "$with_pcre" && with_pcre=no
3712d522f475SmrgAC_MSG_RESULT($with_pcre)
3713d522f475Smrg
3714d522f475Smrgif test "$with_pcre" != no ; then
371520d2c4d2Smrg	CF_TRY_PKG_CONFIG(libpcre,,[
371620d2c4d2Smrg		AC_CHECK_LIB(pcre,pcre_compile,,
371720d2c4d2Smrg			AC_MSG_ERROR(Cannot find PCRE library))])
371820d2c4d2Smrg
37190bd37d32Smrg		AC_DEFINE(HAVE_LIB_PCRE,1,[Define to 1 if we can/should compile with the PCRE library])
372020d2c4d2Smrg
372101037d57Smrg		case $LIBS in
372201037d57Smrg		(*pcreposix*)
372320d2c4d2Smrg			;;
372401037d57Smrg		(*)
372520d2c4d2Smrg			AC_CHECK_LIB(pcreposix,pcreposix_regcomp,
37260bd37d32Smrg				[AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we should include pcreposix.h])
372720d2c4d2Smrg				 CF_ADD_LIB(pcreposix)],
372820d2c4d2Smrg				[AC_CHECK_LIB(pcreposix,regcomp,[
37290bd37d32Smrg					AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we should include pcreposix.h])
373020d2c4d2Smrg					CF_ADD_LIB(pcreposix)],
373120d2c4d2Smrg					AC_MSG_ERROR(Cannot find PCRE POSIX library)]))
373220d2c4d2Smrg			;;
373320d2c4d2Smrg		esac
3734d522f475Smrgfi
3735d522f475Smrg])dnl
3736d522f475Smrgdnl ---------------------------------------------------------------------------
37370bd37d32Smrgdnl CF_WITH_PIXMAPDIR version: 3 updated: 2012/07/22 09:18:02
37380bd37d32Smrgdnl -----------------
37390bd37d32Smrgdnl Handle configure option "--with-pixmapdir", setting these shell variables:
37400bd37d32Smrgdnl
37410bd37d32Smrgdnl $PIXMAPDIR is the option value, used for installing pixmap files.
37420bd37d32Smrgdnl $no_pixmapdir is a "#" (comment) if "--without-pixmapdir" is given.
37430bd37d32SmrgAC_DEFUN([CF_WITH_PIXMAPDIR],[
37440bd37d32SmrgAC_MSG_CHECKING(for directory to install pixmaps)
37450bd37d32SmrgAC_ARG_WITH(pixmapdir,
37460bd37d32Smrg	[  --with-pixmapdir=DIR    directory in which to install pixmaps (DATADIR/pixmaps)],
37470bd37d32Smrg	[PIXMAPDIR=$withval],
37480bd37d32Smrg	[test -z "$PIXMAPDIR" && PIXMAPDIR='${datadir}/pixmaps'])
37490bd37d32Smrg
37500bd37d32Smrgif test "x[$]PIXMAPDIR" = xauto
37510bd37d32Smrgthen
37520bd37d32Smrg	PIXMAPDIR='${datadir}/pixmaps'
37530bd37d32Smrg	for cf_path in \
37540bd37d32Smrg		/usr/share/pixmaps \
37550bd37d32Smrg		/usr/X11R6/share/pixmaps
37560bd37d32Smrg	do
37570bd37d32Smrg		if test -d "$cf_path" ; then
37580bd37d32Smrg			PIXMAPDIR="$cf_path"
37590bd37d32Smrg			break
37600bd37d32Smrg		fi
37610bd37d32Smrg	done
37620bd37d32Smrgelse
37630bd37d32Smrg	cf_path=$PIXMAPDIR
37640bd37d32Smrg	CF_PATH_SYNTAX(cf_path)
37650bd37d32Smrgfi
37660bd37d32SmrgAC_MSG_RESULT($PIXMAPDIR)
37670bd37d32SmrgAC_SUBST(PIXMAPDIR)
37680bd37d32Smrg
37690bd37d32Smrgno_pixmapdir=
37700bd37d32Smrgif test "$PIXMAPDIR" = no
37710bd37d32Smrgthen
37720bd37d32Smrg	no_pixmapdir="#"
37730bd37d32Smrgelse
37740bd37d32Smrg	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(PIXMAPDIR)"
37750bd37d32Smrgfi
37760bd37d32SmrgAC_SUBST(no_pixmapdir)
37770bd37d32Smrg])dnl
37780bd37d32Smrgdnl ---------------------------------------------------------------------------
37790bd37d32Smrgdnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
37800bd37d32Smrgdnl ----------------
37810bd37d32SmrgAC_DEFUN([CF_WITH_VALGRIND],[
37820bd37d32SmrgCF_NO_LEAKS_OPTION(valgrind,
37830bd37d32Smrg	[  --with-valgrind         test: use valgrind],
37840bd37d32Smrg	[USE_VALGRIND])
37850bd37d32Smrg])dnl
37860bd37d32Smrgdnl ---------------------------------------------------------------------------
37872e4f8982Smrgdnl CF_WITH_XINERAMA version: 1 updated: 2016/05/28 14:41:12
37882e4f8982Smrgdnl ----------------
37892e4f8982SmrgAC_DEFUN([CF_WITH_XINERAMA],
37902e4f8982Smrg[
37912e4f8982SmrgAC_MSG_CHECKING(if you want to use the Xinerama extension)
37922e4f8982SmrgAC_ARG_WITH(xinerama,
37932e4f8982Smrg[  --without-xinerama      do not use Xinerama extension for multiscreen support],
37942e4f8982Smrg	[cf_with_xinerama="$withval"],
37952e4f8982Smrg	[cf_with_xinerama=yes])
37962e4f8982SmrgAC_MSG_RESULT($cf_with_xinerama)
37972e4f8982Smrgif test "$cf_with_xinerama" = yes; then
37982e4f8982Smrg	CF_XINERAMA
37992e4f8982Smrgfi
38002e4f8982Smrg])dnl
38012e4f8982Smrgdnl ---------------------------------------------------------------------------
38020bd37d32Smrgdnl CF_WITH_XPM version: 3 updated: 2012/10/04 06:57:36
38030bd37d32Smrgdnl -----------
38040bd37d32Smrgdnl Test for Xpm library, update compiler/loader flags if it is wanted and
38050bd37d32Smrgdnl found.
38060bd37d32Smrgdnl
38070bd37d32Smrgdnl Also sets ICON_SUFFIX
38080bd37d32SmrgAC_DEFUN([CF_WITH_XPM],
38090bd37d32Smrg[
38100bd37d32SmrgICON_SUFFIX=.xbm
38110bd37d32Smrg
38120bd37d32Smrgcf_save_cppflags="${CPPFLAGS}"
38130bd37d32Smrgcf_save_ldflags="${LDFLAGS}"
38140bd37d32Smrg
38150bd37d32SmrgAC_MSG_CHECKING(if you want to use the Xpm library for colored icon)
38160bd37d32SmrgAC_ARG_WITH(xpm,
38170bd37d32Smrg[  --with-xpm=DIR          use Xpm library for colored icon, may specify path],
38180bd37d32Smrg	[cf_Xpm_library="$withval"],
38190bd37d32Smrg	[cf_Xpm_library=yes])
38200bd37d32SmrgAC_MSG_RESULT($cf_Xpm_library)
38210bd37d32Smrg
38220bd37d32Smrgif test "$cf_Xpm_library" != no ; then
38230bd37d32Smrg    if test "$cf_Xpm_library" != yes ; then
38240bd37d32Smrg	CPPFLAGS="$CPPFLAGS -I$withval/include"
38250bd37d32Smrg	LDFLAGS="$LDFLAGS -L$withval/lib"
38260bd37d32Smrg    fi
38270bd37d32Smrg    AC_CHECK_HEADER(X11/xpm.h,[
38280bd37d32Smrg	AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData,[
38290bd37d32Smrg	    AC_DEFINE(HAVE_LIBXPM,1,[Define to 1 if we should use Xpm library])
38300bd37d32Smrg	    ICON_SUFFIX=.xpm
38310bd37d32Smrg	    LIBS="-lXpm $LIBS"],
38320bd37d32Smrg	    [CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"],
38330bd37d32Smrg	    [-lX11 $X_LIBS])],
38340bd37d32Smrg	[CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"])
38350bd37d32Smrgfi
38360bd37d32Smrg
38370bd37d32SmrgAC_SUBST(ICON_SUFFIX)
38380bd37d32Smrg])dnl
38390bd37d32Smrgdnl ---------------------------------------------------------------------------
384001037d57Smrgdnl CF_XBOOL_RESULT version: 3 updated: 2015/04/12 15:39:00
38410bd37d32Smrgdnl ---------------
38420bd37d32Smrgdnl Translate an autoconf boolean yes/no into X11's booleans, e.g., True/False.
38430bd37d32Smrgdnl Allow for more than two values, e.g., "maybe", still using the same leading
38440bd37d32Smrgdnl capital convention.
38450bd37d32Smrgdnl
38460bd37d32Smrgdnl $1 = symbol to define
38470bd37d32Smrgdnl $2 = symbol holding value
38480bd37d32Smrgdnl $3 = description
38490bd37d32Smrgdefine([CF_XBOOL_RESULT],[
38500bd37d32SmrgAC_MSG_RESULT([$]$2)
385101037d57Smrgcase [$]$2 in
385201037d57Smrg(yes)
38530bd37d32Smrg	$2=true
38540bd37d32Smrg	;;
385501037d57Smrg(no)
38560bd37d32Smrg	$2=false
38570bd37d32Smrg	;;
38580bd37d32Smrgesac
38590bd37d32Smrgcf_xbool1=`echo "[$]$2"|sed -e 's/^\(.\).*/\1/'`
38600bd37d32SmrgCF_UPPER(cf_xbool1,$cf_xbool1)
38610bd37d32Smrgcf_xbool2=`echo "[$]$2"|sed -e 's/^.//'`
38620bd37d32Smrg$2=${cf_xbool1}${cf_xbool2}
38630bd37d32SmrgAC_DEFINE_UNQUOTED($1,[$]$2,$3)
38640bd37d32SmrgAC_SUBST($2)
38650bd37d32Smrg])
38660bd37d32Smrgdnl ---------------------------------------------------------------------------
386701037d57Smrgdnl CF_XINERAMA version: 2 updated: 2015/02/15 15:18:41
386801037d57Smrgdnl -----------
386901037d57SmrgAC_DEFUN([CF_XINERAMA],[
387001037d57SmrgCF_TRY_PKG_CONFIG(xinerama,[
387101037d57Smrg	AC_DEFINE(HAVE_X11_EXTENSIONS_XINERAMA_H)],[
387201037d57Smrg	AC_CHECK_LIB(Xinerama,XineramaQueryScreens,
387301037d57Smrg		[CF_ADD_LIB(Xinerama)
387401037d57Smrg		 AC_CHECK_HEADERS( \
387501037d57Smrg			X11/extensions/Xinerama.h \
387601037d57Smrg			)
387701037d57Smrg		])
387801037d57Smrg	])
387901037d57Smrg])dnl
388001037d57Smrgdnl ---------------------------------------------------------------------------
38810bd37d32Smrgdnl CF_XKB_BELL_EXT version: 4 updated: 2012/10/04 20:12:20
3882d522f475Smrgdnl ---------------
3883d522f475Smrgdnl Check for XKB bell extension
3884d522f475SmrgAC_DEFUN([CF_XKB_BELL_EXT],[
3885d522f475SmrgAC_CACHE_CHECK(for XKB Bell extension, cf_cv_xkb_bell_ext,[
3886d522f475SmrgAC_TRY_LINK([
3887956cc18dSsnj#include <X11/Intrinsic.h>
3888d522f475Smrg#include <X11/XKBlib.h>		/* has the prototype */
3889d522f475Smrg#include <X11/extensions/XKBbells.h>	/* has the XkbBI_xxx definitions */
3890d522f475Smrg],[
3891956cc18dSsnj	int x = (XkbBI_Info |XkbBI_MinorError |XkbBI_MajorError |XkbBI_TerminalBell |XkbBI_MarginBell);
3892956cc18dSsnj	Atom y;
3893956cc18dSsnj	XkbBell((Display *)0, (Widget)0, 0, y);
3894d522f475Smrg],[cf_cv_xkb_bell_ext=yes],[cf_cv_xkb_bell_ext=no])
3895d522f475Smrg])
38960bd37d32Smrgtest "$cf_cv_xkb_bell_ext" = yes && AC_DEFINE(HAVE_XKB_BELL_EXT,1,[Define 1 if we have XKB Bell extension])
38970bd37d32Smrg])
38980bd37d32Smrgdnl ---------------------------------------------------------------------------
38990bd37d32Smrgdnl CF_XKB_KEYCODE_TO_KEYSYM version: 2 updated: 2012/09/28 20:23:33
39000bd37d32Smrgdnl ------------------------
39010bd37d32Smrgdnl Some older vendor-unix systems made a practice of delivering fragments of
39020bd37d32Smrgdnl Xkb, requiring test-compiles.
39030bd37d32SmrgAC_DEFUN([CF_XKB_KEYCODE_TO_KEYSYM],[
39040bd37d32SmrgAC_CACHE_CHECK(if we can use XkbKeycodeToKeysym, cf_cv_xkb_keycode_to_keysym,[
39050bd37d32SmrgAC_TRY_COMPILE([
39060bd37d32Smrg#include <X11/Xlib.h>
39070bd37d32Smrg#include <X11/XKBlib.h>
39080bd37d32Smrg],[
39090bd37d32Smrg    KeySym keysym = XkbKeycodeToKeysym((Display *)0, 0, 0, 0);
39100bd37d32Smrg],[
39110bd37d32Smrgcf_cv_xkb_keycode_to_keysym=yes
39120bd37d32Smrg],[
39130bd37d32Smrgcf_cv_xkb_keycode_to_keysym=no
39140bd37d32Smrg])
39150bd37d32Smrg])
39160bd37d32Smrg
39170bd37d32Smrgif test $cf_cv_xkb_keycode_to_keysym = yes
39180bd37d32Smrgthen
39190bd37d32Smrg	AC_CHECK_FUNCS(XkbKeycodeToKeysym)
39200bd37d32Smrgfi
39210bd37d32Smrg])
39220bd37d32Smrgdnl ---------------------------------------------------------------------------
39230bd37d32Smrgdnl CF_XKB_QUERY_EXTENSION version: 2 updated: 2012/09/28 20:23:46
39240bd37d32Smrgdnl ----------------------
39250bd37d32Smrgdnl see ifdef in scrollbar.c - iron out here
39260bd37d32SmrgAC_DEFUN([CF_XKB_QUERY_EXTENSION],[
39270bd37d32SmrgAC_CACHE_CHECK(if we can use XkbQueryExtension, cf_cv_xkb_query_extension,[
39280bd37d32SmrgAC_TRY_COMPILE([
39290bd37d32Smrg#include <X11/Xlib.h>
39300bd37d32Smrg#include <X11/extensions/XKB.h>
39310bd37d32Smrg#include <X11/XKBlib.h>
39320bd37d32Smrg],[
39330bd37d32Smrg	int xkbmajor = XkbMajorVersion;
39340bd37d32Smrg	int xkbminor = XkbMinorVersion;
39350bd37d32Smrg	int xkbopcode, xkbevent, xkberror;
39360bd37d32Smrg
39370bd37d32Smrg	if (XkbLibraryVersion(&xkbmajor, &xkbminor)
39380bd37d32Smrg	    && XkbQueryExtension((Display *)0,
39390bd37d32Smrg				 &xkbopcode,
39400bd37d32Smrg				 &xkbevent,
39410bd37d32Smrg				 &xkberror,
39420bd37d32Smrg				 &xkbmajor,
39430bd37d32Smrg				 &xkbminor))
39440bd37d32Smrg		 return 0;
39450bd37d32Smrg],[
39460bd37d32Smrgcf_cv_xkb_query_extension=yes
39470bd37d32Smrg],[
39480bd37d32Smrgcf_cv_xkb_query_extension=no
39490bd37d32Smrg])
39500bd37d32Smrg])
39510bd37d32Smrg
39520bd37d32Smrgif test $cf_cv_xkb_query_extension = yes
39530bd37d32Smrgthen
39540bd37d32Smrg	AC_CHECK_FUNCS(XkbQueryExtension)
39550bd37d32Smrgfi
3956d522f475Smrg])
3957d522f475Smrgdnl ---------------------------------------------------------------------------
39582e4f8982Smrgdnl CF_XOPEN_SOURCE version: 50 updated: 2015/10/17 19:03:33
3959d522f475Smrgdnl ---------------
3960d522f475Smrgdnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3961d522f475Smrgdnl or adapt to the vendor's definitions to get equivalent functionality,
3962d522f475Smrgdnl without losing the common non-POSIX features.
3963d522f475Smrgdnl
3964d522f475Smrgdnl Parameters:
3965d522f475Smrgdnl	$1 is the nominal value for _XOPEN_SOURCE
3966d522f475Smrgdnl	$2 is the nominal value for _POSIX_C_SOURCE
3967d522f475SmrgAC_DEFUN([CF_XOPEN_SOURCE],[
39680bd37d32SmrgAC_REQUIRE([AC_CANONICAL_HOST])
3969d522f475Smrg
397020d2c4d2Smrgcf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
397120d2c4d2Smrgcf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
397220d2c4d2Smrgcf_xopen_source=
3973d522f475Smrg
397401037d57Smrgcase $host_os in
397501037d57Smrg(aix[[4-7]]*)
397620d2c4d2Smrg	cf_xopen_source="-D_ALL_SOURCE"
397720d2c4d2Smrg	;;
397801037d57Smrg(cygwin|msys)
3979e39b573cSmrg	cf_XOPEN_SOURCE=600
3980e39b573cSmrg	;;
398101037d57Smrg(darwin[[0-8]].*)
398220d2c4d2Smrg	cf_xopen_source="-D_APPLE_C_SOURCE"
398320d2c4d2Smrg	;;
398401037d57Smrg(darwin*)
398520d2c4d2Smrg	cf_xopen_source="-D_DARWIN_C_SOURCE"
39860bd37d32Smrg	cf_XOPEN_SOURCE=
3987d522f475Smrg	;;
398801037d57Smrg(freebsd*|dragonfly*)
3989d522f475Smrg	# 5.x headers associate
3990d522f475Smrg	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
3991d522f475Smrg	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
3992d522f475Smrg	cf_POSIX_C_SOURCE=200112L
3993d522f475Smrg	cf_XOPEN_SOURCE=600
399420d2c4d2Smrg	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
399520d2c4d2Smrg	;;
399601037d57Smrg(hpux11*)
399720d2c4d2Smrg	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3998d522f475Smrg	;;
399901037d57Smrg(hpux*)
400020d2c4d2Smrg	cf_xopen_source="-D_HPUX_SOURCE"
4001d522f475Smrg	;;
400201037d57Smrg(irix[[56]].*)
400320d2c4d2Smrg	cf_xopen_source="-D_SGI_SOURCE"
40040bd37d32Smrg	cf_XOPEN_SOURCE=
4005d522f475Smrg	;;
400601037d57Smrg(linux*|gnu*|mint*|k*bsd*-gnu)
4007d522f475Smrg	CF_GNU_SOURCE
4008d522f475Smrg	;;
400901037d57Smrg(minix*)
401001037d57Smrg	cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
401101037d57Smrg	;;
401201037d57Smrg(mirbsd*)
40130bd37d32Smrg	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
40140bd37d32Smrg	cf_XOPEN_SOURCE=
40150bd37d32Smrg	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
4016d522f475Smrg	;;
401701037d57Smrg(netbsd*)
40180bd37d32Smrg	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
40190bd37d32Smrg	;;
402001037d57Smrg(openbsd[[4-9]]*)
40210bd37d32Smrg	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
40220bd37d32Smrg	cf_xopen_source="-D_BSD_SOURCE"
40230bd37d32Smrg	cf_XOPEN_SOURCE=600
4024d522f475Smrg	;;
402501037d57Smrg(openbsd*)
4026d522f475Smrg	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
4027d522f475Smrg	;;
40282e4f8982Smrg(os2*)
40292e4f8982Smrg	cf_XOPEN_SOURCE=
40302e4f8982Smrg	;;
403101037d57Smrg(osf[[45]]*)
403220d2c4d2Smrg	cf_xopen_source="-D_OSF_SOURCE"
4033d522f475Smrg	;;
403401037d57Smrg(nto-qnx*)
403520d2c4d2Smrg	cf_xopen_source="-D_QNX_SOURCE"
4036d522f475Smrg	;;
403701037d57Smrg(sco*)
4038d522f475Smrg	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
4039d522f475Smrg	;;
404001037d57Smrg(solaris2.*)
404120d2c4d2Smrg	cf_xopen_source="-D__EXTENSIONS__"
4042894e0ac8Smrg	cf_cv_xopen_source=broken
4043d522f475Smrg	;;
404401037d57Smrg(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
404501037d57Smrg	cf_XOPEN_SOURCE=
404601037d57Smrg	cf_POSIX_C_SOURCE=
404701037d57Smrg	;;
404801037d57Smrg(*)
40490bd37d32Smrg	CF_TRY_XOPEN_SOURCE
4050d522f475Smrg	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
4051d522f475Smrg	;;
4052d522f475Smrgesac
405320d2c4d2Smrg
405420d2c4d2Smrgif test -n "$cf_xopen_source" ; then
405501037d57Smrg	CF_ADD_CFLAGS($cf_xopen_source,true)
405620d2c4d2Smrgfi
40570bd37d32Smrg
40580bd37d32Smrgdnl In anything but the default case, we may have system-specific setting
40590bd37d32Smrgdnl which is still not guaranteed to provide all of the entrypoints that
40600bd37d32Smrgdnl _XOPEN_SOURCE would yield.
40610bd37d32Smrgif test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
40620bd37d32Smrg	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
40630bd37d32Smrg	AC_TRY_COMPILE([#include <stdlib.h>],[
40640bd37d32Smrg#ifndef _XOPEN_SOURCE
40650bd37d32Smrgmake an error
40660bd37d32Smrg#endif],
40670bd37d32Smrg	[cf_XOPEN_SOURCE_set=yes],
40680bd37d32Smrg	[cf_XOPEN_SOURCE_set=no])
40690bd37d32Smrg	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
40700bd37d32Smrg	if test $cf_XOPEN_SOURCE_set = yes
40710bd37d32Smrg	then
40720bd37d32Smrg		AC_TRY_COMPILE([#include <stdlib.h>],[
40730bd37d32Smrg#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
40740bd37d32Smrgmake an error
40750bd37d32Smrg#endif],
40760bd37d32Smrg		[cf_XOPEN_SOURCE_set_ok=yes],
40770bd37d32Smrg		[cf_XOPEN_SOURCE_set_ok=no])
40780bd37d32Smrg		if test $cf_XOPEN_SOURCE_set_ok = no
40790bd37d32Smrg		then
40800bd37d32Smrg			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
40810bd37d32Smrg		fi
40820bd37d32Smrg	else
40830bd37d32Smrg		CF_TRY_XOPEN_SOURCE
40840bd37d32Smrg	fi
40850bd37d32Smrgfi
4086d522f475Smrg])
4087d522f475Smrgdnl ---------------------------------------------------------------------------
408801037d57Smrgdnl CF_X_ATHENA version: 23 updated: 2015/04/12 15:39:00
4089d522f475Smrgdnl -----------
4090d522f475Smrgdnl Check for Xaw (Athena) libraries
4091d522f475Smrgdnl
4092d522f475Smrgdnl Sets $cf_x_athena according to the flavor of Xaw which is used.
4093d522f475SmrgAC_DEFUN([CF_X_ATHENA],
409420d2c4d2Smrg[
40956879286fSmrgcf_x_athena=${cf_x_athena:-Xaw}
4096d522f475Smrg
4097d522f475SmrgAC_MSG_CHECKING(if you want to link with Xaw 3d library)
4098d522f475Smrgwithval=
4099d522f475SmrgAC_ARG_WITH(Xaw3d,
4100d522f475Smrg	[  --with-Xaw3d            link with Xaw 3d library])
4101d522f475Smrgif test "$withval" = yes ; then
4102d522f475Smrg	cf_x_athena=Xaw3d
4103d522f475Smrg	AC_MSG_RESULT(yes)
4104d522f475Smrgelse
4105d522f475Smrg	AC_MSG_RESULT(no)
4106d522f475Smrgfi
4107d522f475Smrg
410801037d57SmrgAC_MSG_CHECKING(if you want to link with Xaw 3d xft library)
410901037d57Smrgwithval=
411001037d57SmrgAC_ARG_WITH(Xaw3dxft,
411101037d57Smrg	[  --with-Xaw3dxft         link with Xaw 3d xft library])
411201037d57Smrgif test "$withval" = yes ; then
411301037d57Smrg	cf_x_athena=Xaw3dxft
411401037d57Smrg	AC_MSG_RESULT(yes)
411501037d57Smrgelse
411601037d57Smrg	AC_MSG_RESULT(no)
411701037d57Smrgfi
411801037d57Smrg
4119d522f475SmrgAC_MSG_CHECKING(if you want to link with neXT Athena library)
4120d522f475Smrgwithval=
4121d522f475SmrgAC_ARG_WITH(neXtaw,
4122d522f475Smrg	[  --with-neXtaw           link with neXT Athena library])
4123d522f475Smrgif test "$withval" = yes ; then
4124d522f475Smrg	cf_x_athena=neXtaw
4125d522f475Smrg	AC_MSG_RESULT(yes)
4126d522f475Smrgelse
4127d522f475Smrg	AC_MSG_RESULT(no)
4128d522f475Smrgfi
4129d522f475Smrg
4130d522f475SmrgAC_MSG_CHECKING(if you want to link with Athena-Plus library)
4131d522f475Smrgwithval=
4132d522f475SmrgAC_ARG_WITH(XawPlus,
4133d522f475Smrg	[  --with-XawPlus          link with Athena-Plus library])
4134d522f475Smrgif test "$withval" = yes ; then
4135d522f475Smrg	cf_x_athena=XawPlus
4136d522f475Smrg	AC_MSG_RESULT(yes)
4137d522f475Smrgelse
4138d522f475Smrg	AC_MSG_RESULT(no)
4139d522f475Smrgfi
4140d522f475Smrg
4141d522f475Smrgcf_x_athena_lib=""
4142d522f475Smrg
414320d2c4d2Smrgif test "$PKG_CONFIG" != none ; then
414420d2c4d2Smrg	cf_athena_list=
414520d2c4d2Smrg	test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
414620d2c4d2Smrg	for cf_athena_pkg in \
414720d2c4d2Smrg		$cf_athena_list \
414820d2c4d2Smrg		${cf_x_athena} \
414920d2c4d2Smrg		${cf_x_athena}-devel \
415020d2c4d2Smrg		lib${cf_x_athena} \
415120d2c4d2Smrg		lib${cf_x_athena}-devel
415220d2c4d2Smrg	do
415320d2c4d2Smrg		CF_TRY_PKG_CONFIG($cf_athena_pkg,[
415420d2c4d2Smrg			cf_x_athena_lib="$cf_pkgconfig_libs"
415520d2c4d2Smrg			CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
415620d2c4d2Smrg			AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
41576879286fSmrg
4158e0a2b6dfSmrg			CF_TRIM_X_LIBS
4159e0a2b6dfSmrg
41606879286fSmrgAC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
41616879286fSmrgAC_TRY_LINK([
41626879286fSmrg#include <X11/Xmu/CharSet.h>
41636879286fSmrg],[
41646879286fSmrgint check = XmuCompareISOLatin1("big", "small")
41656879286fSmrg],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
41666879286fSmrg
41676879286fSmrg			if test "$cf_cv_xaw_compat" = no
41686879286fSmrg			then
41696879286fSmrg				# workaround for broken ".pc" files...
417001037d57Smrg				case "$cf_x_athena_lib" in
417101037d57Smrg				(*-lXmu*)
41726879286fSmrg					;;
417301037d57Smrg				(*)
41746879286fSmrg					CF_VERBOSE(work around broken package)
4175e0a2b6dfSmrg					cf_save_xmu="$LIBS"
4176e0a2b6dfSmrg					cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
4177e0a2b6dfSmrg					CF_TRY_PKG_CONFIG(xmu,[
4178e0a2b6dfSmrg							LIBS="$cf_save_xmu"
4179e0a2b6dfSmrg							CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
4180e0a2b6dfSmrg						],[
4181e0a2b6dfSmrg							CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
4182e0a2b6dfSmrg						])
4183e0a2b6dfSmrg					CF_TRIM_X_LIBS
41846879286fSmrg					;;
41856879286fSmrg				esac
41866879286fSmrg			fi
41876879286fSmrg
418820d2c4d2Smrg			break])
418920d2c4d2Smrg	done
419020d2c4d2Smrgfi
419120d2c4d2Smrg
419220d2c4d2Smrgif test -z "$cf_x_athena_lib" ; then
419320d2c4d2Smrg	CF_X_EXT
419420d2c4d2Smrg	CF_X_TOOLKIT
419520d2c4d2Smrg	CF_X_ATHENA_CPPFLAGS($cf_x_athena)
419620d2c4d2Smrg	CF_X_ATHENA_LIBS($cf_x_athena)
419720d2c4d2Smrgfi
4198d522f475Smrg])dnl
4199d522f475Smrgdnl ---------------------------------------------------------------------------
420020d2c4d2Smrgdnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
4201d522f475Smrgdnl --------------------
4202d522f475Smrgdnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
4203d522f475Smrgdnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
4204d522f475SmrgAC_DEFUN([CF_X_ATHENA_CPPFLAGS],
4205d522f475Smrg[
420620d2c4d2Smrgcf_x_athena_root=ifelse([$1],,Xaw,[$1])
420720d2c4d2Smrgcf_x_athena_inc=""
4208d522f475Smrg
4209d522f475Smrgfor cf_path in default \
4210d522f475Smrg	/usr/contrib/X11R6 \
4211d522f475Smrg	/usr/contrib/X11R5 \
4212d522f475Smrg	/usr/lib/X11R5 \
4213d522f475Smrg	/usr/local
4214d522f475Smrgdo
421520d2c4d2Smrg	if test -z "$cf_x_athena_inc" ; then
4216d522f475Smrg		cf_save="$CPPFLAGS"
4217d522f475Smrg		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
4218d522f475Smrg		if test $cf_path != default ; then
4219956cc18dSsnj			CPPFLAGS="$cf_save -I$cf_path/include"
4220d522f475Smrg			AC_MSG_CHECKING(for $cf_test in $cf_path)
4221d522f475Smrg		else
4222d522f475Smrg			AC_MSG_CHECKING(for $cf_test)
4223d522f475Smrg		fi
4224d522f475Smrg		AC_TRY_COMPILE([
4225d522f475Smrg#include <X11/Intrinsic.h>
4226d522f475Smrg#include <$cf_test>],[],
4227d522f475Smrg			[cf_result=yes],
4228d522f475Smrg			[cf_result=no])
4229d522f475Smrg		AC_MSG_RESULT($cf_result)
4230d522f475Smrg		if test "$cf_result" = yes ; then
423120d2c4d2Smrg			cf_x_athena_inc=$cf_path
4232d522f475Smrg			break
4233d522f475Smrg		else
4234d522f475Smrg			CPPFLAGS="$cf_save"
4235d522f475Smrg		fi
4236d522f475Smrg	fi
4237d522f475Smrgdone
4238d522f475Smrg
423920d2c4d2Smrgif test -z "$cf_x_athena_inc" ; then
4240d522f475Smrg	AC_MSG_WARN(
4241d522f475Smrg[Unable to successfully find Athena header files with test program])
424220d2c4d2Smrgelif test "$cf_x_athena_inc" != default ; then
424320d2c4d2Smrg	CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
4244d522f475Smrgfi
4245d522f475Smrg])
4246d522f475Smrgdnl ---------------------------------------------------------------------------
42470bd37d32Smrgdnl CF_X_ATHENA_LIBS version: 12 updated: 2011/07/17 19:55:02
4248d522f475Smrgdnl ----------------
4249d522f475Smrgdnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
4250d522f475Smrgdnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
4251d522f475SmrgAC_DEFUN([CF_X_ATHENA_LIBS],
4252d522f475Smrg[AC_REQUIRE([CF_X_TOOLKIT])
425320d2c4d2Smrgcf_x_athena_root=ifelse([$1],,Xaw,[$1])
4254d522f475Smrgcf_x_athena_lib=""
4255d522f475Smrg
4256d522f475Smrgfor cf_path in default \
4257d522f475Smrg	/usr/contrib/X11R6 \
4258d522f475Smrg	/usr/contrib/X11R5 \
4259d522f475Smrg	/usr/lib/X11R5 \
4260d522f475Smrg	/usr/local
4261d522f475Smrgdo
4262d522f475Smrg	for cf_lib in \
42630bd37d32Smrg		${cf_x_athena_root} \
42640bd37d32Smrg		${cf_x_athena_root}7 \
42650bd37d32Smrg		${cf_x_athena_root}6
42660bd37d32Smrg	do
42670bd37d32Smrg	for cf_libs in \
42680bd37d32Smrg		"-l$cf_lib -lXmu" \
42690bd37d32Smrg		"-l$cf_lib -lXpm -lXmu" \
42700bd37d32Smrg		"-l${cf_lib}_s -lXmu_s"
4271d522f475Smrg	do
4272d522f475Smrg		if test -z "$cf_x_athena_lib" ; then
4273d522f475Smrg			cf_save="$LIBS"
4274d522f475Smrg			cf_test=XawSimpleMenuAddGlobalActions
4275d522f475Smrg			if test $cf_path != default ; then
42760bd37d32Smrg				CF_ADD_LIBS(-L$cf_path/lib $cf_libs)
42770bd37d32Smrg				AC_MSG_CHECKING(for $cf_libs in $cf_path)
4278d522f475Smrg			else
42790bd37d32Smrg				CF_ADD_LIBS($cf_libs)
42800bd37d32Smrg				AC_MSG_CHECKING(for $cf_test in $cf_libs)
4281d522f475Smrg			fi
4282a1f3da82Smrg			AC_TRY_LINK([
4283a1f3da82Smrg#include <X11/Intrinsic.h>
4284a1f3da82Smrg#include <X11/$cf_x_athena_root/SimpleMenu.h>
4285a1f3da82Smrg],[
4286a1f3da82Smrg$cf_test((XtAppContext) 0)],
4287d522f475Smrg				[cf_result=yes],
4288d522f475Smrg				[cf_result=no])
4289d522f475Smrg			AC_MSG_RESULT($cf_result)
4290d522f475Smrg			if test "$cf_result" = yes ; then
42910bd37d32Smrg				cf_x_athena_lib="$cf_libs"
4292d522f475Smrg				break
4293d522f475Smrg			fi
4294d522f475Smrg			LIBS="$cf_save"
4295d522f475Smrg		fi
42960bd37d32Smrg	done # cf_libs
42970bd37d32Smrg		test -n "$cf_x_athena_lib" && break
42980bd37d32Smrg	done # cf_lib
4299d522f475Smrgdone
4300d522f475Smrg
4301d522f475Smrgif test -z "$cf_x_athena_lib" ; then
4302d522f475Smrg	AC_MSG_ERROR(
4303d522f475Smrg[Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
4304d522f475Smrgfi
4305d522f475Smrg
4306d522f475SmrgCF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
4307d522f475SmrgAC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
4308d522f475Smrg])
4309d522f475Smrgdnl ---------------------------------------------------------------------------
431020d2c4d2Smrgdnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
431120d2c4d2Smrgdnl --------
431220d2c4d2SmrgAC_DEFUN([CF_X_EXT],[
431320d2c4d2SmrgCF_TRY_PKG_CONFIG(Xext,,[
431420d2c4d2Smrg	AC_CHECK_LIB(Xext,XextCreateExtension,
431520d2c4d2Smrg		[CF_ADD_LIB(Xext)])])
431620d2c4d2Smrg])dnl
431720d2c4d2Smrgdnl ---------------------------------------------------------------------------
431801037d57Smrgdnl CF_X_FONTCONFIG version: 6 updated: 2015/04/12 15:39:00
43196879286fSmrgdnl ---------------
43206879286fSmrgdnl Check for fontconfig library, a dependency of the X FreeType library.
43216879286fSmrgAC_DEFUN([CF_X_FONTCONFIG],
43226879286fSmrg[
43236879286fSmrgAC_REQUIRE([CF_X_FREETYPE])
43246879286fSmrg
4325e39b573cSmrgif test "$cf_cv_found_freetype" = yes ; then
43266879286fSmrgAC_CACHE_CHECK(for usable Xft/fontconfig package,cf_cv_xft_compat,[
43276879286fSmrgAC_TRY_LINK([
43286879286fSmrg#include <X11/Xft/Xft.h>
43296879286fSmrg],[
43306879286fSmrg	XftPattern *pat;
43316879286fSmrg	XftPatternBuild(pat,
43326879286fSmrg					XFT_FAMILY, XftTypeString, "mono",
43336879286fSmrg					(void *) 0);
43346879286fSmrg],[cf_cv_xft_compat=yes],[cf_cv_xft_compat=no])
43356879286fSmrg])
43366879286fSmrg
43376879286fSmrgif test "$cf_cv_xft_compat" = no
43386879286fSmrgthen
43396879286fSmrg	# workaround for broken ".pc" files used for Xft.
434001037d57Smrg	case "$cf_cv_x_freetype_libs" in
434101037d57Smrg	(*-lfontconfig*)
43426879286fSmrg		;;
434301037d57Smrg	(*)
43446879286fSmrg		CF_VERBOSE(work around broken package)
4345e0a2b6dfSmrg		cf_save_fontconfig="$LIBS"
4346e0a2b6dfSmrg		CF_TRY_PKG_CONFIG(fontconfig,[
4347e0a2b6dfSmrg				CF_ADD_CFLAGS($cf_pkgconfig_incs)
4348e0a2b6dfSmrg				LIBS="$cf_save_fontconfig"
4349e0a2b6dfSmrg				CF_ADD_LIB_AFTER(-lXft,$cf_pkgconfig_libs)
4350e0a2b6dfSmrg			],[
4351e0a2b6dfSmrg				CF_ADD_LIB_AFTER(-lXft,-lfontconfig)
4352e0a2b6dfSmrg			])
43536879286fSmrg		;;
43546879286fSmrg	esac
43556879286fSmrgfi
4356e39b573cSmrgfi
43576879286fSmrg])dnl
43586879286fSmrgdnl ---------------------------------------------------------------------------
435901037d57Smrgdnl CF_X_FREETYPE version: 27 updated: 2015/04/12 15:39:00
4360d522f475Smrgdnl -------------
4361d522f475Smrgdnl Check for X FreeType headers and libraries (XFree86 4.x, etc).
4362d522f475Smrgdnl
4363d522f475Smrgdnl First check for the appropriate config program, since the developers for
4364d522f475Smrgdnl these libraries change their configuration (and config program) more or
4365d522f475Smrgdnl less randomly.  If we cannot find the config program, do not bother trying
4366d522f475Smrgdnl to guess the latest variation of include/lib directories.
4367d522f475Smrgdnl
4368d522f475Smrgdnl If either or both of these configure-script options are not given, rely on
4369d522f475Smrgdnl the output of the config program to provide the cflags/libs options:
4370d522f475Smrgdnl	--with-freetype-cflags
4371d522f475Smrgdnl	--with-freetype-libs
4372d522f475SmrgAC_DEFUN([CF_X_FREETYPE],
4373d522f475Smrg[
4374956cc18dSsnjAC_REQUIRE([CF_PKG_CONFIG])
4375956cc18dSsnj
43760bd37d32Smrgcf_cv_x_freetype_incs=no
43770bd37d32Smrgcf_cv_x_freetype_libs=no
4378d522f475Smrgcf_extra_freetype_libs=
4379956cc18dSsnjFREETYPE_CONFIG=none
4380d522f475SmrgFREETYPE_PARAMS=
4381d522f475Smrg
43820bd37d32SmrgAC_MSG_CHECKING(for FreeType configuration script)
43830bd37d32SmrgAC_ARG_WITH(freetype-config,
43840bd37d32Smrg	[  --with-freetype-config  configure script to use for FreeType],
43850bd37d32Smrg	[cf_cv_x_freetype_cfgs="$withval"],
43860bd37d32Smrg	[cf_cv_x_freetype_cfgs=auto])
43870bd37d32Smrgtest -z $cf_cv_x_freetype_cfgs && cf_cv_x_freetype_cfgs=auto
43880bd37d32Smrgtest $cf_cv_x_freetype_cfgs = no && cf_cv_x_freetype_cfgs=none
43890bd37d32SmrgAC_MSG_RESULT($cf_cv_x_freetype_cfgs)
43900bd37d32Smrg
43910bd37d32Smrgcase $cf_cv_x_freetype_cfgs in
439201037d57Smrg(none)
43930bd37d32Smrg	AC_MSG_CHECKING(if you specified -D/-I options for FreeType)
43940bd37d32Smrg	AC_ARG_WITH(freetype-cflags,
43950bd37d32Smrg		[  --with-freetype-cflags  -D/-I options for compiling with FreeType],
43960bd37d32Smrg		[cf_cv_x_freetype_incs="$with_freetype_cflags"],
43970bd37d32Smrg		[cf_cv_x_freetype_incs=no])
43980bd37d32Smrg	AC_MSG_RESULT($cf_cv_x_freetype_incs)
43990bd37d32Smrg
44000bd37d32Smrg	AC_MSG_CHECKING(if you specified -L/-l options for FreeType)
44010bd37d32Smrg	AC_ARG_WITH(freetype-libs,
44020bd37d32Smrg		[  --with-freetype-libs    -L/-l options to link FreeType],
44030bd37d32Smrg		[cf_cv_x_freetype_libs="$with_freetype_libs"],
44040bd37d32Smrg		[cf_cv_x_freetype_libs=no])
44050bd37d32Smrg	AC_MSG_RESULT($cf_cv_x_freetype_libs)
44060bd37d32Smrg	;;
440701037d57Smrg(auto)
44080bd37d32Smrg	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
44090bd37d32Smrg		FREETYPE_CONFIG=$PKG_CONFIG
44100bd37d32Smrg		FREETYPE_PARAMS=xft
44110bd37d32Smrg	else
44120bd37d32Smrg		AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, none)
44130bd37d32Smrg		if test "$FREETYPE_CONFIG" != none; then
44140bd37d32Smrg			FREETYPE_CONFIG=$FREETYPE_CONFIG
44150bd37d32Smrg			cf_extra_freetype_libs="-lXft"
44160bd37d32Smrg		else
44170bd37d32Smrg			AC_PATH_PROG(FREETYPE_OLD_CONFIG, xft-config, none)
44180bd37d32Smrg			if test "$FREETYPE_OLD_CONFIG" != none; then
44190bd37d32Smrg				FREETYPE_CONFIG=$FREETYPE_OLD_CONFIG
44200bd37d32Smrg			fi
44210bd37d32Smrg		fi
44220bd37d32Smrg	fi
44230bd37d32Smrg	;;
442401037d57Smrg(pkg*)
44250bd37d32Smrg	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
44260bd37d32Smrg		FREETYPE_CONFIG=$cf_cv_x_freetype_cfgs
44270bd37d32Smrg		FREETYPE_PARAMS=xft
44280bd37d32Smrg	else
44290bd37d32Smrg		AC_MSG_WARN(cannot find pkg-config for Xft)
44300bd37d32Smrg	fi
44310bd37d32Smrg	;;
443201037d57Smrg(*)
44330bd37d32Smrg	AC_PATH_PROG(FREETYPE_XFT_CONFIG, $cf_cv_x_freetype_cfgs, none)
4434d522f475Smrg	if test "$FREETYPE_XFT_CONFIG" != none; then
4435d522f475Smrg		FREETYPE_CONFIG=$FREETYPE_XFT_CONFIG
4436d522f475Smrg	else
44370bd37d32Smrg		AC_MSG_WARN(cannot find config script for Xft)
4438d522f475Smrg	fi
44390bd37d32Smrg	;;
44400bd37d32Smrgesac
4441d522f475Smrg
4442956cc18dSsnjif test "$FREETYPE_CONFIG" != none ; then
44430bd37d32Smrg	AC_MSG_CHECKING(for FreeType config)
44440bd37d32Smrg	AC_MSG_RESULT($FREETYPE_CONFIG $FREETYPE_PARAMS)
4445d522f475Smrg
4446956cc18dSsnj	if test "$cf_cv_x_freetype_incs" = no ; then
4447956cc18dSsnj		AC_MSG_CHECKING(for $FREETYPE_CONFIG cflags)
4448956cc18dSsnj		cf_cv_x_freetype_incs="`$FREETYPE_CONFIG $FREETYPE_PARAMS --cflags 2>/dev/null`"
4449956cc18dSsnj		AC_MSG_RESULT($cf_cv_x_freetype_incs)
4450956cc18dSsnj	fi
4451d522f475Smrg
4452956cc18dSsnj	if test "$cf_cv_x_freetype_libs" = no ; then
4453956cc18dSsnj		AC_MSG_CHECKING(for $FREETYPE_CONFIG libs)
4454956cc18dSsnj		cf_cv_x_freetype_libs="$cf_extra_freetype_libs `$FREETYPE_CONFIG $FREETYPE_PARAMS --libs 2>/dev/null`"
4455956cc18dSsnj		AC_MSG_RESULT($cf_cv_x_freetype_libs)
4456956cc18dSsnj	fi
4457d522f475Smrgfi
4458d522f475Smrg
4459d522f475Smrgif test "$cf_cv_x_freetype_incs" = no ; then
4460d522f475Smrg	cf_cv_x_freetype_incs=
4461d522f475Smrgfi
4462d522f475Smrg
4463d522f475Smrgif test "$cf_cv_x_freetype_libs" = no ; then
4464d522f475Smrg	cf_cv_x_freetype_libs=-lXft
4465d522f475Smrgfi
4466d522f475Smrg
4467d522f475SmrgAC_MSG_CHECKING(if we can link with FreeType libraries)
4468d522f475Smrg
4469d522f475Smrgcf_save_LIBS="$LIBS"
4470d522f475Smrgcf_save_INCS="$CPPFLAGS"
4471d522f475Smrg
447220d2c4d2SmrgCF_ADD_LIBS($cf_cv_x_freetype_libs)
4473956cc18dSsnjCPPFLAGS="$CPPFLAGS $cf_cv_x_freetype_incs"
4474d522f475Smrg
4475d522f475SmrgAC_TRY_LINK([
4476d522f475Smrg#include <X11/Xlib.h>
4477d522f475Smrg#include <X11/extensions/Xrender.h>
4478d522f475Smrg#include <X11/Xft/Xft.h>],[
4479d522f475Smrg	XftPattern  *pat = XftNameParse ("name");],
4480d522f475Smrg	[cf_cv_found_freetype=yes],
4481d522f475Smrg	[cf_cv_found_freetype=no])
4482d522f475SmrgAC_MSG_RESULT($cf_cv_found_freetype)
4483d522f475Smrg
4484d522f475SmrgLIBS="$cf_save_LIBS"
4485d522f475SmrgCPPFLAGS="$cf_save_INCS"
4486d522f475Smrg
4487d522f475Smrgif test "$cf_cv_found_freetype" = yes ; then
448820d2c4d2Smrg	CF_ADD_LIBS($cf_cv_x_freetype_libs)
4489d522f475Smrg	CF_ADD_CFLAGS($cf_cv_x_freetype_incs)
44900bd37d32Smrg	AC_DEFINE(XRENDERFONT,1,[Define to 1 if we can/should link with FreeType libraries])
4491d522f475Smrg
4492d522f475SmrgAC_CHECK_FUNCS( \
4493d522f475Smrg	XftDrawCharSpec \
4494d522f475Smrg	XftDrawSetClip \
4495d522f475Smrg	XftDrawSetClipRectangles \
4496d522f475Smrg)
4497d522f475Smrg
4498d522f475Smrgelse
4499d522f475Smrg	AC_MSG_WARN(No libraries found for FreeType)
4500d522f475Smrg	CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
4501d522f475Smrgfi
4502d522f475Smrg
4503d522f475Smrg# FIXME: revisit this if needed
4504d522f475SmrgAC_SUBST(HAVE_TYPE_FCCHAR32)
4505d522f475SmrgAC_SUBST(HAVE_TYPE_XFTCHARSPEC)
4506d522f475Smrg])
4507d522f475Smrgdnl ---------------------------------------------------------------------------
450801037d57Smrgdnl CF_X_TOOLKIT version: 23 updated: 2015/04/12 15:39:00
4509d522f475Smrgdnl ------------
4510d522f475Smrgdnl Check for X Toolkit libraries
4511d522f475SmrgAC_DEFUN([CF_X_TOOLKIT],
4512d522f475Smrg[
4513d522f475SmrgAC_REQUIRE([AC_PATH_XTRA])
4514d522f475SmrgAC_REQUIRE([CF_CHECK_CACHE])
4515d522f475Smrg
451601037d57Smrg# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
451701037d57Smrg# in some cases has installed dummy files in the former, other cases replaced
451801037d57Smrg# it with a link to the new location).  This complicates the configure script.
451901037d57Smrg# Check for that pitfall, and recover using pkg-config
452001037d57Smrg#
452101037d57Smrg# If none of these are set, the configuration is almost certainly broken.
452201037d57Smrgif test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
452301037d57Smrgthen
452401037d57Smrg	CF_TRY_PKG_CONFIG(x11,,[AC_MSG_WARN(unable to find X11 library)])
452501037d57Smrg	CF_TRY_PKG_CONFIG(ice,,[AC_MSG_WARN(unable to find ICE library)])
452601037d57Smrg	CF_TRY_PKG_CONFIG(sm,,[AC_MSG_WARN(unable to find SM library)])
452701037d57Smrg	CF_TRY_PKG_CONFIG(xt,,[AC_MSG_WARN(unable to find Xt library)])
452801037d57Smrgfi
452901037d57Smrg
4530d522f475Smrgcf_have_X_LIBS=no
4531d522f475Smrg
453220d2c4d2SmrgCF_TRY_PKG_CONFIG(xt,[
453320d2c4d2Smrg
453401037d57Smrg	case "x$LIBS" in
453501037d57Smrg	(*-lX11*)
45366879286fSmrg		;;
453701037d57Smrg	(*)
45386879286fSmrg# we have an "xt" package, but it may omit Xt's dependency on X11
45396879286fSmrgAC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
45406879286fSmrgAC_TRY_LINK([
45416879286fSmrg#include <X11/Xlib.h>
45426879286fSmrg],[
45436879286fSmrg	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
45446879286fSmrg	int rc2 = XClearWindow((Display*) 0, (Window) 0);
45456879286fSmrg	int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
45466879286fSmrg	int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
45476879286fSmrg],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
45486879286fSmrg		if test "$cf_cv_xt_x11_compat" = no
45496879286fSmrg		then
45506879286fSmrg			CF_VERBOSE(work around broken X11 dependency)
45516879286fSmrg			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.
45526879286fSmrg			CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
45536879286fSmrg		fi
455420d2c4d2Smrg		;;
455520d2c4d2Smrg	esac
455620d2c4d2Smrg
45576879286fSmrgAC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
45586879286fSmrgAC_TRY_LINK([
45596879286fSmrg#include <X11/Shell.h>
45606879286fSmrg],[int num = IceConnectionNumber(0)
45616879286fSmrg],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
45626879286fSmrg
45636879286fSmrg	if test "$cf_cv_xt_ice_compat" = no
45646879286fSmrg	then
45656879286fSmrg		# workaround for broken ".pc" files used for X Toolkit.
456601037d57Smrg		case "x$X_PRE_LIBS" in
456701037d57Smrg		(*-lICE*)
456801037d57Smrg			case "x$LIBS" in
456901037d57Smrg			(*-lICE*)
45706879286fSmrg				;;
457101037d57Smrg			(*)
45726879286fSmrg				CF_VERBOSE(work around broken ICE dependency)
45736879286fSmrg				CF_TRY_PKG_CONFIG(ice,
45746879286fSmrg					[CF_TRY_PKG_CONFIG(sm)],
45756879286fSmrg					[CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
45766879286fSmrg				;;
45776879286fSmrg			esac
45786879286fSmrg			;;
45796879286fSmrg		esac
45806879286fSmrg	fi
45816879286fSmrg
458220d2c4d2Smrg	cf_have_X_LIBS=yes
458320d2c4d2Smrg],[
458420d2c4d2Smrg
458520d2c4d2Smrg	LDFLAGS="$X_LIBS $LDFLAGS"
458620d2c4d2Smrg	CF_CHECK_CFLAGS($X_CFLAGS)
4587d522f475Smrg
458820d2c4d2Smrg	AC_CHECK_FUNC(XOpenDisplay,,[
458920d2c4d2Smrg	AC_CHECK_LIB(X11,XOpenDisplay,
459020d2c4d2Smrg		[CF_ADD_LIB(X11)],,
459120d2c4d2Smrg		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
4592d522f475Smrg
459320d2c4d2Smrg	AC_CHECK_FUNC(XtAppInitialize,,[
459420d2c4d2Smrg	AC_CHECK_LIB(Xt, XtAppInitialize,
45950bd37d32Smrg		[AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
459620d2c4d2Smrg		 cf_have_X_LIBS=Xt
459720d2c4d2Smrg		 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
459820d2c4d2Smrg		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
459920d2c4d2Smrg])
4600d522f475Smrg
4601d522f475Smrgif test $cf_have_X_LIBS = no ; then
4602d522f475Smrg	AC_MSG_WARN(
4603d522f475Smrg[Unable to successfully link X Toolkit library (-lXt) with
4604d522f475Smrgtest program.  You will have to check and add the proper libraries by hand
4605d522f475Smrgto makefile.])
4606d522f475Smrgfi
4607d522f475Smrg])dnl
46080bd37d32Smrgdnl ---------------------------------------------------------------------------
46090bd37d32Smrgdnl CF__GRANTPT_BODY version: 4 updated: 2012/05/07 19:39:45
46100bd37d32Smrgdnl ----------------
46110bd37d32Smrgdnl Body for workability check of grantpt.
46120bd37d32Smrgdefine([CF__GRANTPT_BODY],[
46130bd37d32Smrg	int code = 0;
46140bd37d32Smrg	int rc;
46150bd37d32Smrg	int pty;
46160bd37d32Smrg	int tty;
46170bd37d32Smrg	char *slave;
46180bd37d32Smrg	struct termios tio;
46190bd37d32Smrg
46200bd37d32Smrg	signal(SIGALRM, my_timeout);
46210bd37d32Smrg
46220bd37d32Smrg	if (alarm(2) == 9)
46230bd37d32Smrg		failed(9);
46240bd37d32Smrg	else if ((pty = posix_openpt(O_RDWR)) < 0)
46250bd37d32Smrg		failed(1);
46260bd37d32Smrg	else if ((rc = grantpt(pty)) < 0)
46270bd37d32Smrg		failed(2);
46280bd37d32Smrg	else if ((rc = unlockpt(pty)) < 0)
46290bd37d32Smrg		failed(3);
46300bd37d32Smrg	else if ((slave = ptsname(pty)) == 0)
46310bd37d32Smrg		failed(4);
46320bd37d32Smrg#if (CONFTEST == 3) || defined(CONFTEST_isatty)
46330bd37d32Smrg	else if (!isatty(pty))
46340bd37d32Smrg		failed(4);
46350bd37d32Smrg#endif
46360bd37d32Smrg#if CONFTEST >= 4
46370bd37d32Smrg    else if ((rc = tcgetattr(pty, &tio)) < 0)
46380bd37d32Smrg		failed(20);
46390bd37d32Smrg    else if ((rc = tcsetattr(pty, TCSAFLUSH, &tio)) < 0)
46400bd37d32Smrg		failed(21);
46410bd37d32Smrg#endif
46420bd37d32Smrg	/* BSD posix_openpt does not treat pty as a terminal until slave is opened.
46430bd37d32Smrg	 * Linux does treat it that way.
46440bd37d32Smrg	 */
46450bd37d32Smrg	else if ((tty = open(slave, O_RDWR)) < 0)
46460bd37d32Smrg		failed(5);
46470bd37d32Smrg#ifdef CONFTEST
46480bd37d32Smrg#ifdef I_PUSH
46490bd37d32Smrg#if (CONFTEST == 0) || defined(CONFTEST_ptem)
46500bd37d32Smrg    else if ((rc = ioctl(tty, I_PUSH, "ptem")) < 0)
46510bd37d32Smrg		failed(10);
46520bd37d32Smrg#endif
46530bd37d32Smrg#if (CONFTEST == 1) || defined(CONFTEST_ldterm)
46540bd37d32Smrg    else if ((rc = ioctl(tty, I_PUSH, "ldterm")) < 0)
46550bd37d32Smrg		failed(11);
46560bd37d32Smrg#endif
46570bd37d32Smrg#if (CONFTEST == 2) || defined(CONFTEST_ttcompat)
46580bd37d32Smrg    else if ((rc = ioctl(tty, I_PUSH, "ttcompat")) < 0)
46590bd37d32Smrg		failed(12);
46600bd37d32Smrg#endif
46610bd37d32Smrg#endif /* I_PUSH */
46620bd37d32Smrg#if CONFTEST >= 5
46630bd37d32Smrg    else if ((rc = tcgetattr(tty, &tio)) < 0)
46640bd37d32Smrg		failed(30);
46650bd37d32Smrg    else if ((rc = tcsetattr(tty, TCSAFLUSH, &tio)) < 0)
46660bd37d32Smrg		failed(31);
46670bd37d32Smrg#endif
46680bd37d32Smrg#endif /* CONFTEST */
46690bd37d32Smrg
46700bd37d32Smrg	${cf_cv_main_return:-return}(code);
46710bd37d32Smrg])
46720bd37d32Smrgdnl ---------------------------------------------------------------------------
46730bd37d32Smrgdnl CF__GRANTPT_HEAD version: 3 updated: 2012/01/29 17:13:14
46740bd37d32Smrgdnl ----------------
46750bd37d32Smrgdnl Headers for workability check of grantpt.
46760bd37d32Smrgdefine([CF__GRANTPT_HEAD],[
46770bd37d32Smrg#include <stdlib.h>
46780bd37d32Smrg#include <termios.h>
46790bd37d32Smrg#include <unistd.h>
46800bd37d32Smrg#include <signal.h>
46810bd37d32Smrg#include <fcntl.h>
46820bd37d32Smrg#include <errno.h>
46830bd37d32Smrg
46840bd37d32Smrg#ifndef HAVE_POSIX_OPENPT
46850bd37d32Smrg#undef posix_openpt
46860bd37d32Smrg#define posix_openpt(mode) open("/dev/ptmx", mode)
46870bd37d32Smrg#endif
46880bd37d32Smrg
46890bd37d32Smrg#ifdef HAVE_STROPTS_H
46900bd37d32Smrg#include <stropts.h>
46910bd37d32Smrg#endif
46920bd37d32Smrg
46930bd37d32Smrgstatic void failed(int code)
46940bd37d32Smrg{
46950bd37d32Smrg	perror("conftest");
46960bd37d32Smrg	exit(code);
46970bd37d32Smrg}
46980bd37d32Smrg
46990bd37d32Smrgstatic void my_timeout(int sig)
47000bd37d32Smrg{
47010bd37d32Smrg	exit(99);
47020bd37d32Smrg}
47030bd37d32Smrg])
4704