aclocal.m4 revision 913cc679
1913cc679Smrgdnl $XTermId: aclocal.m4,v 1.413 2017/05/02 23:45:28 tom Exp $
2d522f475Smrgdnl
3d522f475Smrgdnl ---------------------------------------------------------------------------
4d522f475Smrgdnl
5913cc679Smrgdnl Copyright 1997-2016,2017 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 ---------------------------------------------------------------------------
87913cc679Smrgdnl CF_ADD_CFLAGS version: 13 updated: 2017/02/25 18:57:40
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
117913cc679Smrg				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
118d522f475Smrg				continue
119d522f475Smrg			elif test "${cf_tst_cflags}" = "\"'" ; then
120913cc679Smrg				CF_APPEND_TEXT(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
135913cc679Smrg			CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
136d522f475Smrg			;;
137d522f475Smrg		esac
138d522f475Smrg		;;
13901037d57Smrg	(*)
140913cc679Smrg		CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
141d522f475Smrg		;;
142d522f475Smrg	esac
143d522f475Smrg	;;
14401037d57Smrg(yes)
145913cc679Smrg	CF_APPEND_TEXT(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)])
158913cc679Smrg	CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
159d522f475Smrgfi
160d522f475Smrg
161d522f475Smrgif test -n "$cf_new_cppflags" ; then
16220d2c4d2Smrg	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
163913cc679Smrg	CF_APPEND_TEXT(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)])
168913cc679Smrg	CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_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 ---------------------------------------------------------------------------
222913cc679Smrgdnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
223913cc679Smrgdnl --------------
224913cc679Smrgdnl use this macro for appending text without introducing an extra blank at
225913cc679Smrgdnl the beginning
226913cc679Smrgdefine([CF_APPEND_TEXT],
227913cc679Smrg[
228913cc679Smrg	test -n "[$]$1" && $1="[$]$1 "
229913cc679Smrg	$1="[$]{$1}$2"
230913cc679Smrg])dnl
231913cc679Smrgdnl ---------------------------------------------------------------------------
232d522f475Smrgdnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
233d522f475Smrgdnl --------------
234d522f475Smrgdnl Allow user to disable a normally-on option.
235d522f475SmrgAC_DEFUN([CF_ARG_DISABLE],
236d522f475Smrg[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
237d522f475Smrgdnl ---------------------------------------------------------------------------
238d522f475Smrgdnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
239d522f475Smrgdnl -------------
240d522f475Smrgdnl Allow user to enable a normally-off option.
241d522f475SmrgAC_DEFUN([CF_ARG_ENABLE],
242d522f475Smrg[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
243d522f475Smrgdnl ---------------------------------------------------------------------------
2442e4f8982Smrgdnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
245d522f475Smrgdnl -------------
246d522f475Smrgdnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
247d522f475Smrgdnl values.
248d522f475Smrgdnl
249d522f475Smrgdnl Parameters:
250d522f475Smrgdnl $1 = option name
251d522f475Smrgdnl $2 = help-string
252d522f475Smrgdnl $3 = action to perform if option is not default
253d522f475Smrgdnl $4 = action if perform if option is default
254d522f475Smrgdnl $5 = default option value (either 'yes' or 'no')
255d522f475SmrgAC_DEFUN([CF_ARG_OPTION],
25620d2c4d2Smrg[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
2572e4f8982Smrg	if test "$enableval" != "$5" ; then
25820d2c4d2Smrgifelse([$3],,[    :]dnl
25920d2c4d2Smrg,[    $3]) ifelse([$4],,,[
2602e4f8982Smrg	else
2612e4f8982Smrg		$4])
2622e4f8982Smrg	fi],[enableval=$5 ifelse([$4],,,[
2632e4f8982Smrg	$4
264d522f475Smrg])dnl
2652e4f8982Smrg])])dnl
266d522f475Smrgdnl ---------------------------------------------------------------------------
267913cc679Smrgdnl CF_CC_ENV_FLAGS version: 7 updated: 2017/02/25 18:57:40
2680bd37d32Smrgdnl ---------------
2690bd37d32Smrgdnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
270913cc679Smrgdnl into CC.  This will not help with broken scripts that wrap the compiler
271913cc679Smrgdnl with options, but eliminates a more common category of user confusion.
272913cc679Smrgdnl
273913cc679Smrgdnl In particular, it addresses the problem of being able to run the C
274913cc679Smrgdnl preprocessor in a consistent manner.
2752e4f8982Smrgdnl
2762e4f8982Smrgdnl Caveat: this also disallows blanks in the pathname for the compiler, but
2772e4f8982Smrgdnl the nuisance of having inconsistent settings for compiler and preprocessor
2782e4f8982Smrgdnl outweighs that limitation.
2790bd37d32SmrgAC_DEFUN([CF_CC_ENV_FLAGS],
2800bd37d32Smrg[
2810bd37d32Smrg# This should have been defined by AC_PROG_CC
2820bd37d32Smrg: ${CC:=cc}
2830bd37d32Smrg
2840bd37d32SmrgAC_MSG_CHECKING(\$CC variable)
28501037d57Smrgcase "$CC" in
2862e4f8982Smrg(*[[\ \	]]-*)
2870bd37d32Smrg	AC_MSG_RESULT(broken)
2880bd37d32Smrg	AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
2890bd37d32Smrg	# humor him...
290913cc679Smrg	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
291913cc679Smrg	cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", substr([$]0,1+length(prog))); }'`
292913cc679Smrg	CC="$cf_prog"
293913cc679Smrg	for cf_arg in $cf_flags
294913cc679Smrg	do
295913cc679Smrg		case "x$cf_arg" in
296913cc679Smrg		(x-[[IUDfgOW]]*)
297913cc679Smrg			CF_ADD_CFLAGS($cf_arg)
298913cc679Smrg			;;
299913cc679Smrg		(*)
300913cc679Smrg			CC="$CC $cf_arg"
301913cc679Smrg			;;
302913cc679Smrg		esac
303913cc679Smrg	done
3042e4f8982Smrg	CF_VERBOSE(resulting CC: '$CC')
3052e4f8982Smrg	CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
3062e4f8982Smrg	CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
3070bd37d32Smrg	;;
30801037d57Smrg(*)
3090bd37d32Smrg	AC_MSG_RESULT(ok)
3100bd37d32Smrg	;;
3110bd37d32Smrgesac
3120bd37d32Smrg])dnl
3130bd37d32Smrgdnl ---------------------------------------------------------------------------
3140bd37d32Smrgdnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
315d522f475Smrgdnl --------------
316d522f475Smrgdnl Check if we're accidentally using a cache from a different machine.
317d522f475Smrgdnl Derive the system name, as a check for reusing the autoconf cache.
318d522f475Smrgdnl
319d522f475Smrgdnl If we've packaged config.guess and config.sub, run that (since it does a
320d522f475Smrgdnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
321d522f475Smrgdnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
322d522f475Smrgdnl which is useful in cross-compiles.
323d522f475Smrgdnl
324d522f475Smrgdnl Note: we would use $ac_config_sub, but that is one of the places where
325d522f475Smrgdnl autoconf 2.5x broke compatibility with autoconf 2.13
326d522f475SmrgAC_DEFUN([CF_CHECK_CACHE],
327d522f475Smrg[
328d522f475Smrgif test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
329d522f475Smrg	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
330d522f475Smrg	system_name="$host_os"
331d522f475Smrgelse
332d522f475Smrg	system_name="`(uname -s -r) 2>/dev/null`"
333d522f475Smrg	if test -z "$system_name" ; then
334d522f475Smrg		system_name="`(hostname) 2>/dev/null`"
335d522f475Smrg	fi
336d522f475Smrgfi
3370bd37d32Smrgtest -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
338d522f475SmrgAC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
339d522f475Smrg
340d522f475Smrgtest -z "$system_name" && system_name="$cf_cv_system_name"
341d522f475Smrgtest -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
342d522f475Smrg
343d522f475Smrgif test ".$system_name" != ".$cf_cv_system_name" ; then
344d522f475Smrg	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
345d522f475Smrg	AC_MSG_ERROR("Please remove config.cache and try again.")
346d522f475Smrgfi
347d522f475Smrg])dnl
348d522f475Smrgdnl ---------------------------------------------------------------------------
34901037d57Smrgdnl CF_CHECK_CFLAGS version: 3 updated: 2014/07/22 05:32:57
350d522f475Smrgdnl ---------------
351d522f475Smrgdnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
352d522f475Smrgdnl a build-configuration such as imake.  These have the pitfall that they
353d522f475Smrgdnl often contain compiler-specific options which we cannot use, mixed with
354d522f475Smrgdnl preprocessor options that we usually can.
355d522f475SmrgAC_DEFUN([CF_CHECK_CFLAGS],
356d522f475Smrg[
357d522f475SmrgCF_VERBOSE(checking additions to CFLAGS)
358d522f475Smrgcf_check_cflags="$CFLAGS"
359d522f475Smrgcf_check_cppflags="$CPPFLAGS"
360d522f475SmrgCF_ADD_CFLAGS($1,yes)
36101037d57Smrgif test "x$cf_check_cflags" != "x$CFLAGS" ; then
362d522f475SmrgAC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
363d522f475Smrg	[CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
36401037d57Smrg	 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
365d522f475Smrg		 CF_VERBOSE(but keeping change to \$CPPFLAGS)
366d522f475Smrg	 fi
367d522f475Smrg	 CFLAGS="$cf_check_flags"])
368d522f475Smrgfi
369d522f475Smrg])dnl
370d522f475Smrgdnl ---------------------------------------------------------------------------
3712e4f8982Smrgdnl CF_CHECK_ERRNO version: 12 updated: 2015/04/18 08:56:57
372d522f475Smrgdnl --------------
373d522f475Smrgdnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
374d522f475Smrgdnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
375d522f475Smrgdnl ourselves.
376d522f475Smrgdnl
377d522f475Smrgdnl $1 = the name to check
3782eaa94a1Schristosdnl $2 = the assumed type
379d522f475SmrgAC_DEFUN([CF_CHECK_ERRNO],
380d522f475Smrg[
381d522f475SmrgAC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
3822e4f8982Smrg	AC_TRY_COMPILE([
383d522f475Smrg#ifdef HAVE_STDLIB_H
384d522f475Smrg#include <stdlib.h>
385d522f475Smrg#endif
386d522f475Smrg#include <stdio.h>
387d522f475Smrg#include <sys/types.h>
388d522f475Smrg#include <errno.h> ],
3892e4f8982Smrg	ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1,
3902e4f8982Smrg	[cf_cv_dcl_$1=yes],
3912e4f8982Smrg	[cf_cv_dcl_$1=no])
392d522f475Smrg])
393d522f475Smrg
394d522f475Smrgif test "$cf_cv_dcl_$1" = no ; then
3952e4f8982Smrg	CF_UPPER(cf_result,decl_$1)
3962e4f8982Smrg	AC_DEFINE_UNQUOTED($cf_result)
397d522f475Smrgfi
398d522f475Smrg
399d522f475Smrg# It's possible (for near-UNIX clones) that the data doesn't exist
40020d2c4d2SmrgCF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
401d522f475Smrg])dnl
402d522f475Smrgdnl ---------------------------------------------------------------------------
4032e4f8982Smrgdnl CF_CHECK_EXTERN_DATA version: 4 updated: 2015/04/18 08:56:57
404d522f475Smrgdnl --------------------
405d522f475Smrgdnl Check for existence of external data in the current set of libraries.  If
406d522f475Smrgdnl we can modify it, it's real enough.
407d522f475Smrgdnl $1 = the name to check
408d522f475Smrgdnl $2 = its type
409d522f475SmrgAC_DEFUN([CF_CHECK_EXTERN_DATA],
410d522f475Smrg[
411d522f475SmrgAC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
4122e4f8982Smrg	AC_TRY_LINK([
413d522f475Smrg#undef $1
414d522f475Smrgextern $2 $1;
415d522f475Smrg],
4162e4f8982Smrg	[$1 = 2],
4172e4f8982Smrg	[cf_cv_have_$1=yes],
4182e4f8982Smrg	[cf_cv_have_$1=no])
419d522f475Smrg])
420d522f475Smrg
421d522f475Smrgif test "$cf_cv_have_$1" = yes ; then
4222e4f8982Smrg	CF_UPPER(cf_result,have_$1)
4232e4f8982Smrg	AC_DEFINE_UNQUOTED($cf_result)
424d522f475Smrgfi
425d522f475Smrg
426d522f475Smrg])dnl
427d522f475Smrgdnl ---------------------------------------------------------------------------
428e0a2b6dfSmrgdnl CF_CLANG_COMPILER version: 2 updated: 2013/11/19 19:23:35
4290bd37d32Smrgdnl -----------------
4300bd37d32Smrgdnl Check if the given compiler is really clang.  clang's C driver defines
4310bd37d32Smrgdnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
4320bd37d32Smrgdnl not ignore some gcc options.
4330bd37d32Smrgdnl
4340bd37d32Smrgdnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
4350bd37d32Smrgdnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
4360bd37d32Smrgdnl the wrappers for gcc and g++ warnings.
4370bd37d32Smrgdnl
4380bd37d32Smrgdnl $1 = GCC (default) or GXX
439e0a2b6dfSmrgdnl $2 = CLANG_COMPILER (default)
4400bd37d32Smrgdnl $3 = CFLAGS (default) or CXXFLAGS
4410bd37d32SmrgAC_DEFUN([CF_CLANG_COMPILER],[
4420bd37d32Smrgifelse([$2],,CLANG_COMPILER,[$2])=no
4430bd37d32Smrg
4440bd37d32Smrgif test "$ifelse([$1],,[$1],GCC)" = yes ; then
4450bd37d32Smrg	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
4460bd37d32Smrg	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
4470bd37d32Smrg	ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
4480bd37d32Smrg	AC_TRY_COMPILE([],[
4490bd37d32Smrg#ifdef __clang__
4500bd37d32Smrg#else
4510bd37d32Smrgmake an error
4520bd37d32Smrg#endif
4530bd37d32Smrg],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
4540bd37d32Smrgcf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
4550bd37d32Smrg],[])
4560bd37d32Smrg	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
4570bd37d32Smrg	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
4580bd37d32Smrgfi
4590bd37d32Smrg])
4600bd37d32Smrgdnl ---------------------------------------------------------------------------
461e39b573cSmrgdnl CF_DISABLE_DESKTOP version: 2 updated: 2011/04/22 05:17:37
462e39b573cSmrgdnl ------------------
463e39b573cSmrgdnl Handle a configure option "--disable-desktop", which sets a shell
464e39b573cSmrgdnl variable $desktop_utils to a "#" if the feature is not wanted, or to an
465e39b573cSmrgdnl empty string if enabled.  The variable is used to substitute in front of
466e39b573cSmrgdnl corresponding makefile-rules.
467e39b573cSmrgdnl
468e39b573cSmrgdnl It also tells the configure script to substitute the environment variable
469e39b573cSmrgdnl $DESKTOP_FLAGS, which can be used by external scripts to customize the
470e39b573cSmrgdnl invocation of desktop-file-util.
471e39b573cSmrgdnl
472e39b573cSmrgdnl $1 = program name
473e39b573cSmrgAC_DEFUN([CF_DISABLE_DESKTOP],[
474e39b573cSmrg# Comment-out the install-desktop rule if the desktop-utils are not found.
475e39b573cSmrgAC_MSG_CHECKING(if you want to install desktop files)
476e39b573cSmrgCF_ARG_OPTION(desktop,
477e39b573cSmrg	[  --disable-desktop       disable install of $1 desktop files],
478e39b573cSmrg	[enable_desktop=$enableval],
479e39b573cSmrg	[enable_desktop=$enableval],yes)
480e39b573cSmrgAC_MSG_RESULT($enable_desktop)
481e39b573cSmrg
482e39b573cSmrgdesktop_utils=
483e39b573cSmrgif test "$enable_desktop" = yes ; then
484e39b573cSmrgAC_CHECK_PROG(desktop_utils,desktop-file-install,yes,no)
485e39b573cSmrgfi
486e39b573cSmrg
487e39b573cSmrgtest "$desktop_utils" = yes && desktop_utils= || desktop_utils="#"
488e39b573cSmrgAC_SUBST(DESKTOP_FLAGS)
489e39b573cSmrg])
490e39b573cSmrgdnl ---------------------------------------------------------------------------
4912e4f8982Smrgdnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
492d522f475Smrgdnl ---------------
493d522f475Smrgdnl You can always use "make -n" to see the actual options, but it's hard to
494d522f475Smrgdnl pick out/analyze warning messages when the compile-line is long.
495d522f475Smrgdnl
496d522f475Smrgdnl Sets:
497d522f475Smrgdnl	ECHO_LT - symbol to control if libtool is verbose
498d522f475Smrgdnl	ECHO_LD - symbol to prefix "cc -o" lines
499d522f475Smrgdnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
500d522f475Smrgdnl	SHOW_CC - symbol to put before explicit "cc -c" lines
501d522f475Smrgdnl	ECHO_CC - symbol to put before any "cc" line
502d522f475Smrgdnl
503d522f475SmrgAC_DEFUN([CF_DISABLE_ECHO],[
504d522f475SmrgAC_MSG_CHECKING(if you want to see long compiling messages)
505d522f475SmrgCF_ARG_DISABLE(echo,
5060bd37d32Smrg	[  --disable-echo          do not display "compiling" commands],
507d522f475Smrg	[
5082e4f8982Smrg	ECHO_LT='--silent'
5092e4f8982Smrg	ECHO_LD='@echo linking [$]@;'
5102e4f8982Smrg	RULE_CC='@echo compiling [$]<'
5112e4f8982Smrg	SHOW_CC='@echo compiling [$]@'
5122e4f8982Smrg	ECHO_CC='@'
513d522f475Smrg],[
5142e4f8982Smrg	ECHO_LT=''
5152e4f8982Smrg	ECHO_LD=''
5162e4f8982Smrg	RULE_CC=''
5172e4f8982Smrg	SHOW_CC=''
5182e4f8982Smrg	ECHO_CC=''
519d522f475Smrg])
520d522f475SmrgAC_MSG_RESULT($enableval)
521d522f475SmrgAC_SUBST(ECHO_LT)
522d522f475SmrgAC_SUBST(ECHO_LD)
523d522f475SmrgAC_SUBST(RULE_CC)
524d522f475SmrgAC_SUBST(SHOW_CC)
525d522f475SmrgAC_SUBST(ECHO_CC)
526d522f475Smrg])dnl
527d522f475Smrgdnl ---------------------------------------------------------------------------
5280bd37d32Smrgdnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
5290bd37d32Smrgdnl ----------------
5300bd37d32Smrgdnl Combine no-leak checks with the libraries or tools that are used for the
5310bd37d32Smrgdnl checks.
5320bd37d32SmrgAC_DEFUN([CF_DISABLE_LEAKS],[
5330bd37d32Smrg
5340bd37d32SmrgAC_REQUIRE([CF_WITH_DMALLOC])
5350bd37d32SmrgAC_REQUIRE([CF_WITH_DBMALLOC])
5360bd37d32SmrgAC_REQUIRE([CF_WITH_VALGRIND])
5370bd37d32Smrg
5380bd37d32SmrgAC_MSG_CHECKING(if you want to perform memory-leak testing)
5390bd37d32SmrgAC_ARG_ENABLE(leaks,
5400bd37d32Smrg	[  --disable-leaks         test: free permanent memory, analyze leaks],
5410bd37d32Smrg	[if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
5420bd37d32Smrg	: ${with_no_leaks:=no})
5430bd37d32SmrgAC_MSG_RESULT($with_no_leaks)
5440bd37d32Smrg
5450bd37d32Smrgif test "$with_no_leaks" = yes ; then
5460bd37d32Smrg	AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
5470bd37d32Smrg	AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
5480bd37d32Smrgfi
5490bd37d32Smrg])dnl
5500bd37d32Smrgdnl ---------------------------------------------------------------------------
551a1f3da82Smrgdnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
55220d2c4d2Smrgdnl ---------------------
55320d2c4d2Smrgdnl The rpath-hack makes it simpler to build programs, particularly with the
55420d2c4d2Smrgdnl *BSD ports which may have essential libraries in unusual places.  But it
55520d2c4d2Smrgdnl can interfere with building an executable for the base system.  Use this
55620d2c4d2Smrgdnl option in that case.
55720d2c4d2SmrgAC_DEFUN([CF_DISABLE_RPATH_HACK],
55820d2c4d2Smrg[
559a1f3da82SmrgAC_MSG_CHECKING(if rpath-hack should be disabled)
56020d2c4d2SmrgCF_ARG_DISABLE(rpath-hack,
56120d2c4d2Smrg	[  --disable-rpath-hack    don't add rpath options for additional libraries],
56220d2c4d2Smrg	[cf_disable_rpath_hack=yes],
56320d2c4d2Smrg	[cf_disable_rpath_hack=no])
56420d2c4d2SmrgAC_MSG_RESULT($cf_disable_rpath_hack)
56520d2c4d2Smrgif test "$cf_disable_rpath_hack" = no ; then
56620d2c4d2Smrg	CF_RPATH_HACK
56720d2c4d2Smrgfi
56820d2c4d2Smrg])
56920d2c4d2Smrgdnl ---------------------------------------------------------------------------
57001037d57Smrgdnl CF_ENABLE_NARROWPROTO version: 5 updated: 2015/04/12 15:39:00
571d522f475Smrgdnl ---------------------
572d522f475Smrgdnl If this is not set properly, Xaw's scrollbars will not work.
573d522f475Smrgdnl The so-called "modular" configuration for X.org omits most of the
574d522f475Smrgdnl configure checks that would be needed to provide compatibility with
575d522f475Smrgdnl older X builds.  This one breaks things noticeably.
576d522f475SmrgAC_DEFUN([CF_ENABLE_NARROWPROTO],
577d522f475Smrg[
578d522f475SmrgAC_MSG_CHECKING(if you want narrow prototypes for X libraries)
579d522f475Smrg
58001037d57Smrgcase `$ac_config_guess` in
58101037d57Smrg(*freebsd*|*gnu*|*irix5*|*irix6*|*linux-gnu*|*netbsd*|*openbsd*|*qnx*|*sco*|*sgi*)
582d522f475Smrg	cf_default_narrowproto=yes
583d522f475Smrg	;;
58401037d57Smrg(*)
585d522f475Smrg	cf_default_narrowproto=no
586d522f475Smrg	;;
587d522f475Smrgesac
588d522f475Smrg
589d522f475SmrgCF_ARG_OPTION(narrowproto,
590d522f475Smrg	[  --enable-narrowproto    enable narrow prototypes for X libraries],
591d522f475Smrg	[enable_narrowproto=$enableval],
592d522f475Smrg	[enable_narrowproto=$cf_default_narrowproto],
593d522f475Smrg	[$cf_default_narrowproto])
594d522f475SmrgAC_MSG_RESULT($enable_narrowproto)
595d522f475Smrg])
596d522f475Smrgdnl ---------------------------------------------------------------------------
597d522f475Smrgdnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
598d522f475Smrgdnl --------
599d522f475Smrgdnl Check if 'errno' is declared in <errno.h>
600d522f475SmrgAC_DEFUN([CF_ERRNO],
601d522f475Smrg[
602d522f475SmrgCF_CHECK_ERRNO(errno)
603d522f475Smrg])dnl
604d522f475Smrgdnl ---------------------------------------------------------------------------
60501037d57Smrgdnl CF_FUNC_GRANTPT version: 11 updated: 2015/04/12 15:39:00
606d522f475Smrgdnl ---------------
6070bd37d32Smrgdnl Check for grantpt versus openpty, as well as functions that "should" be
6080bd37d32Smrgdnl available if grantpt is available.
6090bd37d32SmrgAC_DEFUN([CF_FUNC_GRANTPT],[
6100bd37d32Smrg
6110bd37d32SmrgAC_CHECK_HEADERS( \
6120bd37d32Smrgstropts.h \
6130bd37d32Smrg)
6140bd37d32Smrg
6150bd37d32Smrgcf_func_grantpt="grantpt ptsname"
61601037d57Smrgcase $host_os in
61701037d57Smrg(darwin[[0-9]].*)
6180bd37d32Smrg	;;
61901037d57Smrg(*)
6200bd37d32Smrg	cf_func_grantpt="$cf_func_grantpt posix_openpt"
6210bd37d32Smrg	;;
6220bd37d32Smrgesac
6230bd37d32Smrg
6240bd37d32SmrgAC_CHECK_FUNCS($cf_func_grantpt)
6250bd37d32Smrg
6260bd37d32Smrgcf_grantpt_opts=
6270bd37d32Smrgif test "x$ac_cv_func_grantpt" = "xyes" ; then
6280bd37d32Smrg	AC_MSG_CHECKING(if grantpt really works)
6290bd37d32Smrg	AC_TRY_LINK(CF__GRANTPT_HEAD,CF__GRANTPT_BODY,[
6300bd37d32Smrg	AC_TRY_RUN(CF__GRANTPT_HEAD
6310bd37d32Smrgint main(void)
6320bd37d32Smrg{
6330bd37d32SmrgCF__GRANTPT_BODY
634d522f475Smrg}
6350bd37d32Smrg,
6360bd37d32Smrg,ac_cv_func_grantpt=no
6370bd37d32Smrg,ac_cv_func_grantpt=maybe)
6380bd37d32Smrg	],ac_cv_func_grantpt=no)
6390bd37d32Smrg	AC_MSG_RESULT($ac_cv_func_grantpt)
6400bd37d32Smrg
6410bd37d32Smrg	if test "x$ac_cv_func_grantpt" != "xno" ; then
6420bd37d32Smrg
6430bd37d32Smrg		if test "x$ac_cv_func_grantpt" = "xyes" ; then
6440bd37d32Smrg			AC_MSG_CHECKING(for pty features)
6450bd37d32Smrgdnl if we have no stropts.h, skip the checks for streams modules
6460bd37d32Smrg			if test "x$ac_cv_header_stropts_h" = xyes
6470bd37d32Smrg			then
6480bd37d32Smrg				cf_pty_this=0
6490bd37d32Smrg			else
6500bd37d32Smrg				cf_pty_this=3
6510bd37d32Smrg			fi
6520bd37d32Smrg
6530bd37d32Smrg			cf_pty_defines=
6540bd37d32Smrg			while test $cf_pty_this != 6
6550bd37d32Smrg			do
6560bd37d32Smrg
6570bd37d32Smrg				cf_pty_feature=
6580bd37d32Smrg				cf_pty_next=`expr $cf_pty_this + 1`
6590bd37d32Smrg				CF_MSG_LOG(pty feature test $cf_pty_next:5)
6600bd37d32Smrg				AC_TRY_RUN(#define CONFTEST $cf_pty_this
6610bd37d32Smrg$cf_pty_defines
6620bd37d32SmrgCF__GRANTPT_HEAD
6630bd37d32Smrgint main(void)
6640bd37d32Smrg{
6650bd37d32SmrgCF__GRANTPT_BODY
6660bd37d32Smrg}
6670bd37d32Smrg,
6680bd37d32Smrg[
66901037d57Smrg				case $cf_pty_next in
67001037d57Smrg				(1) # - streams
6710bd37d32Smrg					cf_pty_feature=ptem
6720bd37d32Smrg					;;
67301037d57Smrg				(2) # - streams
6740bd37d32Smrg					cf_pty_feature=ldterm
6750bd37d32Smrg					;;
67601037d57Smrg				(3) # - streams
6770bd37d32Smrg					cf_pty_feature=ttcompat
6780bd37d32Smrg					;;
67901037d57Smrg				(4)
6800bd37d32Smrg					cf_pty_feature=pty_isatty
6810bd37d32Smrg					;;
68201037d57Smrg				(5)
6830bd37d32Smrg					cf_pty_feature=pty_tcsetattr
6840bd37d32Smrg					;;
68501037d57Smrg				(6)
6860bd37d32Smrg					cf_pty_feature=tty_tcsetattr
6870bd37d32Smrg					;;
6880bd37d32Smrg				esac
6890bd37d32Smrg],[
69001037d57Smrg				case $cf_pty_next in
69101037d57Smrg				(1|2|3)
6920bd37d32Smrg					CF_MSG_LOG(skipping remaining streams features $cf_pty_this..2)
6930bd37d32Smrg					cf_pty_next=3
6940bd37d32Smrg					;;
6950bd37d32Smrg				esac
6960bd37d32Smrg])
6970bd37d32Smrg				if test -n "$cf_pty_feature"
6980bd37d32Smrg				then
6990bd37d32Smrg					cf_pty_defines="$cf_pty_defines
7000bd37d32Smrg#define CONFTEST_$cf_pty_feature 1
7010bd37d32Smrg"
7020bd37d32Smrg					cf_grantpt_opts="$cf_grantpt_opts $cf_pty_feature"
7030bd37d32Smrg				fi
7040bd37d32Smrg
7050bd37d32Smrg				cf_pty_this=$cf_pty_next
7060bd37d32Smrg			done
7070bd37d32Smrg			AC_MSG_RESULT($cf_grantpt_opts)
7080bd37d32Smrg			cf_grantpt_opts=`echo "$cf_grantpt_opts" | sed -e 's/ isatty//'`
7090bd37d32Smrg		fi
710d522f475Smrg	fi
7110bd37d32Smrgfi
7120bd37d32Smrg
7130bd37d32Smrgdnl If we found grantpt, but no features, e.g., for streams or if we are not
7140bd37d32Smrgdnl able to use tcsetattr, then give openpty a try.  In particular, Darwin 10.7
7150bd37d32Smrgdnl has a more functional openpty than posix_openpt.
7160bd37d32Smrgdnl
7170bd37d32Smrgdnl There is no configure run-test for openpty, since older implementations do
7180bd37d32Smrgdnl not always run properly as a non-root user.  For that reason, we also allow
7190bd37d32Smrgdnl the configure script to suppress this check entirely with $disable_openpty.
7200bd37d32Smrgif test "x$disable_openpty" != "xyes" || test -z "$cf_grantpt_opts" ; then
7210bd37d32Smrg	AC_CHECK_LIB(util, openpty, [cf_have_openpty=yes],[cf_have_openpty=no])
7220bd37d32Smrg	if test "$cf_have_openpty" = yes ; then
7230bd37d32Smrg		ac_cv_func_grantpt=no
7240bd37d32Smrg		LIBS="-lutil $LIBS"
7250bd37d32Smrg		AC_DEFINE(HAVE_OPENPTY,1,[Define to 1 if you have the openpty function])
7260bd37d32Smrg		AC_CHECK_HEADERS( \
7270bd37d32Smrg			util.h \
7280bd37d32Smrg			libutil.h \
7290bd37d32Smrg			pty.h \
7300bd37d32Smrg		)
7310bd37d32Smrg	fi
7320bd37d32Smrgfi
7330bd37d32Smrg
7340bd37d32Smrgdnl If we did not settle on using openpty, fill in the definitions for grantpt.
7350bd37d32Smrgif test "x$ac_cv_func_grantpt" != xno
7360bd37d32Smrgthen
7370bd37d32Smrg	CF_VERBOSE(will rely upon grantpt)
7380bd37d32Smrg	AC_DEFINE(HAVE_WORKING_GRANTPT,1,[Define to 1 if the grantpt function seems to work])
7390bd37d32Smrg	for cf_feature in $cf_grantpt_opts
7400bd37d32Smrg	do
7410bd37d32Smrg		cf_feature=`echo "$cf_feature" | sed -e 's/ //g'`
7420bd37d32Smrg		CF_UPPER(cf_FEATURE,$cf_feature)
7430bd37d32Smrg		AC_DEFINE_UNQUOTED(HAVE_GRANTPT_$cf_FEATURE)
7440bd37d32Smrg	done
7450bd37d32Smrgelif test "x$cf_have_openpty" = xno
7460bd37d32Smrgthen
7470bd37d32Smrg	CF_VERBOSE(will rely upon BSD-pseudoterminals)
7480bd37d32Smrgelse
7490bd37d32Smrg	CF_VERBOSE(will rely upon openpty)
7500bd37d32Smrgfi
7510bd37d32Smrg])dnl
752d522f475Smrgdnl ---------------------------------------------------------------------------
7532e4f8982Smrgdnl CF_FUNC_TGETENT version: 21 updated: 2015/09/12 14:59:46
754d522f475Smrgdnl ---------------
755d522f475Smrgdnl Check for tgetent function in termcap library.  If we cannot find this,
756d522f475Smrgdnl we'll use the $LINES and $COLUMNS environment variables to pass screen
757d522f475Smrgdnl size information to subprocesses.  (We cannot use terminfo's compatibility
758d522f475Smrgdnl function, since it cannot provide the termcap-format data).
759d522f475Smrgdnl
760d522f475Smrgdnl If the --disable-full-tgetent option is given, we'll settle for the first
761d522f475Smrgdnl tgetent function we find.  Since the search list in that case does not
762d522f475Smrgdnl include the termcap library, that allows us to default to terminfo.
763d522f475SmrgAC_DEFUN([CF_FUNC_TGETENT],
764d522f475Smrg[
765d522f475Smrg# compute a reasonable value for $TERM to give tgetent(), since we may be
766d522f475Smrg# running in 'screen', which sets $TERMCAP to a specific entry that is not
767d522f475Smrg# necessarily in /etc/termcap - unsetenv is not portable, so we cannot simply
768d522f475Smrg# discard $TERMCAP.
769d522f475Smrgcf_TERMVAR=vt100
770e39b573cSmrgif test -n "$TERMCAP"
771e39b573cSmrgthen
772e39b573cSmrg	cf_TERMCAP=`echo "$TERMCAP" | tr '\n' ' ' | sed -e 's/^..|//' -e 's/|.*//'`
77301037d57Smrg	case "$cf_TERMCAP" in
77401037d57Smrg	(screen*.*)
775e39b573cSmrg		;;
77601037d57Smrg	(*)
777e39b573cSmrg		cf_TERMVAR="$cf_TERMCAP"
778e39b573cSmrg		;;
779e39b573cSmrg	esac
780e39b573cSmrgfi
781d522f475Smrgtest -z "$cf_TERMVAR" && cf_TERMVAR=vt100
782d522f475Smrg
783d522f475SmrgAC_MSG_CHECKING(if we want full tgetent function)
784d522f475SmrgCF_ARG_DISABLE(full-tgetent,
785d522f475Smrg	[  --disable-full-tgetent  disable check for full tgetent function],
786d522f475Smrg	cf_full_tgetent=no,
787d522f475Smrg	cf_full_tgetent=yes,yes)
788d522f475SmrgAC_MSG_RESULT($cf_full_tgetent)
789d522f475Smrg
790d522f475Smrgif test "$cf_full_tgetent" = yes ; then
791d522f475Smrg	cf_test_message="full tgetent"
792d522f475Smrgelse
793d522f475Smrg	cf_test_message="tgetent"
794d522f475Smrgfi
795d522f475Smrg
796d522f475SmrgAC_CACHE_CHECK(for $cf_test_message function,cf_cv_lib_tgetent,[
797d522f475Smrgcf_save_LIBS="$LIBS"
798d522f475Smrgcf_cv_lib_tgetent=no
799d522f475Smrgif test "$cf_full_tgetent" = yes ; then
8000bd37d32Smrg	cf_TERMLIB="otermcap termcap termlib ncurses curses"
801d522f475Smrg	cf_TERMTST="buffer[[0]] == 0"
802d522f475Smrgelse
803d522f475Smrg	cf_TERMLIB="termlib ncurses curses"
804d522f475Smrg	cf_TERMTST="0"
805d522f475Smrgfi
806d522f475Smrgfor cf_termlib in '' $cf_TERMLIB ; do
807d522f475Smrg	LIBS="$cf_save_LIBS"
8082e4f8982Smrg	test -n "$cf_termlib" && { CF_ADD_LIB($cf_termlib) }
809d522f475Smrg	AC_TRY_RUN([
810d522f475Smrg/* terminfo implementations ignore the buffer argument, making it useless for
811d522f475Smrg * the xterm application, which uses this information to make a new TERMCAP
812d522f475Smrg * environment variable.
813d522f475Smrg */
814d522f475Smrgint main()
815d522f475Smrg{
816d522f475Smrg	char buffer[1024];
817d522f475Smrg	buffer[0] = 0;
818d522f475Smrg	tgetent(buffer, "$cf_TERMVAR");
819d522f475Smrg	${cf_cv_main_return:-return} ($cf_TERMTST); }],
820d522f475Smrg	[echo "yes, there is a termcap/tgetent in $cf_termlib" 1>&AC_FD_CC
821d522f475Smrg	 if test -n "$cf_termlib" ; then
822d522f475Smrg	 	cf_cv_lib_tgetent="-l$cf_termlib"
823d522f475Smrg	 else
824d522f475Smrg	 	cf_cv_lib_tgetent=yes
825d522f475Smrg	 fi
826d522f475Smrg	 break],
827d522f475Smrg	[echo "no, there is no termcap/tgetent in $cf_termlib" 1>&AC_FD_CC],
828d522f475Smrg	[echo "cross-compiling, cannot verify if a termcap/tgetent is present in $cf_termlib" 1>&AC_FD_CC])
829d522f475Smrgdone
830d522f475SmrgLIBS="$cf_save_LIBS"
831d522f475Smrg])
832d522f475Smrg
833d522f475Smrg# If we found a working tgetent(), set LIBS and check for termcap.h.
834d522f475Smrg# (LIBS cannot be set inside AC_CACHE_CHECK; the commands there should
835d522f475Smrg# not have side effects other than setting the cache variable, because
836d522f475Smrg# they are not executed when a cached value exists.)
837e39b573cSmrgif test "x$cf_cv_lib_tgetent" != xno ; then
8382e4f8982Smrg	test "x$cf_cv_lib_tgetent" != xyes && { CF_ADD_LIBS($cf_cv_lib_tgetent) }
8390bd37d32Smrg	AC_DEFINE(USE_TERMCAP,1,[Define 1 to indicate that working tgetent is found])
84020d2c4d2Smrg	if test "$cf_full_tgetent" = no ; then
84120d2c4d2Smrg		AC_TRY_COMPILE([
842d522f475Smrg#include <termcap.h>],[
843d522f475Smrg#ifdef NCURSES_VERSION
844d522f475Smrgmake an error
845d522f475Smrg#endif],[AC_DEFINE(HAVE_TERMCAP_H)])
84620d2c4d2Smrg	else
84720d2c4d2Smrg		AC_CHECK_HEADERS(termcap.h)
84820d2c4d2Smrg	fi
849d522f475Smrgelse
850d522f475Smrg        # If we didn't find a tgetent() that supports the buffer
851d522f475Smrg        # argument, look again to see whether we can find even
852d522f475Smrg        # a crippled one.  A crippled tgetent() is still useful to
853d522f475Smrg        # validate values for the TERM environment variable given to
854d522f475Smrg        # child processes.
855d522f475Smrg	AC_CACHE_CHECK(for partial tgetent function,cf_cv_lib_part_tgetent,[
856d522f475Smrg	cf_cv_lib_part_tgetent=no
857d522f475Smrg	for cf_termlib in $cf_TERMLIB ; do
858d522f475Smrg		LIBS="$cf_save_LIBS -l$cf_termlib"
859d522f475Smrg		AC_TRY_LINK([],[tgetent(0, "$cf_TERMVAR")],
860d522f475Smrg			[echo "there is a terminfo/tgetent in $cf_termlib" 1>&AC_FD_CC
861d522f475Smrg			 cf_cv_lib_part_tgetent="-l$cf_termlib"
862d522f475Smrg			 break])
863d522f475Smrg	done
864d522f475Smrg	LIBS="$cf_save_LIBS"
865d522f475Smrg	])
866d522f475Smrg
867d522f475Smrg	if test "$cf_cv_lib_part_tgetent" != no ; then
86820d2c4d2Smrg		CF_ADD_LIBS($cf_cv_lib_part_tgetent)
869d522f475Smrg		AC_CHECK_HEADERS(termcap.h)
870d522f475Smrg
871d522f475Smrg                # If this is linking against ncurses, we'll trigger the
872d522f475Smrg                # ifdef in resize.c that turns the termcap stuff back off.
8730bd37d32Smrg		AC_DEFINE(USE_TERMINFO,1,[Define to 1 to indicate that terminfo provides the tgetent interface])
874d522f475Smrg	fi
875d522f475Smrgfi
876d522f475Smrg])dnl
877d522f475Smrgdnl ---------------------------------------------------------------------------
87801037d57Smrgdnl CF_GCC_ATTRIBUTES version: 17 updated: 2015/04/12 15:39:00
879d522f475Smrgdnl -----------------
880d522f475Smrgdnl Test for availability of useful gcc __attribute__ directives to quiet
881d522f475Smrgdnl compiler warnings.  Though useful, not all are supported -- and contrary
882d522f475Smrgdnl to documentation, unrecognized directives cause older compilers to barf.
883d522f475SmrgAC_DEFUN([CF_GCC_ATTRIBUTES],
884d522f475Smrg[
885d522f475Smrgif test "$GCC" = yes
886d522f475Smrgthen
887d522f475Smrgcat > conftest.i <<EOF
888d522f475Smrg#ifndef GCC_PRINTF
889d522f475Smrg#define GCC_PRINTF 0
890d522f475Smrg#endif
891d522f475Smrg#ifndef GCC_SCANF
892d522f475Smrg#define GCC_SCANF 0
893d522f475Smrg#endif
894d522f475Smrg#ifndef GCC_NORETURN
895d522f475Smrg#define GCC_NORETURN /* nothing */
896d522f475Smrg#endif
897d522f475Smrg#ifndef GCC_UNUSED
898d522f475Smrg#define GCC_UNUSED /* nothing */
899d522f475Smrg#endif
900d522f475SmrgEOF
901d522f475Smrgif test "$GCC" = yes
902d522f475Smrgthen
903d522f475Smrg	AC_CHECKING([for $CC __attribute__ directives])
904d522f475Smrgcat > conftest.$ac_ext <<EOF
9056879286fSmrg#line __oline__ "${as_me:-configure}"
906d522f475Smrg#include "confdefs.h"
907d522f475Smrg#include "conftest.h"
908d522f475Smrg#include "conftest.i"
909d522f475Smrg#if	GCC_PRINTF
910d522f475Smrg#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
911d522f475Smrg#else
912d522f475Smrg#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
913d522f475Smrg#endif
914d522f475Smrg#if	GCC_SCANF
915d522f475Smrg#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
916d522f475Smrg#else
917d522f475Smrg#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
918d522f475Smrg#endif
919d522f475Smrgextern void wow(char *,...) GCC_SCANFLIKE(1,2);
920d522f475Smrgextern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
921d522f475Smrgextern void foo(void) GCC_NORETURN;
922d522f475Smrgint main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
923d522f475SmrgEOF
92420d2c4d2Smrg	cf_printf_attribute=no
92520d2c4d2Smrg	cf_scanf_attribute=no
926d522f475Smrg	for cf_attribute in scanf printf unused noreturn
927d522f475Smrg	do
928d522f475Smrg		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
929d522f475Smrg		cf_directive="__attribute__(($cf_attribute))"
930d522f475Smrg		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
93120d2c4d2Smrg
93201037d57Smrg		case $cf_attribute in
93301037d57Smrg		(printf)
93420d2c4d2Smrg			cf_printf_attribute=yes
93520d2c4d2Smrg			cat >conftest.h <<EOF
936d522f475Smrg#define GCC_$cf_ATTRIBUTE 1
937d522f475SmrgEOF
938d522f475Smrg			;;
93901037d57Smrg		(scanf)
94020d2c4d2Smrg			cf_scanf_attribute=yes
94120d2c4d2Smrg			cat >conftest.h <<EOF
94220d2c4d2Smrg#define GCC_$cf_ATTRIBUTE 1
94320d2c4d2SmrgEOF
94420d2c4d2Smrg			;;
94501037d57Smrg		(*)
94620d2c4d2Smrg			cat >conftest.h <<EOF
947d522f475Smrg#define GCC_$cf_ATTRIBUTE $cf_directive
948d522f475SmrgEOF
949d522f475Smrg			;;
950d522f475Smrg		esac
95120d2c4d2Smrg
952d522f475Smrg		if AC_TRY_EVAL(ac_compile); then
953d522f475Smrg			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
954d522f475Smrg			cat conftest.h >>confdefs.h
95501037d57Smrg			case $cf_attribute in
95601037d57Smrg			(noreturn)
9570bd37d32Smrg				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
9580bd37d32Smrg				;;
95901037d57Smrg			(printf)
9600bd37d32Smrg				cf_value='/* nothing */'
9610bd37d32Smrg				if test "$cf_printf_attribute" != no ; then
9620bd37d32Smrg					cf_value='__attribute__((format(printf,fmt,var)))'
9630bd37d32Smrg					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
96420d2c4d2Smrg				fi
9650bd37d32Smrg				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
96620d2c4d2Smrg				;;
96701037d57Smrg			(scanf)
9680bd37d32Smrg				cf_value='/* nothing */'
9690bd37d32Smrg				if test "$cf_scanf_attribute" != no ; then
9700bd37d32Smrg					cf_value='__attribute__((format(scanf,fmt,var)))'
9710bd37d32Smrg					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
97220d2c4d2Smrg				fi
9730bd37d32Smrg				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
9740bd37d32Smrg				;;
97501037d57Smrg			(unused)
9760bd37d32Smrg				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
97720d2c4d2Smrg				;;
97820d2c4d2Smrg			esac
979d522f475Smrg		fi
980d522f475Smrg	done
981d522f475Smrgelse
982d522f475Smrg	fgrep define conftest.i >>confdefs.h
983d522f475Smrgfi
984d522f475Smrgrm -rf conftest*
985d522f475Smrgfi
986d522f475Smrg])dnl
987d522f475Smrgdnl ---------------------------------------------------------------------------
9880bd37d32Smrgdnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
989d522f475Smrgdnl --------------
990d522f475Smrgdnl Find version of gcc
991d522f475SmrgAC_DEFUN([CF_GCC_VERSION],[
992d522f475SmrgAC_REQUIRE([AC_PROG_CC])
993d522f475SmrgGCC_VERSION=none
994d522f475Smrgif test "$GCC" = yes ; then
995d522f475Smrg	AC_MSG_CHECKING(version of $CC)
9960bd37d32Smrg	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.]].*//'`"
997d522f475Smrg	test -z "$GCC_VERSION" && GCC_VERSION=unknown
998d522f475Smrg	AC_MSG_RESULT($GCC_VERSION)
999d522f475Smrgfi
1000d522f475Smrg])dnl
1001d522f475Smrgdnl ---------------------------------------------------------------------------
100201037d57Smrgdnl CF_GCC_WARNINGS version: 32 updated: 2015/04/12 15:39:00
1003d522f475Smrgdnl ---------------
1004d522f475Smrgdnl Check if the compiler supports useful warning options.  There's a few that
1005d522f475Smrgdnl we don't use, simply because they're too noisy:
1006d522f475Smrgdnl
1007d522f475Smrgdnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1008d522f475Smrgdnl	-Wredundant-decls (system headers make this too noisy)
1009d522f475Smrgdnl	-Wtraditional (combines too many unrelated messages, only a few useful)
1010d522f475Smrgdnl	-Wwrite-strings (too noisy, but should review occasionally).  This
1011d522f475Smrgdnl		is enabled for ncurses using "--enable-const".
1012d522f475Smrgdnl	-pedantic
1013d522f475Smrgdnl
1014d522f475Smrgdnl Parameter:
1015d522f475Smrgdnl	$1 is an optional list of gcc warning flags that a particular
1016d522f475Smrgdnl		application might want to use, e.g., "no-unused" for
1017d522f475Smrgdnl		-Wno-unused
1018d522f475Smrgdnl Special:
1019d522f475Smrgdnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
1020d522f475Smrgdnl
1021d522f475SmrgAC_DEFUN([CF_GCC_WARNINGS],
1022d522f475Smrg[
1023d522f475SmrgAC_REQUIRE([CF_GCC_VERSION])
1024d522f475SmrgCF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
10250bd37d32SmrgCF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
1026d522f475Smrg
1027d522f475Smrgcat > conftest.$ac_ext <<EOF
10286879286fSmrg#line __oline__ "${as_me:-configure}"
1029d522f475Smrgint main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1030d522f475SmrgEOF
1031d522f475Smrg
1032d522f475Smrgif test "$INTEL_COMPILER" = yes
1033d522f475Smrgthen
1034d522f475Smrg# The "-wdXXX" options suppress warnings:
1035d522f475Smrg# remark #1419: external declaration in primary source file
1036d522f475Smrg# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1037d522f475Smrg# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1038d522f475Smrg# remark #193: zero used for undefined preprocessing identifier
1039d522f475Smrg# remark #593: variable "curs_sb_left_arrow" was set but never used
1040d522f475Smrg# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1041d522f475Smrg# remark #869: parameter "tw" was never referenced
1042d522f475Smrg# remark #981: operands are evaluated in unspecified order
1043956cc18dSsnj# warning #279: controlling expression is constant
1044d522f475Smrg
1045d522f475Smrg	AC_CHECKING([for $CC warning options])
1046d522f475Smrg	cf_save_CFLAGS="$CFLAGS"
1047d522f475Smrg	EXTRA_CFLAGS="-Wall"
1048d522f475Smrg	for cf_opt in \
1049d522f475Smrg		wd1419 \
1050d522f475Smrg		wd1683 \
1051d522f475Smrg		wd1684 \
1052d522f475Smrg		wd193 \
1053d522f475Smrg		wd593 \
1054956cc18dSsnj		wd279 \
1055d522f475Smrg		wd810 \
1056d522f475Smrg		wd869 \
1057d522f475Smrg		wd981
1058d522f475Smrg	do
1059d522f475Smrg		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1060d522f475Smrg		if AC_TRY_EVAL(ac_compile); then
1061d522f475Smrg			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1062d522f475Smrg			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1063d522f475Smrg		fi
1064d522f475Smrg	done
1065d522f475Smrg	CFLAGS="$cf_save_CFLAGS"
1066d522f475Smrg
1067d522f475Smrgelif test "$GCC" = yes
1068d522f475Smrgthen
1069d522f475Smrg	AC_CHECKING([for $CC warning options])
1070d522f475Smrg	cf_save_CFLAGS="$CFLAGS"
107120d2c4d2Smrg	EXTRA_CFLAGS=
1072d522f475Smrg	cf_warn_CONST=""
1073d522f475Smrg	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1074e0a2b6dfSmrg	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
1075e0a2b6dfSmrg	test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
107620d2c4d2Smrg	for cf_opt in W Wall \
1077d522f475Smrg		Wbad-function-cast \
1078d522f475Smrg		Wcast-align \
1079d522f475Smrg		Wcast-qual \
1080e0a2b6dfSmrg		Wdeclaration-after-statement \
1081e0a2b6dfSmrg		Wextra \
1082d522f475Smrg		Winline \
1083d522f475Smrg		Wmissing-declarations \
1084d522f475Smrg		Wmissing-prototypes \
1085d522f475Smrg		Wnested-externs \
1086d522f475Smrg		Wpointer-arith \
1087d522f475Smrg		Wshadow \
1088d522f475Smrg		Wstrict-prototypes \
1089e0a2b6dfSmrg		Wundef $cf_gcc_warnings $cf_warn_CONST $1
1090d522f475Smrg	do
1091d522f475Smrg		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1092d522f475Smrg		if AC_TRY_EVAL(ac_compile); then
1093d522f475Smrg			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
109401037d57Smrg			case $cf_opt in
109501037d57Smrg			(Wcast-qual)
1096d522f475Smrg				CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1097d522f475Smrg				;;
109801037d57Smrg			(Winline)
1099d522f475Smrg				case $GCC_VERSION in
110001037d57Smrg				([[34]].*)
1101d522f475Smrg					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1102d522f475Smrg					continue;;
1103d522f475Smrg				esac
1104d522f475Smrg				;;
110501037d57Smrg			(Wpointer-arith)
11060bd37d32Smrg				case $GCC_VERSION in
110701037d57Smrg				([[12]].*)
11080bd37d32Smrg					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
11090bd37d32Smrg					continue;;
11100bd37d32Smrg				esac
11110bd37d32Smrg				;;
1112d522f475Smrg			esac
1113d522f475Smrg			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1114d522f475Smrg		fi
1115d522f475Smrg	done
1116d522f475Smrg	CFLAGS="$cf_save_CFLAGS"
1117d522f475Smrgfi
11186879286fSmrgrm -rf conftest*
1119d522f475Smrg
1120d522f475SmrgAC_SUBST(EXTRA_CFLAGS)
1121d522f475Smrg])dnl
1122d522f475Smrgdnl ---------------------------------------------------------------------------
1123913cc679Smrgdnl CF_GNU_SOURCE version: 7 updated: 2016/08/05 05:15:37
1124d522f475Smrgdnl -------------
1125d522f475Smrgdnl Check if we must define _GNU_SOURCE to get a reasonable value for
1126d522f475Smrgdnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1127d522f475Smrgdnl (or misfeature) of glibc2, which breaks portability of many applications,
1128d522f475Smrgdnl since it is interwoven with GNU extensions.
1129d522f475Smrgdnl
1130d522f475Smrgdnl Well, yes we could work around it...
1131d522f475SmrgAC_DEFUN([CF_GNU_SOURCE],
1132d522f475Smrg[
1133d522f475SmrgAC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1134d522f475SmrgAC_TRY_COMPILE([#include <sys/types.h>],[
1135d522f475Smrg#ifndef _XOPEN_SOURCE
1136d522f475Smrgmake an error
1137d522f475Smrg#endif],
1138d522f475Smrg	[cf_cv_gnu_source=no],
1139d522f475Smrg	[cf_save="$CPPFLAGS"
1140d522f475Smrg	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1141d522f475Smrg	 AC_TRY_COMPILE([#include <sys/types.h>],[
1142d522f475Smrg#ifdef _XOPEN_SOURCE
1143d522f475Smrgmake an error
1144d522f475Smrg#endif],
1145d522f475Smrg	[cf_cv_gnu_source=no],
1146d522f475Smrg	[cf_cv_gnu_source=yes])
1147d522f475Smrg	CPPFLAGS="$cf_save"
1148d522f475Smrg	])
1149d522f475Smrg])
1150913cc679Smrg
1151913cc679Smrgif test "$cf_cv_gnu_source" = yes
1152913cc679Smrgthen
1153913cc679SmrgAC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
1154913cc679SmrgCPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1155913cc679Smrg	AC_TRY_COMPILE([#include <sys/types.h>],[
1156913cc679Smrg#ifdef _DEFAULT_SOURCE
1157913cc679Smrgmake an error
1158913cc679Smrg#endif],
1159913cc679Smrg		[cf_cv_default_source=no],
1160913cc679Smrg		[cf_cv_default_source=yes])
1161913cc679Smrg	])
1162913cc679Smrgtest "$cf_cv_default_source" = yes && CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE"
1163913cc679Smrgfi
1164d522f475Smrg])dnl
1165d522f475Smrgdnl ---------------------------------------------------------------------------
1166d522f475Smrgdnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1167d522f475Smrgdnl ---------------
1168d522f475Smrgdnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1169d522f475SmrgAC_DEFUN([CF_HELP_MESSAGE],
1170d522f475Smrg[AC_DIVERT_HELP([$1])dnl
1171d522f475Smrg])dnl
1172d522f475Smrgdnl ---------------------------------------------------------------------------
117301037d57Smrgdnl CF_IMAKE_CFLAGS version: 32 updated: 2015/04/12 15:39:00
1174d522f475Smrgdnl ---------------
1175d522f475Smrgdnl Use imake to obtain compiler flags.  We could, in principle, write tests to
1176d522f475Smrgdnl get these, but if imake is properly configured there is no point in doing
1177d522f475Smrgdnl this.
1178d522f475Smrgdnl
1179d522f475Smrgdnl Parameters (used in constructing a sample Imakefile):
1180d522f475Smrgdnl	$1 = optional value to append to $IMAKE_CFLAGS
1181d522f475Smrgdnl	$2 = optional value to append to $IMAKE_LOADFLAGS
1182d522f475SmrgAC_DEFUN([CF_IMAKE_CFLAGS],
1183d522f475Smrg[
1184d522f475SmrgAC_PATH_PROGS(IMAKE,xmkmf imake)
1185d522f475Smrg
1186d522f475Smrgif test -n "$IMAKE" ; then
1187d522f475Smrg
118801037d57Smrgcase $IMAKE in
118901037d57Smrg(*/imake)
119001037d57Smrg	cf_imake_opts="-DUseInstalled=YES"
1191d522f475Smrg	;;
119201037d57Smrg(*/util/xmkmf)
1193d522f475Smrg	# A single parameter tells xmkmf where the config-files are:
119401037d57Smrg	cf_imake_opts="`echo $IMAKE|sed -e s,/config/util/xmkmf,,`"
1195d522f475Smrg	;;
119601037d57Smrg(*)
1197d522f475Smrg	cf_imake_opts=
1198d522f475Smrg	;;
1199d522f475Smrgesac
1200d522f475Smrg
1201d522f475Smrg# If it's installed properly, imake (or its wrapper, xmkmf) will point to the
1202d522f475Smrg# config directory.
1203d522f475Smrgif mkdir conftestdir; then
1204d522f475Smrg	CDPATH=; export CDPATH
1205d522f475Smrg	cf_makefile=`cd $srcdir;pwd`/Imakefile
1206d522f475Smrg	cd conftestdir
1207d522f475Smrg
1208d522f475Smrg	cat >fix_cflags.sed <<'CF_EOF'
1209d522f475Smrgs/\\//g
1210d522f475Smrgs/[[ 	]][[ 	]]*/ /g
1211d522f475Smrgs/"//g
1212d522f475Smrg:pack
1213d522f475Smrgs/\(=[[^ ]][[^ ]]*\) \([[^-]]\)/\1	\2/g
1214d522f475Smrgt pack
1215d522f475Smrgs/\(-D[[a-zA-Z0-9_]][[a-zA-Z0-9_]]*\)=\([[^\'0-9 ]][[^ ]]*\)/\1='\\"\2\\"'/g
1216d522f475Smrgs/^IMAKE[[ ]]/IMAKE_CFLAGS="/
1217d522f475Smrgs/	/ /g
1218d522f475Smrgs/$/"/
1219d522f475SmrgCF_EOF
1220d522f475Smrg
1221d522f475Smrg	cat >fix_lflags.sed <<'CF_EOF'
1222d522f475Smrgs/^IMAKE[[ 	]]*/IMAKE_LOADFLAGS="/
1223d522f475Smrgs/$/"/
1224d522f475SmrgCF_EOF
1225d522f475Smrg
1226d522f475Smrg	echo >./Imakefile
1227d522f475Smrg	test -f $cf_makefile && cat $cf_makefile >>./Imakefile
1228d522f475Smrg
1229d522f475Smrg	cat >> ./Imakefile <<'CF_EOF'
1230d522f475Smrgfindstddefs:
123120d2c4d2Smrg	@echo IMAKE ${ALLDEFINES}ifelse([$1],,,[ $1])       | sed -f fix_cflags.sed
123220d2c4d2Smrg	@echo IMAKE ${EXTRA_LOAD_FLAGS}ifelse([$2],,,[ $2]) | sed -f fix_lflags.sed
1233d522f475SmrgCF_EOF
1234d522f475Smrg
1235d522f475Smrg	if ( $IMAKE $cf_imake_opts 1>/dev/null 2>&AC_FD_CC && test -f Makefile)
1236d522f475Smrg	then
1237d522f475Smrg		CF_VERBOSE(Using $IMAKE $cf_imake_opts)
1238d522f475Smrg	else
1239d522f475Smrg		# sometimes imake doesn't have the config path compiled in.  Find it.
1240d522f475Smrg		cf_config=
1241d522f475Smrg		for cf_libpath in $X_LIBS $LIBS ; do
124201037d57Smrg			case $cf_libpath in
124301037d57Smrg			(-L*)
1244d522f475Smrg				cf_libpath=`echo .$cf_libpath | sed -e 's/^...//'`
1245d522f475Smrg				cf_libpath=$cf_libpath/X11/config
1246d522f475Smrg				if test -d $cf_libpath ; then
1247d522f475Smrg					cf_config=$cf_libpath
1248d522f475Smrg					break
1249d522f475Smrg				fi
1250d522f475Smrg				;;
1251d522f475Smrg			esac
1252d522f475Smrg		done
1253d522f475Smrg		if test -z "$cf_config" ; then
1254d522f475Smrg			AC_MSG_WARN(Could not find imake config-directory)
1255d522f475Smrg		else
1256d522f475Smrg			cf_imake_opts="$cf_imake_opts -I$cf_config"
1257d522f475Smrg			if ( $IMAKE -v $cf_imake_opts 2>&AC_FD_CC)
1258d522f475Smrg			then
1259d522f475Smrg				CF_VERBOSE(Using $IMAKE $cf_config)
1260d522f475Smrg			else
1261d522f475Smrg				AC_MSG_WARN(Cannot run $IMAKE)
1262d522f475Smrg			fi
1263d522f475Smrg		fi
1264d522f475Smrg	fi
1265d522f475Smrg
1266d522f475Smrg	# GNU make sometimes prints "make[1]: Entering...", which
1267d522f475Smrg	# would confuse us.
1268d522f475Smrg	eval `make findstddefs 2>/dev/null | grep -v make`
1269d522f475Smrg
1270d522f475Smrg	cd ..
1271d522f475Smrg	rm -rf conftestdir
1272d522f475Smrg
1273d522f475Smrg	# We use ${ALLDEFINES} rather than ${STD_DEFINES} because the former
1274d522f475Smrg	# declares XTFUNCPROTO there.  However, some vendors (e.g., SGI) have
1275d522f475Smrg	# modified it to support site.cf, adding a kludge for the /usr/include
1276d522f475Smrg	# directory.  Try to filter that out, otherwise gcc won't find its
1277d522f475Smrg	# headers.
1278d522f475Smrg	if test -n "$GCC" ; then
1279d522f475Smrg	    if test -n "$IMAKE_CFLAGS" ; then
1280d522f475Smrg		cf_nostdinc=""
1281d522f475Smrg		cf_std_incl=""
1282d522f475Smrg		cf_cpp_opts=""
1283d522f475Smrg		for cf_opt in $IMAKE_CFLAGS
1284d522f475Smrg		do
1285d522f475Smrg		    case "$cf_opt" in
128601037d57Smrg		    (-nostdinc)
1287d522f475Smrg			cf_nostdinc="$cf_opt"
1288d522f475Smrg			;;
128901037d57Smrg		    (-I/usr/include)
1290d522f475Smrg			cf_std_incl="$cf_opt"
1291d522f475Smrg			;;
129201037d57Smrg		    (*)
1293d522f475Smrg			cf_cpp_opts="$cf_cpp_opts $cf_opt"
1294d522f475Smrg			;;
1295d522f475Smrg		    esac
1296d522f475Smrg		done
1297d522f475Smrg		if test -z "$cf_nostdinc" ; then
1298d522f475Smrg		    IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl"
1299d522f475Smrg		elif test -z "$cf_std_incl" ; then
1300d522f475Smrg		    IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc"
1301d522f475Smrg		else
1302d522f475Smrg		    CF_VERBOSE(suppressed \"$cf_nostdinc\" and \"$cf_std_incl\")
1303d522f475Smrg		    IMAKE_CFLAGS="$cf_cpp_opts"
1304d522f475Smrg		fi
1305d522f475Smrg	    fi
1306d522f475Smrg	fi
1307d522f475Smrgfi
1308d522f475Smrg
1309d522f475Smrg# Some imake configurations define PROJECTROOT with an empty value.  Remove
1310d522f475Smrg# the empty definition.
1311d522f475Smrgcase $IMAKE_CFLAGS in
131201037d57Smrg(*-DPROJECTROOT=/*)
1313d522f475Smrg	;;
131401037d57Smrg(*)
1315d522f475Smrg	IMAKE_CFLAGS=`echo "$IMAKE_CFLAGS" |sed -e "s,-DPROJECTROOT=[[ 	]], ,"`
1316d522f475Smrg	;;
1317d522f475Smrgesac
1318d522f475Smrg
1319d522f475Smrgfi
1320d522f475Smrg
1321d522f475SmrgCF_VERBOSE(IMAKE_CFLAGS $IMAKE_CFLAGS)
1322d522f475SmrgCF_VERBOSE(IMAKE_LOADFLAGS $IMAKE_LOADFLAGS)
1323d522f475Smrg
1324d522f475SmrgAC_SUBST(IMAKE_CFLAGS)
1325d522f475SmrgAC_SUBST(IMAKE_LOADFLAGS)
1326d522f475Smrg])dnl
1327d522f475Smrgdnl ---------------------------------------------------------------------------
1328d522f475Smrgdnl CF_INPUT_METHOD version: 3 updated: 2000/04/11 23:46:57
1329d522f475Smrgdnl ---------------
1330d522f475Smrgdnl Check if the X libraries support input-method
1331d522f475SmrgAC_DEFUN([CF_INPUT_METHOD],
1332d522f475Smrg[
1333d522f475SmrgAC_CACHE_CHECK([if X libraries support input-method],cf_cv_input_method,[
1334d522f475SmrgAC_TRY_LINK([
1335d522f475Smrg#include <X11/IntrinsicP.h>
1336d522f475Smrg#include <X11/Xatom.h>
1337d522f475Smrg#include <X11/Xutil.h>
1338d522f475Smrg#include <X11/Xmu/Atoms.h>
1339d522f475Smrg#include <X11/Xmu/Converters.h>
1340d522f475Smrg#include <X11/Xaw/XawImP.h>
1341d522f475Smrg],[
1342d522f475Smrg{
1343d522f475Smrg	XIM xim;
1344d522f475Smrg	XIMStyles *xim_styles = 0;
1345d522f475Smrg	XIMStyle input_style;
1346d522f475Smrg	Widget w = 0;
1347d522f475Smrg
1348d522f475Smrg	XSetLocaleModifiers("@im=none");
1349d522f475Smrg	xim = XOpenIM(XtDisplay(w), NULL, NULL, NULL);
1350d522f475Smrg	XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);
1351d522f475Smrg	XCloseIM(xim);
1352d522f475Smrg	input_style = (XIMPreeditNothing | XIMStatusNothing);
1353d522f475Smrg}
1354d522f475Smrg],
1355d522f475Smrg[cf_cv_input_method=yes],
1356d522f475Smrg[cf_cv_input_method=no])])
1357d522f475Smrg])dnl
1358d522f475Smrgdnl ---------------------------------------------------------------------------
135901037d57Smrgdnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00
1360d522f475Smrgdnl -----------------
1361d522f475Smrgdnl Check if the given compiler is really the Intel compiler for Linux.  It
1362d522f475Smrgdnl tries to imitate gcc, but does not return an error when it finds a mismatch
1363d522f475Smrgdnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1364d522f475Smrgdnl
1365d522f475Smrgdnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1366d522f475Smrgdnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1367d522f475Smrgdnl the wrappers for gcc and g++ warnings.
1368d522f475Smrgdnl
1369d522f475Smrgdnl $1 = GCC (default) or GXX
1370d522f475Smrgdnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1371d522f475Smrgdnl $3 = CFLAGS (default) or CXXFLAGS
1372d522f475SmrgAC_DEFUN([CF_INTEL_COMPILER],[
13730bd37d32SmrgAC_REQUIRE([AC_CANONICAL_HOST])
137420d2c4d2Smrgifelse([$2],,INTEL_COMPILER,[$2])=no
1375d522f475Smrg
137620d2c4d2Smrgif test "$ifelse([$1],,[$1],GCC)" = yes ; then
1377d522f475Smrg	case $host_os in
137801037d57Smrg	(linux*|gnu*)
137920d2c4d2Smrg		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
138020d2c4d2Smrg		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
138120d2c4d2Smrg		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1382d522f475Smrg		AC_TRY_COMPILE([],[
1383d522f475Smrg#ifdef __INTEL_COMPILER
1384d522f475Smrg#else
1385d522f475Smrgmake an error
1386d522f475Smrg#endif
138720d2c4d2Smrg],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1388894e0ac8Smrgcf_save_CFLAGS="$cf_save_CFLAGS -we147"
1389d522f475Smrg],[])
139020d2c4d2Smrg		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
139120d2c4d2Smrg		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1392d522f475Smrg		;;
1393d522f475Smrg	esac
1394d522f475Smrgfi
1395d522f475Smrg])dnl
1396d522f475Smrgdnl ---------------------------------------------------------------------------
13970bd37d32Smrgdnl CF_LASTLOG version: 5 updated: 2012/10/04 20:12:20
1398d522f475Smrgdnl ----------
1399d522f475Smrgdnl Check for header defining _PATH_LASTLOG, or failing that, see if the lastlog
1400d522f475Smrgdnl file exists.
1401d522f475SmrgAC_DEFUN([CF_LASTLOG],
1402d522f475Smrg[
1403d522f475SmrgAC_CHECK_HEADERS(lastlog.h paths.h)
1404d522f475SmrgAC_CACHE_CHECK(for lastlog path,cf_cv_path_lastlog,[
1405d522f475SmrgAC_TRY_COMPILE([
1406d522f475Smrg#include <sys/types.h>
1407d522f475Smrg#ifdef HAVE_LASTLOG_H
1408d522f475Smrg#include <lastlog.h>
1409d522f475Smrg#else
1410d522f475Smrg#ifdef HAVE_PATHS_H
1411d522f475Smrg#include <paths.h>
1412d522f475Smrg#endif
1413d522f475Smrg#endif],[char *path = _PATH_LASTLOG],
1414d522f475Smrg	[cf_cv_path_lastlog="_PATH_LASTLOG"],
1415d522f475Smrg	[if test -f /usr/adm/lastlog ; then
1416d522f475Smrg	 	cf_cv_path_lastlog=/usr/adm/lastlog
1417d522f475Smrg	else
1418d522f475Smrg		cf_cv_path_lastlog=no
1419d522f475Smrg	fi])
1420d522f475Smrg])
14210bd37d32Smrgtest $cf_cv_path_lastlog != no && AC_DEFINE(USE_LASTLOG,1,[Define to 1 if we can define lastlog pathname])
1422d522f475Smrg])dnl
1423d522f475Smrgdnl ---------------------------------------------------------------------------
14242e4f8982Smrgdnl CF_LD_RPATH_OPT version: 7 updated: 2016/02/20 18:01:19
142520d2c4d2Smrgdnl ---------------
142620d2c4d2Smrgdnl For the given system and compiler, find the compiler flags to pass to the
142720d2c4d2Smrgdnl loader to use the "rpath" feature.
142820d2c4d2SmrgAC_DEFUN([CF_LD_RPATH_OPT],
142920d2c4d2Smrg[
143020d2c4d2SmrgAC_REQUIRE([CF_CHECK_CACHE])
143120d2c4d2Smrg
143220d2c4d2SmrgLD_RPATH_OPT=
143320d2c4d2SmrgAC_MSG_CHECKING(for an rpath option)
143401037d57Smrgcase $cf_cv_system_name in
143501037d57Smrg(irix*)
143620d2c4d2Smrg	if test "$GCC" = yes; then
143720d2c4d2Smrg		LD_RPATH_OPT="-Wl,-rpath,"
143820d2c4d2Smrg	else
143920d2c4d2Smrg		LD_RPATH_OPT="-rpath "
144020d2c4d2Smrg	fi
144120d2c4d2Smrg	;;
14422e4f8982Smrg(linux*|gnu*|k*bsd*-gnu|freebsd*)
144320d2c4d2Smrg	LD_RPATH_OPT="-Wl,-rpath,"
144420d2c4d2Smrg	;;
144501037d57Smrg(openbsd[[2-9]].*|mirbsd*)
144620d2c4d2Smrg	LD_RPATH_OPT="-Wl,-rpath,"
144720d2c4d2Smrg	;;
14482e4f8982Smrg(dragonfly*)
144920d2c4d2Smrg	LD_RPATH_OPT="-rpath "
145020d2c4d2Smrg	;;
145101037d57Smrg(netbsd*)
145220d2c4d2Smrg	LD_RPATH_OPT="-Wl,-rpath,"
145320d2c4d2Smrg	;;
145401037d57Smrg(osf*|mls+*)
145520d2c4d2Smrg	LD_RPATH_OPT="-rpath "
145620d2c4d2Smrg	;;
145701037d57Smrg(solaris2*)
145820d2c4d2Smrg	LD_RPATH_OPT="-R"
145920d2c4d2Smrg	;;
146001037d57Smrg(*)
146120d2c4d2Smrg	;;
146220d2c4d2Smrgesac
146320d2c4d2SmrgAC_MSG_RESULT($LD_RPATH_OPT)
146420d2c4d2Smrg
146501037d57Smrgcase "x$LD_RPATH_OPT" in
146601037d57Smrg(x-R*)
146720d2c4d2Smrg	AC_MSG_CHECKING(if we need a space after rpath option)
146820d2c4d2Smrg	cf_save_LIBS="$LIBS"
146920d2c4d2Smrg	CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
147020d2c4d2Smrg	AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
147120d2c4d2Smrg	LIBS="$cf_save_LIBS"
147220d2c4d2Smrg	AC_MSG_RESULT($cf_rpath_space)
147320d2c4d2Smrg	test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
147420d2c4d2Smrg	;;
147520d2c4d2Smrgesac
147620d2c4d2Smrg])dnl
147720d2c4d2Smrgdnl ---------------------------------------------------------------------------
14786879286fSmrgdnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
147920d2c4d2Smrgdnl ------------
148020d2c4d2Smrgdnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
148120d2c4d2Smrgdnl a monocase filesystem.
148220d2c4d2SmrgAC_DEFUN([CF_MAKE_TAGS],[
148320d2c4d2SmrgAC_REQUIRE([CF_MIXEDCASE_FILENAMES])
148420d2c4d2Smrg
148520d2c4d2SmrgAC_CHECK_PROGS(CTAGS, exctags ctags)
148620d2c4d2SmrgAC_CHECK_PROGS(ETAGS, exetags etags)
148720d2c4d2Smrg
14886879286fSmrgAC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
148920d2c4d2Smrg
149020d2c4d2Smrgif test "$cf_cv_mixedcase" = yes ; then
14916879286fSmrg	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
149220d2c4d2Smrgelse
149320d2c4d2Smrg	MAKE_UPPER_TAGS=no
149420d2c4d2Smrgfi
149520d2c4d2Smrg
149620d2c4d2Smrgif test "$MAKE_UPPER_TAGS" = yes ; then
149720d2c4d2Smrg	MAKE_UPPER_TAGS=
149820d2c4d2Smrgelse
149920d2c4d2Smrg	MAKE_UPPER_TAGS="#"
150020d2c4d2Smrgfi
150120d2c4d2Smrg
150220d2c4d2Smrgif test "$MAKE_LOWER_TAGS" = yes ; then
150320d2c4d2Smrg	MAKE_LOWER_TAGS=
150420d2c4d2Smrgelse
150520d2c4d2Smrg	MAKE_LOWER_TAGS="#"
150620d2c4d2Smrgfi
150720d2c4d2Smrg
150820d2c4d2SmrgAC_SUBST(CTAGS)
150920d2c4d2SmrgAC_SUBST(ETAGS)
151020d2c4d2Smrg
151120d2c4d2SmrgAC_SUBST(MAKE_UPPER_TAGS)
151220d2c4d2SmrgAC_SUBST(MAKE_LOWER_TAGS)
151320d2c4d2Smrg])dnl
151420d2c4d2Smrgdnl ---------------------------------------------------------------------------
1515913cc679Smrgdnl CF_MATH_LIB version: 9 updated: 2017/01/21 11:06:25
1516894e0ac8Smrgdnl -----------
1517894e0ac8Smrgdnl Checks for libraries.  At least one UNIX system, Apple Macintosh
1518894e0ac8Smrgdnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
1519894e0ac8Smrgdnl AC_CHECK_LIB(m,sin), because that fails for C++.
1520894e0ac8SmrgAC_DEFUN([CF_MATH_LIB],
1521894e0ac8Smrg[
1522894e0ac8SmrgAC_CACHE_CHECK(if -lm needed for math functions,
1523894e0ac8Smrg	cf_cv_need_libm,[
1524894e0ac8Smrg	AC_TRY_LINK([
1525894e0ac8Smrg	#include <stdio.h>
1526913cc679Smrg	#include <stdlib.h>
1527894e0ac8Smrg	#include <math.h>
1528894e0ac8Smrg	],
1529894e0ac8Smrg	[double x = rand(); printf("result = %g\n", ]ifelse([$2],,sin(x),$2)[)],
1530894e0ac8Smrg	[cf_cv_need_libm=no],
1531894e0ac8Smrg	[cf_cv_need_libm=yes])])
1532894e0ac8Smrgif test "$cf_cv_need_libm" = yes
1533894e0ac8Smrgthen
1534894e0ac8Smrgifelse($1,,[
1535894e0ac8Smrg	CF_ADD_LIB(m)
1536894e0ac8Smrg],[$1=-lm])
1537894e0ac8Smrgfi
1538894e0ac8Smrg])
1539894e0ac8Smrgdnl ---------------------------------------------------------------------------
154001037d57Smrgdnl CF_MIXEDCASE_FILENAMES version: 7 updated: 2015/04/12 15:39:00
154120d2c4d2Smrgdnl ----------------------
154220d2c4d2Smrgdnl Check if the file-system supports mixed-case filenames.  If we're able to
154320d2c4d2Smrgdnl create a lowercase name and see it as uppercase, it doesn't support that.
154420d2c4d2SmrgAC_DEFUN([CF_MIXEDCASE_FILENAMES],
154520d2c4d2Smrg[
154620d2c4d2SmrgAC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
154720d2c4d2Smrgif test "$cross_compiling" = yes ; then
154801037d57Smrg	case $target_alias in
154901037d57Smrg	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
155020d2c4d2Smrg		cf_cv_mixedcase=no
155120d2c4d2Smrg		;;
155201037d57Smrg	(*)
155320d2c4d2Smrg		cf_cv_mixedcase=yes
155420d2c4d2Smrg		;;
155520d2c4d2Smrg	esac
155620d2c4d2Smrgelse
155720d2c4d2Smrg	rm -f conftest CONFTEST
155820d2c4d2Smrg	echo test >conftest
155920d2c4d2Smrg	if test -f CONFTEST ; then
156020d2c4d2Smrg		cf_cv_mixedcase=no
156120d2c4d2Smrg	else
156220d2c4d2Smrg		cf_cv_mixedcase=yes
156320d2c4d2Smrg	fi
156420d2c4d2Smrg	rm -f conftest CONFTEST
156520d2c4d2Smrgfi
156620d2c4d2Smrg])
15670bd37d32Smrgtest "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
156820d2c4d2Smrg])dnl
156920d2c4d2Smrgdnl ---------------------------------------------------------------------------
15706879286fSmrgdnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1571d522f475Smrgdnl ----------
1572d522f475Smrgdnl Write a debug message to config.log, along with the line number in the
1573d522f475Smrgdnl configure script.
1574d522f475SmrgAC_DEFUN([CF_MSG_LOG],[
15756879286fSmrgecho "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1576d522f475Smrg])dnl
1577d522f475Smrgdnl ---------------------------------------------------------------------------
157801037d57Smrgdnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
15790bd37d32Smrgdnl ------------------
15800bd37d32Smrgdnl see CF_WITH_NO_LEAKS
15810bd37d32SmrgAC_DEFUN([CF_NO_LEAKS_OPTION],[
15820bd37d32SmrgAC_MSG_CHECKING(if you want to use $1 for testing)
15830bd37d32SmrgAC_ARG_WITH($1,
15840bd37d32Smrg	[$2],
15850bd37d32Smrg	[AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
15860bd37d32Smrg	 $4
15870bd37d32Smrg])
15880bd37d32Smrg	: ${with_cflags:=-g}
15890bd37d32Smrg	: ${with_no_leaks:=yes}
15900bd37d32Smrg	 with_$1=yes],
15910bd37d32Smrg	[with_$1=])
15920bd37d32SmrgAC_MSG_RESULT(${with_$1:-no})
15930bd37d32Smrg
159401037d57Smrgcase .$with_cflags in
159501037d57Smrg(.*-g*)
159601037d57Smrg	case .$CFLAGS in
159701037d57Smrg	(.*-g*)
15980bd37d32Smrg		;;
159901037d57Smrg	(*)
16000bd37d32Smrg		CF_ADD_CFLAGS([-g])
16010bd37d32Smrg		;;
16020bd37d32Smrg	esac
16030bd37d32Smrg	;;
16040bd37d32Smrgesac
16050bd37d32Smrg])dnl
16060bd37d32Smrgdnl ---------------------------------------------------------------------------
160701037d57Smrgdnl CF_PATHSEP version: 7 updated: 2015/04/12 15:39:00
1608956cc18dSsnjdnl ----------
16090bd37d32Smrgdnl Provide a value for the $PATH and similar separator (or amend the value
16100bd37d32Smrgdnl as provided in autoconf 2.5x).
1611956cc18dSsnjAC_DEFUN([CF_PATHSEP],
1612956cc18dSsnj[
16130bd37d32Smrg	AC_MSG_CHECKING(for PATH separator)
1614956cc18dSsnj	case $cf_cv_system_name in
161501037d57Smrg	(os2*)	PATH_SEPARATOR=';'  ;;
161601037d57Smrg	(*)	${PATH_SEPARATOR:=':'}  ;;
1617956cc18dSsnj	esac
161820d2c4d2Smrgifelse([$1],,,[$1=$PATH_SEPARATOR])
1619956cc18dSsnj	AC_SUBST(PATH_SEPARATOR)
16200bd37d32Smrg	AC_MSG_RESULT($PATH_SEPARATOR)
1621956cc18dSsnj])dnl
1622956cc18dSsnjdnl ---------------------------------------------------------------------------
16230bd37d32Smrgdnl CF_PATH_PROG version: 9 updated: 2012/10/04 20:12:20
1624d522f475Smrgdnl ------------
1625d522f475Smrgdnl Check for a given program, defining corresponding symbol.
1626d522f475Smrgdnl	$1 = environment variable, which is suffixed by "_PATH" in the #define.
1627d522f475Smrgdnl	$2 = program name to find.
1628d522f475Smrgdnl	$3 = optional list of additional program names to test.
1629d522f475Smrgdnl
1630d522f475Smrgdnl If there is more than one token in the result, #define the remaining tokens
1631d522f475Smrgdnl to $1_ARGS.  We need this for 'install' in particular.
1632d522f475Smrgdnl
1633d522f475Smrgdnl FIXME: we should allow this to be overridden by environment variables
1634d522f475Smrgdnl
1635d522f475SmrgAC_DEFUN([CF_PATH_PROG],[
1636956cc18dSsnjAC_REQUIRE([CF_PATHSEP])
1637d522f475Smrgtest -z "[$]$1" && $1=$2
1638d522f475SmrgAC_PATH_PROGS($1,[$]$1 $2 $3,[$]$1)
1639d522f475Smrg
1640d522f475Smrgcf_path_prog=""
1641d522f475Smrgcf_path_args=""
16426879286fSmrgIFS="${IFS:- 	}"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
1643d522f475Smrgfor cf_temp in $ac_cv_path_$1
1644d522f475Smrgdo
1645d522f475Smrg	if test -z "$cf_path_prog" ; then
1646d522f475Smrg		if test "$with_full_paths" = yes ; then
1647d522f475Smrg			CF_PATH_SYNTAX(cf_temp,break)
1648d522f475Smrg			cf_path_prog="$cf_temp"
1649d522f475Smrg		else
1650d522f475Smrg			cf_path_prog="`basename $cf_temp`"
1651d522f475Smrg		fi
1652d522f475Smrg	elif test -z "$cf_path_args" ; then
1653d522f475Smrg		cf_path_args="$cf_temp"
1654d522f475Smrg	else
1655d522f475Smrg		cf_path_args="$cf_path_args $cf_temp"
1656d522f475Smrg	fi
1657d522f475Smrgdone
1658d522f475SmrgIFS="$cf_save_ifs"
1659d522f475Smrg
1660d522f475Smrgif test -n "$cf_path_prog" ; then
1661d522f475Smrg	CF_MSG_LOG(defining path for ${cf_path_prog})
16620bd37d32Smrg	AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog",Define to pathname $1)
16630bd37d32Smrg	test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args",Define to provide args for $1)
1664d522f475Smrgfi
1665d522f475Smrg])dnl
1666d522f475Smrgdnl ---------------------------------------------------------------------------
16672e4f8982Smrgdnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
1668d522f475Smrgdnl --------------
1669d522f475Smrgdnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1670d522f475Smrgdnl begins with one of the prefix/exec_prefix variables, and then again if the
1671d522f475Smrgdnl result begins with 'NONE'.  This is necessary to work around autoconf's
1672d522f475Smrgdnl delayed evaluation of those symbols.
1673d522f475SmrgAC_DEFUN([CF_PATH_SYNTAX],[
1674d522f475Smrgif test "x$prefix" != xNONE; then
16752e4f8982Smrg	cf_path_syntax="$prefix"
1676d522f475Smrgelse
16772e4f8982Smrg	cf_path_syntax="$ac_default_prefix"
1678d522f475Smrgfi
1679d522f475Smrg
168001037d57Smrgcase ".[$]$1" in
168101037d57Smrg(.\[$]\(*\)*|.\'*\'*)
16822e4f8982Smrg	;;
168301037d57Smrg(..|./*|.\\*)
16842e4f8982Smrg	;;
168501037d57Smrg(.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
16862e4f8982Smrg	;;
168701037d57Smrg(.\[$]{*prefix}*|.\[$]{*dir}*)
16882e4f8982Smrg	eval $1="[$]$1"
16892e4f8982Smrg	case ".[$]$1" in
16902e4f8982Smrg	(.NONE/*)
16912e4f8982Smrg		$1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
16922e4f8982Smrg		;;
16932e4f8982Smrg	esac
16942e4f8982Smrg	;;
169501037d57Smrg(.no|.NONE/*)
16962e4f8982Smrg	$1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
16972e4f8982Smrg	;;
169801037d57Smrg(*)
16992e4f8982Smrg	ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
17002e4f8982Smrg	;;
1701d522f475Smrgesac
1702d522f475Smrg])dnl
1703d522f475Smrgdnl ---------------------------------------------------------------------------
17042e4f8982Smrgdnl CF_PKG_CONFIG version: 10 updated: 2015/04/26 18:06:58
1705956cc18dSsnjdnl -------------
1706956cc18dSsnjdnl Check for the package-config program, unless disabled by command-line.
1707956cc18dSsnjAC_DEFUN([CF_PKG_CONFIG],
1708956cc18dSsnj[
1709956cc18dSsnjAC_MSG_CHECKING(if you want to use pkg-config)
1710956cc18dSsnjAC_ARG_WITH(pkg-config,
1711956cc18dSsnj	[  --with-pkg-config{=path} enable/disable use of pkg-config],
1712956cc18dSsnj	[cf_pkg_config=$withval],
1713956cc18dSsnj	[cf_pkg_config=yes])
1714956cc18dSsnjAC_MSG_RESULT($cf_pkg_config)
1715956cc18dSsnj
171601037d57Smrgcase $cf_pkg_config in
171701037d57Smrg(no)
1718956cc18dSsnj	PKG_CONFIG=none
1719956cc18dSsnj	;;
172001037d57Smrg(yes)
1721e39b573cSmrg	CF_ACVERSION_CHECK(2.52,
1722e39b573cSmrg		[AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
1723e39b573cSmrg		[AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
1724956cc18dSsnj	;;
172501037d57Smrg(*)
1726956cc18dSsnj	PKG_CONFIG=$withval
1727956cc18dSsnj	;;
1728956cc18dSsnjesac
1729956cc18dSsnj
1730956cc18dSsnjtest -z "$PKG_CONFIG" && PKG_CONFIG=none
1731956cc18dSsnjif test "$PKG_CONFIG" != none ; then
1732956cc18dSsnj	CF_PATH_SYNTAX(PKG_CONFIG)
17332e4f8982Smrgelif test "x$cf_pkg_config" != xno ; then
173401037d57Smrg	AC_MSG_WARN(pkg-config is not installed)
1735956cc18dSsnjfi
1736956cc18dSsnj
1737956cc18dSsnjAC_SUBST(PKG_CONFIG)
1738956cc18dSsnj])dnl
1739956cc18dSsnjdnl ---------------------------------------------------------------------------
174001037d57Smrgdnl CF_POSIX_C_SOURCE version: 9 updated: 2015/04/12 15:39:00
1741d522f475Smrgdnl -----------------
1742d522f475Smrgdnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1743d522f475Smrgdnl
1744d522f475Smrgdnl	POSIX.1-1990				_POSIX_SOURCE
1745d522f475Smrgdnl	POSIX.1-1990 and			_POSIX_SOURCE and
1746d522f475Smrgdnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
1747d522f475Smrgdnl		Bindings Option
1748d522f475Smrgdnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
1749d522f475Smrgdnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
1750d522f475Smrgdnl	X/Open 2000				_POSIX_C_SOURCE=200112L
1751d522f475Smrgdnl
1752d522f475Smrgdnl Parameters:
1753d522f475Smrgdnl	$1 is the nominal value for _POSIX_C_SOURCE
1754d522f475SmrgAC_DEFUN([CF_POSIX_C_SOURCE],
1755d522f475Smrg[
175620d2c4d2Smrgcf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1757d522f475Smrg
1758d522f475Smrgcf_save_CFLAGS="$CFLAGS"
1759d522f475Smrgcf_save_CPPFLAGS="$CPPFLAGS"
1760d522f475Smrg
1761d522f475SmrgCF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1762d522f475SmrgCF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1763d522f475Smrg
1764d522f475SmrgAC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1765d522f475Smrg	CF_MSG_LOG(if the symbol is already defined go no further)
1766d522f475Smrg	AC_TRY_COMPILE([#include <sys/types.h>],[
1767d522f475Smrg#ifndef _POSIX_C_SOURCE
1768d522f475Smrgmake an error
1769d522f475Smrg#endif],
1770d522f475Smrg	[cf_cv_posix_c_source=no],
1771d522f475Smrg	[cf_want_posix_source=no
177201037d57Smrg	 case .$cf_POSIX_C_SOURCE in
177301037d57Smrg	 (.[[12]]??*)
1774d522f475Smrg		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1775d522f475Smrg		;;
177601037d57Smrg	 (.2)
1777d522f475Smrg		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1778d522f475Smrg		cf_want_posix_source=yes
1779d522f475Smrg		;;
178001037d57Smrg	 (.*)
1781d522f475Smrg		cf_want_posix_source=yes
1782d522f475Smrg		;;
1783d522f475Smrg	 esac
1784d522f475Smrg	 if test "$cf_want_posix_source" = yes ; then
1785d522f475Smrg		AC_TRY_COMPILE([#include <sys/types.h>],[
1786d522f475Smrg#ifdef _POSIX_SOURCE
1787d522f475Smrgmake an error
1788d522f475Smrg#endif],[],
1789d522f475Smrg		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1790d522f475Smrg	 fi
1791d522f475Smrg	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1792d522f475Smrg	 CFLAGS="$cf_trim_CFLAGS"
1793d522f475Smrg	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1794d522f475Smrg	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1795d522f475Smrg	 AC_TRY_COMPILE([#include <sys/types.h>],[
1796d522f475Smrg#ifndef _POSIX_C_SOURCE
1797d522f475Smrgmake an error
1798d522f475Smrg#endif],,
1799d522f475Smrg	 [cf_cv_posix_c_source=no])
1800d522f475Smrg	 CFLAGS="$cf_save_CFLAGS"
1801d522f475Smrg	 CPPFLAGS="$cf_save_CPPFLAGS"
1802d522f475Smrg	])
1803d522f475Smrg])
1804d522f475Smrg
1805d522f475Smrgif test "$cf_cv_posix_c_source" != no ; then
1806d522f475Smrg	CFLAGS="$cf_trim_CFLAGS"
1807d522f475Smrg	CPPFLAGS="$cf_trim_CPPFLAGS"
180820d2c4d2Smrg	CF_ADD_CFLAGS($cf_cv_posix_c_source)
1809d522f475Smrgfi
1810d522f475Smrg
1811d522f475Smrg])dnl
1812d522f475Smrgdnl ---------------------------------------------------------------------------
18130bd37d32Smrgdnl CF_POSIX_SAVED_IDS version: 8 updated: 2012/10/04 20:12:20
1814d522f475Smrgdnl ------------------
1815d522f475Smrgdnl
1816d522f475Smrgdnl Check first if saved-ids are always supported.  Some systems
1817d522f475Smrgdnl may require runtime checks.
1818d522f475SmrgAC_DEFUN([CF_POSIX_SAVED_IDS],
1819d522f475Smrg[
1820d522f475SmrgAC_CHECK_HEADERS( \
1821d522f475Smrgsys/param.h \
1822d522f475Smrg)
1823d522f475Smrg
1824d522f475SmrgAC_CACHE_CHECK(if POSIX saved-ids are supported,cf_cv_posix_saved_ids,[
1825d522f475SmrgAC_TRY_LINK(
1826d522f475Smrg[
1827d522f475Smrg#include <unistd.h>
1828d522f475Smrg#ifdef HAVE_SYS_PARAM_H
1829d522f475Smrg#include <sys/param.h>		/* this may define "BSD" */
1830d522f475Smrg#endif
1831d522f475Smrg],[
1832d522f475Smrg#if defined(_POSIX_SAVED_IDS) && (_POSIX_SAVED_IDS > 0)
1833d522f475Smrg	void *p = (void *) seteuid;
1834d522f475Smrg	int x = seteuid(geteuid());
1835d522f475Smrg#elif defined(BSD) && (BSD >= 199103)
1836d522f475Smrg/* The BSD's may implement the runtime check - and it fails.
1837d522f475Smrg * However, saved-ids work almost like POSIX (close enough for most uses).
1838d522f475Smrg */
1839d522f475Smrg#else
1840d522f475Smrgmake an error
1841d522f475Smrg#endif
1842d522f475Smrg],[cf_cv_posix_saved_ids=yes
1843d522f475Smrg],[
1844d522f475SmrgAC_TRY_RUN([
1845d522f475Smrg#ifdef HAVE_STDLIB_H
1846d522f475Smrg#include <stdlib.h>
1847d522f475Smrg#endif
1848d522f475Smrg#include <unistd.h>
1849d522f475Smrgint main()
1850d522f475Smrg{
1851d522f475Smrg	void *p = (void *) seteuid;
1852d522f475Smrg	long code = sysconf(_SC_SAVED_IDS);
1853d522f475Smrg	${cf_cv_main_return:-return}  ((code > 0) ? 0 : 1);
1854d522f475Smrg}],
1855d522f475Smrg	cf_cv_posix_saved_ids=yes,
1856d522f475Smrg	cf_cv_posix_saved_ids=no,
1857d522f475Smrg	cf_cv_posix_saved_ids=unknown)
1858d522f475Smrg])
1859d522f475Smrg])
1860d522f475Smrg
18610bd37d32Smrgtest "$cf_cv_posix_saved_ids" = yes && AC_DEFINE(HAVE_POSIX_SAVED_IDS,1,[Define to 1 if POSIX saved-ids are supported])
1862d522f475Smrg])
1863d522f475Smrgdnl ---------------------------------------------------------------------------
18640bd37d32Smrgdnl CF_POSIX_WAIT version: 3 updated: 2012/10/04 20:12:20
1865d522f475Smrgdnl -------------
1866d522f475Smrgdnl Check for POSIX wait support
1867d522f475SmrgAC_DEFUN([CF_POSIX_WAIT],
1868d522f475Smrg[
1869d522f475SmrgAC_REQUIRE([AC_HEADER_SYS_WAIT])
1870d522f475SmrgAC_CACHE_CHECK(for POSIX wait functions,cf_cv_posix_wait,[
1871d522f475SmrgAC_TRY_LINK([
1872d522f475Smrg#include <stdlib.h>
1873d522f475Smrg#include <stdio.h>
1874d522f475Smrg#include <sys/types.h>
1875d522f475Smrg#ifdef HAVE_SYS_WAIT_H
1876d522f475Smrg#include <sys/wait.h>
1877d522f475Smrg#endif
1878d522f475Smrg],[
1879d522f475Smrg	int stat_loc;
1880d522f475Smrg	pid_t pid = waitpid(-1, &stat_loc, WNOHANG|WUNTRACED);
1881d522f475Smrg	pid_t pid2 = wait(&stat_loc);
1882d522f475Smrg],
1883d522f475Smrg[cf_cv_posix_wait=yes],
1884d522f475Smrg[cf_cv_posix_wait=no])
1885d522f475Smrg])
18860bd37d32Smrgtest "$cf_cv_posix_wait" = yes && AC_DEFINE(USE_POSIX_WAIT,1,[Define to 1 if we have POSIX wait functions])
1887d522f475Smrg])dnl
1888d522f475Smrgdnl ---------------------------------------------------------------------------
1889d522f475Smrgdnl CF_PROCFS_CWD version: 2 updated: 2007/03/12 20:39:04
1890d522f475Smrgdnl -------------
1891d522f475Smrgdnl Find /proc tree (may be in a different place) which implements the "cwd"
1892d522f475Smrgdnl link.
1893d522f475SmrgAC_DEFUN([CF_PROCFS_CWD],[
1894d522f475SmrgAC_CACHE_CHECK(for proc tree with cwd-support,cf_cv_procfs_cwd,[
1895d522f475Smrgcf_cv_procfs_cwd=no
1896d522f475Smrgfor cf_path in /proc /compat/linux/proc /usr/compat/linux/proc
1897d522f475Smrgdo
1898d522f475Smrg	if test -d $cf_path && \
1899d522f475Smrg	   test -d $cf_path/$$ && \
1900d522f475Smrg	   ( test -d $cf_path/$$/cwd || \
1901d522f475Smrg	     test -L $cf_path/$$/cwd ); then
1902d522f475Smrg		cf_cv_procfs_cwd=$cf_path
1903d522f475Smrg		break
1904d522f475Smrg	fi
1905d522f475Smrgdone
1906d522f475Smrg])
1907d522f475Smrg])dnl
1908d522f475Smrgdnl ---------------------------------------------------------------------------
190901037d57Smrgdnl CF_PROG_CC version: 4 updated: 2014/07/12 18:57:58
19100bd37d32Smrgdnl ----------
19110bd37d32Smrgdnl standard check for CC, plus followup sanity checks
19120bd37d32Smrgdnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
19130bd37d32SmrgAC_DEFUN([CF_PROG_CC],[
19140bd37d32Smrgifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
19150bd37d32SmrgCF_GCC_VERSION
19160bd37d32SmrgCF_ACVERSION_CHECK(2.52,
19170bd37d32Smrg	[AC_PROG_CC_STDC],
19180bd37d32Smrg	[CF_ANSI_CC_REQD])
191901037d57SmrgCF_CC_ENV_FLAGS
1920d522f475Smrg])dnl
1921d522f475Smrgdnl ---------------------------------------------------------------------------
19222e4f8982Smrgdnl CF_PROG_GROFF version: 2 updated: 2015/07/04 11:16:27
19230bd37d32Smrgdnl -------------
19240bd37d32Smrgdnl Check if groff is available, for cases (such as html output) where nroff
19250bd37d32Smrgdnl is not enough.
19260bd37d32SmrgAC_DEFUN([CF_PROG_GROFF],[
19270bd37d32SmrgAC_PATH_PROG(GROFF_PATH,groff,no)
19282e4f8982SmrgAC_PATH_PROG(NROFF_PATH,nroff,no)
19290bd37d32Smrgif test "x$GROFF_PATH" = xno
19300bd37d32Smrgthen
19310bd37d32Smrg	NROFF_NOTE=
19320bd37d32Smrg	GROFF_NOTE="#"
19330bd37d32Smrgelse
19340bd37d32Smrg	NROFF_NOTE="#"
19350bd37d32Smrg	GROFF_NOTE=
19360bd37d32Smrgfi
19370bd37d32SmrgAC_SUBST(GROFF_NOTE)
19380bd37d32SmrgAC_SUBST(NROFF_NOTE)
1939d522f475Smrg])dnl
1940d522f475Smrgdnl ---------------------------------------------------------------------------
19412e4f8982Smrgdnl CF_PROG_LINT version: 3 updated: 2016/05/22 15:25:54
19422e4f8982Smrgdnl ------------
19432e4f8982SmrgAC_DEFUN([CF_PROG_LINT],
19442e4f8982Smrg[
19452e4f8982SmrgAC_CHECK_PROGS(LINT, lint cppcheck splint)
19462e4f8982SmrgAC_SUBST(LINT_OPTS)
19472e4f8982Smrg])dnl
19482e4f8982Smrgdnl ---------------------------------------------------------------------------
19492e4f8982Smrgdnl CF_REGEX version: 12 updated: 2015/04/18 08:56:57
1950d522f475Smrgdnl --------
1951d522f475Smrgdnl Attempt to determine if we've got one of the flavors of regular-expression
1952d522f475Smrgdnl code that we can support.
1953d522f475SmrgAC_DEFUN([CF_REGEX],
1954d522f475Smrg[
195520d2c4d2Smrg
195620d2c4d2Smrgcf_regex_func=no
195720d2c4d2Smrg
19586879286fSmrgcf_regex_libs="regex re"
195901037d57Smrgcase $host_os in
196001037d57Smrg(mingw*)
19610bd37d32Smrg	cf_regex_libs="gnurx $cf_regex_libs"
19626879286fSmrg	;;
19636879286fSmrgesac
19646879286fSmrg
196520d2c4d2SmrgAC_CHECK_FUNC(regcomp,[cf_regex_func=regcomp],[
19666879286fSmrg	for cf_regex_lib in $cf_regex_libs
196720d2c4d2Smrg	do
196820d2c4d2Smrg		AC_CHECK_LIB($cf_regex_lib,regcomp,[
196920d2c4d2Smrg				CF_ADD_LIB($cf_regex_lib)
197020d2c4d2Smrg				cf_regex_func=regcomp
197120d2c4d2Smrg				break])
197220d2c4d2Smrg	done
197320d2c4d2Smrg])
197420d2c4d2Smrg
197520d2c4d2Smrgif test "$cf_regex_func" = no ; then
197620d2c4d2Smrg	AC_CHECK_FUNC(compile,[cf_regex_func=compile],[
197720d2c4d2Smrg		AC_CHECK_LIB(gen,compile,[
197820d2c4d2Smrg				CF_ADD_LIB(gen)
197920d2c4d2Smrg				cf_regex_func=compile])])
198020d2c4d2Smrgfi
198120d2c4d2Smrg
198220d2c4d2Smrgif test "$cf_regex_func" = no ; then
198320d2c4d2Smrg	AC_MSG_WARN(cannot find regular expression library)
198420d2c4d2Smrgfi
198520d2c4d2Smrg
198620d2c4d2SmrgAC_CACHE_CHECK(for regular-expression headers,cf_cv_regex_hdrs,[
198720d2c4d2Smrg
198820d2c4d2Smrgcf_cv_regex_hdrs=no
198901037d57Smrgcase $cf_regex_func in
199001037d57Smrg(compile)
199120d2c4d2Smrg	for cf_regex_hdr in regexp.h regexpr.h
199220d2c4d2Smrg	do
199320d2c4d2Smrg		AC_TRY_LINK([#include <$cf_regex_hdr>],[
199420d2c4d2Smrg			char *p = compile("", "", "", 0);
1995d522f475Smrg			int x = step("", "");
199620d2c4d2Smrg		],[
199720d2c4d2Smrg			cf_cv_regex_hdrs=$cf_regex_hdr
199820d2c4d2Smrg			break
199920d2c4d2Smrg		])
200020d2c4d2Smrg	done
200120d2c4d2Smrg	;;
200201037d57Smrg(*)
200320d2c4d2Smrg	for cf_regex_hdr in regex.h
200420d2c4d2Smrg	do
200520d2c4d2Smrg		AC_TRY_LINK([#include <sys/types.h>
200620d2c4d2Smrg#include <$cf_regex_hdr>],[
200720d2c4d2Smrg			regex_t *p;
200820d2c4d2Smrg			int x = regcomp(p, "", 0);
200920d2c4d2Smrg			int y = regexec(p, "", 0, 0, 0);
201020d2c4d2Smrg			regfree(p);
201120d2c4d2Smrg		],[
201220d2c4d2Smrg			cf_cv_regex_hdrs=$cf_regex_hdr
201320d2c4d2Smrg			break
201420d2c4d2Smrg		])
201520d2c4d2Smrg	done
201620d2c4d2Smrg	;;
201720d2c4d2Smrgesac
201820d2c4d2Smrg
2019d522f475Smrg])
202020d2c4d2Smrg
202101037d57Smrgcase $cf_cv_regex_hdrs in
20222e4f8982Smrg	(no)		AC_MSG_WARN(no regular expression header found) ;;
20232e4f8982Smrg	(regex.h)	AC_DEFINE(HAVE_REGEX_H_FUNCS,1,[Define to 1 to include regex.h for regular expressions]) ;;
20242e4f8982Smrg	(regexp.h)	AC_DEFINE(HAVE_REGEXP_H_FUNCS,1,[Define to 1 to include regexp.h for regular expressions]) ;;
20252e4f8982Smrg	(regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS,1,[Define to 1 to include regexpr.h for regular expressions]) ;;
2026d522f475Smrgesac
2027d522f475Smrg])dnl
2028d522f475Smrgdnl ---------------------------------------------------------------------------
202920d2c4d2Smrgdnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
2030d522f475Smrgdnl ----------------
2031d522f475Smrgdnl Remove all -U and -D options that refer to the given symbol from a list
2032d522f475Smrgdnl of C compiler options.  This works around the problem that not all
2033d522f475Smrgdnl compilers process -U and -D options from left-to-right, so a -U option
2034d522f475Smrgdnl cannot be used to cancel the effect of a preceding -D option.
2035d522f475Smrgdnl
2036d522f475Smrgdnl $1 = target (which could be the same as the source variable)
2037d522f475Smrgdnl $2 = source (including '$')
2038d522f475Smrgdnl $3 = symbol to remove
2039d522f475Smrgdefine([CF_REMOVE_DEFINE],
2040d522f475Smrg[
2041d522f475Smrg$1=`echo "$2" | \
204220d2c4d2Smrg	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
204320d2c4d2Smrg		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
204420d2c4d2Smrg])dnl
204520d2c4d2Smrgdnl ---------------------------------------------------------------------------
2046e0a2b6dfSmrgdnl CF_RPATH_HACK version: 11 updated: 2013/09/01 13:02:00
204720d2c4d2Smrgdnl -------------
204820d2c4d2SmrgAC_DEFUN([CF_RPATH_HACK],
204920d2c4d2Smrg[
205020d2c4d2SmrgAC_REQUIRE([CF_LD_RPATH_OPT])
205120d2c4d2SmrgAC_MSG_CHECKING(for updated LDFLAGS)
205220d2c4d2Smrgif test -n "$LD_RPATH_OPT" ; then
205320d2c4d2Smrg	AC_MSG_RESULT(maybe)
205420d2c4d2Smrg
205520d2c4d2Smrg	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
205620d2c4d2Smrg	cf_rpath_list="/usr/lib /lib"
205720d2c4d2Smrg	if test "$cf_ldd_prog" != no
205820d2c4d2Smrg	then
2059a1f3da82Smrg		cf_rpath_oops=
2060a1f3da82Smrg
206120d2c4d2SmrgAC_TRY_LINK([#include <stdio.h>],
206220d2c4d2Smrg		[printf("Hello");],
2063e0a2b6dfSmrg		[cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
2064e0a2b6dfSmrg		 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
2065a1f3da82Smrg
2066a1f3da82Smrg		# If we passed the link-test, but get a "not found" on a given library,
2067a1f3da82Smrg		# this could be due to inept reconfiguration of gcc to make it only
2068a1f3da82Smrg		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
2069a1f3da82Smrg		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
2070a1f3da82Smrg		# /usr/local libraries.
2071a1f3da82Smrg		if test -n "$cf_rpath_oops"
2072a1f3da82Smrg		then
2073a1f3da82Smrg			for cf_rpath_src in $cf_rpath_oops
2074a1f3da82Smrg			do
2075a1f3da82Smrg				for cf_rpath_dir in \
2076a1f3da82Smrg					/usr/local \
2077a1f3da82Smrg					/usr/pkg \
2078a1f3da82Smrg					/opt/sfw
2079a1f3da82Smrg				do
2080a1f3da82Smrg					if test -f $cf_rpath_dir/lib/$cf_rpath_src
2081a1f3da82Smrg					then
2082a1f3da82Smrg						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
2083a1f3da82Smrg						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
2084a1f3da82Smrg						break
2085a1f3da82Smrg					fi
2086a1f3da82Smrg				done
2087a1f3da82Smrg			done
2088a1f3da82Smrg		fi
208920d2c4d2Smrg	fi
209020d2c4d2Smrg
209120d2c4d2Smrg	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
209220d2c4d2Smrg
209320d2c4d2Smrg	CF_RPATH_HACK_2(LDFLAGS)
209420d2c4d2Smrg	CF_RPATH_HACK_2(LIBS)
209520d2c4d2Smrg
209620d2c4d2Smrg	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2097e0a2b6dfSmrgelse
2098e0a2b6dfSmrg	AC_MSG_RESULT(no)
209920d2c4d2Smrgfi
210020d2c4d2SmrgAC_SUBST(EXTRA_LDFLAGS)
210120d2c4d2Smrg])dnl
210220d2c4d2Smrgdnl ---------------------------------------------------------------------------
210301037d57Smrgdnl CF_RPATH_HACK_2 version: 7 updated: 2015/04/12 15:39:00
210420d2c4d2Smrgdnl ---------------
210520d2c4d2Smrgdnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
210620d2c4d2Smrgdnl EXTRA_LDFLAGS for each -L option found.
210720d2c4d2Smrgdnl
210820d2c4d2Smrgdnl $cf_rpath_list contains a list of directories to ignore.
210920d2c4d2Smrgdnl
211020d2c4d2Smrgdnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
211120d2c4d2Smrgdnl      but LIBS often has misplaced -L options.
211220d2c4d2SmrgAC_DEFUN([CF_RPATH_HACK_2],
211320d2c4d2Smrg[
211420d2c4d2SmrgCF_VERBOSE(...checking $1 [$]$1)
211520d2c4d2Smrg
211620d2c4d2Smrgcf_rpath_dst=
211720d2c4d2Smrgfor cf_rpath_src in [$]$1
211820d2c4d2Smrgdo
211901037d57Smrg	case $cf_rpath_src in
212001037d57Smrg	(-L*)
212120d2c4d2Smrg
212220d2c4d2Smrg		# check if this refers to a directory which we will ignore
212320d2c4d2Smrg		cf_rpath_skip=no
212420d2c4d2Smrg		if test -n "$cf_rpath_list"
212520d2c4d2Smrg		then
212620d2c4d2Smrg			for cf_rpath_item in $cf_rpath_list
212720d2c4d2Smrg			do
212820d2c4d2Smrg				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
212920d2c4d2Smrg				then
213020d2c4d2Smrg					cf_rpath_skip=yes
213120d2c4d2Smrg					break
213220d2c4d2Smrg				fi
213320d2c4d2Smrg			done
213420d2c4d2Smrg		fi
213520d2c4d2Smrg
213620d2c4d2Smrg		if test "$cf_rpath_skip" = no
213720d2c4d2Smrg		then
213820d2c4d2Smrg			# transform the option
213920d2c4d2Smrg			if test "$LD_RPATH_OPT" = "-R " ; then
214020d2c4d2Smrg				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
214120d2c4d2Smrg			else
214220d2c4d2Smrg				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
214320d2c4d2Smrg			fi
214420d2c4d2Smrg
214520d2c4d2Smrg			# if we have not already added this, add it now
214620d2c4d2Smrg			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
214720d2c4d2Smrg			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
214820d2c4d2Smrg			then
214920d2c4d2Smrg				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
215020d2c4d2Smrg				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
215120d2c4d2Smrg			fi
215220d2c4d2Smrg		fi
215320d2c4d2Smrg		;;
215420d2c4d2Smrg	esac
215520d2c4d2Smrg	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
215620d2c4d2Smrgdone
215720d2c4d2Smrg$1=$cf_rpath_dst
215820d2c4d2Smrg
215920d2c4d2SmrgCF_VERBOSE(...checked $1 [$]$1)
216020d2c4d2SmrgAC_SUBST(EXTRA_LDFLAGS)
2161d522f475Smrg])dnl
2162d522f475Smrgdnl ---------------------------------------------------------------------------
2163d522f475Smrgdnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
2164d522f475Smrgdnl -----------
2165d522f475Smrgdnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
2166d522f475Smrgdnl programs need this test).
2167d522f475Smrgdnl
2168d522f475Smrgdnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
2169d522f475Smrgdnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
2170d522f475Smrgdnl winsize declaration is left alone - we may revisit this if Apple choose to
2171d522f475Smrgdnl break that part of the interface as well.
2172d522f475SmrgAC_DEFUN([CF_SIGWINCH],
2173d522f475Smrg[
2174d522f475SmrgAC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
2175d522f475Smrg	AC_TRY_COMPILE([
2176d522f475Smrg#include <sys/types.h>
2177d522f475Smrg#include <sys/signal.h>
2178d522f475Smrg],[int x = SIGWINCH],
2179d522f475Smrg	[cf_cv_define_sigwinch=yes],
2180d522f475Smrg	[AC_TRY_COMPILE([
2181d522f475Smrg#undef _XOPEN_SOURCE
2182d522f475Smrg#undef _POSIX_SOURCE
2183d522f475Smrg#undef _POSIX_C_SOURCE
2184d522f475Smrg#include <sys/types.h>
2185d522f475Smrg#include <sys/signal.h>
2186d522f475Smrg],[int x = SIGWINCH],
2187d522f475Smrg	[cf_cv_define_sigwinch=maybe],
2188d522f475Smrg	[cf_cv_define_sigwinch=no])
2189d522f475Smrg])
2190d522f475Smrg])
2191d522f475Smrg
2192d522f475Smrgif test "$cf_cv_define_sigwinch" = maybe ; then
2193d522f475SmrgAC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
2194d522f475Smrgcf_cv_fixup_sigwinch=unknown
2195d522f475Smrgcf_sigwinch=32
2196d522f475Smrgwhile test $cf_sigwinch != 1
2197d522f475Smrgdo
2198d522f475Smrg	AC_TRY_COMPILE([
2199d522f475Smrg#undef _XOPEN_SOURCE
2200d522f475Smrg#undef _POSIX_SOURCE
2201d522f475Smrg#undef _POSIX_C_SOURCE
2202d522f475Smrg#include <sys/types.h>
2203d522f475Smrg#include <sys/signal.h>
2204d522f475Smrg],[
2205d522f475Smrg#if SIGWINCH != $cf_sigwinch
2206d522f475Smrgmake an error
2207d522f475Smrg#endif
2208d522f475Smrgint x = SIGWINCH],
2209d522f475Smrg	[cf_cv_fixup_sigwinch=$cf_sigwinch
2210d522f475Smrg	 break])
2211d522f475Smrg
2212d522f475Smrgcf_sigwinch=`expr $cf_sigwinch - 1`
2213d522f475Smrgdone
2214d522f475Smrg])
2215d522f475Smrg
2216d522f475Smrg	if test "$cf_cv_fixup_sigwinch" != unknown ; then
2217d522f475Smrg		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
2218d522f475Smrg	fi
2219d522f475Smrgfi
2220d522f475Smrg])dnl
2221d522f475Smrgdnl ---------------------------------------------------------------------------
22220bd37d32Smrgdnl CF_SIG_ATOMIC_T version: 3 updated: 2012/10/04 20:12:20
2223d522f475Smrgdnl ---------------
2224d522f475Smrgdnl signal handler, but there are some gcc depedencies in that recommendation.
2225d522f475Smrgdnl Try anyway.
2226d522f475SmrgAC_DEFUN([CF_SIG_ATOMIC_T],
2227d522f475Smrg[
2228d522f475SmrgAC_MSG_CHECKING(for signal global datatype)
2229d522f475SmrgAC_CACHE_VAL(cf_cv_sig_atomic_t,[
2230d522f475Smrg	for cf_type in \
2231d522f475Smrg		"volatile sig_atomic_t" \
2232d522f475Smrg		"sig_atomic_t" \
2233d522f475Smrg		"int"
2234d522f475Smrg	do
2235d522f475Smrg	AC_TRY_COMPILE([
2236d522f475Smrg#include <sys/types.h>
2237d522f475Smrg#include <signal.h>
2238d522f475Smrg#include <stdio.h>
2239d522f475Smrg
2240d522f475Smrgextern $cf_type x;
2241d522f475Smrg$cf_type x;
2242d522f475Smrgstatic void handler(int sig)
2243d522f475Smrg{
2244d522f475Smrg	x = 5;
2245d522f475Smrg}],
2246d522f475Smrg		[signal(SIGINT, handler);
2247d522f475Smrg		 x = 1],
2248d522f475Smrg		[cf_cv_sig_atomic_t=$cf_type],
2249d522f475Smrg		[cf_cv_sig_atomic_t=no])
2250d522f475Smrg		test "$cf_cv_sig_atomic_t" != no && break
2251d522f475Smrg	done
2252d522f475Smrg	])
2253d522f475SmrgAC_MSG_RESULT($cf_cv_sig_atomic_t)
22540bd37d32Smrgtest "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
2255d522f475Smrg])dnl
2256d522f475Smrgdnl ---------------------------------------------------------------------------
22570bd37d32Smrgdnl CF_STRUCT_LASTLOG version: 2 updated: 2012/10/04 20:12:20
2258d522f475Smrgdnl -----------------
2259d522f475Smrgdnl Check for header defining struct lastlog, ensure that its .ll_time member
2260d522f475Smrgdnl is compatible with time().
2261d522f475SmrgAC_DEFUN([CF_STRUCT_LASTLOG],
2262d522f475Smrg[
2263d522f475SmrgAC_CHECK_HEADERS(lastlog.h)
2264d522f475SmrgAC_CACHE_CHECK(for struct lastlog,cf_cv_struct_lastlog,[
2265d522f475SmrgAC_TRY_RUN([
2266d522f475Smrg#include <sys/types.h>
2267d522f475Smrg#include <time.h>
2268d522f475Smrg#include <lastlog.h>
2269d522f475Smrg
2270d522f475Smrgint main()
2271d522f475Smrg{
2272d522f475Smrg	struct lastlog data;
2273d522f475Smrg	return (sizeof(data.ll_time) != sizeof(time_t));
2274d522f475Smrg}],[
2275d522f475Smrgcf_cv_struct_lastlog=yes],[
2276d522f475Smrgcf_cv_struct_lastlog=no],[
2277d522f475Smrgcf_cv_struct_lastlog=unknown])])
2278d522f475Smrg
22790bd37d32Smrgtest $cf_cv_struct_lastlog != no && AC_DEFINE(USE_STRUCT_LASTLOG,1,[Define to 1 if we have struct lastlog])
2280d522f475Smrg])dnl
2281d522f475Smrgdnl ---------------------------------------------------------------------------
22820bd37d32Smrgdnl CF_SVR4 version: 5 updated: 2012/10/04 05:24:07
2283d522f475Smrgdnl -------
2284d522f475Smrgdnl Check if this is an SVR4 system.  We need the definition for xterm
2285d522f475SmrgAC_DEFUN([CF_SVR4],
2286d522f475Smrg[
2287d522f475SmrgAC_CHECK_LIB(elf, elf_begin,[
2288d522f475SmrgAC_CACHE_CHECK(if this is an SVR4 system, cf_cv_svr4,[
2289d522f475SmrgAC_TRY_COMPILE([
22900bd37d32Smrg#if defined(__CYGWIN__)
22910bd37d32Smrgmake an error
22920bd37d32Smrg#endif
2293d522f475Smrg#include <elf.h>
2294d522f475Smrg#include <sys/termio.h>
2295d522f475Smrg],[
2296d522f475Smrgstatic struct termio d_tio;
2297d522f475Smrg	d_tio.c_cc[VINTR] = 0;
2298d522f475Smrg	d_tio.c_cc[VQUIT] = 0;
2299d522f475Smrg	d_tio.c_cc[VERASE] = 0;
2300d522f475Smrg	d_tio.c_cc[VKILL] = 0;
2301d522f475Smrg	d_tio.c_cc[VEOF] = 0;
2302d522f475Smrg	d_tio.c_cc[VEOL] = 0;
2303d522f475Smrg	d_tio.c_cc[VMIN] = 0;
2304d522f475Smrg	d_tio.c_cc[VTIME] = 0;
2305d522f475Smrg	d_tio.c_cc[VLNEXT] = 0;
2306d522f475Smrg],
2307d522f475Smrg[cf_cv_svr4=yes],
2308d522f475Smrg[cf_cv_svr4=no])
2309d522f475Smrg])
2310d522f475Smrg])
23110bd37d32Smrgtest "$cf_cv_svr4" = yes && AC_DEFINE(SVR4,1,[Define to 1 if this is an SVR4 system])
2312d522f475Smrg])dnl
2313d522f475Smrgdnl ---------------------------------------------------------------------------
23140bd37d32Smrgdnl CF_SYSV version: 15 updated: 2012/10/04 05:24:07
2315d522f475Smrgdnl -------
2316d522f475Smrgdnl Check if this is a SYSV platform, e.g., as used in <X11/Xos.h>, and whether
2317d522f475Smrgdnl defining it will be helpful.  The following features are used to check:
2318d522f475Smrgdnl
2319d522f475Smrgdnl a) bona-fide SVSV doesn't use const for sys_errlist[].  Since this is a
2320d522f475Smrgdnl legacy (pre-ANSI) feature, const should not apply.  Modern systems only
2321d522f475Smrgdnl declare strerror().  Xos.h declares the legacy form of str_errlist[], and
2322d522f475Smrgdnl a compile-time error will result from trying to assign to a const array.
2323d522f475Smrgdnl
2324d522f475Smrgdnl b) compile with headers that exist on SYSV hosts.
2325d522f475Smrgdnl
2326d522f475Smrgdnl c) compile with type definitions that differ on SYSV hosts from standard C.
2327d522f475SmrgAC_DEFUN([CF_SYSV],
2328d522f475Smrg[
2329d522f475SmrgAC_CHECK_HEADERS( \
2330d522f475Smrgtermios.h \
2331d522f475Smrgstdlib.h \
2332d522f475SmrgX11/Intrinsic.h \
2333d522f475Smrg)
2334d522f475Smrg
2335d522f475SmrgAC_REQUIRE([CF_SYS_ERRLIST])
2336d522f475Smrg
2337d522f475SmrgAC_CACHE_CHECK(if we should define SYSV,cf_cv_sysv,[
2338d522f475SmrgAC_TRY_COMPILE([
2339d522f475Smrg#undef  SYSV
2340d522f475Smrg#define SYSV 1			/* get Xos.h to declare sys_errlist[] */
2341d522f475Smrg#ifdef HAVE_STDLIB_H
2342d522f475Smrg#include <stdlib.h>		/* look for wchar_t */
2343d522f475Smrg#endif
2344d522f475Smrg#ifdef HAVE_X11_INTRINSIC_H
2345d522f475Smrg#include <X11/Intrinsic.h>	/* Intrinsic.h has other traps... */
2346d522f475Smrg#endif
23470bd37d32Smrg#ifdef HAVE_TERMIOS_H		/* needed for HPUX 10.20 */
23480bd37d32Smrg#include <termios.h>
23490bd37d32Smrg#define STRUCT_TERMIOS struct termios
23500bd37d32Smrg#else
23510bd37d32Smrg#define STRUCT_TERMIOS struct termio
23520bd37d32Smrg#endif
2353d522f475Smrg#include <curses.h>
2354d522f475Smrg#include <term.h>		/* eliminate most BSD hacks */
2355d522f475Smrg#include <errno.h>		/* declare sys_errlist on older systems */
2356d522f475Smrg#include <sys/termio.h>		/* eliminate most of the remaining ones */
2357d522f475Smrg],[
2358d522f475Smrgstatic STRUCT_TERMIOS d_tio;
2359d522f475Smrg	d_tio.c_cc[VINTR] = 0;
2360d522f475Smrg	d_tio.c_cc[VQUIT] = 0;
2361d522f475Smrg	d_tio.c_cc[VERASE] = 0;
2362d522f475Smrg	d_tio.c_cc[VKILL] = 0;
2363d522f475Smrg	d_tio.c_cc[VEOF] = 0;
2364d522f475Smrg	d_tio.c_cc[VEOL] = 0;
2365d522f475Smrg	d_tio.c_cc[VMIN] = 0;
2366d522f475Smrg	d_tio.c_cc[VTIME] = 0;
2367d522f475Smrg#if defined(HAVE_SYS_ERRLIST) && !defined(DECL_SYS_ERRLIST)
2368d522f475Smrgsys_errlist[0] = "";		/* Cygwin mis-declares this */
2369d522f475Smrg#endif
2370d522f475Smrg],
2371d522f475Smrg[cf_cv_sysv=yes],
2372d522f475Smrg[cf_cv_sysv=no])
2373d522f475Smrg])
23740bd37d32Smrgtest "$cf_cv_sysv" = yes && AC_DEFINE(SYSV,1,[Define to 1 if this is an SYSV system])
2375d522f475Smrg])dnl
2376d522f475Smrgdnl ---------------------------------------------------------------------------
23770bd37d32Smrgdnl CF_SYSV_UTMP version: 6 updated: 2012/10/04 20:12:20
2378d522f475Smrgdnl ------------
2379d522f475Smrgdnl Check if this is a SYSV flavor of UTMP
2380d522f475SmrgAC_DEFUN([CF_SYSV_UTMP],
2381d522f475Smrg[
2382d522f475SmrgAC_CACHE_CHECK(if $cf_cv_have_utmp is SYSV flavor,cf_cv_sysv_utmp,[
2383d522f475Smrgtest "$cf_cv_have_utmp" = "utmp" && cf_prefix="ut" || cf_prefix="utx"
2384d522f475SmrgAC_TRY_LINK([
2385d522f475Smrg#include <sys/types.h>
2386d522f475Smrg#include <${cf_cv_have_utmp}.h>],[
2387d522f475Smrgstruct $cf_cv_have_utmp x;
2388d522f475Smrg	set${cf_prefix}ent ();
2389d522f475Smrg	get${cf_prefix}id(&x);
2390d522f475Smrg	put${cf_prefix}line(&x);
2391d522f475Smrg	end${cf_prefix}ent();],
2392d522f475Smrg	[cf_cv_sysv_utmp=yes],
2393d522f475Smrg	[cf_cv_sysv_utmp=no])
2394d522f475Smrg])
23950bd37d32Smrgtest $cf_cv_sysv_utmp = yes && AC_DEFINE(USE_SYSV_UTMP,1,[Define to 1 if utmp is SYSV flavor])
2396d522f475Smrg])dnl
2397d522f475Smrgdnl ---------------------------------------------------------------------------
2398d522f475Smrgdnl CF_SYS_ERRLIST version: 6 updated: 2001/12/30 13:03:23
2399d522f475Smrgdnl --------------
2400d522f475Smrgdnl Check for declaration of sys_nerr and sys_errlist in one of stdio.h and
2401d522f475Smrgdnl errno.h.  Declaration of sys_errlist on BSD4.4 interferes with our
2402d522f475Smrgdnl declaration.  Reported by Keith Bostic.
2403d522f475SmrgAC_DEFUN([CF_SYS_ERRLIST],
2404d522f475Smrg[
2405d522f475Smrg    CF_CHECK_ERRNO(sys_nerr)
2406d522f475Smrg    CF_CHECK_ERRNO(sys_errlist)
2407d522f475Smrg])dnl
2408d522f475Smrgdnl ---------------------------------------------------------------------------
24090bd37d32Smrgdnl CF_TERMIO_C_ISPEED version: 3 updated: 2012/10/04 20:12:20
2410d522f475Smrgdnl ------------------
2411d522f475Smrgdnl Check for SGI's broken redefinition of baud rates introduced in IRIX 6.5
2412d522f475Smrgdnl (there doesn't appear to be a useful predefined symbol).
2413d522f475SmrgAC_DEFUN([CF_TERMIO_C_ISPEED],
2414d522f475Smrg[
2415d522f475SmrgAC_CACHE_CHECK(for IRIX 6.5 baud-rate redefinitions,cf_cv_termio_c_ispeed,[
2416d522f475SmrgAC_TRY_COMPILE([
2417d522f475Smrg#include <sys/types.h>
2418d522f475Smrg#include <sys/termio.h>],[
2419d522f475Smrgstruct termio foo;
2420d522f475Smrgfoo.c_ispeed = B38400;
2421d522f475Smrgfoo.c_ospeed = B9600;
2422d522f475Smrg],[cf_cv_termio_c_ispeed=yes
2423d522f475Smrg],[cf_cv_termio_c_ispeed=no])
2424d522f475Smrg])
24250bd37d32Smrgtest "$cf_cv_termio_c_ispeed" = yes && AC_DEFINE(HAVE_TERMIO_C_ISPEED,1,[define 1 if we have IRIX 6.5 baud-rate redefinitions])
2426d522f475Smrg])dnl
2427d522f475Smrgdnl ---------------------------------------------------------------------------
242801037d57Smrgdnl CF_TRIM_X_LIBS version: 3 updated: 2015/04/12 15:39:00
2429e0a2b6dfSmrgdnl --------------
2430e0a2b6dfSmrgdnl Trim extra base X libraries added as a workaround for inconsistent library
2431e0a2b6dfSmrgdnl dependencies returned by "new" pkg-config files.
2432e0a2b6dfSmrgAC_DEFUN([CF_TRIM_X_LIBS],[
2433e0a2b6dfSmrg	for cf_trim_lib in Xmu Xt X11
2434e0a2b6dfSmrg	do
2435e0a2b6dfSmrg		case "$LIBS" in
243601037d57Smrg		(*-l$cf_trim_lib\ *-l$cf_trim_lib*)
2437e0a2b6dfSmrg			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
2438e0a2b6dfSmrg			CF_VERBOSE(..trimmed $LIBS)
2439e0a2b6dfSmrg			;;
2440e0a2b6dfSmrg		esac
2441e0a2b6dfSmrg	done
2442e0a2b6dfSmrg])
2443e0a2b6dfSmrgdnl ---------------------------------------------------------------------------
2444e0a2b6dfSmrgdnl CF_TRY_PKG_CONFIG version: 5 updated: 2013/07/06 21:27:06
244520d2c4d2Smrgdnl -----------------
244620d2c4d2Smrgdnl This is a simple wrapper to use for pkg-config, for libraries which may be
244720d2c4d2Smrgdnl available in that form.
244820d2c4d2Smrgdnl
244920d2c4d2Smrgdnl $1 = package name
245020d2c4d2Smrgdnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
245120d2c4d2Smrgdnl $3 = logic to use if pkg-config does not have the package
245220d2c4d2SmrgAC_DEFUN([CF_TRY_PKG_CONFIG],[
245320d2c4d2SmrgAC_REQUIRE([CF_PKG_CONFIG])
245420d2c4d2Smrg
245520d2c4d2Smrgif test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
245620d2c4d2Smrg	CF_VERBOSE(found package $1)
245720d2c4d2Smrg	cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
245820d2c4d2Smrg	cf_pkgconfig_libs="`$PKG_CONFIG --libs   $1 2>/dev/null`"
245920d2c4d2Smrg	CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
246020d2c4d2Smrg	CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
246120d2c4d2Smrg	CF_ADD_CFLAGS($cf_pkgconfig_incs)
246220d2c4d2Smrg	CF_ADD_LIBS($cf_pkgconfig_libs)
246320d2c4d2Smrg	ifelse([$2],,:,[$2])
246420d2c4d2Smrgelse
2465e0a2b6dfSmrg	cf_pkgconfig_incs=
2466e0a2b6dfSmrg	cf_pkgconfig_libs=
246720d2c4d2Smrg	ifelse([$3],,:,[$3])
246820d2c4d2Smrgfi
246920d2c4d2Smrg])
247020d2c4d2Smrgdnl ---------------------------------------------------------------------------
24710bd37d32Smrgdnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
24720bd37d32Smrgdnl -------------------
24730bd37d32Smrgdnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
24740bd37d32Smrgdnl can define it successfully.
24750bd37d32SmrgAC_DEFUN([CF_TRY_XOPEN_SOURCE],[
24760bd37d32SmrgAC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
24770bd37d32Smrg	AC_TRY_COMPILE([
24780bd37d32Smrg#include <stdlib.h>
24790bd37d32Smrg#include <string.h>
24800bd37d32Smrg#include <sys/types.h>
24810bd37d32Smrg],[
24820bd37d32Smrg#ifndef _XOPEN_SOURCE
24830bd37d32Smrgmake an error
24840bd37d32Smrg#endif],
24850bd37d32Smrg	[cf_cv_xopen_source=no],
24860bd37d32Smrg	[cf_save="$CPPFLAGS"
24870bd37d32Smrg	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
24880bd37d32Smrg	 AC_TRY_COMPILE([
24890bd37d32Smrg#include <stdlib.h>
24900bd37d32Smrg#include <string.h>
24910bd37d32Smrg#include <sys/types.h>
24920bd37d32Smrg],[
24930bd37d32Smrg#ifdef _XOPEN_SOURCE
24940bd37d32Smrgmake an error
24950bd37d32Smrg#endif],
24960bd37d32Smrg	[cf_cv_xopen_source=no],
24970bd37d32Smrg	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
24980bd37d32Smrg	CPPFLAGS="$cf_save"
24990bd37d32Smrg	])
25000bd37d32Smrg])
25010bd37d32Smrg
25020bd37d32Smrgif test "$cf_cv_xopen_source" != no ; then
25030bd37d32Smrg	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
25040bd37d32Smrg	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
25050bd37d32Smrg	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
25060bd37d32Smrg	CF_ADD_CFLAGS($cf_temp_xopen_source)
25070bd37d32Smrgfi
25080bd37d32Smrg])
25090bd37d32Smrgdnl ---------------------------------------------------------------------------
251001037d57Smrgdnl CF_TTY_GROUP version: 9 updated: 2015/04/12 15:39:00
2511d522f475Smrgdnl ------------
2512d522f475Smrgdnl Check if the system has a tty-group defined.  This is used in xterm when
2513d522f475Smrgdnl setting pty ownership.
2514d522f475SmrgAC_DEFUN([CF_TTY_GROUP],
2515d522f475Smrg[
2516d522f475SmrgAC_MSG_CHECKING(for explicit tty group name)
2517d522f475SmrgAC_ARG_WITH(tty-group,
2518d522f475Smrg	[  --with-tty-group=XXX    use XXX for the tty-group],
2519d522f475Smrg	[cf_tty_group=$withval],
2520d522f475Smrg	[cf_tty_group=auto...])
2521d522f475Smrgtest -z "$cf_tty_group"    && cf_tty_group=auto...
2522d522f475Smrgtest "$cf_tty_group" = yes && cf_tty_group=auto...
2523d522f475SmrgAC_MSG_RESULT($cf_tty_group)
2524d522f475Smrg
2525d522f475Smrgif test "$cf_tty_group" = "auto..." ; then
2526d522f475SmrgAC_CACHE_CHECK(for tty group name,cf_cv_tty_group_name,[
2527d522f475Smrg
2528d522f475Smrg# If we are configuring as root, it is hard to get a clue about the tty group.
2529d522f475Smrg# But we'll guess based on how our connection is set up - assuming it is done
2530d522f475Smrg# properly.
2531d522f475Smrg
2532d522f475Smrgcf_uid=`id | sed -e 's/^[^=]*=//' -e 's/(.*$//'`
2533d522f475Smrg# )vi
2534d522f475Smrgif test "$cf_uid" != 0 ; then
2535d522f475Smrgcf_cv_tty_group_name=
2536d522f475Smrgcf_tty_name=`tty`
2537d522f475Smrgtest "$cf_tty_name" = "not a tty" && cf_tty_name=/dev/tty
2538d522f475Smrgtest -z "$cf_tty_name" && cf_tty_name=/dev/tty
2539d522f475Smrgif test -c "$cf_tty_name"
2540d522f475Smrgthen
2541d522f475Smrg	cf_option="-l -L"
2542d522f475Smrg
2543d522f475Smrg	# Expect listing to have fields like this:
2544d522f475Smrg	#-rwxrwxrwx   1 user      group       34293 Jul 18 16:29 pathname
2545d522f475Smrg	ls $cf_option $cf_tty_name >conftest.out
2546d522f475Smrg	read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
2547d522f475Smrg	if test -z "$cf_rest" ; then
2548d522f475Smrg		cf_option="$cf_option -g"
2549d522f475Smrg		ls $cf_option $cf_tty_name >conftest.out
2550d522f475Smrg		read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
2551d522f475Smrg	fi
2552d522f475Smrg	rm -f conftest.out
2553d522f475Smrg	cf_cv_tty_group_name=$cf_grp
2554d522f475Smrgfi
2555d522f475Smrgfi
2556d522f475Smrg
2557d522f475Smrg# If we cannot deduce the tty group, fall back on hardcoded cases
2558d522f475Smrg
2559d522f475Smrgif test -z "$cf_cv_tty_group_name"
2560d522f475Smrgthen
256101037d57Smrgcase $host_os in
256201037d57Smrg(osf*)
2563d522f475Smrg	cf_cv_tty_group_name="terminal"
2564d522f475Smrg	;;
256501037d57Smrg(*)
2566d522f475Smrg	cf_cv_tty_group_name="unknown"
2567d522f475Smrg	if ( egrep '^tty:' /etc/group 2>/dev/null 1>/dev/null ) then
2568d522f475Smrg		cf_cv_tty_group_name="tty"
2569d522f475Smrg	fi
2570d522f475Smrg	;;
2571d522f475Smrgesac
2572d522f475Smrgfi
2573d522f475Smrg])
2574d522f475Smrgcf_tty_group="$cf_cv_tty_group_name"
2575d522f475Smrgelse
2576d522f475Smrg	# if configure option, always do this
25770bd37d32Smrg	AC_DEFINE(USE_TTY_GROUP,1,[Define to 1 if we have a tty groupname])
2578d522f475Smrgfi
2579d522f475Smrg
25800bd37d32SmrgAC_DEFINE_UNQUOTED(TTY_GROUP_NAME,"$cf_tty_group",[Define to the name use for tty group])
2581d522f475Smrg
2582d522f475Smrg# This is only a double-check that the group-name we obtained above really
2583d522f475Smrg# does apply to the device.  We cannot perform this test if we are in batch
2584d522f475Smrg# mode, or if we are cross-compiling.
2585d522f475Smrg
2586d522f475SmrgAC_CACHE_CHECK(if we may use the $cf_tty_group group,cf_cv_tty_group,[
2587d522f475Smrgcf_tty_name=`tty`
2588d522f475Smrgif test "$cf_tty_name" != "not a tty"
2589d522f475Smrgthen
2590d522f475SmrgAC_TRY_RUN([
2591d522f475Smrg#include <unistd.h>
2592d522f475Smrg#include <sys/types.h>
2593d522f475Smrg#include <sys/stat.h>
2594d522f475Smrg#include <grp.h>
2595d522f475Smrgint main()
2596d522f475Smrg{
2597d522f475Smrg	struct stat sb;
2598d522f475Smrg	struct group *ttygrp = getgrnam(TTY_GROUP_NAME);
2599d522f475Smrg	char *name = ttyname(0);
2600d522f475Smrg
2601d522f475Smrg	endgrent();
2602d522f475Smrg	if (ttygrp != 0
2603d522f475Smrg	 && name != 0
2604d522f475Smrg	 && stat(name, &sb) == 0
2605d522f475Smrg	 && sb.st_gid != getgid()
2606d522f475Smrg	 && sb.st_gid == ttygrp->gr_gid) {
2607d522f475Smrg		${cf_cv_main_return:-return} (0);
2608d522f475Smrg	}
2609d522f475Smrg	${cf_cv_main_return:-return} (1);
2610d522f475Smrg}
2611d522f475Smrg	],
2612d522f475Smrg	[cf_cv_tty_group=yes],
2613d522f475Smrg	[cf_cv_tty_group=no],
2614d522f475Smrg	[cf_cv_tty_group=unknown])
2615d522f475Smrgelif test "$cross_compiling" = yes; then
2616d522f475Smrg	cf_cv_tty_group=unknown
2617d522f475Smrgelse
2618d522f475Smrg	cf_cv_tty_group=yes
2619d522f475Smrgfi
2620d522f475Smrg])
2621d522f475Smrg
2622d522f475Smrgif test $cf_cv_tty_group = no ; then
2623d522f475Smrg	AC_MSG_WARN(Cannot use $cf_tty_group group)
2624d522f475Smrgelse
2625d522f475Smrg	AC_DEFINE(USE_TTY_GROUP)
2626d522f475Smrgfi
2627d522f475Smrg])dnl
2628d522f475Smrgdnl ---------------------------------------------------------------------------
26290bd37d32Smrgdnl CF_TYPE_CC_T version: 2 updated: 2012/10/04 20:12:20
26300bd37d32Smrgdnl ------------
26310bd37d32Smrgdnl	Check for cc_t type, used in termio.
26320bd37d32SmrgAC_DEFUN([CF_TYPE_CC_T],
26330bd37d32Smrg[
26340bd37d32SmrgAC_MSG_CHECKING(for cc_t in <termios.h> or <termio.h>)
26350bd37d32SmrgAC_CACHE_VAL(cf_cv_type_cc_t,[
26360bd37d32Smrg	AC_TRY_COMPILE([
26370bd37d32Smrg#include <sys/types.h>
26380bd37d32Smrg#if defined(HAVE_TERMIOS_H)
26390bd37d32Smrg#include <termios.h>
26400bd37d32Smrg#else
26410bd37d32Smrg#include <termio.h>
26420bd37d32Smrg#include <sys/ioctl.h>
26430bd37d32Smrg#endif
26440bd37d32Smrg],
26450bd37d32Smrg		[cc_t x],
26460bd37d32Smrg		[cf_cv_type_cc_t=yes],
26470bd37d32Smrg		[cf_cv_type_cc_t=no])
26480bd37d32Smrg	])
26490bd37d32SmrgAC_MSG_RESULT($cf_cv_type_cc_t)
26500bd37d32Smrgtest $cf_cv_type_cc_t = no && AC_DEFINE(cc_t, unsigned char,[Define to cc_t type used in termio])
26510bd37d32Smrg])dnl
26520bd37d32Smrgdnl ---------------------------------------------------------------------------
26530bd37d32Smrgdnl CF_TYPE_FD_MASK version: 3 updated: 2012/10/04 06:57:36
2654d522f475Smrgdnl ---------------
2655d522f475Smrgdnl Check for the declaration of fd_mask, which is like fd_set, associated
2656d522f475Smrgdnl with select().  The check for fd_set should have pulled in this as well,
2657d522f475Smrgdnl but there is a special case for Mac OS X, possibly other BSD-derived
2658d522f475Smrgdnl platforms.
2659d522f475SmrgAC_DEFUN([CF_TYPE_FD_MASK],
2660d522f475Smrg[
2661d522f475SmrgAC_REQUIRE([CF_TYPE_FD_SET])
2662d522f475Smrg
2663d522f475SmrgAC_CACHE_CHECK(for declaration of fd_mask,cf_cv_type_fd_mask,[
2664d522f475Smrg    if test x$cf_cv_type_fd_set = xX11/Xpoll.h ; then
2665d522f475Smrg        AC_TRY_COMPILE([
2666d522f475Smrg#include <X11/Xpoll.h>],[fd_mask x],,
2667d522f475Smrg        [CF_MSG_LOG(if we must define CSRG_BASED)
2668d522f475Smrg# Xosdefs.h on Mac OS X may not define this (but it should).
2669d522f475Smrg            AC_TRY_COMPILE([
2670d522f475Smrg#define CSRG_BASED
2671d522f475Smrg#include <X11/Xpoll.h>],[fd_mask x],
2672d522f475Smrg        cf_cv_type_fd_mask=CSRG_BASED)])
2673d522f475Smrg    else
2674d522f475Smrg        cf_cv_type_fd_mask=$cf_cv_type_fd_set
2675d522f475Smrg    fi
2676d522f475Smrg])
2677d522f475Smrgif test x$cf_cv_type_fd_mask = xCSRG_BASED ; then
26780bd37d32Smrg    AC_DEFINE(CSRG_BASED,1,[Define to 1 if needed for declaring fd_mask()])
2679d522f475Smrgfi
2680d522f475Smrg])dnl
2681d522f475Smrgdnl ---------------------------------------------------------------------------
26820bd37d32Smrgdnl CF_TYPE_FD_SET version: 5 updated: 2012/10/04 20:12:20
2683d522f475Smrgdnl --------------
2684d522f475Smrgdnl Check for the declaration of fd_set.  Some platforms declare it in
2685d522f475Smrgdnl <sys/types.h>, and some in <sys/select.h>, which requires <sys/types.h>.
2686d522f475Smrgdnl Finally, if we are using this for an X application, Xpoll.h may include
2687d522f475Smrgdnl <sys/select.h>, so we don't want to do it twice.
2688d522f475SmrgAC_DEFUN([CF_TYPE_FD_SET],
2689d522f475Smrg[
2690d522f475SmrgAC_CHECK_HEADERS(X11/Xpoll.h)
2691d522f475Smrg
2692d522f475SmrgAC_CACHE_CHECK(for declaration of fd_set,cf_cv_type_fd_set,
2693d522f475Smrg	[CF_MSG_LOG(sys/types alone)
2694d522f475SmrgAC_TRY_COMPILE([
2695d522f475Smrg#include <sys/types.h>],
2696d522f475Smrg	[fd_set x],
2697d522f475Smrg	[cf_cv_type_fd_set=sys/types.h],
2698d522f475Smrg	[CF_MSG_LOG(X11/Xpoll.h)
2699d522f475SmrgAC_TRY_COMPILE([
2700d522f475Smrg#ifdef HAVE_X11_XPOLL_H
2701d522f475Smrg#include <X11/Xpoll.h>
2702d522f475Smrg#endif],
2703d522f475Smrg	[fd_set x],
2704d522f475Smrg	[cf_cv_type_fd_set=X11/Xpoll.h],
2705d522f475Smrg	[CF_MSG_LOG(sys/select.h)
2706d522f475SmrgAC_TRY_COMPILE([
2707d522f475Smrg#include <sys/types.h>
2708d522f475Smrg#include <sys/select.h>],
2709d522f475Smrg	[fd_set x],
2710d522f475Smrg	[cf_cv_type_fd_set=sys/select.h],
2711d522f475Smrg	[cf_cv_type_fd_set=unknown])])])])
2712d522f475Smrgif test $cf_cv_type_fd_set = sys/select.h ; then
27130bd37d32Smrg	AC_DEFINE(USE_SYS_SELECT_H,1,[Define to 1 to include sys/select.h to declare fd_set])
2714d522f475Smrgfi
2715d522f475Smrg])
2716d522f475Smrgdnl ---------------------------------------------------------------------------
2717e39b573cSmrgdnl CF_UNDO_CFLAGS version: 1 updated: 2011/07/02 09:27:51
2718e39b573cSmrgdnl --------------
2719e39b573cSmrgdnl Remove flags from $CFLAGS or similar shell variable using sed.
2720e39b573cSmrgdnl $1 = variable
2721e39b573cSmrgdnl $2 = message
2722e39b573cSmrgdnl $3 = pattern to remove
2723e39b573cSmrgAC_DEFUN([CF_UNDO_CFLAGS],
2724e39b573cSmrg[
2725e39b573cSmrg	CF_VERBOSE(removing $2 flags from $1)
2726e39b573cSmrg	$1=`echo "[$]$1" | sed -e 's/$3//'`
2727e39b573cSmrg	CF_VERBOSE(...result [$]$1)
2728e39b573cSmrg])dnl
2729e39b573cSmrgdnl ---------------------------------------------------------------------------
2730d522f475Smrgdnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
2731d522f475Smrgdnl --------
2732d522f475Smrgdnl Make an uppercase version of a variable
2733d522f475Smrgdnl $1=uppercase($2)
2734d522f475SmrgAC_DEFUN([CF_UPPER],
2735d522f475Smrg[
2736d522f475Smrg$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2737d522f475Smrg])dnl
2738d522f475Smrgdnl ---------------------------------------------------------------------------
27390bd37d32Smrgdnl CF_UTEMPTER version: 4 updated: 2012/10/04 20:12:20
2740d522f475Smrgdnl -----------
2741d522f475Smrgdnl Try to link with utempter library
2742d522f475SmrgAC_DEFUN([CF_UTEMPTER],
2743d522f475Smrg[
2744d522f475SmrgAC_CACHE_CHECK(if we can link with utempter library,cf_cv_have_utempter,[
2745d522f475Smrgcf_save_LIBS="$LIBS"
274620d2c4d2SmrgCF_ADD_LIB(utempter)
2747d522f475SmrgAC_TRY_LINK([
2748d522f475Smrg#include <utempter.h>
2749d522f475Smrg],[
2750d522f475Smrg	addToUtmp("/dev/tty", 0, 1);
2751d522f475Smrg	removeFromUtmp();
2752d522f475Smrg],[
2753d522f475Smrg	cf_cv_have_utempter=yes],[
2754d522f475Smrg	cf_cv_have_utempter=no])
2755d522f475SmrgLIBS="$cf_save_LIBS"
2756d522f475Smrg])
2757d522f475Smrgif test "$cf_cv_have_utempter" = yes ; then
27580bd37d32Smrg	AC_DEFINE(USE_UTEMPTER,1,[Define to 1 if we can/should link with utempter])
275920d2c4d2Smrg	CF_ADD_LIB(utempter)
2760d522f475Smrgfi
2761d522f475Smrg])dnl
2762d522f475Smrgdnl ---------------------------------------------------------------------------
27630bd37d32Smrgdnl CF_UTMP version: 10 updated: 2012/10/04 20:12:20
2764d522f475Smrgdnl -------
2765d522f475Smrgdnl Check for UTMP/UTMPX headers
2766d522f475SmrgAC_DEFUN([CF_UTMP],
2767d522f475Smrg[
2768d522f475SmrgAC_REQUIRE([CF_LASTLOG])
2769d522f475Smrg
2770d522f475SmrgAC_CACHE_CHECK(for utmp implementation,cf_cv_have_utmp,[
2771d522f475Smrg	cf_cv_have_utmp=no
2772d522f475Smrgfor cf_header in utmpx utmp ; do
2773d522f475Smrgcf_utmp_includes="
2774d522f475Smrg#include <sys/types.h>
2775d522f475Smrg#include <${cf_header}.h>
2776d522f475Smrg#define getutent getutxent
2777d522f475Smrg#ifdef USE_LASTLOG
2778d522f475Smrg#include <lastlog.h>	/* may conflict with utmpx.h on Linux */
2779d522f475Smrg#endif
2780d522f475Smrg"
2781d522f475Smrg	AC_TRY_COMPILE([$cf_utmp_includes],
2782d522f475Smrg	[struct $cf_header x;
2783d522f475Smrg	 char *name = x.ut_name; /* utmp.h and compatible definitions */
2784d522f475Smrg	],
2785d522f475Smrg	[cf_cv_have_utmp=$cf_header
2786d522f475Smrg	 break],
2787d522f475Smrg	[
2788d522f475Smrg	AC_TRY_COMPILE([$cf_utmp_includes],
2789d522f475Smrg	[struct $cf_header x;
2790d522f475Smrg	 char *name = x.ut_user; /* utmpx.h must declare this */
2791d522f475Smrg	],
2792d522f475Smrg	[cf_cv_have_utmp=$cf_header
2793d522f475Smrg	 break
2794d522f475Smrg	])])
2795d522f475Smrgdone
2796d522f475Smrg])
2797d522f475Smrg
2798d522f475Smrgif test $cf_cv_have_utmp != no ; then
27990bd37d32Smrg	AC_DEFINE(HAVE_UTMP,1,[Define to 1 if the utmp interface is available])
28000bd37d32Smrg	test $cf_cv_have_utmp = utmpx && AC_DEFINE(UTMPX_FOR_UTMP,1,[Define if we have utmpx interface])
2801d522f475Smrg	CF_UTMP_UT_HOST
2802d522f475Smrg	CF_UTMP_UT_SYSLEN
2803d522f475Smrg	CF_UTMP_UT_NAME
2804d522f475Smrg	CF_UTMP_UT_XSTATUS
2805d522f475Smrg	CF_UTMP_UT_XTIME
2806d522f475Smrg	CF_UTMP_UT_SESSION
2807d522f475Smrg	CF_SYSV_UTMP
2808d522f475Smrgfi
2809d522f475Smrg])dnl
2810d522f475Smrgdnl ---------------------------------------------------------------------------
2811d522f475Smrgdnl CF_UTMP_GROUP version: 1 updated: 2005/10/06 20:29:29
2812d522f475Smrgdnl -------------
2813d522f475Smrgdnl Find the utmp/utmpx file and determine its group to allow setgid programs
2814d522f475Smrgdnl to manipulate it, e.g., when there is no intermediary.
2815d522f475SmrgAC_DEFUN([CF_UTMP_GROUP],[
2816d522f475SmrgAC_REQUIRE([CF_UTMP])
2817d522f475Smrgif test $cf_cv_have_utmp != no ; then
2818d522f475SmrgAC_CACHE_CHECK(for utmp/utmpx group,cf_cv_utmp_group,[
2819d522f475Smrgfor cf_utmp_path in /var/adm /var/run
2820d522f475Smrgdo
2821d522f475Smrg	for cf_utmp_file in utmpx utmp
2822d522f475Smrg	do
2823d522f475Smrg		if test -f $cf_utmp_path/$cf_utmp_file
2824d522f475Smrg		then
2825d522f475Smrg			cf_cv_utmp_group=root
2826d522f475Smrg
2827d522f475Smrg			cf_option="-l -L"
2828d522f475Smrg
2829d522f475Smrg			# Expect listing to have fields like this:
2830d522f475Smrg			#-r--r--r--   1 user      group       34293 Jul 18 16:29 pathname
2831d522f475Smrg			ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
2832d522f475Smrg			read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
2833d522f475Smrg			if test -z "$cf_rest" ; then
2834d522f475Smrg				cf_option="$cf_option -g"
2835d522f475Smrg				ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
2836d522f475Smrg				read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
2837d522f475Smrg			fi
2838d522f475Smrg			rm -f conftest
2839d522f475Smrg
2840d522f475Smrg			# If we have a pathname, and the date fields look right, assume we've
2841d522f475Smrg			# captured the group as well.
2842d522f475Smrg			if test -n "$cf_rest" ; then
2843d522f475Smrg				cf_test=`echo "${cf_date2}${cf_date3}" | sed -e 's/[[0-9:]]//g'`
2844d522f475Smrg				if test -z "$cf_test" ; then
2845d522f475Smrg					cf_cv_utmp_group=$cf_grp;
2846d522f475Smrg				fi
2847d522f475Smrg			fi
2848d522f475Smrg			break
2849d522f475Smrg		fi
2850d522f475Smrg	done
2851d522f475Smrg	test -n "$cf_cv_utmp_group" && break
2852d522f475Smrgdone
2853d522f475Smrg])
2854d522f475Smrgelse
2855d522f475Smrg	AC_MSG_ERROR(cannot find utmp group)
2856d522f475Smrgfi
2857d522f475Smrg])dnl
2858d522f475Smrgdnl ---------------------------------------------------------------------------
28590bd37d32Smrgdnl CF_UTMP_UT_HOST version: 8 updated: 2012/10/04 20:12:20
2860d522f475Smrgdnl ---------------
2861d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_host member
2862d522f475SmrgAC_DEFUN([CF_UTMP_UT_HOST],
2863d522f475Smrg[
2864d522f475Smrgif test $cf_cv_have_utmp != no ; then
2865d522f475SmrgAC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_host is declared)
2866d522f475SmrgAC_CACHE_VAL(cf_cv_have_utmp_ut_host,[
2867d522f475Smrg	AC_TRY_COMPILE([
2868d522f475Smrg#include <sys/types.h>
2869d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2870d522f475Smrg	[struct $cf_cv_have_utmp x; char *y = &x.ut_host[0]],
2871d522f475Smrg	[cf_cv_have_utmp_ut_host=yes],
2872d522f475Smrg	[cf_cv_have_utmp_ut_host=no])
2873d522f475Smrg	])
2874d522f475SmrgAC_MSG_RESULT($cf_cv_have_utmp_ut_host)
28750bd37d32Smrgtest $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])
2876d522f475Smrgfi
2877d522f475Smrg])dnl
2878d522f475Smrgdnl ---------------------------------------------------------------------------
287901037d57Smrgdnl CF_UTMP_UT_NAME version: 6 updated: 2015/04/12 15:39:00
2880d522f475Smrgdnl ---------------
2881d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_name member
2882d522f475SmrgAC_DEFUN([CF_UTMP_UT_NAME],
2883d522f475Smrg[
2884d522f475Smrgif test $cf_cv_have_utmp != no ; then
2885d522f475SmrgAC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_name is declared,cf_cv_have_utmp_ut_name,[
2886d522f475Smrg	cf_cv_have_utmp_ut_name=no
2887d522f475Smrgcf_utmp_includes="
2888d522f475Smrg#include <sys/types.h>
2889d522f475Smrg#include <${cf_cv_have_utmp}.h>
2890d522f475Smrg#define getutent getutxent
2891d522f475Smrg#ifdef USE_LASTLOG
2892d522f475Smrg#include <lastlog.h>		/* may conflict with utmpx.h on Linux */
2893d522f475Smrg#endif
2894d522f475Smrg"
2895d522f475Smrgfor cf_header in ut_name ut_user ; do
2896d522f475Smrg	AC_TRY_COMPILE([$cf_utmp_includes],
2897d522f475Smrg	[struct $cf_cv_have_utmp x;
2898d522f475Smrg	 char *name = x.$cf_header;
2899d522f475Smrg	],
2900d522f475Smrg	[cf_cv_have_utmp_ut_name=$cf_header
2901d522f475Smrg	 break])
2902d522f475Smrgdone
2903d522f475Smrg])
2904d522f475Smrg
290501037d57Smrgcase $cf_cv_have_utmp_ut_name in
290601037d57Smrg(no)
2907d522f475Smrg	AC_MSG_ERROR(Cannot find declaration for ut.ut_name)
2908d522f475Smrg	;;
290901037d57Smrg(ut_user)
29100bd37d32Smrg	AC_DEFINE(ut_name,ut_user,[Define to rename UTMP/UTMPX struct ut_name member])
2911d522f475Smrg	;;
2912d522f475Smrgesac
2913d522f475Smrgfi
2914d522f475Smrg])dnl
2915d522f475Smrgdnl ---------------------------------------------------------------------------
29160bd37d32Smrgdnl CF_UTMP_UT_SESSION version: 6 updated: 2012/10/04 20:12:20
2917d522f475Smrgdnl ------------------
2918d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_session member
2919d522f475SmrgAC_DEFUN([CF_UTMP_UT_SESSION],
2920d522f475Smrg[
2921d522f475Smrgif test $cf_cv_have_utmp != no ; then
2922d522f475SmrgAC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_session is declared, cf_cv_have_utmp_ut_session,[
2923d522f475Smrg	AC_TRY_COMPILE([
2924d522f475Smrg#include <sys/types.h>
2925d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2926d522f475Smrg	[struct $cf_cv_have_utmp x; long y = x.ut_session],
2927d522f475Smrg	[cf_cv_have_utmp_ut_session=yes],
2928d522f475Smrg	[cf_cv_have_utmp_ut_session=no])
2929d522f475Smrg])
2930d522f475Smrgif test $cf_cv_have_utmp_ut_session != no ; then
29310bd37d32Smrg	AC_DEFINE(HAVE_UTMP_UT_SESSION,1,[Define to 1 if UTMP/UTMPX struct defines ut_session member])
2932d522f475Smrgfi
2933d522f475Smrgfi
2934d522f475Smrg])dnl
2935d522f475Smrgdnl ---------------------------------------------------------------------------
29360bd37d32Smrgdnl CF_UTMP_UT_SYSLEN version: 2 updated: 2012/10/04 20:12:20
2937d522f475Smrgdnl -----------------
2938d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_syslen member
2939d522f475SmrgAC_DEFUN([CF_UTMP_UT_SYSLEN],
2940d522f475Smrg[
2941d522f475Smrgif test $cf_cv_have_utmp != no ; then
2942d522f475SmrgAC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_syslen is declared)
2943d522f475SmrgAC_CACHE_VAL(cf_cv_have_utmp_ut_syslen,[
2944d522f475Smrg	AC_TRY_COMPILE([
2945d522f475Smrg#include <sys/types.h>
2946d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2947d522f475Smrg	[struct $cf_cv_have_utmp x; int y = x.ut_syslen],
2948d522f475Smrg	[cf_cv_have_utmp_ut_syslen=yes],
2949d522f475Smrg	[cf_cv_have_utmp_ut_syslen=no])
2950d522f475Smrg	])
2951d522f475SmrgAC_MSG_RESULT($cf_cv_have_utmp_ut_syslen)
29520bd37d32Smrgtest $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])
2953d522f475Smrgfi
2954d522f475Smrg])dnl
2955d522f475Smrgdnl ---------------------------------------------------------------------------
29560bd37d32Smrgdnl CF_UTMP_UT_XSTATUS version: 4 updated: 2012/10/04 20:12:20
2957d522f475Smrgdnl ------------------
2958d522f475Smrgdnl Check for known variants on the UTMP/UTMPX struct's exit-status as reported
2959d522f475Smrgdnl by various people:
2960d522f475Smrgdnl
2961d522f475Smrgdnl	ut_exit.__e_exit (HPUX 11 - David Ellement, also in glibc2)
2962d522f475Smrgdnl	ut_exit.e_exit (SVR4)
2963d522f475Smrgdnl	ut_exit.ut_e_exit (os390 - Greg Smith)
2964d522f475Smrgdnl	ut_exit.ut_exit (Tru64 4.0f - Jeremie Petit, 4.0e - Tomas Vanhala)
2965d522f475Smrgdnl
2966d522f475Smrgdnl Note: utmp_xstatus is not a conventional compatibility definition in the
2967d522f475Smrgdnl system header files.
2968d522f475SmrgAC_DEFUN([CF_UTMP_UT_XSTATUS],
2969d522f475Smrg[
2970d522f475Smrgif test $cf_cv_have_utmp != no ; then
2971d522f475SmrgAC_CACHE_CHECK(for exit-status in $cf_cv_have_utmp,cf_cv_have_utmp_ut_xstatus,[
2972d522f475Smrgfor cf_result in \
2973d522f475Smrg	ut_exit.__e_exit \
2974d522f475Smrg	ut_exit.e_exit \
2975d522f475Smrg	ut_exit.ut_e_exit \
2976d522f475Smrg	ut_exit.ut_exit
2977d522f475Smrgdo
2978d522f475SmrgAC_TRY_COMPILE([
2979d522f475Smrg#include <sys/types.h>
2980d522f475Smrg#include <${cf_cv_have_utmp}.h>],
2981d522f475Smrg	[struct $cf_cv_have_utmp x; long y = x.$cf_result = 0],
2982d522f475Smrg	[cf_cv_have_utmp_ut_xstatus=$cf_result
2983d522f475Smrg	 break],
2984d522f475Smrg	[cf_cv_have_utmp_ut_xstatus=no])
2985d522f475Smrgdone
2986d522f475Smrg])
2987d522f475Smrgif test $cf_cv_have_utmp_ut_xstatus != no ; then
29880bd37d32Smrg	AC_DEFINE(HAVE_UTMP_UT_XSTATUS,1,[Define to 1 if UTMP/UTMPX has exit-status member])
29890bd37d32Smrg	AC_DEFINE_UNQUOTED(ut_xstatus,$cf_cv_have_utmp_ut_xstatus,[Define if needed to rename member ut_xstatus of UTMP/UTMPX])
2990d522f475Smrgfi
2991d522f475Smrgfi
2992d522f475Smrg])dnl
2993d522f475Smrgdnl ---------------------------------------------------------------------------
29940bd37d32Smrgdnl CF_UTMP_UT_XTIME version: 9 updated: 2012/10/04 20:12:20
2995d522f475Smrgdnl ----------------
2996d522f475Smrgdnl Check if UTMP/UTMPX struct defines ut_xtime member
2997d522f475SmrgAC_DEFUN([CF_UTMP_UT_XTIME],
2998d522f475Smrg[
2999d522f475Smrgif test $cf_cv_have_utmp != no ; then
3000d522f475SmrgAC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_xtime is declared, cf_cv_have_utmp_ut_xtime,[
3001d522f475Smrg	AC_TRY_COMPILE([
3002d522f475Smrg#include <sys/types.h>
3003d522f475Smrg#include <${cf_cv_have_utmp}.h>],
3004d522f475Smrg	[struct $cf_cv_have_utmp x; long y = x.ut_xtime = 0],
3005d522f475Smrg	[cf_cv_have_utmp_ut_xtime=yes],
3006d522f475Smrg	[AC_TRY_COMPILE([
3007d522f475Smrg#include <sys/types.h>
3008d522f475Smrg#include <${cf_cv_have_utmp}.h>],
3009d522f475Smrg	[struct $cf_cv_have_utmp x; long y = x.ut_tv.tv_sec],
3010d522f475Smrg	[cf_cv_have_utmp_ut_xtime=define],
3011d522f475Smrg	[cf_cv_have_utmp_ut_xtime=no])
3012d522f475Smrg	])
3013d522f475Smrg])
3014d522f475Smrgif test $cf_cv_have_utmp_ut_xtime != no ; then
30150bd37d32Smrg	AC_DEFINE(HAVE_UTMP_UT_XTIME,1,[Define to 1 if UTMP/UTMPX struct defines ut_xtime member])
3016d522f475Smrg	if test $cf_cv_have_utmp_ut_xtime = define ; then
30170bd37d32Smrg		AC_DEFINE(ut_xtime,ut_tv.tv_sec,[Define if needed to alternate name for utmpx.ut_xtime member])
3018d522f475Smrg	fi
3019d522f475Smrgfi
3020d522f475Smrgfi
3021d522f475Smrg])dnl
3022d522f475Smrgdnl ---------------------------------------------------------------------------
3023d522f475Smrgdnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
3024d522f475Smrgdnl ----------
3025d522f475Smrgdnl Use AC_VERBOSE w/o the warnings
3026d522f475SmrgAC_DEFUN([CF_VERBOSE],
3027d522f475Smrg[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
3028d522f475SmrgCF_MSG_LOG([$1])
3029d522f475Smrg])dnl
3030d522f475Smrgdnl ---------------------------------------------------------------------------
303101037d57Smrgdnl CF_WITH_APP_CLASS version: 3 updated: 2015/04/12 15:39:00
3032e39b573cSmrgdnl -----------------
3033e39b573cSmrgdnl Handle configure option "--with-app-class", setting the $APP_CLASS
3034e39b573cSmrgdnl variable, used for X resources.
3035e39b573cSmrgdnl
3036e39b573cSmrgdnl $1 = default value.
30370bd37d32SmrgAC_DEFUN([CF_WITH_APP_CLASS],[
3038e39b573cSmrgAC_MSG_CHECKING(for X applications class)
3039e39b573cSmrgAC_ARG_WITH(app-class,
3040e39b573cSmrg	[  --with-app-class=XXX    override X applications class (default $1)],
3041e39b573cSmrg	[APP_CLASS=$withval],
3042e39b573cSmrg	[APP_CLASS=$1])
3043e39b573cSmrg
304401037d57Smrgcase x$APP_CLASS in
304501037d57Smrg(*[[/@,%]]*)
3046e39b573cSmrg	AC_MSG_WARN(X applications class cannot contain punctuation)
3047e39b573cSmrg	APP_CLASS=$1
3048e39b573cSmrg	;;
304901037d57Smrg(x[[A-Z]]*)
3050e39b573cSmrg	;;
305101037d57Smrg(*)
3052e39b573cSmrg	AC_MSG_WARN([X applications class must start with capital, ignoring $APP_CLASS])
3053e39b573cSmrg	APP_CLASS=$1
3054e39b573cSmrg	;;
3055e39b573cSmrgesac
3056e39b573cSmrg
3057e39b573cSmrgAC_MSG_RESULT($APP_CLASS)
3058e39b573cSmrg
3059e39b573cSmrgAC_SUBST(APP_CLASS)
3060e39b573cSmrg])dnl
3061e39b573cSmrgdnl ---------------------------------------------------------------------------
306201037d57Smrgdnl CF_WITH_APP_DEFAULTS version: 6 updated: 2015/01/02 09:05:50
3063e39b573cSmrgdnl --------------------
3064e39b573cSmrgdnl Handle configure option "--with-app-defaults", setting these shell
3065e39b573cSmrgdnl variables:
30660bd37d32Smrgdnl
30670bd37d32Smrgdnl $APPSDIR is the option value, used for installing app-defaults files.
3068e39b573cSmrgdnl $no_appsdir is a "#" (comment) if "--without-app-defaults" is given.
30690bd37d32Smrgdnl
30700bd37d32Smrgdnl Most Linux's use this:
30710bd37d32Smrgdnl 	/usr/share/X11/app-defaults
30720bd37d32Smrgdnl Debian uses this:
30730bd37d32Smrgdnl 	/etc/X11/app-defaults
30740bd37d32Smrgdnl DragonFlyBSD ports uses this:
30750bd37d32Smrgdnl 	/usr/pkg/lib/X11/app-defaults
30760bd37d32Smrgdnl FreeBSD ports use these:
30770bd37d32Smrgdnl 	/usr/local/lib/X11/app-defaults
30780bd37d32Smrgdnl 	/usr/local/share/X11/app-defaults
30790bd37d32Smrgdnl Mandriva has these:
30800bd37d32Smrgdnl 	/usr/lib/X11/app-defaults
30810bd37d32Smrgdnl 	/usr/lib64/X11/app-defaults
30820bd37d32Smrgdnl NetBSD has these
30830bd37d32Smrgdnl 	/usr/X11R7/lib/X11/app-defaults
30840bd37d32Smrgdnl OpenSolaris uses
30850bd37d32Smrgdnl 	32-bit:
30860bd37d32Smrgdnl 	/usr/X11/etc/X11/app-defaults
30870bd37d32Smrgdnl 	/usr/X11/share/X11/app-defaults
30880bd37d32Smrgdnl 	/usr/X11/lib/X11/app-defaults
308901037d57Smrgdnl OSX uses
309001037d57Smrgdnl		/opt/local/share/X11/app-defaults (MacPorts)
309101037d57Smrgdnl		/opt/X11/share/X11/app-defaults (non-ports)
30920bd37d32Smrgdnl	64-bit:
30930bd37d32Smrgdnl 	/usr/X11/etc/X11/app-defaults
30940bd37d32Smrgdnl 	/usr/X11/share/X11/app-defaults (I mkdir'd this)
30950bd37d32Smrgdnl 	/usr/X11/lib/amd64/X11/app-defaults
30960bd37d32Smrgdnl Solaris10 uses (in this order):
30970bd37d32Smrgdnl 	/usr/openwin/lib/X11/app-defaults
30980bd37d32Smrgdnl 	/usr/X11/lib/X11/app-defaults
30990bd37d32SmrgAC_DEFUN([CF_WITH_APP_DEFAULTS],[
3100e39b573cSmrgAC_MSG_CHECKING(for directory to install resource files)
31010bd37d32SmrgAC_ARG_WITH(app-defaults,
31020bd37d32Smrg	[  --with-app-defaults=DIR directory in which to install resource files (EPREFIX/lib/X11/app-defaults)],
31030bd37d32Smrg	[APPSDIR=$withval],
31040bd37d32Smrg	[APPSDIR='${exec_prefix}/lib/X11/app-defaults'])
31050bd37d32Smrg
31060bd37d32Smrgif test "x[$]APPSDIR" = xauto
31070bd37d32Smrgthen
31080bd37d32Smrg	APPSDIR='${exec_prefix}/lib/X11/app-defaults'
31090bd37d32Smrg	for cf_path in \
311001037d57Smrg		/opt/local/share/X11/app-defaults \
311101037d57Smrg		/opt/X11/share/X11/app-defaults \
31120bd37d32Smrg		/usr/share/X11/app-defaults \
31130bd37d32Smrg		/usr/X11/share/X11/app-defaults \
31140bd37d32Smrg		/usr/X11/lib/X11/app-defaults \
31150bd37d32Smrg		/usr/lib/X11/app-defaults \
31160bd37d32Smrg		/etc/X11/app-defaults \
31170bd37d32Smrg		/usr/pkg/lib/X11/app-defaults \
31180bd37d32Smrg		/usr/X11R7/lib/X11/app-defaults \
31190bd37d32Smrg		/usr/X11R6/lib/X11/app-defaults \
31200bd37d32Smrg		/usr/X11R5/lib/X11/app-defaults \
31210bd37d32Smrg		/usr/X11R4/lib/X11/app-defaults \
31220bd37d32Smrg		/usr/local/lib/X11/app-defaults \
31230bd37d32Smrg		/usr/local/share/X11/app-defaults \
31240bd37d32Smrg		/usr/lib64/X11/app-defaults
31250bd37d32Smrg	do
31260bd37d32Smrg		if test -d "$cf_path" ; then
31270bd37d32Smrg			APPSDIR="$cf_path"
31280bd37d32Smrg			break
31290bd37d32Smrg		fi
31300bd37d32Smrg	done
31310bd37d32Smrgelse
31320bd37d32Smrg	cf_path=$APPSDIR
31330bd37d32Smrg	CF_PATH_SYNTAX(cf_path)
31340bd37d32Smrgfi
31350bd37d32Smrg
31360bd37d32SmrgAC_MSG_RESULT($APPSDIR)
31370bd37d32SmrgAC_SUBST(APPSDIR)
3138e39b573cSmrg
3139e39b573cSmrgno_appsdir=
31400bd37d32Smrgif test "$APPSDIR" = no
31410bd37d32Smrgthen
31420bd37d32Smrg	no_appsdir="#"
31430bd37d32Smrgelse
31440bd37d32Smrg	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(APPSDIR)"
31450bd37d32Smrgfi
3146e39b573cSmrgAC_SUBST(no_appsdir)
3147e39b573cSmrg])dnl
3148e39b573cSmrgdnl ---------------------------------------------------------------------------
31490bd37d32Smrgdnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
31500bd37d32Smrgdnl ----------------
31510bd37d32Smrgdnl Configure-option for dbmalloc.  The optional parameter is used to override
31520bd37d32Smrgdnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
31530bd37d32SmrgAC_DEFUN([CF_WITH_DBMALLOC],[
31540bd37d32SmrgCF_NO_LEAKS_OPTION(dbmalloc,
31550bd37d32Smrg	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
31560bd37d32Smrg	[USE_DBMALLOC])
31570bd37d32Smrg
31580bd37d32Smrgif test "$with_dbmalloc" = yes ; then
31590bd37d32Smrg	AC_CHECK_HEADER(dbmalloc.h,
31600bd37d32Smrg		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
31610bd37d32Smrgfi
31620bd37d32Smrg])dnl
31630bd37d32Smrgdnl ---------------------------------------------------------------------------
316401037d57Smrgdnl CF_WITH_DESKTOP_CATEGORY version: 5 updated: 2015/04/12 15:39:00
3165e39b573cSmrgdnl ------------------------
3166e39b573cSmrgdnl Taking into account the absence of standardization of desktop categories
3167e39b573cSmrgdnl take a look to see whether other applications on the current system are
3168e39b573cSmrgdnl assigned any/all of a set of suggested categories.
3169e39b573cSmrgdnl
3170e39b573cSmrgdnl $1 = program name
3171e39b573cSmrgdnl $2 = case-pattern to match comparable desktop files to obtain category
3172e39b573cSmrgdnl      This pattern may contain wildcards.
3173e39b573cSmrgdnl $3 = suggested categories, also a case-pattern but without wildcards,
31740bd37d32Smrgdnl      since it doubles as a default value for a shell case-statement.
31750bd37d32Smrgdnl $4 = categories to use if no match is found on the build-machine for the
31760bd37d32Smrgdnl      --with-desktop-category "auto" setting.
3177e39b573cSmrgdnl
3178e39b573cSmrgdnl The macro tells the configure script to substitute the $DESKTOP_CATEGORY
3179e39b573cSmrgdnl value.
3180e39b573cSmrgAC_DEFUN([CF_WITH_DESKTOP_CATEGORY],[
3181e39b573cSmrgAC_REQUIRE([CF_DISABLE_DESKTOP])
3182e39b573cSmrg
3183e39b573cSmrgif test -z "$desktop_utils"
3184e39b573cSmrgthen
3185e39b573cSmrg	AC_MSG_CHECKING(for requested desktop-category)
3186e39b573cSmrg	AC_ARG_WITH(desktop-category,
3187e39b573cSmrg		[  --with-desktop-category=XXX  one or more desktop catgories or auto],
3188e39b573cSmrg		[cf_desktop_want=$withval],
3189e39b573cSmrg		[cf_desktop_want=auto])
3190e39b573cSmrg	AC_MSG_RESULT($cf_desktop_want)
3191e39b573cSmrg
3192e39b573cSmrg	if test "$cf_desktop_want" = auto
3193e39b573cSmrg	then
3194e39b573cSmrg		rm -rf conftest*
3195e39b573cSmrg		cf_desktop_also=
3196e39b573cSmrg		for cf_desktop_dir in  \
3197e39b573cSmrg			/usr/share/app-install \
3198e39b573cSmrg			/usr/share/applications
3199e39b573cSmrg		do
3200e39b573cSmrg			if test -d $cf_desktop_dir
3201e39b573cSmrg			then
3202e39b573cSmrg				find $cf_desktop_dir -name '*.desktop' | \
3203e39b573cSmrg				while true
3204e39b573cSmrg				do
3205e39b573cSmrg					read cf_desktop_path
3206e39b573cSmrg					test -z "$cf_desktop_path" && break
3207e39b573cSmrg					cf_desktop_name=`basename $cf_desktop_path .desktop`
320801037d57Smrg					case $cf_desktop_name in
320901037d57Smrg					($1|*-$1|$2)
3210e39b573cSmrg						CF_VERBOSE(inspect $cf_desktop_path)
3211e39b573cSmrg						egrep '^Categories=' $cf_desktop_path | \
3212e39b573cSmrg							tr ';' '\n' | \
3213e39b573cSmrg							sed -e 's%^.*=%%' -e '/^$/d' >>conftest.1
3214e39b573cSmrg						;;
3215e39b573cSmrg					esac
3216e39b573cSmrg				done
3217e39b573cSmrg			fi
3218e39b573cSmrg		done
3219e39b573cSmrg		if test -s conftest.1
3220e39b573cSmrg		then
3221e39b573cSmrg			cf_desktop_last=
3222e39b573cSmrg			sort conftest.1 | \
3223e39b573cSmrg			while true
3224e39b573cSmrg			do
3225e39b573cSmrg				read cf_desktop_this
3226e39b573cSmrg				test -z "$cf_desktop_this" && break
322701037d57Smrg				case $cf_desktop_this in
322801037d57Smrg				(Qt*|GTK*|KDE*|GNOME*|*XFCE*|*Xfce*)
3229e39b573cSmrg					;;
323001037d57Smrg				($3)
3231e39b573cSmrg					test "x$cf_desktop_last" != "x$cf_desktop_this" && echo $cf_desktop_this >>conftest.2
3232e39b573cSmrg					;;
3233e39b573cSmrg				esac
3234e39b573cSmrg				cf_desktop_last=$cf_desktop_this
3235e39b573cSmrg			done
3236e39b573cSmrg			cf_desktop_want=`cat conftest.2 | tr '\n' ';'`
3237e39b573cSmrg		fi
32380bd37d32Smrg		if test -n "$cf_desktop_want"
32390bd37d32Smrg		then
32400bd37d32Smrg			if test "$cf_desktop_want" = auto
32410bd37d32Smrg			then
32420bd37d32Smrg				cf_desktop_want=
32430bd37d32Smrg			else
32440bd37d32Smrg				# do a sanity check on the semicolon-separated list, ignore on failure
32450bd37d32Smrg				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/[[^;]]//g'`
32460bd37d32Smrg				test -z "$cf_desktop_test" && cf_desktop_want=
32470bd37d32Smrg				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/^.*;$/./g'`
32480bd37d32Smrg				test -z "$cf_desktop_test" && cf_desktop_want=
32490bd37d32Smrg			fi
32500bd37d32Smrg		fi
32510bd37d32Smrg		if test -z "$cf_desktop_want"
32520bd37d32Smrg		then
32530bd37d32Smrg			cf_desktop_want="ifelse([$4],,ifelse([$3],,[Application;],[`echo "$3" | sed -e 's/\*//g' -e 's/|/;/g' -e 's/[[;]]*$/;/g'`]),[$4])"
32540bd37d32Smrg			CF_VERBOSE(no usable value found for desktop category, using $cf_desktop_want)
32550bd37d32Smrg		fi
3256e39b573cSmrg	fi
3257e39b573cSmrg	DESKTOP_CATEGORY=`echo "$cf_desktop_want" | sed -e 's/[[ ,]]/;/g'`
32580bd37d32Smrg	CF_VERBOSE(will use Categories=$DESKTOP_CATEGORY)
3259e39b573cSmrg	AC_SUBST(DESKTOP_CATEGORY)
3260e39b573cSmrgfi
3261e39b573cSmrg])
3262e39b573cSmrgdnl ---------------------------------------------------------------------------
32630bd37d32Smrgdnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
3264e39b573cSmrgdnl ---------------
32650bd37d32Smrgdnl Configure-option for dmalloc.  The optional parameter is used to override
32660bd37d32Smrgdnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
32670bd37d32SmrgAC_DEFUN([CF_WITH_DMALLOC],[
32680bd37d32SmrgCF_NO_LEAKS_OPTION(dmalloc,
32690bd37d32Smrg	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
32700bd37d32Smrg	[USE_DMALLOC])
32710bd37d32Smrg
32720bd37d32Smrgif test "$with_dmalloc" = yes ; then
32730bd37d32Smrg	AC_CHECK_HEADER(dmalloc.h,
32740bd37d32Smrg		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
32750bd37d32Smrgfi
32760bd37d32Smrg])dnl
32770bd37d32Smrgdnl ---------------------------------------------------------------------------
32780bd37d32Smrgdnl CF_WITH_ICONDIR version: 5 updated: 2012/07/22 09:18:02
32790bd37d32Smrgdnl ---------------
32800bd37d32Smrgdnl Handle configure option "--with-icondir", setting these shell variables:
32810bd37d32Smrgdnl
32820bd37d32Smrgdnl $ICONDIR is the option value, used for installing icon files.
3283e39b573cSmrgdnl $no_icondir is a "#" (comment) if "--without-icondir" is given.
3284e39b573cSmrgAC_DEFUN([CF_WITH_ICONDIR],[
3285e39b573cSmrgAC_MSG_CHECKING(for directory to install icons)
32860bd37d32SmrgAC_ARG_WITH(icondir,
32870bd37d32Smrg	[  --with-icondir=DIR      directory in which to install icons for desktop],
32880bd37d32Smrg	[ICONDIR=$withval],
32890bd37d32Smrg	[test -z "$ICONDIR" && ICONDIR=no])
32900bd37d32Smrg
32910bd37d32Smrgif test "x[$]ICONDIR" = xauto
32920bd37d32Smrgthen
32930bd37d32Smrg	ICONDIR='${datadir}/icons'
32940bd37d32Smrg	for cf_path in \
32950bd37d32Smrg		/usr/share/icons \
32960bd37d32Smrg		/usr/X11R6/share/icons
32970bd37d32Smrg	do
32980bd37d32Smrg		if test -d "$cf_path" ; then
32990bd37d32Smrg			ICONDIR="$cf_path"
33000bd37d32Smrg			break
33010bd37d32Smrg		fi
33020bd37d32Smrg	done
33030bd37d32Smrgelse
33040bd37d32Smrg	cf_path=$ICONDIR
33050bd37d32Smrg	CF_PATH_SYNTAX(cf_path)
33060bd37d32Smrgfi
33070bd37d32SmrgAC_MSG_RESULT($ICONDIR)
33080bd37d32SmrgAC_SUBST(ICONDIR)
3309e39b573cSmrg
3310e39b573cSmrgno_icondir=
33110bd37d32Smrgif test "$ICONDIR" = no
33120bd37d32Smrgthen
33130bd37d32Smrg	no_icondir="#"
33140bd37d32Smrgelse
33150bd37d32Smrg	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(ICONDIR)"
33160bd37d32Smrgfi
3317e39b573cSmrgAC_SUBST(no_icondir)
3318e39b573cSmrg])dnl
3319e39b573cSmrgdnl ---------------------------------------------------------------------------
332001037d57Smrgdnl CF_WITH_ICON_NAME version: 3 updated: 2015/04/12 15:39:00
33210bd37d32Smrgdnl -----------------
33220bd37d32Smrgdnl Allow a default icon-name to be overridden.
33230bd37d32Smrgdnl $1 = default icon name
33240bd37d32SmrgAC_DEFUN([CF_WITH_ICON_NAME],[
33250bd37d32SmrgAC_MSG_CHECKING(for the icon name)
33260bd37d32SmrgAC_ARG_WITH(icon-name,
33270bd37d32Smrg	[  --with-icon-name=XXXX   override icon name (default: $1)],
33280bd37d32Smrg	[ICON_NAME="$withval"],
33290bd37d32Smrg	[ICON_NAME=$1])
33300bd37d32Smrgcase "x$ICON_NAME" in
333101037d57Smrg(xyes|xno|x)
33320bd37d32Smrg	ICON_NAME=$1
33330bd37d32Smrg	;;
33340bd37d32Smrgesac
33350bd37d32SmrgAC_SUBST(ICON_NAME)
33360bd37d32SmrgAC_MSG_RESULT($ICON_NAME)
33370bd37d32Smrg])dnl
33380bd37d32Smrgdnl ---------------------------------------------------------------------------
333901037d57Smrgdnl CF_WITH_ICON_SYMLINK version: 2 updated: 2015/04/12 15:39:00
33400bd37d32Smrgdnl --------------------
33410bd37d32Smrgdnl Workaround for systems which are (mis)configured to map all icon references
33420bd37d32Smrgdnl for xterm into "xterm" name.  For instance, recent (2013) KDE ignores both
33430bd37d32Smrgdnl the name given in the .desktop file (xterm-color) and the application name
33440bd37d32Smrgdnl (xterm-dev).
33450bd37d32Smrgdnl
33460bd37d32Smrgdnl $1 = default icon name to use if symlink is wanted
33470bd37d32SmrgAC_DEFUN([CF_WITH_ICON_SYMLINK],[
33480bd37d32SmrgAC_MSG_CHECKING(for icon symlink to use)
33490bd37d32SmrgAC_ARG_WITH(icon-symlink,
33500bd37d32Smrg	[  --with-icon-symlink=XXX make symbolic link for icon name (default: $1)],
33510bd37d32Smrg	[ICON_SYMLINK="$withval"],
33520bd37d32Smrg	[ICON_SYMLINK=NONE])
33530bd37d32Smrgcase "x$ICON_SYMLINK" in
335401037d57Smrg(xyes)
33550bd37d32Smrg	ICON_SYMLINK=$1
33560bd37d32Smrg	;;
335701037d57Smrg(xno|x)
33580bd37d32Smrg	ICON_SYMLINK=NONE
33590bd37d32Smrg	;;
33600bd37d32Smrgesac
33610bd37d32SmrgAC_SUBST(ICON_SYMLINK)
33620bd37d32SmrgAC_MSG_RESULT($ICON_SYMLINK)
33630bd37d32Smrg])dnl
33640bd37d32Smrgdnl ---------------------------------------------------------------------------
336501037d57Smrgdnl CF_WITH_ICON_THEME version: 11 updated: 2015/04/12 15:39:00
33660bd37d32Smrgdnl ------------------
33670bd37d32Smrgdnl If asked, check for prerequisites and setup symbols to permit installing
33680bd37d32Smrgdnl one or more application icons in the Red Hat icon-theme directory
336901037d57Smrgdnl hierarchy.
33700bd37d32Smrgdnl
33710bd37d32Smrgdnl If the prerequisites are missing, give a warning and revert to the long-
33720bd37d32Smrgdnl standing pixmaps directory.
33730bd37d32Smrgdnl
33740bd37d32Smrgdnl Parameters:
33750bd37d32Smrgdnl
33760bd37d32Smrgdnl $1 = application icon.  This can be a list, and is not optional.
33770bd37d32Smrgdnl $2 = default theme (defaults to hicolor)
33780bd37d32Smrgdnl $3 = formats (defaults to list [.svg .png .xpm])
33790bd37d32Smrgdnl $4 = alternate icon if no theme is used (defaults to $1).
33800bd37d32Smrgdnl
33810bd37d32Smrgdnl Result:
33820bd37d32Smrgdnl ICON_NAME = basename of first item in $1
33830bd37d32Smrgdnl ICON_LIST = reprocessed $1
33840bd37d32Smrgdnl ICON_THEME = reprocessed $2
33850bd37d32Smrgdnl ICON_FORMAT = reprocessed $3
33860bd37d32SmrgAC_DEFUN([CF_WITH_ICON_THEME],
33870bd37d32Smrg[
33880bd37d32Smrgifelse([$1],,[
33890bd37d32Smrg	AC_MSG_ERROR([macro [CF_WITH_ICON_THEME] requires application-icon name])
33900bd37d32Smrg],[
33910bd37d32Smrg
33920bd37d32SmrgCF_WITH_PIXMAPDIR
33930bd37d32SmrgCF_WITH_ICONDIR
33940bd37d32Smrg
33950bd37d32SmrgAC_MSG_CHECKING(if icon theme should be used)
33960bd37d32SmrgAC_ARG_WITH(icon-theme,
33970bd37d32Smrg	[  --with-icon-theme=XXX   install icons into desktop theme (hicolor)],
33980bd37d32Smrg	[ICON_THEME=$withval],
33990bd37d32Smrg	[ICON_THEME=no])
34000bd37d32Smrg
340101037d57Smrgcase "x$ICON_THEME" in
340201037d57Smrg(xno)
34030bd37d32Smrg	;;
340401037d57Smrg(x|xyes)
34050bd37d32Smrg	ICON_THEME=ifelse([$2],,hicolor,$2)
34060bd37d32Smrg	;;
34070bd37d32Smrgesac
34080bd37d32SmrgAC_MSG_RESULT($ICON_THEME)
34090bd37d32Smrg
34100bd37d32Smrgif test "x$ICON_THEME" = xno
34110bd37d32Smrgthen
34120bd37d32Smrg	if test "x$ICONDIR" != xno
34130bd37d32Smrg	then
34140bd37d32Smrg		CF_VERBOSE(ignoring icondir without theme)
34150bd37d32Smrg		no_icondir="#"
34160bd37d32Smrg	fi
34170bd37d32Smrgelse
34180bd37d32Smrg	if test "x$ICONDIR" = xno
34190bd37d32Smrg	then
34200bd37d32Smrg		AC_MSG_ERROR(icondir must be set for icon theme)
34210bd37d32Smrg	fi
34220bd37d32Smrgfi
34230bd37d32Smrg
34240bd37d32Smrg: ${ICON_FORMAT:=ifelse([$3],,[".svg .png .xpm"],[$3])}
34250bd37d32Smrg
34260bd37d32Smrg# ICON_NAME=
34270bd37d32SmrgICON_LIST=
34280bd37d32Smrg
34290bd37d32Smrgifelse([$4],,[cf_icon_list=$1],[
34300bd37d32Smrgif test "x$ICON_THEME" != xno
34310bd37d32Smrgthen
34320bd37d32Smrg	cf_icon_list="$1"
34330bd37d32Smrgelse
34340bd37d32Smrg	cf_icon_list="$4"
34350bd37d32Smrgfi
34360bd37d32Smrg])
34370bd37d32Smrg
34380bd37d32SmrgAC_MSG_CHECKING([for icon(s) to install])
34390bd37d32Smrgfor cf_name in $cf_icon_list
34400bd37d32Smrgdo
34410bd37d32Smrg	CF_VERBOSE(using $ICON_FORMAT)
34420bd37d32Smrg	for cf_suffix in $ICON_FORMAT
34430bd37d32Smrg	do
34440bd37d32Smrg		cf_icon="${cf_name}${cf_suffix}"
34450bd37d32Smrg		cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
34460bd37d32Smrg		if test ! -f "${cf_left}"
34470bd37d32Smrg		then
34480bd37d32Smrg			if test "x$srcdir" != "x."
34490bd37d32Smrg			then
34500bd37d32Smrg				cf_icon="${srcdir}/${cf_left}"
34510bd37d32Smrg				cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
34520bd37d32Smrg				if test ! -f "${cf_left}"
34530bd37d32Smrg				then
34540bd37d32Smrg					continue
34550bd37d32Smrg				fi
34560bd37d32Smrg			else
34570bd37d32Smrg				continue
34580bd37d32Smrg			fi
34590bd37d32Smrg		fi
34600bd37d32Smrg		if test "x$ICON_THEME" != xno
34610bd37d32Smrg		then
34620bd37d32Smrg			cf_base=`basename $cf_left`
34630bd37d32Smrg			cf_trim=`echo "$cf_base" | sed -e 's/_[[0-9]][[0-9]]x[[0-9]][[0-9]]\././'`
346401037d57Smrg			case "x${cf_base}" in
346501037d57Smrg			(*:*)
34660bd37d32Smrg				cf_next=$cf_base
34670bd37d32Smrg				# user-defined mapping
34680bd37d32Smrg				;;
346901037d57Smrg			(*.png)
34700bd37d32Smrg				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'`
34710bd37d32Smrg				if test -z "$cf_size"
34720bd37d32Smrg				then
34730bd37d32Smrg					AC_MSG_WARN(cannot determine size of $cf_left)
34740bd37d32Smrg					continue
34750bd37d32Smrg				fi
34760bd37d32Smrg				cf_next="$cf_size/apps/$cf_trim"
34770bd37d32Smrg				;;
347801037d57Smrg			(*.svg)
34790bd37d32Smrg				cf_next="scalable/apps/$cf_trim"
34800bd37d32Smrg				;;
348101037d57Smrg			(*.xpm)
34820bd37d32Smrg				CF_VERBOSE(ignored XPM file in icon theme)
34830bd37d32Smrg				continue
34840bd37d32Smrg				;;
348501037d57Smrg			(*_[[0-9]][[0-9]]*x[[0-9]][[0-9]]*.*)
34860bd37d32Smrg				cf_size=`echo "$cf_left"|sed -e 's/^.*_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\..*$/\1/'`
34870bd37d32Smrg				cf_left=`echo "$cf_left"|sed -e 's/^\(.*\)_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\(\..*\)$/\1\3/'`
34880bd37d32Smrg				cf_next="$cf_size/apps/$cf_base"
34890bd37d32Smrg				;;
34900bd37d32Smrg			esac
34910bd37d32Smrg			CF_VERBOSE(adding $cf_next)
34920bd37d32Smrg			cf_icon="${cf_icon}:${cf_next}"
34930bd37d32Smrg		fi
34940bd37d32Smrg		test -n "$ICON_LIST" && ICON_LIST="$ICON_LIST "
34950bd37d32Smrg		ICON_LIST="$ICON_LIST${cf_icon}"
34960bd37d32Smrg		if test -z "$ICON_NAME"
34970bd37d32Smrg		then
34980bd37d32Smrg			ICON_NAME=`basename $cf_icon | sed -e 's/[[.:]].*//'`
34990bd37d32Smrg		fi
35000bd37d32Smrg	done
35010bd37d32Smrgdone
35020bd37d32Smrg
35030bd37d32Smrgif test -n "$verbose"
35040bd37d32Smrgthen
35050bd37d32Smrg	AC_MSG_CHECKING(result)
35060bd37d32Smrgfi
35070bd37d32SmrgAC_MSG_RESULT($ICON_LIST)
35080bd37d32Smrg
35090bd37d32Smrgif test -z "$ICON_LIST"
35100bd37d32Smrgthen
35110bd37d32Smrg	AC_MSG_ERROR(no icons found)
35120bd37d32Smrgfi
35130bd37d32Smrg])
35140bd37d32Smrg
35150bd37d32SmrgAC_MSG_CHECKING(for icon name)
35160bd37d32SmrgAC_MSG_RESULT($ICON_NAME)
35170bd37d32Smrg
35180bd37d32SmrgAC_SUBST(ICON_FORMAT)
35190bd37d32SmrgAC_SUBST(ICON_THEME)
35200bd37d32SmrgAC_SUBST(ICON_LIST)
35210bd37d32SmrgAC_SUBST(ICON_NAME)
35220bd37d32Smrg])dnl
35230bd37d32Smrgdnl ---------------------------------------------------------------------------
352401037d57Smrgdnl CF_WITH_IMAKE_CFLAGS version: 10 updated: 2015/04/12 15:39:00
3525d522f475Smrgdnl --------------------
3526d522f475Smrgdnl xterm and similar programs build more readily when propped up with imake's
3527d522f475Smrgdnl hand-tuned definitions.  If we do not use imake, provide fallbacks for the
3528d522f475Smrgdnl most common definitions that we're not likely to do by autoconf tests.
3529d522f475SmrgAC_DEFUN([CF_WITH_IMAKE_CFLAGS],[
3530d522f475SmrgAC_REQUIRE([CF_ENABLE_NARROWPROTO])
3531d522f475Smrg
3532d522f475SmrgAC_MSG_CHECKING(if we should use imake to help)
3533d522f475SmrgCF_ARG_DISABLE(imake,
3534d522f475Smrg	[  --disable-imake         disable use of imake for definitions],
3535d522f475Smrg	[enable_imake=no],
3536d522f475Smrg	[enable_imake=yes])
3537d522f475SmrgAC_MSG_RESULT($enable_imake)
3538d522f475Smrg
3539d522f475Smrgif test "$enable_imake" = yes ; then
354020d2c4d2Smrg	CF_IMAKE_CFLAGS(ifelse([$1],,,[$1]))
3541d522f475Smrgfi
3542d522f475Smrg
3543d522f475Smrgif test -n "$IMAKE" && test -n "$IMAKE_CFLAGS" ; then
3544d522f475Smrg	CF_ADD_CFLAGS($IMAKE_CFLAGS)
3545d522f475Smrgelse
3546d522f475Smrg	IMAKE_CFLAGS=
3547d522f475Smrg	IMAKE_LOADFLAGS=
3548d522f475Smrg	CF_VERBOSE(make fallback definitions)
3549d522f475Smrg
3550d522f475Smrg	# We prefer config.guess' values when we can get them, to avoid
3551d522f475Smrg	# inconsistent results with uname (AIX for instance).  However,
3552d522f475Smrg	# config.guess is not always consistent either.
3553d522f475Smrg	case $host_os in
355401037d57Smrg	(*[[0-9]].[[0-9]]*)
3555d522f475Smrg		UNAME_RELEASE="$host_os"
3556d522f475Smrg		;;
355701037d57Smrg	(*)
3558d522f475Smrg		UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
3559d522f475Smrg		;;
3560d522f475Smrg	esac
3561d522f475Smrg
3562d522f475Smrg	case .$UNAME_RELEASE in
356301037d57Smrg	(*[[0-9]].[[0-9]]*)
3564d522f475Smrg		OSMAJORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/\..*//'`
3565d522f475Smrg		OSMINORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/^[[^.]]*\.//' -e 's/\..*//' -e 's/[[^0-9]].*//' `
3566d522f475Smrg		test -z "$OSMAJORVERSION" && OSMAJORVERSION=1
3567d522f475Smrg		test -z "$OSMINORVERSION" && OSMINORVERSION=0
3568d522f475Smrg		IMAKE_CFLAGS="-DOSMAJORVERSION=$OSMAJORVERSION -DOSMINORVERSION=$OSMINORVERSION $IMAKE_CFLAGS"
3569d522f475Smrg		;;
3570d522f475Smrg	esac
3571d522f475Smrg
3572d522f475Smrg	# FUNCPROTO is standard with X11R6, but XFree86 drops it, leaving some
3573d522f475Smrg	# fallback/fragments for NeedPrototypes, etc.
3574d522f475Smrg	IMAKE_CFLAGS="-DFUNCPROTO=15 $IMAKE_CFLAGS"
3575d522f475Smrg
3576d522f475Smrg	# If this is not set properly, Xaw's scrollbars will not work
3577d522f475Smrg	if test "$enable_narrowproto" = yes ; then
3578d522f475Smrg		IMAKE_CFLAGS="-DNARROWPROTO=1 $IMAKE_CFLAGS"
3579d522f475Smrg	fi
3580d522f475Smrg
3581d522f475Smrg	# Other special definitions:
3582d522f475Smrg	case $host_os in
358301037d57Smrg	(aix*)
3584d522f475Smrg		# imake on AIX 5.1 defines AIXV3.  really.
3585d522f475Smrg		IMAKE_CFLAGS="-DAIXV3 -DAIXV4 $IMAKE_CFLAGS"
3586d522f475Smrg		;;
358701037d57Smrg	(irix[[56]].*)
3588d522f475Smrg		# these are needed to make SIGWINCH work in xterm
3589d522f475Smrg		IMAKE_CFLAGS="-DSYSV -DSVR4 $IMAKE_CFLAGS"
3590d522f475Smrg		;;
3591d522f475Smrg	esac
3592d522f475Smrg
3593d522f475Smrg	CF_ADD_CFLAGS($IMAKE_CFLAGS)
3594d522f475Smrg
3595d522f475Smrg	AC_SUBST(IMAKE_CFLAGS)
3596d522f475Smrg	AC_SUBST(IMAKE_LOADFLAGS)
3597d522f475Smrgfi
3598d522f475Smrg])dnl
3599d522f475Smrgdnl ---------------------------------------------------------------------------
36002e4f8982Smrgdnl CF_WITH_MAN2HTML version: 5 updated: 2015/08/20 04:51:36
360101037d57Smrgdnl ----------------
360201037d57Smrgdnl Check for man2html and groff.  Optionally prefer man2html over groff.
360301037d57Smrgdnl Generate a shell script which hides the differences between the two.
360401037d57Smrgdnl
360501037d57Smrgdnl We name that "man2html.tmp".
360601037d57Smrgdnl
360701037d57Smrgdnl The shell script can be removed later, e.g., using "make distclean".
360801037d57SmrgAC_DEFUN([CF_WITH_MAN2HTML],[
360901037d57SmrgAC_REQUIRE([CF_PROG_GROFF])
361001037d57Smrg
361101037d57SmrgAC_MSG_CHECKING(for program to convert manpage to html)
361201037d57SmrgAC_ARG_WITH(man2html,
361301037d57Smrg	[  --with-man2html=XXX     use XXX rather than groff],
361401037d57Smrg	[cf_man2html=$withval],
361501037d57Smrg	[cf_man2html=$GROFF_PATH])
361601037d57Smrg
361701037d57Smrgcf_with_groff=no
361801037d57Smrg
361901037d57Smrgcase $cf_man2html in
362001037d57Smrg(yes)
362101037d57Smrg	AC_MSG_RESULT(man2html)
362201037d57Smrg	AC_PATH_PROG(cf_man2html,man2html,no)
362301037d57Smrg	;;
362401037d57Smrg(no|groff|*/groff*)
362501037d57Smrg	cf_with_groff=yes
362601037d57Smrg	cf_man2html=$GROFF_PATH
362701037d57Smrg	AC_MSG_RESULT($cf_man2html)
362801037d57Smrg	;;
362901037d57Smrg(*)
363001037d57Smrg	AC_MSG_RESULT($cf_man2html)
363101037d57Smrg	;;
363201037d57Smrgesac
363301037d57Smrg
363401037d57SmrgMAN2HTML_TEMP="man2html.tmp"
363501037d57Smrg	cat >$MAN2HTML_TEMP <<CF_EOF
36362e4f8982Smrg#!$SHELL
363701037d57Smrg# Temporary script generated by CF_WITH_MAN2HTML
363801037d57Smrg# Convert inputs to html, sending result to standard output.
363901037d57Smrg#
364001037d57Smrg# Parameters:
36412e4f8982Smrg# \${1} = rootname of file to convert
36422e4f8982Smrg# \${2} = suffix of file to convert, e.g., "1"
36432e4f8982Smrg# \${3} = macros to use, e.g., "man"
364401037d57Smrg#
364501037d57SmrgROOT=\[$]1
364601037d57SmrgTYPE=\[$]2
364701037d57SmrgMACS=\[$]3
364801037d57Smrg
364901037d57Smrgunset LANG
365001037d57Smrgunset LC_ALL
365101037d57Smrgunset LC_CTYPE
365201037d57Smrgunset LANGUAGE
365301037d57SmrgGROFF_NO_SGR=stupid
365401037d57Smrgexport GROFF_NO_SGR
365501037d57Smrg
365601037d57SmrgCF_EOF
365701037d57Smrg
365801037d57Smrgif test "x$cf_with_groff" = xyes
365901037d57Smrgthen
366001037d57Smrg	MAN2HTML_NOTE="$GROFF_NOTE"
366101037d57Smrg	MAN2HTML_PATH="$GROFF_PATH"
366201037d57Smrg	cat >>$MAN2HTML_TEMP <<CF_EOF
36632e4f8982Smrg$SHELL -c "tbl \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
366401037d57SmrgCF_EOF
366501037d57Smrgelse
366601037d57Smrg	MAN2HTML_NOTE=""
366701037d57Smrg	CF_PATH_SYNTAX(cf_man2html)
366801037d57Smrg	MAN2HTML_PATH="$cf_man2html"
366901037d57Smrg	AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
367001037d57Smrg
367101037d57Smrg	# for this example, expect 3 lines of content, the remainder is head/foot
367201037d57Smrg	cat >conftest.in <<CF_EOF
367301037d57Smrg.TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
367401037d57Smrg.SH SECTION
367501037d57SmrgMARKER
367601037d57SmrgCF_EOF
367701037d57Smrg
367801037d57Smrg	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C nroff -man conftest.in >conftest.out
367901037d57Smrg
368001037d57Smrg	cf_man2html_1st=`fgrep -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
368101037d57Smrg	cf_man2html_top=`expr $cf_man2html_1st - 2`
368201037d57Smrg	cf_man2html_bot=`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`
368301037d57Smrg	cf_man2html_bot=`expr $cf_man2html_bot - 2 - $cf_man2html_top`
368401037d57Smrg	cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
368501037d57Smrg
368601037d57Smrg	AC_MSG_RESULT($cf_man2html_top_bot)
368701037d57Smrg
368801037d57Smrg	AC_MSG_CHECKING(for pagesize to use)
368901037d57Smrg	for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
369001037d57Smrg	do
369101037d57Smrg	cat >>conftest.in <<CF_EOF
369201037d57Smrg.nf
369301037d57Smrg0
369401037d57Smrg1
369501037d57Smrg2
369601037d57Smrg3
369701037d57Smrg4
369801037d57Smrg5
369901037d57Smrg6
370001037d57Smrg7
370101037d57Smrg8
370201037d57Smrg9
370301037d57SmrgCF_EOF
370401037d57Smrg	done
370501037d57Smrg
370601037d57Smrg	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C nroff -man conftest.in >conftest.out
370701037d57Smrg	cf_man2html_page=`fgrep -n HEAD1 conftest.out |tail -n 1 |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
370801037d57Smrg	test -z "$cf_man2html_page" && cf_man2html_page=99999
370901037d57Smrg	test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
371001037d57Smrg
371101037d57Smrg	rm -rf conftest*
371201037d57Smrg	AC_MSG_RESULT($cf_man2html_page)
371301037d57Smrg
371401037d57Smrg	cat >>$MAN2HTML_TEMP <<CF_EOF
371501037d57Smrg: \${MAN2HTML_PATH=$MAN2HTML_PATH}
371601037d57SmrgMAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title="\$ROOT\(\$TYPE\)" -compress -pgsize $cf_man2html_page"
371701037d57Smrgcase \${TYPE} in
371801037d57Smrg(ms)
371901037d57Smrg	tbl \${ROOT}.\${TYPE} | nroff -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
372001037d57Smrg	;;
372101037d57Smrg(*)
372201037d57Smrg	tbl \${ROOT}.\${TYPE} | nroff -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
372301037d57Smrg	;;
372401037d57Smrgesac
372501037d57SmrgCF_EOF
372601037d57Smrgfi
372701037d57Smrg
372801037d57Smrgchmod 700 $MAN2HTML_TEMP
372901037d57Smrg
373001037d57SmrgAC_SUBST(MAN2HTML_NOTE)
373101037d57SmrgAC_SUBST(MAN2HTML_PATH)
373201037d57SmrgAC_SUBST(MAN2HTML_TEMP)
373301037d57Smrg])dnl
373401037d57Smrgdnl ---------------------------------------------------------------------------
373501037d57Smrgdnl CF_WITH_PCRE version: 11 updated: 2015/04/12 15:39:00
3736d522f475Smrgdnl ------------
3737d522f475Smrgdnl Add PCRE (Perl-compatible regular expressions) to the build if it is
3738d522f475Smrgdnl available and the user requests it.  Assume the application will otherwise
3739d522f475Smrgdnl use the POSIX interface.
3740d522f475Smrgdnl
3741d522f475Smrgdnl TODO allow $withval to specify package location
3742d522f475SmrgAC_DEFUN([CF_WITH_PCRE],
3743d522f475Smrg[
374420d2c4d2SmrgAC_REQUIRE([CF_PKG_CONFIG])
374520d2c4d2Smrg
3746d522f475SmrgAC_MSG_CHECKING(if you want to use PCRE for regular-expressions)
3747d522f475SmrgAC_ARG_WITH(pcre,
3748d522f475Smrg	[  --with-pcre             use PCRE for regular-expressions])
3749d522f475Smrgtest -z "$with_pcre" && with_pcre=no
3750d522f475SmrgAC_MSG_RESULT($with_pcre)
3751d522f475Smrg
3752d522f475Smrgif test "$with_pcre" != no ; then
375320d2c4d2Smrg	CF_TRY_PKG_CONFIG(libpcre,,[
375420d2c4d2Smrg		AC_CHECK_LIB(pcre,pcre_compile,,
375520d2c4d2Smrg			AC_MSG_ERROR(Cannot find PCRE library))])
375620d2c4d2Smrg
37570bd37d32Smrg		AC_DEFINE(HAVE_LIB_PCRE,1,[Define to 1 if we can/should compile with the PCRE library])
375820d2c4d2Smrg
375901037d57Smrg		case $LIBS in
376001037d57Smrg		(*pcreposix*)
376120d2c4d2Smrg			;;
376201037d57Smrg		(*)
376320d2c4d2Smrg			AC_CHECK_LIB(pcreposix,pcreposix_regcomp,
37640bd37d32Smrg				[AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we should include pcreposix.h])
376520d2c4d2Smrg				 CF_ADD_LIB(pcreposix)],
376620d2c4d2Smrg				[AC_CHECK_LIB(pcreposix,regcomp,[
37670bd37d32Smrg					AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we should include pcreposix.h])
376820d2c4d2Smrg					CF_ADD_LIB(pcreposix)],
376920d2c4d2Smrg					AC_MSG_ERROR(Cannot find PCRE POSIX library)]))
377020d2c4d2Smrg			;;
377120d2c4d2Smrg		esac
3772d522f475Smrgfi
3773d522f475Smrg])dnl
3774d522f475Smrgdnl ---------------------------------------------------------------------------
37750bd37d32Smrgdnl CF_WITH_PIXMAPDIR version: 3 updated: 2012/07/22 09:18:02
37760bd37d32Smrgdnl -----------------
37770bd37d32Smrgdnl Handle configure option "--with-pixmapdir", setting these shell variables:
37780bd37d32Smrgdnl
37790bd37d32Smrgdnl $PIXMAPDIR is the option value, used for installing pixmap files.
37800bd37d32Smrgdnl $no_pixmapdir is a "#" (comment) if "--without-pixmapdir" is given.
37810bd37d32SmrgAC_DEFUN([CF_WITH_PIXMAPDIR],[
37820bd37d32SmrgAC_MSG_CHECKING(for directory to install pixmaps)
37830bd37d32SmrgAC_ARG_WITH(pixmapdir,
37840bd37d32Smrg	[  --with-pixmapdir=DIR    directory in which to install pixmaps (DATADIR/pixmaps)],
37850bd37d32Smrg	[PIXMAPDIR=$withval],
37860bd37d32Smrg	[test -z "$PIXMAPDIR" && PIXMAPDIR='${datadir}/pixmaps'])
37870bd37d32Smrg
37880bd37d32Smrgif test "x[$]PIXMAPDIR" = xauto
37890bd37d32Smrgthen
37900bd37d32Smrg	PIXMAPDIR='${datadir}/pixmaps'
37910bd37d32Smrg	for cf_path in \
37920bd37d32Smrg		/usr/share/pixmaps \
37930bd37d32Smrg		/usr/X11R6/share/pixmaps
37940bd37d32Smrg	do
37950bd37d32Smrg		if test -d "$cf_path" ; then
37960bd37d32Smrg			PIXMAPDIR="$cf_path"
37970bd37d32Smrg			break
37980bd37d32Smrg		fi
37990bd37d32Smrg	done
38000bd37d32Smrgelse
38010bd37d32Smrg	cf_path=$PIXMAPDIR
38020bd37d32Smrg	CF_PATH_SYNTAX(cf_path)
38030bd37d32Smrgfi
38040bd37d32SmrgAC_MSG_RESULT($PIXMAPDIR)
38050bd37d32SmrgAC_SUBST(PIXMAPDIR)
38060bd37d32Smrg
38070bd37d32Smrgno_pixmapdir=
38080bd37d32Smrgif test "$PIXMAPDIR" = no
38090bd37d32Smrgthen
38100bd37d32Smrg	no_pixmapdir="#"
38110bd37d32Smrgelse
38120bd37d32Smrg	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(PIXMAPDIR)"
38130bd37d32Smrgfi
38140bd37d32SmrgAC_SUBST(no_pixmapdir)
38150bd37d32Smrg])dnl
38160bd37d32Smrgdnl ---------------------------------------------------------------------------
38170bd37d32Smrgdnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
38180bd37d32Smrgdnl ----------------
38190bd37d32SmrgAC_DEFUN([CF_WITH_VALGRIND],[
38200bd37d32SmrgCF_NO_LEAKS_OPTION(valgrind,
38210bd37d32Smrg	[  --with-valgrind         test: use valgrind],
38220bd37d32Smrg	[USE_VALGRIND])
38230bd37d32Smrg])dnl
38240bd37d32Smrgdnl ---------------------------------------------------------------------------
38252e4f8982Smrgdnl CF_WITH_XINERAMA version: 1 updated: 2016/05/28 14:41:12
38262e4f8982Smrgdnl ----------------
38272e4f8982SmrgAC_DEFUN([CF_WITH_XINERAMA],
38282e4f8982Smrg[
38292e4f8982SmrgAC_MSG_CHECKING(if you want to use the Xinerama extension)
38302e4f8982SmrgAC_ARG_WITH(xinerama,
38312e4f8982Smrg[  --without-xinerama      do not use Xinerama extension for multiscreen support],
38322e4f8982Smrg	[cf_with_xinerama="$withval"],
38332e4f8982Smrg	[cf_with_xinerama=yes])
38342e4f8982SmrgAC_MSG_RESULT($cf_with_xinerama)
38352e4f8982Smrgif test "$cf_with_xinerama" = yes; then
38362e4f8982Smrg	CF_XINERAMA
38372e4f8982Smrgfi
38382e4f8982Smrg])dnl
38392e4f8982Smrgdnl ---------------------------------------------------------------------------
38400bd37d32Smrgdnl CF_WITH_XPM version: 3 updated: 2012/10/04 06:57:36
38410bd37d32Smrgdnl -----------
38420bd37d32Smrgdnl Test for Xpm library, update compiler/loader flags if it is wanted and
38430bd37d32Smrgdnl found.
38440bd37d32Smrgdnl
38450bd37d32Smrgdnl Also sets ICON_SUFFIX
38460bd37d32SmrgAC_DEFUN([CF_WITH_XPM],
38470bd37d32Smrg[
38480bd37d32SmrgICON_SUFFIX=.xbm
38490bd37d32Smrg
38500bd37d32Smrgcf_save_cppflags="${CPPFLAGS}"
38510bd37d32Smrgcf_save_ldflags="${LDFLAGS}"
38520bd37d32Smrg
38530bd37d32SmrgAC_MSG_CHECKING(if you want to use the Xpm library for colored icon)
38540bd37d32SmrgAC_ARG_WITH(xpm,
38550bd37d32Smrg[  --with-xpm=DIR          use Xpm library for colored icon, may specify path],
38560bd37d32Smrg	[cf_Xpm_library="$withval"],
38570bd37d32Smrg	[cf_Xpm_library=yes])
38580bd37d32SmrgAC_MSG_RESULT($cf_Xpm_library)
38590bd37d32Smrg
38600bd37d32Smrgif test "$cf_Xpm_library" != no ; then
38610bd37d32Smrg    if test "$cf_Xpm_library" != yes ; then
38620bd37d32Smrg	CPPFLAGS="$CPPFLAGS -I$withval/include"
38630bd37d32Smrg	LDFLAGS="$LDFLAGS -L$withval/lib"
38640bd37d32Smrg    fi
38650bd37d32Smrg    AC_CHECK_HEADER(X11/xpm.h,[
38660bd37d32Smrg	AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData,[
38670bd37d32Smrg	    AC_DEFINE(HAVE_LIBXPM,1,[Define to 1 if we should use Xpm library])
38680bd37d32Smrg	    ICON_SUFFIX=.xpm
38690bd37d32Smrg	    LIBS="-lXpm $LIBS"],
38700bd37d32Smrg	    [CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"],
38710bd37d32Smrg	    [-lX11 $X_LIBS])],
38720bd37d32Smrg	[CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"])
38730bd37d32Smrgfi
38740bd37d32Smrg
38750bd37d32SmrgAC_SUBST(ICON_SUFFIX)
38760bd37d32Smrg])dnl
38770bd37d32Smrgdnl ---------------------------------------------------------------------------
387801037d57Smrgdnl CF_XBOOL_RESULT version: 3 updated: 2015/04/12 15:39:00
38790bd37d32Smrgdnl ---------------
38800bd37d32Smrgdnl Translate an autoconf boolean yes/no into X11's booleans, e.g., True/False.
38810bd37d32Smrgdnl Allow for more than two values, e.g., "maybe", still using the same leading
38820bd37d32Smrgdnl capital convention.
38830bd37d32Smrgdnl
38840bd37d32Smrgdnl $1 = symbol to define
38850bd37d32Smrgdnl $2 = symbol holding value
38860bd37d32Smrgdnl $3 = description
38870bd37d32Smrgdefine([CF_XBOOL_RESULT],[
38880bd37d32SmrgAC_MSG_RESULT([$]$2)
388901037d57Smrgcase [$]$2 in
389001037d57Smrg(yes)
38910bd37d32Smrg	$2=true
38920bd37d32Smrg	;;
389301037d57Smrg(no)
38940bd37d32Smrg	$2=false
38950bd37d32Smrg	;;
38960bd37d32Smrgesac
38970bd37d32Smrgcf_xbool1=`echo "[$]$2"|sed -e 's/^\(.\).*/\1/'`
38980bd37d32SmrgCF_UPPER(cf_xbool1,$cf_xbool1)
38990bd37d32Smrgcf_xbool2=`echo "[$]$2"|sed -e 's/^.//'`
39000bd37d32Smrg$2=${cf_xbool1}${cf_xbool2}
39010bd37d32SmrgAC_DEFINE_UNQUOTED($1,[$]$2,$3)
39020bd37d32SmrgAC_SUBST($2)
39030bd37d32Smrg])
39040bd37d32Smrgdnl ---------------------------------------------------------------------------
390501037d57Smrgdnl CF_XINERAMA version: 2 updated: 2015/02/15 15:18:41
390601037d57Smrgdnl -----------
390701037d57SmrgAC_DEFUN([CF_XINERAMA],[
390801037d57SmrgCF_TRY_PKG_CONFIG(xinerama,[
390901037d57Smrg	AC_DEFINE(HAVE_X11_EXTENSIONS_XINERAMA_H)],[
391001037d57Smrg	AC_CHECK_LIB(Xinerama,XineramaQueryScreens,
391101037d57Smrg		[CF_ADD_LIB(Xinerama)
391201037d57Smrg		 AC_CHECK_HEADERS( \
391301037d57Smrg			X11/extensions/Xinerama.h \
391401037d57Smrg			)
391501037d57Smrg		])
391601037d57Smrg	])
391701037d57Smrg])dnl
391801037d57Smrgdnl ---------------------------------------------------------------------------
39190bd37d32Smrgdnl CF_XKB_BELL_EXT version: 4 updated: 2012/10/04 20:12:20
3920d522f475Smrgdnl ---------------
3921d522f475Smrgdnl Check for XKB bell extension
3922d522f475SmrgAC_DEFUN([CF_XKB_BELL_EXT],[
3923d522f475SmrgAC_CACHE_CHECK(for XKB Bell extension, cf_cv_xkb_bell_ext,[
3924d522f475SmrgAC_TRY_LINK([
3925956cc18dSsnj#include <X11/Intrinsic.h>
3926d522f475Smrg#include <X11/XKBlib.h>		/* has the prototype */
3927d522f475Smrg#include <X11/extensions/XKBbells.h>	/* has the XkbBI_xxx definitions */
3928d522f475Smrg],[
3929956cc18dSsnj	int x = (XkbBI_Info |XkbBI_MinorError |XkbBI_MajorError |XkbBI_TerminalBell |XkbBI_MarginBell);
3930956cc18dSsnj	Atom y;
3931956cc18dSsnj	XkbBell((Display *)0, (Widget)0, 0, y);
3932d522f475Smrg],[cf_cv_xkb_bell_ext=yes],[cf_cv_xkb_bell_ext=no])
3933d522f475Smrg])
39340bd37d32Smrgtest "$cf_cv_xkb_bell_ext" = yes && AC_DEFINE(HAVE_XKB_BELL_EXT,1,[Define 1 if we have XKB Bell extension])
39350bd37d32Smrg])
39360bd37d32Smrgdnl ---------------------------------------------------------------------------
39370bd37d32Smrgdnl CF_XKB_KEYCODE_TO_KEYSYM version: 2 updated: 2012/09/28 20:23:33
39380bd37d32Smrgdnl ------------------------
39390bd37d32Smrgdnl Some older vendor-unix systems made a practice of delivering fragments of
39400bd37d32Smrgdnl Xkb, requiring test-compiles.
39410bd37d32SmrgAC_DEFUN([CF_XKB_KEYCODE_TO_KEYSYM],[
39420bd37d32SmrgAC_CACHE_CHECK(if we can use XkbKeycodeToKeysym, cf_cv_xkb_keycode_to_keysym,[
39430bd37d32SmrgAC_TRY_COMPILE([
39440bd37d32Smrg#include <X11/Xlib.h>
39450bd37d32Smrg#include <X11/XKBlib.h>
39460bd37d32Smrg],[
39470bd37d32Smrg    KeySym keysym = XkbKeycodeToKeysym((Display *)0, 0, 0, 0);
39480bd37d32Smrg],[
39490bd37d32Smrgcf_cv_xkb_keycode_to_keysym=yes
39500bd37d32Smrg],[
39510bd37d32Smrgcf_cv_xkb_keycode_to_keysym=no
39520bd37d32Smrg])
39530bd37d32Smrg])
39540bd37d32Smrg
39550bd37d32Smrgif test $cf_cv_xkb_keycode_to_keysym = yes
39560bd37d32Smrgthen
39570bd37d32Smrg	AC_CHECK_FUNCS(XkbKeycodeToKeysym)
39580bd37d32Smrgfi
39590bd37d32Smrg])
39600bd37d32Smrgdnl ---------------------------------------------------------------------------
39610bd37d32Smrgdnl CF_XKB_QUERY_EXTENSION version: 2 updated: 2012/09/28 20:23:46
39620bd37d32Smrgdnl ----------------------
39630bd37d32Smrgdnl see ifdef in scrollbar.c - iron out here
39640bd37d32SmrgAC_DEFUN([CF_XKB_QUERY_EXTENSION],[
39650bd37d32SmrgAC_CACHE_CHECK(if we can use XkbQueryExtension, cf_cv_xkb_query_extension,[
39660bd37d32SmrgAC_TRY_COMPILE([
39670bd37d32Smrg#include <X11/Xlib.h>
39680bd37d32Smrg#include <X11/extensions/XKB.h>
39690bd37d32Smrg#include <X11/XKBlib.h>
39700bd37d32Smrg],[
39710bd37d32Smrg	int xkbmajor = XkbMajorVersion;
39720bd37d32Smrg	int xkbminor = XkbMinorVersion;
39730bd37d32Smrg	int xkbopcode, xkbevent, xkberror;
39740bd37d32Smrg
39750bd37d32Smrg	if (XkbLibraryVersion(&xkbmajor, &xkbminor)
39760bd37d32Smrg	    && XkbQueryExtension((Display *)0,
39770bd37d32Smrg				 &xkbopcode,
39780bd37d32Smrg				 &xkbevent,
39790bd37d32Smrg				 &xkberror,
39800bd37d32Smrg				 &xkbmajor,
39810bd37d32Smrg				 &xkbminor))
39820bd37d32Smrg		 return 0;
39830bd37d32Smrg],[
39840bd37d32Smrgcf_cv_xkb_query_extension=yes
39850bd37d32Smrg],[
39860bd37d32Smrgcf_cv_xkb_query_extension=no
39870bd37d32Smrg])
39880bd37d32Smrg])
39890bd37d32Smrg
39900bd37d32Smrgif test $cf_cv_xkb_query_extension = yes
39910bd37d32Smrgthen
39920bd37d32Smrg	AC_CHECK_FUNCS(XkbQueryExtension)
39930bd37d32Smrgfi
3994d522f475Smrg])
3995d522f475Smrgdnl ---------------------------------------------------------------------------
3996913cc679Smrgdnl CF_XOPEN_SOURCE version: 52 updated: 2016/08/27 12:21:42
3997d522f475Smrgdnl ---------------
3998d522f475Smrgdnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3999d522f475Smrgdnl or adapt to the vendor's definitions to get equivalent functionality,
4000d522f475Smrgdnl without losing the common non-POSIX features.
4001d522f475Smrgdnl
4002d522f475Smrgdnl Parameters:
4003d522f475Smrgdnl	$1 is the nominal value for _XOPEN_SOURCE
4004d522f475Smrgdnl	$2 is the nominal value for _POSIX_C_SOURCE
4005d522f475SmrgAC_DEFUN([CF_XOPEN_SOURCE],[
40060bd37d32SmrgAC_REQUIRE([AC_CANONICAL_HOST])
4007d522f475Smrg
400820d2c4d2Smrgcf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
400920d2c4d2Smrgcf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
401020d2c4d2Smrgcf_xopen_source=
4011d522f475Smrg
401201037d57Smrgcase $host_os in
401301037d57Smrg(aix[[4-7]]*)
401420d2c4d2Smrg	cf_xopen_source="-D_ALL_SOURCE"
401520d2c4d2Smrg	;;
4016913cc679Smrg(msys)
4017e39b573cSmrg	cf_XOPEN_SOURCE=600
4018e39b573cSmrg	;;
401901037d57Smrg(darwin[[0-8]].*)
402020d2c4d2Smrg	cf_xopen_source="-D_APPLE_C_SOURCE"
402120d2c4d2Smrg	;;
402201037d57Smrg(darwin*)
402320d2c4d2Smrg	cf_xopen_source="-D_DARWIN_C_SOURCE"
40240bd37d32Smrg	cf_XOPEN_SOURCE=
4025d522f475Smrg	;;
402601037d57Smrg(freebsd*|dragonfly*)
4027d522f475Smrg	# 5.x headers associate
4028d522f475Smrg	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
4029d522f475Smrg	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
4030d522f475Smrg	cf_POSIX_C_SOURCE=200112L
4031d522f475Smrg	cf_XOPEN_SOURCE=600
403220d2c4d2Smrg	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
403320d2c4d2Smrg	;;
403401037d57Smrg(hpux11*)
403520d2c4d2Smrg	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
4036d522f475Smrg	;;
403701037d57Smrg(hpux*)
403820d2c4d2Smrg	cf_xopen_source="-D_HPUX_SOURCE"
4039d522f475Smrg	;;
404001037d57Smrg(irix[[56]].*)
404120d2c4d2Smrg	cf_xopen_source="-D_SGI_SOURCE"
40420bd37d32Smrg	cf_XOPEN_SOURCE=
4043d522f475Smrg	;;
4044913cc679Smrg(linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
4045d522f475Smrg	CF_GNU_SOURCE
4046d522f475Smrg	;;
404701037d57Smrg(minix*)
404801037d57Smrg	cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
404901037d57Smrg	;;
405001037d57Smrg(mirbsd*)
40510bd37d32Smrg	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
40520bd37d32Smrg	cf_XOPEN_SOURCE=
40530bd37d32Smrg	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
4054d522f475Smrg	;;
405501037d57Smrg(netbsd*)
40560bd37d32Smrg	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
40570bd37d32Smrg	;;
405801037d57Smrg(openbsd[[4-9]]*)
40590bd37d32Smrg	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
40600bd37d32Smrg	cf_xopen_source="-D_BSD_SOURCE"
40610bd37d32Smrg	cf_XOPEN_SOURCE=600
4062d522f475Smrg	;;
406301037d57Smrg(openbsd*)
4064d522f475Smrg	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
4065d522f475Smrg	;;
406601037d57Smrg(osf[[45]]*)
406720d2c4d2Smrg	cf_xopen_source="-D_OSF_SOURCE"
4068d522f475Smrg	;;
406901037d57Smrg(nto-qnx*)
407020d2c4d2Smrg	cf_xopen_source="-D_QNX_SOURCE"
4071d522f475Smrg	;;
407201037d57Smrg(sco*)
4073d522f475Smrg	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
4074d522f475Smrg	;;
407501037d57Smrg(solaris2.*)
407620d2c4d2Smrg	cf_xopen_source="-D__EXTENSIONS__"
4077894e0ac8Smrg	cf_cv_xopen_source=broken
4078d522f475Smrg	;;
407901037d57Smrg(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
408001037d57Smrg	cf_XOPEN_SOURCE=
408101037d57Smrg	cf_POSIX_C_SOURCE=
408201037d57Smrg	;;
408301037d57Smrg(*)
40840bd37d32Smrg	CF_TRY_XOPEN_SOURCE
4085d522f475Smrg	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
4086d522f475Smrg	;;
4087d522f475Smrgesac
408820d2c4d2Smrg
408920d2c4d2Smrgif test -n "$cf_xopen_source" ; then
409001037d57Smrg	CF_ADD_CFLAGS($cf_xopen_source,true)
409120d2c4d2Smrgfi
40920bd37d32Smrg
40930bd37d32Smrgdnl In anything but the default case, we may have system-specific setting
40940bd37d32Smrgdnl which is still not guaranteed to provide all of the entrypoints that
40950bd37d32Smrgdnl _XOPEN_SOURCE would yield.
40960bd37d32Smrgif test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
40970bd37d32Smrg	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
40980bd37d32Smrg	AC_TRY_COMPILE([#include <stdlib.h>],[
40990bd37d32Smrg#ifndef _XOPEN_SOURCE
41000bd37d32Smrgmake an error
41010bd37d32Smrg#endif],
41020bd37d32Smrg	[cf_XOPEN_SOURCE_set=yes],
41030bd37d32Smrg	[cf_XOPEN_SOURCE_set=no])
41040bd37d32Smrg	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
41050bd37d32Smrg	if test $cf_XOPEN_SOURCE_set = yes
41060bd37d32Smrg	then
41070bd37d32Smrg		AC_TRY_COMPILE([#include <stdlib.h>],[
41080bd37d32Smrg#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
41090bd37d32Smrgmake an error
41100bd37d32Smrg#endif],
41110bd37d32Smrg		[cf_XOPEN_SOURCE_set_ok=yes],
41120bd37d32Smrg		[cf_XOPEN_SOURCE_set_ok=no])
41130bd37d32Smrg		if test $cf_XOPEN_SOURCE_set_ok = no
41140bd37d32Smrg		then
41150bd37d32Smrg			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
41160bd37d32Smrg		fi
41170bd37d32Smrg	else
41180bd37d32Smrg		CF_TRY_XOPEN_SOURCE
41190bd37d32Smrg	fi
41200bd37d32Smrgfi
4121d522f475Smrg])
4122d522f475Smrgdnl ---------------------------------------------------------------------------
412301037d57Smrgdnl CF_X_ATHENA version: 23 updated: 2015/04/12 15:39:00
4124d522f475Smrgdnl -----------
4125d522f475Smrgdnl Check for Xaw (Athena) libraries
4126d522f475Smrgdnl
4127d522f475Smrgdnl Sets $cf_x_athena according to the flavor of Xaw which is used.
4128d522f475SmrgAC_DEFUN([CF_X_ATHENA],
412920d2c4d2Smrg[
41306879286fSmrgcf_x_athena=${cf_x_athena:-Xaw}
4131d522f475Smrg
4132d522f475SmrgAC_MSG_CHECKING(if you want to link with Xaw 3d library)
4133d522f475Smrgwithval=
4134d522f475SmrgAC_ARG_WITH(Xaw3d,
4135d522f475Smrg	[  --with-Xaw3d            link with Xaw 3d library])
4136d522f475Smrgif test "$withval" = yes ; then
4137d522f475Smrg	cf_x_athena=Xaw3d
4138d522f475Smrg	AC_MSG_RESULT(yes)
4139d522f475Smrgelse
4140d522f475Smrg	AC_MSG_RESULT(no)
4141d522f475Smrgfi
4142d522f475Smrg
414301037d57SmrgAC_MSG_CHECKING(if you want to link with Xaw 3d xft library)
414401037d57Smrgwithval=
414501037d57SmrgAC_ARG_WITH(Xaw3dxft,
414601037d57Smrg	[  --with-Xaw3dxft         link with Xaw 3d xft library])
414701037d57Smrgif test "$withval" = yes ; then
414801037d57Smrg	cf_x_athena=Xaw3dxft
414901037d57Smrg	AC_MSG_RESULT(yes)
415001037d57Smrgelse
415101037d57Smrg	AC_MSG_RESULT(no)
415201037d57Smrgfi
415301037d57Smrg
4154d522f475SmrgAC_MSG_CHECKING(if you want to link with neXT Athena library)
4155d522f475Smrgwithval=
4156d522f475SmrgAC_ARG_WITH(neXtaw,
4157d522f475Smrg	[  --with-neXtaw           link with neXT Athena library])
4158d522f475Smrgif test "$withval" = yes ; then
4159d522f475Smrg	cf_x_athena=neXtaw
4160d522f475Smrg	AC_MSG_RESULT(yes)
4161d522f475Smrgelse
4162d522f475Smrg	AC_MSG_RESULT(no)
4163d522f475Smrgfi
4164d522f475Smrg
4165d522f475SmrgAC_MSG_CHECKING(if you want to link with Athena-Plus library)
4166d522f475Smrgwithval=
4167d522f475SmrgAC_ARG_WITH(XawPlus,
4168d522f475Smrg	[  --with-XawPlus          link with Athena-Plus library])
4169d522f475Smrgif test "$withval" = yes ; then
4170d522f475Smrg	cf_x_athena=XawPlus
4171d522f475Smrg	AC_MSG_RESULT(yes)
4172d522f475Smrgelse
4173d522f475Smrg	AC_MSG_RESULT(no)
4174d522f475Smrgfi
4175d522f475Smrg
4176d522f475Smrgcf_x_athena_lib=""
4177d522f475Smrg
417820d2c4d2Smrgif test "$PKG_CONFIG" != none ; then
417920d2c4d2Smrg	cf_athena_list=
418020d2c4d2Smrg	test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
418120d2c4d2Smrg	for cf_athena_pkg in \
418220d2c4d2Smrg		$cf_athena_list \
418320d2c4d2Smrg		${cf_x_athena} \
418420d2c4d2Smrg		${cf_x_athena}-devel \
418520d2c4d2Smrg		lib${cf_x_athena} \
418620d2c4d2Smrg		lib${cf_x_athena}-devel
418720d2c4d2Smrg	do
418820d2c4d2Smrg		CF_TRY_PKG_CONFIG($cf_athena_pkg,[
418920d2c4d2Smrg			cf_x_athena_lib="$cf_pkgconfig_libs"
419020d2c4d2Smrg			CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
419120d2c4d2Smrg			AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
41926879286fSmrg
4193e0a2b6dfSmrg			CF_TRIM_X_LIBS
4194e0a2b6dfSmrg
41956879286fSmrgAC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
41966879286fSmrgAC_TRY_LINK([
41976879286fSmrg#include <X11/Xmu/CharSet.h>
41986879286fSmrg],[
41996879286fSmrgint check = XmuCompareISOLatin1("big", "small")
42006879286fSmrg],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
42016879286fSmrg
42026879286fSmrg			if test "$cf_cv_xaw_compat" = no
42036879286fSmrg			then
42046879286fSmrg				# workaround for broken ".pc" files...
420501037d57Smrg				case "$cf_x_athena_lib" in
420601037d57Smrg				(*-lXmu*)
42076879286fSmrg					;;
420801037d57Smrg				(*)
42096879286fSmrg					CF_VERBOSE(work around broken package)
4210e0a2b6dfSmrg					cf_save_xmu="$LIBS"
4211e0a2b6dfSmrg					cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
4212e0a2b6dfSmrg					CF_TRY_PKG_CONFIG(xmu,[
4213e0a2b6dfSmrg							LIBS="$cf_save_xmu"
4214e0a2b6dfSmrg							CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
4215e0a2b6dfSmrg						],[
4216e0a2b6dfSmrg							CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
4217e0a2b6dfSmrg						])
4218e0a2b6dfSmrg					CF_TRIM_X_LIBS
42196879286fSmrg					;;
42206879286fSmrg				esac
42216879286fSmrg			fi
42226879286fSmrg
422320d2c4d2Smrg			break])
422420d2c4d2Smrg	done
422520d2c4d2Smrgfi
422620d2c4d2Smrg
422720d2c4d2Smrgif test -z "$cf_x_athena_lib" ; then
422820d2c4d2Smrg	CF_X_EXT
422920d2c4d2Smrg	CF_X_TOOLKIT
423020d2c4d2Smrg	CF_X_ATHENA_CPPFLAGS($cf_x_athena)
423120d2c4d2Smrg	CF_X_ATHENA_LIBS($cf_x_athena)
423220d2c4d2Smrgfi
4233d522f475Smrg])dnl
4234d522f475Smrgdnl ---------------------------------------------------------------------------
423520d2c4d2Smrgdnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
4236d522f475Smrgdnl --------------------
4237d522f475Smrgdnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
4238d522f475Smrgdnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
4239d522f475SmrgAC_DEFUN([CF_X_ATHENA_CPPFLAGS],
4240d522f475Smrg[
424120d2c4d2Smrgcf_x_athena_root=ifelse([$1],,Xaw,[$1])
424220d2c4d2Smrgcf_x_athena_inc=""
4243d522f475Smrg
4244d522f475Smrgfor cf_path in default \
4245d522f475Smrg	/usr/contrib/X11R6 \
4246d522f475Smrg	/usr/contrib/X11R5 \
4247d522f475Smrg	/usr/lib/X11R5 \
4248d522f475Smrg	/usr/local
4249d522f475Smrgdo
425020d2c4d2Smrg	if test -z "$cf_x_athena_inc" ; then
4251d522f475Smrg		cf_save="$CPPFLAGS"
4252d522f475Smrg		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
4253d522f475Smrg		if test $cf_path != default ; then
4254956cc18dSsnj			CPPFLAGS="$cf_save -I$cf_path/include"
4255d522f475Smrg			AC_MSG_CHECKING(for $cf_test in $cf_path)
4256d522f475Smrg		else
4257d522f475Smrg			AC_MSG_CHECKING(for $cf_test)
4258d522f475Smrg		fi
4259d522f475Smrg		AC_TRY_COMPILE([
4260d522f475Smrg#include <X11/Intrinsic.h>
4261d522f475Smrg#include <$cf_test>],[],
4262d522f475Smrg			[cf_result=yes],
4263d522f475Smrg			[cf_result=no])
4264d522f475Smrg		AC_MSG_RESULT($cf_result)
4265d522f475Smrg		if test "$cf_result" = yes ; then
426620d2c4d2Smrg			cf_x_athena_inc=$cf_path
4267d522f475Smrg			break
4268d522f475Smrg		else
4269d522f475Smrg			CPPFLAGS="$cf_save"
4270d522f475Smrg		fi
4271d522f475Smrg	fi
4272d522f475Smrgdone
4273d522f475Smrg
427420d2c4d2Smrgif test -z "$cf_x_athena_inc" ; then
4275d522f475Smrg	AC_MSG_WARN(
4276d522f475Smrg[Unable to successfully find Athena header files with test program])
427720d2c4d2Smrgelif test "$cf_x_athena_inc" != default ; then
427820d2c4d2Smrg	CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
4279d522f475Smrgfi
4280d522f475Smrg])
4281d522f475Smrgdnl ---------------------------------------------------------------------------
42820bd37d32Smrgdnl CF_X_ATHENA_LIBS version: 12 updated: 2011/07/17 19:55:02
4283d522f475Smrgdnl ----------------
4284d522f475Smrgdnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
4285d522f475Smrgdnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
4286d522f475SmrgAC_DEFUN([CF_X_ATHENA_LIBS],
4287d522f475Smrg[AC_REQUIRE([CF_X_TOOLKIT])
428820d2c4d2Smrgcf_x_athena_root=ifelse([$1],,Xaw,[$1])
4289d522f475Smrgcf_x_athena_lib=""
4290d522f475Smrg
4291d522f475Smrgfor cf_path in default \
4292d522f475Smrg	/usr/contrib/X11R6 \
4293d522f475Smrg	/usr/contrib/X11R5 \
4294d522f475Smrg	/usr/lib/X11R5 \
4295d522f475Smrg	/usr/local
4296d522f475Smrgdo
4297d522f475Smrg	for cf_lib in \
42980bd37d32Smrg		${cf_x_athena_root} \
42990bd37d32Smrg		${cf_x_athena_root}7 \
43000bd37d32Smrg		${cf_x_athena_root}6
43010bd37d32Smrg	do
43020bd37d32Smrg	for cf_libs in \
43030bd37d32Smrg		"-l$cf_lib -lXmu" \
43040bd37d32Smrg		"-l$cf_lib -lXpm -lXmu" \
43050bd37d32Smrg		"-l${cf_lib}_s -lXmu_s"
4306d522f475Smrg	do
4307d522f475Smrg		if test -z "$cf_x_athena_lib" ; then
4308d522f475Smrg			cf_save="$LIBS"
4309d522f475Smrg			cf_test=XawSimpleMenuAddGlobalActions
4310d522f475Smrg			if test $cf_path != default ; then
43110bd37d32Smrg				CF_ADD_LIBS(-L$cf_path/lib $cf_libs)
43120bd37d32Smrg				AC_MSG_CHECKING(for $cf_libs in $cf_path)
4313d522f475Smrg			else
43140bd37d32Smrg				CF_ADD_LIBS($cf_libs)
43150bd37d32Smrg				AC_MSG_CHECKING(for $cf_test in $cf_libs)
4316d522f475Smrg			fi
4317a1f3da82Smrg			AC_TRY_LINK([
4318a1f3da82Smrg#include <X11/Intrinsic.h>
4319a1f3da82Smrg#include <X11/$cf_x_athena_root/SimpleMenu.h>
4320a1f3da82Smrg],[
4321a1f3da82Smrg$cf_test((XtAppContext) 0)],
4322d522f475Smrg				[cf_result=yes],
4323d522f475Smrg				[cf_result=no])
4324d522f475Smrg			AC_MSG_RESULT($cf_result)
4325d522f475Smrg			if test "$cf_result" = yes ; then
43260bd37d32Smrg				cf_x_athena_lib="$cf_libs"
4327d522f475Smrg				break
4328d522f475Smrg			fi
4329d522f475Smrg			LIBS="$cf_save"
4330d522f475Smrg		fi
43310bd37d32Smrg	done # cf_libs
43320bd37d32Smrg		test -n "$cf_x_athena_lib" && break
43330bd37d32Smrg	done # cf_lib
4334d522f475Smrgdone
4335d522f475Smrg
4336d522f475Smrgif test -z "$cf_x_athena_lib" ; then
4337d522f475Smrg	AC_MSG_ERROR(
4338d522f475Smrg[Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
4339d522f475Smrgfi
4340d522f475Smrg
4341d522f475SmrgCF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
4342d522f475SmrgAC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
4343d522f475Smrg])
4344d522f475Smrgdnl ---------------------------------------------------------------------------
434520d2c4d2Smrgdnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
434620d2c4d2Smrgdnl --------
434720d2c4d2SmrgAC_DEFUN([CF_X_EXT],[
434820d2c4d2SmrgCF_TRY_PKG_CONFIG(Xext,,[
434920d2c4d2Smrg	AC_CHECK_LIB(Xext,XextCreateExtension,
435020d2c4d2Smrg		[CF_ADD_LIB(Xext)])])
435120d2c4d2Smrg])dnl
435220d2c4d2Smrgdnl ---------------------------------------------------------------------------
435301037d57Smrgdnl CF_X_FONTCONFIG version: 6 updated: 2015/04/12 15:39:00
43546879286fSmrgdnl ---------------
43556879286fSmrgdnl Check for fontconfig library, a dependency of the X FreeType library.
43566879286fSmrgAC_DEFUN([CF_X_FONTCONFIG],
43576879286fSmrg[
43586879286fSmrgAC_REQUIRE([CF_X_FREETYPE])
43596879286fSmrg
4360e39b573cSmrgif test "$cf_cv_found_freetype" = yes ; then
43616879286fSmrgAC_CACHE_CHECK(for usable Xft/fontconfig package,cf_cv_xft_compat,[
43626879286fSmrgAC_TRY_LINK([
43636879286fSmrg#include <X11/Xft/Xft.h>
43646879286fSmrg],[
43656879286fSmrg	XftPattern *pat;
43666879286fSmrg	XftPatternBuild(pat,
43676879286fSmrg					XFT_FAMILY, XftTypeString, "mono",
43686879286fSmrg					(void *) 0);
43696879286fSmrg],[cf_cv_xft_compat=yes],[cf_cv_xft_compat=no])
43706879286fSmrg])
43716879286fSmrg
43726879286fSmrgif test "$cf_cv_xft_compat" = no
43736879286fSmrgthen
43746879286fSmrg	# workaround for broken ".pc" files used for Xft.
437501037d57Smrg	case "$cf_cv_x_freetype_libs" in
437601037d57Smrg	(*-lfontconfig*)
43776879286fSmrg		;;
437801037d57Smrg	(*)
43796879286fSmrg		CF_VERBOSE(work around broken package)
4380e0a2b6dfSmrg		cf_save_fontconfig="$LIBS"
4381e0a2b6dfSmrg		CF_TRY_PKG_CONFIG(fontconfig,[
4382e0a2b6dfSmrg				CF_ADD_CFLAGS($cf_pkgconfig_incs)
4383e0a2b6dfSmrg				LIBS="$cf_save_fontconfig"
4384e0a2b6dfSmrg				CF_ADD_LIB_AFTER(-lXft,$cf_pkgconfig_libs)
4385e0a2b6dfSmrg			],[
4386e0a2b6dfSmrg				CF_ADD_LIB_AFTER(-lXft,-lfontconfig)
4387e0a2b6dfSmrg			])
43886879286fSmrg		;;
43896879286fSmrg	esac
43906879286fSmrgfi
4391e39b573cSmrgfi
43926879286fSmrg])dnl
43936879286fSmrgdnl ---------------------------------------------------------------------------
439401037d57Smrgdnl CF_X_FREETYPE version: 27 updated: 2015/04/12 15:39:00
4395d522f475Smrgdnl -------------
4396d522f475Smrgdnl Check for X FreeType headers and libraries (XFree86 4.x, etc).
4397d522f475Smrgdnl
4398d522f475Smrgdnl First check for the appropriate config program, since the developers for
4399d522f475Smrgdnl these libraries change their configuration (and config program) more or
4400d522f475Smrgdnl less randomly.  If we cannot find the config program, do not bother trying
4401d522f475Smrgdnl to guess the latest variation of include/lib directories.
4402d522f475Smrgdnl
4403d522f475Smrgdnl If either or both of these configure-script options are not given, rely on
4404d522f475Smrgdnl the output of the config program to provide the cflags/libs options:
4405d522f475Smrgdnl	--with-freetype-cflags
4406d522f475Smrgdnl	--with-freetype-libs
4407d522f475SmrgAC_DEFUN([CF_X_FREETYPE],
4408d522f475Smrg[
4409956cc18dSsnjAC_REQUIRE([CF_PKG_CONFIG])
4410956cc18dSsnj
44110bd37d32Smrgcf_cv_x_freetype_incs=no
44120bd37d32Smrgcf_cv_x_freetype_libs=no
4413d522f475Smrgcf_extra_freetype_libs=
4414956cc18dSsnjFREETYPE_CONFIG=none
4415d522f475SmrgFREETYPE_PARAMS=
4416d522f475Smrg
44170bd37d32SmrgAC_MSG_CHECKING(for FreeType configuration script)
44180bd37d32SmrgAC_ARG_WITH(freetype-config,
44190bd37d32Smrg	[  --with-freetype-config  configure script to use for FreeType],
44200bd37d32Smrg	[cf_cv_x_freetype_cfgs="$withval"],
44210bd37d32Smrg	[cf_cv_x_freetype_cfgs=auto])
44220bd37d32Smrgtest -z $cf_cv_x_freetype_cfgs && cf_cv_x_freetype_cfgs=auto
44230bd37d32Smrgtest $cf_cv_x_freetype_cfgs = no && cf_cv_x_freetype_cfgs=none
44240bd37d32SmrgAC_MSG_RESULT($cf_cv_x_freetype_cfgs)
44250bd37d32Smrg
44260bd37d32Smrgcase $cf_cv_x_freetype_cfgs in
442701037d57Smrg(none)
44280bd37d32Smrg	AC_MSG_CHECKING(if you specified -D/-I options for FreeType)
44290bd37d32Smrg	AC_ARG_WITH(freetype-cflags,
44300bd37d32Smrg		[  --with-freetype-cflags  -D/-I options for compiling with FreeType],
44310bd37d32Smrg		[cf_cv_x_freetype_incs="$with_freetype_cflags"],
44320bd37d32Smrg		[cf_cv_x_freetype_incs=no])
44330bd37d32Smrg	AC_MSG_RESULT($cf_cv_x_freetype_incs)
44340bd37d32Smrg
44350bd37d32Smrg	AC_MSG_CHECKING(if you specified -L/-l options for FreeType)
44360bd37d32Smrg	AC_ARG_WITH(freetype-libs,
44370bd37d32Smrg		[  --with-freetype-libs    -L/-l options to link FreeType],
44380bd37d32Smrg		[cf_cv_x_freetype_libs="$with_freetype_libs"],
44390bd37d32Smrg		[cf_cv_x_freetype_libs=no])
44400bd37d32Smrg	AC_MSG_RESULT($cf_cv_x_freetype_libs)
44410bd37d32Smrg	;;
444201037d57Smrg(auto)
44430bd37d32Smrg	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
44440bd37d32Smrg		FREETYPE_CONFIG=$PKG_CONFIG
44450bd37d32Smrg		FREETYPE_PARAMS=xft
44460bd37d32Smrg	else
44470bd37d32Smrg		AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, none)
44480bd37d32Smrg		if test "$FREETYPE_CONFIG" != none; then
44490bd37d32Smrg			FREETYPE_CONFIG=$FREETYPE_CONFIG
44500bd37d32Smrg			cf_extra_freetype_libs="-lXft"
44510bd37d32Smrg		else
44520bd37d32Smrg			AC_PATH_PROG(FREETYPE_OLD_CONFIG, xft-config, none)
44530bd37d32Smrg			if test "$FREETYPE_OLD_CONFIG" != none; then
44540bd37d32Smrg				FREETYPE_CONFIG=$FREETYPE_OLD_CONFIG
44550bd37d32Smrg			fi
44560bd37d32Smrg		fi
44570bd37d32Smrg	fi
44580bd37d32Smrg	;;
445901037d57Smrg(pkg*)
44600bd37d32Smrg	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
44610bd37d32Smrg		FREETYPE_CONFIG=$cf_cv_x_freetype_cfgs
44620bd37d32Smrg		FREETYPE_PARAMS=xft
44630bd37d32Smrg	else
44640bd37d32Smrg		AC_MSG_WARN(cannot find pkg-config for Xft)
44650bd37d32Smrg	fi
44660bd37d32Smrg	;;
446701037d57Smrg(*)
44680bd37d32Smrg	AC_PATH_PROG(FREETYPE_XFT_CONFIG, $cf_cv_x_freetype_cfgs, none)
4469d522f475Smrg	if test "$FREETYPE_XFT_CONFIG" != none; then
4470d522f475Smrg		FREETYPE_CONFIG=$FREETYPE_XFT_CONFIG
4471d522f475Smrg	else
44720bd37d32Smrg		AC_MSG_WARN(cannot find config script for Xft)
4473d522f475Smrg	fi
44740bd37d32Smrg	;;
44750bd37d32Smrgesac
4476d522f475Smrg
4477956cc18dSsnjif test "$FREETYPE_CONFIG" != none ; then
44780bd37d32Smrg	AC_MSG_CHECKING(for FreeType config)
44790bd37d32Smrg	AC_MSG_RESULT($FREETYPE_CONFIG $FREETYPE_PARAMS)
4480d522f475Smrg
4481956cc18dSsnj	if test "$cf_cv_x_freetype_incs" = no ; then
4482956cc18dSsnj		AC_MSG_CHECKING(for $FREETYPE_CONFIG cflags)
4483956cc18dSsnj		cf_cv_x_freetype_incs="`$FREETYPE_CONFIG $FREETYPE_PARAMS --cflags 2>/dev/null`"
4484956cc18dSsnj		AC_MSG_RESULT($cf_cv_x_freetype_incs)
4485956cc18dSsnj	fi
4486d522f475Smrg
4487956cc18dSsnj	if test "$cf_cv_x_freetype_libs" = no ; then
4488956cc18dSsnj		AC_MSG_CHECKING(for $FREETYPE_CONFIG libs)
4489956cc18dSsnj		cf_cv_x_freetype_libs="$cf_extra_freetype_libs `$FREETYPE_CONFIG $FREETYPE_PARAMS --libs 2>/dev/null`"
4490956cc18dSsnj		AC_MSG_RESULT($cf_cv_x_freetype_libs)
4491956cc18dSsnj	fi
4492d522f475Smrgfi
4493d522f475Smrg
4494d522f475Smrgif test "$cf_cv_x_freetype_incs" = no ; then
4495d522f475Smrg	cf_cv_x_freetype_incs=
4496d522f475Smrgfi
4497d522f475Smrg
4498d522f475Smrgif test "$cf_cv_x_freetype_libs" = no ; then
4499d522f475Smrg	cf_cv_x_freetype_libs=-lXft
4500d522f475Smrgfi
4501d522f475Smrg
4502d522f475SmrgAC_MSG_CHECKING(if we can link with FreeType libraries)
4503d522f475Smrg
4504d522f475Smrgcf_save_LIBS="$LIBS"
4505d522f475Smrgcf_save_INCS="$CPPFLAGS"
4506d522f475Smrg
450720d2c4d2SmrgCF_ADD_LIBS($cf_cv_x_freetype_libs)
4508956cc18dSsnjCPPFLAGS="$CPPFLAGS $cf_cv_x_freetype_incs"
4509d522f475Smrg
4510d522f475SmrgAC_TRY_LINK([
4511d522f475Smrg#include <X11/Xlib.h>
4512d522f475Smrg#include <X11/extensions/Xrender.h>
4513d522f475Smrg#include <X11/Xft/Xft.h>],[
4514d522f475Smrg	XftPattern  *pat = XftNameParse ("name");],
4515d522f475Smrg	[cf_cv_found_freetype=yes],
4516d522f475Smrg	[cf_cv_found_freetype=no])
4517d522f475SmrgAC_MSG_RESULT($cf_cv_found_freetype)
4518d522f475Smrg
4519d522f475SmrgLIBS="$cf_save_LIBS"
4520d522f475SmrgCPPFLAGS="$cf_save_INCS"
4521d522f475Smrg
4522d522f475Smrgif test "$cf_cv_found_freetype" = yes ; then
452320d2c4d2Smrg	CF_ADD_LIBS($cf_cv_x_freetype_libs)
4524d522f475Smrg	CF_ADD_CFLAGS($cf_cv_x_freetype_incs)
45250bd37d32Smrg	AC_DEFINE(XRENDERFONT,1,[Define to 1 if we can/should link with FreeType libraries])
4526d522f475Smrg
4527d522f475SmrgAC_CHECK_FUNCS( \
4528d522f475Smrg	XftDrawCharSpec \
4529d522f475Smrg	XftDrawSetClip \
4530d522f475Smrg	XftDrawSetClipRectangles \
4531d522f475Smrg)
4532d522f475Smrg
4533d522f475Smrgelse
4534d522f475Smrg	AC_MSG_WARN(No libraries found for FreeType)
4535d522f475Smrg	CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
4536d522f475Smrgfi
4537d522f475Smrg
4538d522f475Smrg# FIXME: revisit this if needed
4539d522f475SmrgAC_SUBST(HAVE_TYPE_FCCHAR32)
4540d522f475SmrgAC_SUBST(HAVE_TYPE_XFTCHARSPEC)
4541d522f475Smrg])
4542d522f475Smrgdnl ---------------------------------------------------------------------------
454301037d57Smrgdnl CF_X_TOOLKIT version: 23 updated: 2015/04/12 15:39:00
4544d522f475Smrgdnl ------------
4545d522f475Smrgdnl Check for X Toolkit libraries
4546d522f475SmrgAC_DEFUN([CF_X_TOOLKIT],
4547d522f475Smrg[
4548d522f475SmrgAC_REQUIRE([AC_PATH_XTRA])
4549d522f475SmrgAC_REQUIRE([CF_CHECK_CACHE])
4550d522f475Smrg
455101037d57Smrg# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
455201037d57Smrg# in some cases has installed dummy files in the former, other cases replaced
455301037d57Smrg# it with a link to the new location).  This complicates the configure script.
455401037d57Smrg# Check for that pitfall, and recover using pkg-config
455501037d57Smrg#
455601037d57Smrg# If none of these are set, the configuration is almost certainly broken.
455701037d57Smrgif test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
455801037d57Smrgthen
455901037d57Smrg	CF_TRY_PKG_CONFIG(x11,,[AC_MSG_WARN(unable to find X11 library)])
456001037d57Smrg	CF_TRY_PKG_CONFIG(ice,,[AC_MSG_WARN(unable to find ICE library)])
456101037d57Smrg	CF_TRY_PKG_CONFIG(sm,,[AC_MSG_WARN(unable to find SM library)])
456201037d57Smrg	CF_TRY_PKG_CONFIG(xt,,[AC_MSG_WARN(unable to find Xt library)])
456301037d57Smrgfi
456401037d57Smrg
4565d522f475Smrgcf_have_X_LIBS=no
4566d522f475Smrg
456720d2c4d2SmrgCF_TRY_PKG_CONFIG(xt,[
456820d2c4d2Smrg
456901037d57Smrg	case "x$LIBS" in
457001037d57Smrg	(*-lX11*)
45716879286fSmrg		;;
457201037d57Smrg	(*)
45736879286fSmrg# we have an "xt" package, but it may omit Xt's dependency on X11
45746879286fSmrgAC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
45756879286fSmrgAC_TRY_LINK([
45766879286fSmrg#include <X11/Xlib.h>
45776879286fSmrg],[
45786879286fSmrg	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
45796879286fSmrg	int rc2 = XClearWindow((Display*) 0, (Window) 0);
45806879286fSmrg	int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
45816879286fSmrg	int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
45826879286fSmrg],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
45836879286fSmrg		if test "$cf_cv_xt_x11_compat" = no
45846879286fSmrg		then
45856879286fSmrg			CF_VERBOSE(work around broken X11 dependency)
45866879286fSmrg			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.
45876879286fSmrg			CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
45886879286fSmrg		fi
458920d2c4d2Smrg		;;
459020d2c4d2Smrg	esac
459120d2c4d2Smrg
45926879286fSmrgAC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
45936879286fSmrgAC_TRY_LINK([
45946879286fSmrg#include <X11/Shell.h>
45956879286fSmrg],[int num = IceConnectionNumber(0)
45966879286fSmrg],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
45976879286fSmrg
45986879286fSmrg	if test "$cf_cv_xt_ice_compat" = no
45996879286fSmrg	then
46006879286fSmrg		# workaround for broken ".pc" files used for X Toolkit.
460101037d57Smrg		case "x$X_PRE_LIBS" in
460201037d57Smrg		(*-lICE*)
460301037d57Smrg			case "x$LIBS" in
460401037d57Smrg			(*-lICE*)
46056879286fSmrg				;;
460601037d57Smrg			(*)
46076879286fSmrg				CF_VERBOSE(work around broken ICE dependency)
46086879286fSmrg				CF_TRY_PKG_CONFIG(ice,
46096879286fSmrg					[CF_TRY_PKG_CONFIG(sm)],
46106879286fSmrg					[CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
46116879286fSmrg				;;
46126879286fSmrg			esac
46136879286fSmrg			;;
46146879286fSmrg		esac
46156879286fSmrg	fi
46166879286fSmrg
461720d2c4d2Smrg	cf_have_X_LIBS=yes
461820d2c4d2Smrg],[
461920d2c4d2Smrg
462020d2c4d2Smrg	LDFLAGS="$X_LIBS $LDFLAGS"
462120d2c4d2Smrg	CF_CHECK_CFLAGS($X_CFLAGS)
4622d522f475Smrg
462320d2c4d2Smrg	AC_CHECK_FUNC(XOpenDisplay,,[
462420d2c4d2Smrg	AC_CHECK_LIB(X11,XOpenDisplay,
462520d2c4d2Smrg		[CF_ADD_LIB(X11)],,
462620d2c4d2Smrg		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
4627d522f475Smrg
462820d2c4d2Smrg	AC_CHECK_FUNC(XtAppInitialize,,[
462920d2c4d2Smrg	AC_CHECK_LIB(Xt, XtAppInitialize,
46300bd37d32Smrg		[AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
463120d2c4d2Smrg		 cf_have_X_LIBS=Xt
463220d2c4d2Smrg		 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
463320d2c4d2Smrg		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
463420d2c4d2Smrg])
4635d522f475Smrg
4636d522f475Smrgif test $cf_have_X_LIBS = no ; then
4637d522f475Smrg	AC_MSG_WARN(
4638d522f475Smrg[Unable to successfully link X Toolkit library (-lXt) with
4639d522f475Smrgtest program.  You will have to check and add the proper libraries by hand
4640d522f475Smrgto makefile.])
4641d522f475Smrgfi
4642d522f475Smrg])dnl
46430bd37d32Smrgdnl ---------------------------------------------------------------------------
46440bd37d32Smrgdnl CF__GRANTPT_BODY version: 4 updated: 2012/05/07 19:39:45
46450bd37d32Smrgdnl ----------------
46460bd37d32Smrgdnl Body for workability check of grantpt.
46470bd37d32Smrgdefine([CF__GRANTPT_BODY],[
46480bd37d32Smrg	int code = 0;
46490bd37d32Smrg	int rc;
46500bd37d32Smrg	int pty;
46510bd37d32Smrg	int tty;
46520bd37d32Smrg	char *slave;
46530bd37d32Smrg	struct termios tio;
46540bd37d32Smrg
46550bd37d32Smrg	signal(SIGALRM, my_timeout);
46560bd37d32Smrg
46570bd37d32Smrg	if (alarm(2) == 9)
46580bd37d32Smrg		failed(9);
46590bd37d32Smrg	else if ((pty = posix_openpt(O_RDWR)) < 0)
46600bd37d32Smrg		failed(1);
46610bd37d32Smrg	else if ((rc = grantpt(pty)) < 0)
46620bd37d32Smrg		failed(2);
46630bd37d32Smrg	else if ((rc = unlockpt(pty)) < 0)
46640bd37d32Smrg		failed(3);
46650bd37d32Smrg	else if ((slave = ptsname(pty)) == 0)
46660bd37d32Smrg		failed(4);
46670bd37d32Smrg#if (CONFTEST == 3) || defined(CONFTEST_isatty)
46680bd37d32Smrg	else if (!isatty(pty))
46690bd37d32Smrg		failed(4);
46700bd37d32Smrg#endif
46710bd37d32Smrg#if CONFTEST >= 4
46720bd37d32Smrg    else if ((rc = tcgetattr(pty, &tio)) < 0)
46730bd37d32Smrg		failed(20);
46740bd37d32Smrg    else if ((rc = tcsetattr(pty, TCSAFLUSH, &tio)) < 0)
46750bd37d32Smrg		failed(21);
46760bd37d32Smrg#endif
46770bd37d32Smrg	/* BSD posix_openpt does not treat pty as a terminal until slave is opened.
46780bd37d32Smrg	 * Linux does treat it that way.
46790bd37d32Smrg	 */
46800bd37d32Smrg	else if ((tty = open(slave, O_RDWR)) < 0)
46810bd37d32Smrg		failed(5);
46820bd37d32Smrg#ifdef CONFTEST
46830bd37d32Smrg#ifdef I_PUSH
46840bd37d32Smrg#if (CONFTEST == 0) || defined(CONFTEST_ptem)
46850bd37d32Smrg    else if ((rc = ioctl(tty, I_PUSH, "ptem")) < 0)
46860bd37d32Smrg		failed(10);
46870bd37d32Smrg#endif
46880bd37d32Smrg#if (CONFTEST == 1) || defined(CONFTEST_ldterm)
46890bd37d32Smrg    else if ((rc = ioctl(tty, I_PUSH, "ldterm")) < 0)
46900bd37d32Smrg		failed(11);
46910bd37d32Smrg#endif
46920bd37d32Smrg#if (CONFTEST == 2) || defined(CONFTEST_ttcompat)
46930bd37d32Smrg    else if ((rc = ioctl(tty, I_PUSH, "ttcompat")) < 0)
46940bd37d32Smrg		failed(12);
46950bd37d32Smrg#endif
46960bd37d32Smrg#endif /* I_PUSH */
46970bd37d32Smrg#if CONFTEST >= 5
46980bd37d32Smrg    else if ((rc = tcgetattr(tty, &tio)) < 0)
46990bd37d32Smrg		failed(30);
47000bd37d32Smrg    else if ((rc = tcsetattr(tty, TCSAFLUSH, &tio)) < 0)
47010bd37d32Smrg		failed(31);
47020bd37d32Smrg#endif
47030bd37d32Smrg#endif /* CONFTEST */
47040bd37d32Smrg
47050bd37d32Smrg	${cf_cv_main_return:-return}(code);
47060bd37d32Smrg])
47070bd37d32Smrgdnl ---------------------------------------------------------------------------
47080bd37d32Smrgdnl CF__GRANTPT_HEAD version: 3 updated: 2012/01/29 17:13:14
47090bd37d32Smrgdnl ----------------
47100bd37d32Smrgdnl Headers for workability check of grantpt.
47110bd37d32Smrgdefine([CF__GRANTPT_HEAD],[
47120bd37d32Smrg#include <stdlib.h>
47130bd37d32Smrg#include <termios.h>
47140bd37d32Smrg#include <unistd.h>
47150bd37d32Smrg#include <signal.h>
47160bd37d32Smrg#include <fcntl.h>
47170bd37d32Smrg#include <errno.h>
47180bd37d32Smrg
47190bd37d32Smrg#ifndef HAVE_POSIX_OPENPT
47200bd37d32Smrg#undef posix_openpt
47210bd37d32Smrg#define posix_openpt(mode) open("/dev/ptmx", mode)
47220bd37d32Smrg#endif
47230bd37d32Smrg
47240bd37d32Smrg#ifdef HAVE_STROPTS_H
47250bd37d32Smrg#include <stropts.h>
47260bd37d32Smrg#endif
47270bd37d32Smrg
47280bd37d32Smrgstatic void failed(int code)
47290bd37d32Smrg{
47300bd37d32Smrg	perror("conftest");
47310bd37d32Smrg	exit(code);
47320bd37d32Smrg}
47330bd37d32Smrg
47340bd37d32Smrgstatic void my_timeout(int sig)
47350bd37d32Smrg{
47360bd37d32Smrg	exit(99);
47370bd37d32Smrg}
47380bd37d32Smrg])
4739