aclocal.m4 revision 894e0ac8
1dnl $XTermId: aclocal.m4,v 1.373 2014/04/14 19:16:55 tom Exp $
2dnl
3dnl ---------------------------------------------------------------------------
4dnl
5dnl Copyright 1997-2013,2014 by Thomas E. Dickey
6dnl
7dnl                         All Rights Reserved
8dnl
9dnl Permission is hereby granted, free of charge, to any person obtaining a
10dnl copy of this software and associated documentation files (the
11dnl "Software"), to deal in the Software without restriction, including
12dnl without limitation the rights to use, copy, modify, merge, publish,
13dnl distribute, sublicense, and/or sell copies of the Software, and to
14dnl permit persons to whom the Software is furnished to do so, subject to
15dnl the following conditions:
16dnl
17dnl The above copyright notice and this permission notice shall be included
18dnl in all copies or substantial portions of the Software.
19dnl
20dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23dnl IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
24dnl CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25dnl TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26dnl SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27dnl
28dnl Except as contained in this notice, the name(s) of the above copyright
29dnl holders shall not be used in advertising or otherwise to promote the
30dnl sale, use or other dealings in this Software without prior written
31dnl authorization.
32dnl
33dnl ---------------------------------------------------------------------------
34dnl See
35dnl		http://invisible-island.net/autoconf/autoconf.html
36dnl ---------------------------------------------------------------------------
37dnl ---------------------------------------------------------------------------
38dnl AM_LANGINFO_CODESET version: 3 updated: 2002/10/27 23:21:42
39dnl -------------------
40dnl Inserted as requested by gettext 0.10.40
41dnl File from /usr/share/aclocal
42dnl codeset.m4
43dnl ====================
44dnl serial AM1
45dnl
46dnl From Bruno Haible.
47AC_DEFUN([AM_LANGINFO_CODESET],
48[
49  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
50    [AC_TRY_LINK([#include <langinfo.h>],
51      [char* cs = nl_langinfo(CODESET);],
52      am_cv_langinfo_codeset=yes,
53      am_cv_langinfo_codeset=no)
54    ])
55  if test $am_cv_langinfo_codeset = yes; then
56    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
57      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
58  fi
59])dnl
60dnl ---------------------------------------------------------------------------
61dnl CF_ACVERSION_CHECK version: 4 updated: 2013/03/04 19:52:56
62dnl ------------------
63dnl Conditionally generate script according to whether we're using a given autoconf.
64dnl
65dnl $1 = version to compare against
66dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
67dnl $3 = code to use if AC_ACVERSION is older than $1.
68define([CF_ACVERSION_CHECK],
69[
70ifdef([AC_ACVERSION], ,[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])dnl
71ifdef([m4_version_compare],
72[m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
73[CF_ACVERSION_COMPARE(
74AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
75AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
76dnl ---------------------------------------------------------------------------
77dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
78dnl --------------------
79dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
80dnl                      MAJOR2, MINOR2, TERNARY2,
81dnl                      PRINTABLE2, not FOUND, FOUND)
82define([CF_ACVERSION_COMPARE],
83[ifelse(builtin([eval], [$2 < $5]), 1,
84[ifelse([$8], , ,[$8])],
85[ifelse([$9], , ,[$9])])])dnl
86dnl ---------------------------------------------------------------------------
87dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
88dnl -------------
89dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
90dnl The second parameter if given makes this macro verbose.
91dnl
92dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
93dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
94dnl confused by the quotes (which require backslashes to keep them usable).
95AC_DEFUN([CF_ADD_CFLAGS],
96[
97cf_fix_cppflags=no
98cf_new_cflags=
99cf_new_cppflags=
100cf_new_extra_cppflags=
101
102for cf_add_cflags in $1
103do
104case $cf_fix_cppflags in
105no)
106	case $cf_add_cflags in #(vi
107	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
108		case $cf_add_cflags in
109		-D*)
110			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
111
112			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
113				&& test -z "${cf_tst_cflags}" \
114				&& cf_fix_cppflags=yes
115
116			if test $cf_fix_cppflags = yes ; then
117				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
118				continue
119			elif test "${cf_tst_cflags}" = "\"'" ; then
120				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
121				continue
122			fi
123			;;
124		esac
125		case "$CPPFLAGS" in
126		*$cf_add_cflags) #(vi
127			;;
128		*) #(vi
129			case $cf_add_cflags in #(vi
130			-D*)
131				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
132				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
133				;;
134			esac
135			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
136			;;
137		esac
138		;;
139	*)
140		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
141		;;
142	esac
143	;;
144yes)
145	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
146
147	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
148
149	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
150		&& test -z "${cf_tst_cflags}" \
151		&& cf_fix_cppflags=no
152	;;
153esac
154done
155
156if test -n "$cf_new_cflags" ; then
157	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
158	CFLAGS="$CFLAGS $cf_new_cflags"
159fi
160
161if test -n "$cf_new_cppflags" ; then
162	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
163	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
164fi
165
166if test -n "$cf_new_extra_cppflags" ; then
167	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
168	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
169fi
170
171AC_SUBST(EXTRA_CPPFLAGS)
172
173])dnl
174dnl ---------------------------------------------------------------------------
175dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
176dnl ----------
177dnl Add a library, used to enforce consistency.
178dnl
179dnl $1 = library to add, without the "-l"
180dnl $2 = variable to update (default $LIBS)
181AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
182dnl ---------------------------------------------------------------------------
183dnl CF_ADD_LIBS version: 1 updated: 2010/06/02 05:03:05
184dnl -----------
185dnl Add one or more libraries, used to enforce consistency.
186dnl
187dnl $1 = libraries to add, with the "-l", etc.
188dnl $2 = variable to update (default $LIBS)
189AC_DEFUN([CF_ADD_LIBS],[ifelse($2,,LIBS,[$2])="$1 [$]ifelse($2,,LIBS,[$2])"])dnl
190dnl ---------------------------------------------------------------------------
191dnl CF_ADD_LIB_AFTER version: 3 updated: 2013/07/09 21:27:22
192dnl ----------------
193dnl Add a given library after another, e.g., following the one it satisfies a
194dnl dependency for.
195dnl
196dnl $1 = the first library
197dnl $2 = its dependency
198AC_DEFUN([CF_ADD_LIB_AFTER],[
199CF_VERBOSE(...before $LIBS)
200LIBS=`echo "$LIBS" | sed -e "s/[[ 	]][[ 	]]*/ /g" -e "s%$1 %$1 $2 %" -e 's%  % %g'`
201CF_VERBOSE(...after  $LIBS)
202])dnl
203dnl ---------------------------------------------------------------------------
204dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
205dnl --------------
206dnl Allow user to disable a normally-on option.
207AC_DEFUN([CF_ARG_DISABLE],
208[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
209dnl ---------------------------------------------------------------------------
210dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
211dnl -------------
212dnl Allow user to enable a normally-off option.
213AC_DEFUN([CF_ARG_ENABLE],
214[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
215dnl ---------------------------------------------------------------------------
216dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
217dnl -------------
218dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
219dnl values.
220dnl
221dnl Parameters:
222dnl $1 = option name
223dnl $2 = help-string
224dnl $3 = action to perform if option is not default
225dnl $4 = action if perform if option is default
226dnl $5 = default option value (either 'yes' or 'no')
227AC_DEFUN([CF_ARG_OPTION],
228[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
229  if test "$enableval" != "$5" ; then
230ifelse([$3],,[    :]dnl
231,[    $3]) ifelse([$4],,,[
232  else
233    $4])
234  fi],[enableval=$5 ifelse([$4],,,[
235  $4
236])dnl
237  ])])dnl
238dnl ---------------------------------------------------------------------------
239dnl CF_CC_ENV_FLAGS version: 1 updated: 2012/10/03 05:25:49
240dnl ---------------
241dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
242dnl into CC.  This will not help with broken scripts that wrap the compiler with
243dnl options, but eliminates a more common category of user confusion.
244AC_DEFUN([CF_CC_ENV_FLAGS],
245[
246# This should have been defined by AC_PROG_CC
247: ${CC:=cc}
248
249AC_MSG_CHECKING(\$CC variable)
250case "$CC" in #(vi
251*[[\ \	]]-[[IUD]]*)
252	AC_MSG_RESULT(broken)
253	AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
254	# humor him...
255	cf_flags=`echo "$CC" | sed -e 's/^[[^ 	]]*[[ 	]]//'`
256	CC=`echo "$CC" | sed -e 's/[[ 	]].*//'`
257	CF_ADD_CFLAGS($cf_flags)
258	;;
259*)
260	AC_MSG_RESULT(ok)
261	;;
262esac
263])dnl
264dnl ---------------------------------------------------------------------------
265dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
266dnl --------------
267dnl Check if we're accidentally using a cache from a different machine.
268dnl Derive the system name, as a check for reusing the autoconf cache.
269dnl
270dnl If we've packaged config.guess and config.sub, run that (since it does a
271dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
272dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
273dnl which is useful in cross-compiles.
274dnl
275dnl Note: we would use $ac_config_sub, but that is one of the places where
276dnl autoconf 2.5x broke compatibility with autoconf 2.13
277AC_DEFUN([CF_CHECK_CACHE],
278[
279if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
280	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
281	system_name="$host_os"
282else
283	system_name="`(uname -s -r) 2>/dev/null`"
284	if test -z "$system_name" ; then
285		system_name="`(hostname) 2>/dev/null`"
286	fi
287fi
288test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
289AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
290
291test -z "$system_name" && system_name="$cf_cv_system_name"
292test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
293
294if test ".$system_name" != ".$cf_cv_system_name" ; then
295	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
296	AC_MSG_ERROR("Please remove config.cache and try again.")
297fi
298])dnl
299dnl ---------------------------------------------------------------------------
300dnl CF_CHECK_CFLAGS version: 2 updated: 2001/12/30 19:09:58
301dnl ---------------
302dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
303dnl a build-configuration such as imake.  These have the pitfall that they
304dnl often contain compiler-specific options which we cannot use, mixed with
305dnl preprocessor options that we usually can.
306AC_DEFUN([CF_CHECK_CFLAGS],
307[
308CF_VERBOSE(checking additions to CFLAGS)
309cf_check_cflags="$CFLAGS"
310cf_check_cppflags="$CPPFLAGS"
311CF_ADD_CFLAGS($1,yes)
312if test "$cf_check_cflags" != "$CFLAGS" ; then
313AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
314	[CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
315	 if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
316		 CF_VERBOSE(but keeping change to \$CPPFLAGS)
317	 fi
318	 CFLAGS="$cf_check_flags"])
319fi
320])dnl
321dnl ---------------------------------------------------------------------------
322dnl CF_CHECK_ERRNO version: 11 updated: 2010/05/26 05:38:42
323dnl --------------
324dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
325dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
326dnl ourselves.
327dnl
328dnl $1 = the name to check
329dnl $2 = the assumed type
330AC_DEFUN([CF_CHECK_ERRNO],
331[
332AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
333    AC_TRY_COMPILE([
334#ifdef HAVE_STDLIB_H
335#include <stdlib.h>
336#endif
337#include <stdio.h>
338#include <sys/types.h>
339#include <errno.h> ],
340    ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1,
341    [cf_cv_dcl_$1=yes],
342    [cf_cv_dcl_$1=no])
343])
344
345if test "$cf_cv_dcl_$1" = no ; then
346    CF_UPPER(cf_result,decl_$1)
347    AC_DEFINE_UNQUOTED($cf_result)
348fi
349
350# It's possible (for near-UNIX clones) that the data doesn't exist
351CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
352])dnl
353dnl ---------------------------------------------------------------------------
354dnl CF_CHECK_EXTERN_DATA version: 3 updated: 2001/12/30 18:03:23
355dnl --------------------
356dnl Check for existence of external data in the current set of libraries.  If
357dnl we can modify it, it's real enough.
358dnl $1 = the name to check
359dnl $2 = its type
360AC_DEFUN([CF_CHECK_EXTERN_DATA],
361[
362AC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
363    AC_TRY_LINK([
364#undef $1
365extern $2 $1;
366],
367    [$1 = 2],
368    [cf_cv_have_$1=yes],
369    [cf_cv_have_$1=no])
370])
371
372if test "$cf_cv_have_$1" = yes ; then
373    CF_UPPER(cf_result,have_$1)
374    AC_DEFINE_UNQUOTED($cf_result)
375fi
376
377])dnl
378dnl ---------------------------------------------------------------------------
379dnl CF_CLANG_COMPILER version: 2 updated: 2013/11/19 19:23:35
380dnl -----------------
381dnl Check if the given compiler is really clang.  clang's C driver defines
382dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
383dnl not ignore some gcc options.
384dnl
385dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
386dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
387dnl the wrappers for gcc and g++ warnings.
388dnl
389dnl $1 = GCC (default) or GXX
390dnl $2 = CLANG_COMPILER (default)
391dnl $3 = CFLAGS (default) or CXXFLAGS
392AC_DEFUN([CF_CLANG_COMPILER],[
393ifelse([$2],,CLANG_COMPILER,[$2])=no
394
395if test "$ifelse([$1],,[$1],GCC)" = yes ; then
396	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
397	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
398	ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
399	AC_TRY_COMPILE([],[
400#ifdef __clang__
401#else
402make an error
403#endif
404],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
405cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
406],[])
407	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
408	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
409fi
410])
411dnl ---------------------------------------------------------------------------
412dnl CF_DISABLE_DESKTOP version: 2 updated: 2011/04/22 05:17:37
413dnl ------------------
414dnl Handle a configure option "--disable-desktop", which sets a shell
415dnl variable $desktop_utils to a "#" if the feature is not wanted, or to an
416dnl empty string if enabled.  The variable is used to substitute in front of
417dnl corresponding makefile-rules.
418dnl
419dnl It also tells the configure script to substitute the environment variable
420dnl $DESKTOP_FLAGS, which can be used by external scripts to customize the
421dnl invocation of desktop-file-util.
422dnl
423dnl $1 = program name
424AC_DEFUN([CF_DISABLE_DESKTOP],[
425# Comment-out the install-desktop rule if the desktop-utils are not found.
426AC_MSG_CHECKING(if you want to install desktop files)
427CF_ARG_OPTION(desktop,
428	[  --disable-desktop       disable install of $1 desktop files],
429	[enable_desktop=$enableval],
430	[enable_desktop=$enableval],yes)
431AC_MSG_RESULT($enable_desktop)
432
433desktop_utils=
434if test "$enable_desktop" = yes ; then
435AC_CHECK_PROG(desktop_utils,desktop-file-install,yes,no)
436fi
437
438test "$desktop_utils" = yes && desktop_utils= || desktop_utils="#"
439AC_SUBST(DESKTOP_FLAGS)
440])
441dnl ---------------------------------------------------------------------------
442dnl CF_DISABLE_ECHO version: 12 updated: 2012/10/06 16:30:28
443dnl ---------------
444dnl You can always use "make -n" to see the actual options, but it's hard to
445dnl pick out/analyze warning messages when the compile-line is long.
446dnl
447dnl Sets:
448dnl	ECHO_LT - symbol to control if libtool is verbose
449dnl	ECHO_LD - symbol to prefix "cc -o" lines
450dnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
451dnl	SHOW_CC - symbol to put before explicit "cc -c" lines
452dnl	ECHO_CC - symbol to put before any "cc" line
453dnl
454AC_DEFUN([CF_DISABLE_ECHO],[
455AC_MSG_CHECKING(if you want to see long compiling messages)
456CF_ARG_DISABLE(echo,
457	[  --disable-echo          do not display "compiling" commands],
458	[
459    ECHO_LT='--silent'
460    ECHO_LD='@echo linking [$]@;'
461    RULE_CC='@echo compiling [$]<'
462    SHOW_CC='@echo compiling [$]@'
463    ECHO_CC='@'
464],[
465    ECHO_LT=''
466    ECHO_LD=''
467    RULE_CC=''
468    SHOW_CC=''
469    ECHO_CC=''
470])
471AC_MSG_RESULT($enableval)
472AC_SUBST(ECHO_LT)
473AC_SUBST(ECHO_LD)
474AC_SUBST(RULE_CC)
475AC_SUBST(SHOW_CC)
476AC_SUBST(ECHO_CC)
477])dnl
478dnl ---------------------------------------------------------------------------
479dnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
480dnl ----------------
481dnl Combine no-leak checks with the libraries or tools that are used for the
482dnl checks.
483AC_DEFUN([CF_DISABLE_LEAKS],[
484
485AC_REQUIRE([CF_WITH_DMALLOC])
486AC_REQUIRE([CF_WITH_DBMALLOC])
487AC_REQUIRE([CF_WITH_VALGRIND])
488
489AC_MSG_CHECKING(if you want to perform memory-leak testing)
490AC_ARG_ENABLE(leaks,
491	[  --disable-leaks         test: free permanent memory, analyze leaks],
492	[if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
493	: ${with_no_leaks:=no})
494AC_MSG_RESULT($with_no_leaks)
495
496if test "$with_no_leaks" = yes ; then
497	AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
498	AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
499fi
500])dnl
501dnl ---------------------------------------------------------------------------
502dnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
503dnl ---------------------
504dnl The rpath-hack makes it simpler to build programs, particularly with the
505dnl *BSD ports which may have essential libraries in unusual places.  But it
506dnl can interfere with building an executable for the base system.  Use this
507dnl option in that case.
508AC_DEFUN([CF_DISABLE_RPATH_HACK],
509[
510AC_MSG_CHECKING(if rpath-hack should be disabled)
511CF_ARG_DISABLE(rpath-hack,
512	[  --disable-rpath-hack    don't add rpath options for additional libraries],
513	[cf_disable_rpath_hack=yes],
514	[cf_disable_rpath_hack=no])
515AC_MSG_RESULT($cf_disable_rpath_hack)
516if test "$cf_disable_rpath_hack" = no ; then
517	CF_RPATH_HACK
518fi
519])
520dnl ---------------------------------------------------------------------------
521dnl CF_ENABLE_NARROWPROTO version: 3 updated: 2006/02/12 17:46:00
522dnl ---------------------
523dnl If this is not set properly, Xaw's scrollbars will not work.
524dnl The so-called "modular" configuration for X.org omits most of the
525dnl configure checks that would be needed to provide compatibility with
526dnl older X builds.  This one breaks things noticeably.
527AC_DEFUN([CF_ENABLE_NARROWPROTO],
528[
529AC_MSG_CHECKING(if you want narrow prototypes for X libraries)
530
531case `$ac_config_guess` in #(vi
532*cygwin*|*freebsd*|*gnu*|*irix5*|*irix6*|*linux-gnu*|*netbsd*|*openbsd*|*qnx*|*sco*|*sgi*) #(vi
533	cf_default_narrowproto=yes
534	;;
535*)
536	cf_default_narrowproto=no
537	;;
538esac
539
540CF_ARG_OPTION(narrowproto,
541	[  --enable-narrowproto    enable narrow prototypes for X libraries],
542	[enable_narrowproto=$enableval],
543	[enable_narrowproto=$cf_default_narrowproto],
544	[$cf_default_narrowproto])
545AC_MSG_RESULT($enable_narrowproto)
546])
547dnl ---------------------------------------------------------------------------
548dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
549dnl --------
550dnl Check if 'errno' is declared in <errno.h>
551AC_DEFUN([CF_ERRNO],
552[
553CF_CHECK_ERRNO(errno)
554])dnl
555dnl ---------------------------------------------------------------------------
556dnl CF_FUNC_GRANTPT version: 10 updated: 2013/04/17 05:31:24
557dnl ---------------
558dnl Check for grantpt versus openpty, as well as functions that "should" be
559dnl available if grantpt is available.
560AC_DEFUN([CF_FUNC_GRANTPT],[
561
562AC_CHECK_HEADERS( \
563stropts.h \
564)
565
566cf_func_grantpt="grantpt ptsname"
567case $host_os in #(vi
568darwin[[0-9]].*) #(vi
569	;;
570*)
571	cf_func_grantpt="$cf_func_grantpt posix_openpt"
572	;;
573esac
574
575AC_CHECK_FUNCS($cf_func_grantpt)
576
577cf_grantpt_opts=
578if test "x$ac_cv_func_grantpt" = "xyes" ; then
579	AC_MSG_CHECKING(if grantpt really works)
580	AC_TRY_LINK(CF__GRANTPT_HEAD,CF__GRANTPT_BODY,[
581	AC_TRY_RUN(CF__GRANTPT_HEAD
582int main(void)
583{
584CF__GRANTPT_BODY
585}
586,
587,ac_cv_func_grantpt=no
588,ac_cv_func_grantpt=maybe)
589	],ac_cv_func_grantpt=no)
590	AC_MSG_RESULT($ac_cv_func_grantpt)
591
592	if test "x$ac_cv_func_grantpt" != "xno" ; then
593
594		if test "x$ac_cv_func_grantpt" = "xyes" ; then
595			AC_MSG_CHECKING(for pty features)
596dnl if we have no stropts.h, skip the checks for streams modules
597			if test "x$ac_cv_header_stropts_h" = xyes
598			then
599				cf_pty_this=0
600			else
601				cf_pty_this=3
602			fi
603
604			cf_pty_defines=
605			while test $cf_pty_this != 6
606			do
607
608				cf_pty_feature=
609				cf_pty_next=`expr $cf_pty_this + 1`
610				CF_MSG_LOG(pty feature test $cf_pty_next:5)
611				AC_TRY_RUN(#define CONFTEST $cf_pty_this
612$cf_pty_defines
613CF__GRANTPT_HEAD
614int main(void)
615{
616CF__GRANTPT_BODY
617}
618,
619[
620				case $cf_pty_next in #(vi
621				1) #(vi - streams
622					cf_pty_feature=ptem
623					;;
624				2) #(vi - streams
625					cf_pty_feature=ldterm
626					;;
627				3) #(vi - streams
628					cf_pty_feature=ttcompat
629					;;
630				4) #(vi
631					cf_pty_feature=pty_isatty
632					;;
633				5) #(vi
634					cf_pty_feature=pty_tcsetattr
635					;;
636				6) #(vi
637					cf_pty_feature=tty_tcsetattr
638					;;
639				esac
640],[
641				case $cf_pty_next in #(vi
642				1|2|3)
643					CF_MSG_LOG(skipping remaining streams features $cf_pty_this..2)
644					cf_pty_next=3
645					;;
646				esac
647])
648				if test -n "$cf_pty_feature"
649				then
650					cf_pty_defines="$cf_pty_defines
651#define CONFTEST_$cf_pty_feature 1
652"
653					cf_grantpt_opts="$cf_grantpt_opts $cf_pty_feature"
654				fi
655
656				cf_pty_this=$cf_pty_next
657			done
658			AC_MSG_RESULT($cf_grantpt_opts)
659			cf_grantpt_opts=`echo "$cf_grantpt_opts" | sed -e 's/ isatty//'`
660		fi
661	fi
662fi
663
664dnl If we found grantpt, but no features, e.g., for streams or if we are not
665dnl able to use tcsetattr, then give openpty a try.  In particular, Darwin 10.7
666dnl has a more functional openpty than posix_openpt.
667dnl
668dnl There is no configure run-test for openpty, since older implementations do
669dnl not always run properly as a non-root user.  For that reason, we also allow
670dnl the configure script to suppress this check entirely with $disable_openpty.
671if test "x$disable_openpty" != "xyes" || test -z "$cf_grantpt_opts" ; then
672	AC_CHECK_LIB(util, openpty, [cf_have_openpty=yes],[cf_have_openpty=no])
673	if test "$cf_have_openpty" = yes ; then
674		ac_cv_func_grantpt=no
675		LIBS="-lutil $LIBS"
676		AC_DEFINE(HAVE_OPENPTY,1,[Define to 1 if you have the openpty function])
677		AC_CHECK_HEADERS( \
678			util.h \
679			libutil.h \
680			pty.h \
681		)
682	fi
683fi
684
685dnl If we did not settle on using openpty, fill in the definitions for grantpt.
686if test "x$ac_cv_func_grantpt" != xno
687then
688	CF_VERBOSE(will rely upon grantpt)
689	AC_DEFINE(HAVE_WORKING_GRANTPT,1,[Define to 1 if the grantpt function seems to work])
690	for cf_feature in $cf_grantpt_opts
691	do
692		cf_feature=`echo "$cf_feature" | sed -e 's/ //g'`
693		CF_UPPER(cf_FEATURE,$cf_feature)
694		AC_DEFINE_UNQUOTED(HAVE_GRANTPT_$cf_FEATURE)
695	done
696elif test "x$cf_have_openpty" = xno
697then
698	CF_VERBOSE(will rely upon BSD-pseudoterminals)
699else
700	CF_VERBOSE(will rely upon openpty)
701fi
702])dnl
703dnl ---------------------------------------------------------------------------
704dnl CF_FUNC_TGETENT version: 19 updated: 2012/10/04 20:12:20
705dnl ---------------
706dnl Check for tgetent function in termcap library.  If we cannot find this,
707dnl we'll use the $LINES and $COLUMNS environment variables to pass screen
708dnl size information to subprocesses.  (We cannot use terminfo's compatibility
709dnl function, since it cannot provide the termcap-format data).
710dnl
711dnl If the --disable-full-tgetent option is given, we'll settle for the first
712dnl tgetent function we find.  Since the search list in that case does not
713dnl include the termcap library, that allows us to default to terminfo.
714AC_DEFUN([CF_FUNC_TGETENT],
715[
716# compute a reasonable value for $TERM to give tgetent(), since we may be
717# running in 'screen', which sets $TERMCAP to a specific entry that is not
718# necessarily in /etc/termcap - unsetenv is not portable, so we cannot simply
719# discard $TERMCAP.
720cf_TERMVAR=vt100
721if test -n "$TERMCAP"
722then
723	cf_TERMCAP=`echo "$TERMCAP" | tr '\n' ' ' | sed -e 's/^..|//' -e 's/|.*//'`
724	case "$cf_TERMCAP" in #(vi
725	screen*.*) #(vi
726		;;
727	*)
728		cf_TERMVAR="$cf_TERMCAP"
729		;;
730	esac
731fi
732test -z "$cf_TERMVAR" && cf_TERMVAR=vt100
733
734AC_MSG_CHECKING(if we want full tgetent function)
735CF_ARG_DISABLE(full-tgetent,
736	[  --disable-full-tgetent  disable check for full tgetent function],
737	cf_full_tgetent=no,
738	cf_full_tgetent=yes,yes)
739AC_MSG_RESULT($cf_full_tgetent)
740
741if test "$cf_full_tgetent" = yes ; then
742	cf_test_message="full tgetent"
743else
744	cf_test_message="tgetent"
745fi
746
747AC_CACHE_CHECK(for $cf_test_message function,cf_cv_lib_tgetent,[
748cf_save_LIBS="$LIBS"
749cf_cv_lib_tgetent=no
750if test "$cf_full_tgetent" = yes ; then
751	cf_TERMLIB="otermcap termcap termlib ncurses curses"
752	cf_TERMTST="buffer[[0]] == 0"
753else
754	cf_TERMLIB="termlib ncurses curses"
755	cf_TERMTST="0"
756fi
757for cf_termlib in '' $cf_TERMLIB ; do
758	LIBS="$cf_save_LIBS"
759	test -n "$cf_termlib" && CF_ADD_LIB($cf_termlib)
760	AC_TRY_RUN([
761/* terminfo implementations ignore the buffer argument, making it useless for
762 * the xterm application, which uses this information to make a new TERMCAP
763 * environment variable.
764 */
765int main()
766{
767	char buffer[1024];
768	buffer[0] = 0;
769	tgetent(buffer, "$cf_TERMVAR");
770	${cf_cv_main_return:-return} ($cf_TERMTST); }],
771	[echo "yes, there is a termcap/tgetent in $cf_termlib" 1>&AC_FD_CC
772	 if test -n "$cf_termlib" ; then
773	 	cf_cv_lib_tgetent="-l$cf_termlib"
774	 else
775	 	cf_cv_lib_tgetent=yes
776	 fi
777	 break],
778	[echo "no, there is no termcap/tgetent in $cf_termlib" 1>&AC_FD_CC],
779	[echo "cross-compiling, cannot verify if a termcap/tgetent is present in $cf_termlib" 1>&AC_FD_CC])
780done
781LIBS="$cf_save_LIBS"
782])
783
784# If we found a working tgetent(), set LIBS and check for termcap.h.
785# (LIBS cannot be set inside AC_CACHE_CHECK; the commands there should
786# not have side effects other than setting the cache variable, because
787# they are not executed when a cached value exists.)
788if test "x$cf_cv_lib_tgetent" != xno ; then
789	test "x$cf_cv_lib_tgetent" != xyes && CF_ADD_LIBS($cf_cv_lib_tgetent)
790	AC_DEFINE(USE_TERMCAP,1,[Define 1 to indicate that working tgetent is found])
791	if test "$cf_full_tgetent" = no ; then
792		AC_TRY_COMPILE([
793#include <termcap.h>],[
794#ifdef NCURSES_VERSION
795make an error
796#endif],[AC_DEFINE(HAVE_TERMCAP_H)])
797	else
798		AC_CHECK_HEADERS(termcap.h)
799	fi
800else
801        # If we didn't find a tgetent() that supports the buffer
802        # argument, look again to see whether we can find even
803        # a crippled one.  A crippled tgetent() is still useful to
804        # validate values for the TERM environment variable given to
805        # child processes.
806	AC_CACHE_CHECK(for partial tgetent function,cf_cv_lib_part_tgetent,[
807	cf_cv_lib_part_tgetent=no
808	for cf_termlib in $cf_TERMLIB ; do
809		LIBS="$cf_save_LIBS -l$cf_termlib"
810		AC_TRY_LINK([],[tgetent(0, "$cf_TERMVAR")],
811			[echo "there is a terminfo/tgetent in $cf_termlib" 1>&AC_FD_CC
812			 cf_cv_lib_part_tgetent="-l$cf_termlib"
813			 break])
814	done
815	LIBS="$cf_save_LIBS"
816	])
817
818	if test "$cf_cv_lib_part_tgetent" != no ; then
819		CF_ADD_LIBS($cf_cv_lib_part_tgetent)
820		AC_CHECK_HEADERS(termcap.h)
821
822                # If this is linking against ncurses, we'll trigger the
823                # ifdef in resize.c that turns the termcap stuff back off.
824		AC_DEFINE(USE_TERMINFO,1,[Define to 1 to indicate that terminfo provides the tgetent interface])
825	fi
826fi
827])dnl
828dnl ---------------------------------------------------------------------------
829dnl CF_GCC_ATTRIBUTES version: 16 updated: 2012/10/02 20:55:03
830dnl -----------------
831dnl Test for availability of useful gcc __attribute__ directives to quiet
832dnl compiler warnings.  Though useful, not all are supported -- and contrary
833dnl to documentation, unrecognized directives cause older compilers to barf.
834AC_DEFUN([CF_GCC_ATTRIBUTES],
835[
836if test "$GCC" = yes
837then
838cat > conftest.i <<EOF
839#ifndef GCC_PRINTF
840#define GCC_PRINTF 0
841#endif
842#ifndef GCC_SCANF
843#define GCC_SCANF 0
844#endif
845#ifndef GCC_NORETURN
846#define GCC_NORETURN /* nothing */
847#endif
848#ifndef GCC_UNUSED
849#define GCC_UNUSED /* nothing */
850#endif
851EOF
852if test "$GCC" = yes
853then
854	AC_CHECKING([for $CC __attribute__ directives])
855cat > conftest.$ac_ext <<EOF
856#line __oline__ "${as_me:-configure}"
857#include "confdefs.h"
858#include "conftest.h"
859#include "conftest.i"
860#if	GCC_PRINTF
861#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
862#else
863#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
864#endif
865#if	GCC_SCANF
866#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
867#else
868#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
869#endif
870extern void wow(char *,...) GCC_SCANFLIKE(1,2);
871extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
872extern void foo(void) GCC_NORETURN;
873int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
874EOF
875	cf_printf_attribute=no
876	cf_scanf_attribute=no
877	for cf_attribute in scanf printf unused noreturn
878	do
879		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
880		cf_directive="__attribute__(($cf_attribute))"
881		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
882
883		case $cf_attribute in #(vi
884		printf) #(vi
885			cf_printf_attribute=yes
886			cat >conftest.h <<EOF
887#define GCC_$cf_ATTRIBUTE 1
888EOF
889			;;
890		scanf) #(vi
891			cf_scanf_attribute=yes
892			cat >conftest.h <<EOF
893#define GCC_$cf_ATTRIBUTE 1
894EOF
895			;;
896		*) #(vi
897			cat >conftest.h <<EOF
898#define GCC_$cf_ATTRIBUTE $cf_directive
899EOF
900			;;
901		esac
902
903		if AC_TRY_EVAL(ac_compile); then
904			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
905			cat conftest.h >>confdefs.h
906			case $cf_attribute in #(vi
907			noreturn) #(vi
908				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
909				;;
910			printf) #(vi
911				cf_value='/* nothing */'
912				if test "$cf_printf_attribute" != no ; then
913					cf_value='__attribute__((format(printf,fmt,var)))'
914					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
915				fi
916				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
917				;;
918			scanf) #(vi
919				cf_value='/* nothing */'
920				if test "$cf_scanf_attribute" != no ; then
921					cf_value='__attribute__((format(scanf,fmt,var)))'
922					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
923				fi
924				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
925				;;
926			unused) #(vi
927				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
928				;;
929			esac
930		fi
931	done
932else
933	fgrep define conftest.i >>confdefs.h
934fi
935rm -rf conftest*
936fi
937])dnl
938dnl ---------------------------------------------------------------------------
939dnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
940dnl --------------
941dnl Find version of gcc
942AC_DEFUN([CF_GCC_VERSION],[
943AC_REQUIRE([AC_PROG_CC])
944GCC_VERSION=none
945if test "$GCC" = yes ; then
946	AC_MSG_CHECKING(version of $CC)
947	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
948	test -z "$GCC_VERSION" && GCC_VERSION=unknown
949	AC_MSG_RESULT($GCC_VERSION)
950fi
951])dnl
952dnl ---------------------------------------------------------------------------
953dnl CF_GCC_WARNINGS version: 31 updated: 2013/11/19 19:23:35
954dnl ---------------
955dnl Check if the compiler supports useful warning options.  There's a few that
956dnl we don't use, simply because they're too noisy:
957dnl
958dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
959dnl	-Wredundant-decls (system headers make this too noisy)
960dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
961dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
962dnl		is enabled for ncurses using "--enable-const".
963dnl	-pedantic
964dnl
965dnl Parameter:
966dnl	$1 is an optional list of gcc warning flags that a particular
967dnl		application might want to use, e.g., "no-unused" for
968dnl		-Wno-unused
969dnl Special:
970dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
971dnl
972AC_DEFUN([CF_GCC_WARNINGS],
973[
974AC_REQUIRE([CF_GCC_VERSION])
975CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
976CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
977
978cat > conftest.$ac_ext <<EOF
979#line __oline__ "${as_me:-configure}"
980int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
981EOF
982
983if test "$INTEL_COMPILER" = yes
984then
985# The "-wdXXX" options suppress warnings:
986# remark #1419: external declaration in primary source file
987# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
988# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
989# remark #193: zero used for undefined preprocessing identifier
990# remark #593: variable "curs_sb_left_arrow" was set but never used
991# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
992# remark #869: parameter "tw" was never referenced
993# remark #981: operands are evaluated in unspecified order
994# warning #279: controlling expression is constant
995
996	AC_CHECKING([for $CC warning options])
997	cf_save_CFLAGS="$CFLAGS"
998	EXTRA_CFLAGS="-Wall"
999	for cf_opt in \
1000		wd1419 \
1001		wd1683 \
1002		wd1684 \
1003		wd193 \
1004		wd593 \
1005		wd279 \
1006		wd810 \
1007		wd869 \
1008		wd981
1009	do
1010		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1011		if AC_TRY_EVAL(ac_compile); then
1012			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1013			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1014		fi
1015	done
1016	CFLAGS="$cf_save_CFLAGS"
1017
1018elif test "$GCC" = yes
1019then
1020	AC_CHECKING([for $CC warning options])
1021	cf_save_CFLAGS="$CFLAGS"
1022	EXTRA_CFLAGS=
1023	cf_warn_CONST=""
1024	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1025	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
1026	test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
1027	for cf_opt in W Wall \
1028		Wbad-function-cast \
1029		Wcast-align \
1030		Wcast-qual \
1031		Wdeclaration-after-statement \
1032		Wextra \
1033		Winline \
1034		Wmissing-declarations \
1035		Wmissing-prototypes \
1036		Wnested-externs \
1037		Wpointer-arith \
1038		Wshadow \
1039		Wstrict-prototypes \
1040		Wundef $cf_gcc_warnings $cf_warn_CONST $1
1041	do
1042		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1043		if AC_TRY_EVAL(ac_compile); then
1044			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1045			case $cf_opt in #(vi
1046			Wcast-qual) #(vi
1047				CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1048				;;
1049			Winline) #(vi
1050				case $GCC_VERSION in
1051				[[34]].*)
1052					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1053					continue;;
1054				esac
1055				;;
1056			Wpointer-arith) #(vi
1057				case $GCC_VERSION in
1058				[[12]].*)
1059					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1060					continue;;
1061				esac
1062				;;
1063			esac
1064			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1065		fi
1066	done
1067	CFLAGS="$cf_save_CFLAGS"
1068fi
1069rm -rf conftest*
1070
1071AC_SUBST(EXTRA_CFLAGS)
1072])dnl
1073dnl ---------------------------------------------------------------------------
1074dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1075dnl -------------
1076dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1077dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1078dnl (or misfeature) of glibc2, which breaks portability of many applications,
1079dnl since it is interwoven with GNU extensions.
1080dnl
1081dnl Well, yes we could work around it...
1082AC_DEFUN([CF_GNU_SOURCE],
1083[
1084AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1085AC_TRY_COMPILE([#include <sys/types.h>],[
1086#ifndef _XOPEN_SOURCE
1087make an error
1088#endif],
1089	[cf_cv_gnu_source=no],
1090	[cf_save="$CPPFLAGS"
1091	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1092	 AC_TRY_COMPILE([#include <sys/types.h>],[
1093#ifdef _XOPEN_SOURCE
1094make an error
1095#endif],
1096	[cf_cv_gnu_source=no],
1097	[cf_cv_gnu_source=yes])
1098	CPPFLAGS="$cf_save"
1099	])
1100])
1101test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1102])dnl
1103dnl ---------------------------------------------------------------------------
1104dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1105dnl ---------------
1106dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1107AC_DEFUN([CF_HELP_MESSAGE],
1108[AC_DIVERT_HELP([$1])dnl
1109])dnl
1110dnl ---------------------------------------------------------------------------
1111dnl CF_IMAKE_CFLAGS version: 31 updated: 2010/05/26 05:38:42
1112dnl ---------------
1113dnl Use imake to obtain compiler flags.  We could, in principle, write tests to
1114dnl get these, but if imake is properly configured there is no point in doing
1115dnl this.
1116dnl
1117dnl Parameters (used in constructing a sample Imakefile):
1118dnl	$1 = optional value to append to $IMAKE_CFLAGS
1119dnl	$2 = optional value to append to $IMAKE_LOADFLAGS
1120AC_DEFUN([CF_IMAKE_CFLAGS],
1121[
1122AC_PATH_PROGS(IMAKE,xmkmf imake)
1123
1124if test -n "$IMAKE" ; then
1125
1126case $IMAKE in # (vi
1127*/imake)
1128	cf_imake_opts="-DUseInstalled=YES" # (vi
1129	;;
1130*/util/xmkmf)
1131	# A single parameter tells xmkmf where the config-files are:
1132	cf_imake_opts="`echo $IMAKE|sed -e s,/config/util/xmkmf,,`" # (vi
1133	;;
1134*)
1135	cf_imake_opts=
1136	;;
1137esac
1138
1139# If it's installed properly, imake (or its wrapper, xmkmf) will point to the
1140# config directory.
1141if mkdir conftestdir; then
1142	CDPATH=; export CDPATH
1143	cf_makefile=`cd $srcdir;pwd`/Imakefile
1144	cd conftestdir
1145
1146	cat >fix_cflags.sed <<'CF_EOF'
1147s/\\//g
1148s/[[ 	]][[ 	]]*/ /g
1149s/"//g
1150:pack
1151s/\(=[[^ ]][[^ ]]*\) \([[^-]]\)/\1	\2/g
1152t pack
1153s/\(-D[[a-zA-Z0-9_]][[a-zA-Z0-9_]]*\)=\([[^\'0-9 ]][[^ ]]*\)/\1='\\"\2\\"'/g
1154s/^IMAKE[[ ]]/IMAKE_CFLAGS="/
1155s/	/ /g
1156s/$/"/
1157CF_EOF
1158
1159	cat >fix_lflags.sed <<'CF_EOF'
1160s/^IMAKE[[ 	]]*/IMAKE_LOADFLAGS="/
1161s/$/"/
1162CF_EOF
1163
1164	echo >./Imakefile
1165	test -f $cf_makefile && cat $cf_makefile >>./Imakefile
1166
1167	cat >> ./Imakefile <<'CF_EOF'
1168findstddefs:
1169	@echo IMAKE ${ALLDEFINES}ifelse([$1],,,[ $1])       | sed -f fix_cflags.sed
1170	@echo IMAKE ${EXTRA_LOAD_FLAGS}ifelse([$2],,,[ $2]) | sed -f fix_lflags.sed
1171CF_EOF
1172
1173	if ( $IMAKE $cf_imake_opts 1>/dev/null 2>&AC_FD_CC && test -f Makefile)
1174	then
1175		CF_VERBOSE(Using $IMAKE $cf_imake_opts)
1176	else
1177		# sometimes imake doesn't have the config path compiled in.  Find it.
1178		cf_config=
1179		for cf_libpath in $X_LIBS $LIBS ; do
1180			case $cf_libpath in # (vi
1181			-L*)
1182				cf_libpath=`echo .$cf_libpath | sed -e 's/^...//'`
1183				cf_libpath=$cf_libpath/X11/config
1184				if test -d $cf_libpath ; then
1185					cf_config=$cf_libpath
1186					break
1187				fi
1188				;;
1189			esac
1190		done
1191		if test -z "$cf_config" ; then
1192			AC_MSG_WARN(Could not find imake config-directory)
1193		else
1194			cf_imake_opts="$cf_imake_opts -I$cf_config"
1195			if ( $IMAKE -v $cf_imake_opts 2>&AC_FD_CC)
1196			then
1197				CF_VERBOSE(Using $IMAKE $cf_config)
1198			else
1199				AC_MSG_WARN(Cannot run $IMAKE)
1200			fi
1201		fi
1202	fi
1203
1204	# GNU make sometimes prints "make[1]: Entering...", which
1205	# would confuse us.
1206	eval `make findstddefs 2>/dev/null | grep -v make`
1207
1208	cd ..
1209	rm -rf conftestdir
1210
1211	# We use ${ALLDEFINES} rather than ${STD_DEFINES} because the former
1212	# declares XTFUNCPROTO there.  However, some vendors (e.g., SGI) have
1213	# modified it to support site.cf, adding a kludge for the /usr/include
1214	# directory.  Try to filter that out, otherwise gcc won't find its
1215	# headers.
1216	if test -n "$GCC" ; then
1217	    if test -n "$IMAKE_CFLAGS" ; then
1218		cf_nostdinc=""
1219		cf_std_incl=""
1220		cf_cpp_opts=""
1221		for cf_opt in $IMAKE_CFLAGS
1222		do
1223		    case "$cf_opt" in
1224		    -nostdinc) #(vi
1225			cf_nostdinc="$cf_opt"
1226			;;
1227		    -I/usr/include) #(vi
1228			cf_std_incl="$cf_opt"
1229			;;
1230		    *) #(vi
1231			cf_cpp_opts="$cf_cpp_opts $cf_opt"
1232			;;
1233		    esac
1234		done
1235		if test -z "$cf_nostdinc" ; then
1236		    IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl"
1237		elif test -z "$cf_std_incl" ; then
1238		    IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc"
1239		else
1240		    CF_VERBOSE(suppressed \"$cf_nostdinc\" and \"$cf_std_incl\")
1241		    IMAKE_CFLAGS="$cf_cpp_opts"
1242		fi
1243	    fi
1244	fi
1245fi
1246
1247# Some imake configurations define PROJECTROOT with an empty value.  Remove
1248# the empty definition.
1249case $IMAKE_CFLAGS in
1250*-DPROJECTROOT=/*)
1251	;;
1252*)
1253	IMAKE_CFLAGS=`echo "$IMAKE_CFLAGS" |sed -e "s,-DPROJECTROOT=[[ 	]], ,"`
1254	;;
1255esac
1256
1257fi
1258
1259CF_VERBOSE(IMAKE_CFLAGS $IMAKE_CFLAGS)
1260CF_VERBOSE(IMAKE_LOADFLAGS $IMAKE_LOADFLAGS)
1261
1262AC_SUBST(IMAKE_CFLAGS)
1263AC_SUBST(IMAKE_LOADFLAGS)
1264])dnl
1265dnl ---------------------------------------------------------------------------
1266dnl CF_INPUT_METHOD version: 3 updated: 2000/04/11 23:46:57
1267dnl ---------------
1268dnl Check if the X libraries support input-method
1269AC_DEFUN([CF_INPUT_METHOD],
1270[
1271AC_CACHE_CHECK([if X libraries support input-method],cf_cv_input_method,[
1272AC_TRY_LINK([
1273#include <X11/IntrinsicP.h>
1274#include <X11/Xatom.h>
1275#include <X11/Xutil.h>
1276#include <X11/Xmu/Atoms.h>
1277#include <X11/Xmu/Converters.h>
1278#include <X11/Xaw/XawImP.h>
1279],[
1280{
1281	XIM xim;
1282	XIMStyles *xim_styles = 0;
1283	XIMStyle input_style;
1284	Widget w = 0;
1285
1286	XSetLocaleModifiers("@im=none");
1287	xim = XOpenIM(XtDisplay(w), NULL, NULL, NULL);
1288	XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);
1289	XCloseIM(xim);
1290	input_style = (XIMPreeditNothing | XIMStatusNothing);
1291}
1292],
1293[cf_cv_input_method=yes],
1294[cf_cv_input_method=no])])
1295])dnl
1296dnl ---------------------------------------------------------------------------
1297dnl CF_INTEL_COMPILER version: 6 updated: 2014/03/17 13:13:07
1298dnl -----------------
1299dnl Check if the given compiler is really the Intel compiler for Linux.  It
1300dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1301dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1302dnl
1303dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1304dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1305dnl the wrappers for gcc and g++ warnings.
1306dnl
1307dnl $1 = GCC (default) or GXX
1308dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1309dnl $3 = CFLAGS (default) or CXXFLAGS
1310AC_DEFUN([CF_INTEL_COMPILER],[
1311AC_REQUIRE([AC_CANONICAL_HOST])
1312ifelse([$2],,INTEL_COMPILER,[$2])=no
1313
1314if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1315	case $host_os in
1316	linux*|gnu*)
1317		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
1318		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1319		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1320		AC_TRY_COMPILE([],[
1321#ifdef __INTEL_COMPILER
1322#else
1323make an error
1324#endif
1325],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1326cf_save_CFLAGS="$cf_save_CFLAGS -we147"
1327],[])
1328		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1329		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1330		;;
1331	esac
1332fi
1333])dnl
1334dnl ---------------------------------------------------------------------------
1335dnl CF_LASTLOG version: 5 updated: 2012/10/04 20:12:20
1336dnl ----------
1337dnl Check for header defining _PATH_LASTLOG, or failing that, see if the lastlog
1338dnl file exists.
1339AC_DEFUN([CF_LASTLOG],
1340[
1341AC_CHECK_HEADERS(lastlog.h paths.h)
1342AC_CACHE_CHECK(for lastlog path,cf_cv_path_lastlog,[
1343AC_TRY_COMPILE([
1344#include <sys/types.h>
1345#ifdef HAVE_LASTLOG_H
1346#include <lastlog.h>
1347#else
1348#ifdef HAVE_PATHS_H
1349#include <paths.h>
1350#endif
1351#endif],[char *path = _PATH_LASTLOG],
1352	[cf_cv_path_lastlog="_PATH_LASTLOG"],
1353	[if test -f /usr/adm/lastlog ; then
1354	 	cf_cv_path_lastlog=/usr/adm/lastlog
1355	else
1356		cf_cv_path_lastlog=no
1357	fi])
1358])
1359test $cf_cv_path_lastlog != no && AC_DEFINE(USE_LASTLOG,1,[Define to 1 if we can define lastlog pathname])
1360])dnl
1361dnl ---------------------------------------------------------------------------
1362dnl CF_LD_RPATH_OPT version: 5 updated: 2011/07/17 14:48:41
1363dnl ---------------
1364dnl For the given system and compiler, find the compiler flags to pass to the
1365dnl loader to use the "rpath" feature.
1366AC_DEFUN([CF_LD_RPATH_OPT],
1367[
1368AC_REQUIRE([CF_CHECK_CACHE])
1369
1370LD_RPATH_OPT=
1371AC_MSG_CHECKING(for an rpath option)
1372case $cf_cv_system_name in #(vi
1373irix*) #(vi
1374	if test "$GCC" = yes; then
1375		LD_RPATH_OPT="-Wl,-rpath,"
1376	else
1377		LD_RPATH_OPT="-rpath "
1378	fi
1379	;;
1380linux*|gnu*|k*bsd*-gnu) #(vi
1381	LD_RPATH_OPT="-Wl,-rpath,"
1382	;;
1383openbsd[[2-9]].*|mirbsd*) #(vi
1384	LD_RPATH_OPT="-Wl,-rpath,"
1385	;;
1386dragonfly*|freebsd*) #(vi
1387	LD_RPATH_OPT="-rpath "
1388	;;
1389netbsd*) #(vi
1390	LD_RPATH_OPT="-Wl,-rpath,"
1391	;;
1392osf*|mls+*) #(vi
1393	LD_RPATH_OPT="-rpath "
1394	;;
1395solaris2*) #(vi
1396	LD_RPATH_OPT="-R"
1397	;;
1398*)
1399	;;
1400esac
1401AC_MSG_RESULT($LD_RPATH_OPT)
1402
1403case "x$LD_RPATH_OPT" in #(vi
1404x-R*)
1405	AC_MSG_CHECKING(if we need a space after rpath option)
1406	cf_save_LIBS="$LIBS"
1407	CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
1408	AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1409	LIBS="$cf_save_LIBS"
1410	AC_MSG_RESULT($cf_rpath_space)
1411	test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
1412	;;
1413esac
1414])dnl
1415dnl ---------------------------------------------------------------------------
1416dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
1417dnl ------------
1418dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
1419dnl a monocase filesystem.
1420AC_DEFUN([CF_MAKE_TAGS],[
1421AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1422
1423AC_CHECK_PROGS(CTAGS, exctags ctags)
1424AC_CHECK_PROGS(ETAGS, exetags etags)
1425
1426AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1427
1428if test "$cf_cv_mixedcase" = yes ; then
1429	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1430else
1431	MAKE_UPPER_TAGS=no
1432fi
1433
1434if test "$MAKE_UPPER_TAGS" = yes ; then
1435	MAKE_UPPER_TAGS=
1436else
1437	MAKE_UPPER_TAGS="#"
1438fi
1439
1440if test "$MAKE_LOWER_TAGS" = yes ; then
1441	MAKE_LOWER_TAGS=
1442else
1443	MAKE_LOWER_TAGS="#"
1444fi
1445
1446AC_SUBST(CTAGS)
1447AC_SUBST(ETAGS)
1448
1449AC_SUBST(MAKE_UPPER_TAGS)
1450AC_SUBST(MAKE_LOWER_TAGS)
1451])dnl
1452dnl ---------------------------------------------------------------------------
1453dnl CF_MATH_LIB version: 8 updated: 2010/05/29 16:31:02
1454dnl -----------
1455dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
1456dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
1457dnl AC_CHECK_LIB(m,sin), because that fails for C++.
1458AC_DEFUN([CF_MATH_LIB],
1459[
1460AC_CACHE_CHECK(if -lm needed for math functions,
1461	cf_cv_need_libm,[
1462	AC_TRY_LINK([
1463	#include <stdio.h>
1464	#include <math.h>
1465	],
1466	[double x = rand(); printf("result = %g\n", ]ifelse([$2],,sin(x),$2)[)],
1467	[cf_cv_need_libm=no],
1468	[cf_cv_need_libm=yes])])
1469if test "$cf_cv_need_libm" = yes
1470then
1471ifelse($1,,[
1472	CF_ADD_LIB(m)
1473],[$1=-lm])
1474fi
1475])
1476dnl ---------------------------------------------------------------------------
1477dnl CF_MIXEDCASE_FILENAMES version: 6 updated: 2013/10/08 17:47:05
1478dnl ----------------------
1479dnl Check if the file-system supports mixed-case filenames.  If we're able to
1480dnl create a lowercase name and see it as uppercase, it doesn't support that.
1481AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1482[
1483AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1484if test "$cross_compiling" = yes ; then
1485	case $target_alias in #(vi
1486	*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*) #(vi
1487		cf_cv_mixedcase=no
1488		;;
1489	*)
1490		cf_cv_mixedcase=yes
1491		;;
1492	esac
1493else
1494	rm -f conftest CONFTEST
1495	echo test >conftest
1496	if test -f CONFTEST ; then
1497		cf_cv_mixedcase=no
1498	else
1499		cf_cv_mixedcase=yes
1500	fi
1501	rm -f conftest CONFTEST
1502fi
1503])
1504test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
1505])dnl
1506dnl ---------------------------------------------------------------------------
1507dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1508dnl ----------
1509dnl Write a debug message to config.log, along with the line number in the
1510dnl configure script.
1511AC_DEFUN([CF_MSG_LOG],[
1512echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1513])dnl
1514dnl ---------------------------------------------------------------------------
1515dnl CF_NO_LEAKS_OPTION version: 5 updated: 2012/10/02 20:55:03
1516dnl ------------------
1517dnl see CF_WITH_NO_LEAKS
1518AC_DEFUN([CF_NO_LEAKS_OPTION],[
1519AC_MSG_CHECKING(if you want to use $1 for testing)
1520AC_ARG_WITH($1,
1521	[$2],
1522	[AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
1523	 $4
1524])
1525	: ${with_cflags:=-g}
1526	: ${with_no_leaks:=yes}
1527	 with_$1=yes],
1528	[with_$1=])
1529AC_MSG_RESULT(${with_$1:-no})
1530
1531case .$with_cflags in #(vi
1532.*-g*)
1533	case .$CFLAGS in #(vi
1534	.*-g*) #(vi
1535		;;
1536	*)
1537		CF_ADD_CFLAGS([-g])
1538		;;
1539	esac
1540	;;
1541esac
1542])dnl
1543dnl ---------------------------------------------------------------------------
1544dnl CF_PATHSEP version: 6 updated: 2012/09/29 18:38:12
1545dnl ----------
1546dnl Provide a value for the $PATH and similar separator (or amend the value
1547dnl as provided in autoconf 2.5x).
1548AC_DEFUN([CF_PATHSEP],
1549[
1550	AC_MSG_CHECKING(for PATH separator)
1551	case $cf_cv_system_name in
1552	os2*)	PATH_SEPARATOR=';'  ;;
1553	*)	${PATH_SEPARATOR:=':'}  ;;
1554	esac
1555ifelse([$1],,,[$1=$PATH_SEPARATOR])
1556	AC_SUBST(PATH_SEPARATOR)
1557	AC_MSG_RESULT($PATH_SEPARATOR)
1558])dnl
1559dnl ---------------------------------------------------------------------------
1560dnl CF_PATH_PROG version: 9 updated: 2012/10/04 20:12:20
1561dnl ------------
1562dnl Check for a given program, defining corresponding symbol.
1563dnl	$1 = environment variable, which is suffixed by "_PATH" in the #define.
1564dnl	$2 = program name to find.
1565dnl	$3 = optional list of additional program names to test.
1566dnl
1567dnl If there is more than one token in the result, #define the remaining tokens
1568dnl to $1_ARGS.  We need this for 'install' in particular.
1569dnl
1570dnl FIXME: we should allow this to be overridden by environment variables
1571dnl
1572AC_DEFUN([CF_PATH_PROG],[
1573AC_REQUIRE([CF_PATHSEP])
1574test -z "[$]$1" && $1=$2
1575AC_PATH_PROGS($1,[$]$1 $2 $3,[$]$1)
1576
1577cf_path_prog=""
1578cf_path_args=""
1579IFS="${IFS:- 	}"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
1580for cf_temp in $ac_cv_path_$1
1581do
1582	if test -z "$cf_path_prog" ; then
1583		if test "$with_full_paths" = yes ; then
1584			CF_PATH_SYNTAX(cf_temp,break)
1585			cf_path_prog="$cf_temp"
1586		else
1587			cf_path_prog="`basename $cf_temp`"
1588		fi
1589	elif test -z "$cf_path_args" ; then
1590		cf_path_args="$cf_temp"
1591	else
1592		cf_path_args="$cf_path_args $cf_temp"
1593	fi
1594done
1595IFS="$cf_save_ifs"
1596
1597if test -n "$cf_path_prog" ; then
1598	CF_MSG_LOG(defining path for ${cf_path_prog})
1599	AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog",Define to pathname $1)
1600	test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args",Define to provide args for $1)
1601fi
1602])dnl
1603dnl ---------------------------------------------------------------------------
1604dnl CF_PATH_SYNTAX version: 14 updated: 2012/06/19 20:58:54
1605dnl --------------
1606dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1607dnl begins with one of the prefix/exec_prefix variables, and then again if the
1608dnl result begins with 'NONE'.  This is necessary to work around autoconf's
1609dnl delayed evaluation of those symbols.
1610AC_DEFUN([CF_PATH_SYNTAX],[
1611if test "x$prefix" != xNONE; then
1612  cf_path_syntax="$prefix"
1613else
1614  cf_path_syntax="$ac_default_prefix"
1615fi
1616
1617case ".[$]$1" in #(vi
1618.\[$]\(*\)*|.\'*\'*) #(vi
1619  ;;
1620..|./*|.\\*) #(vi
1621  ;;
1622.[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
1623  ;;
1624.\[$]{*prefix}*|.\[$]{*dir}*) #(vi
1625  eval $1="[$]$1"
1626  case ".[$]$1" in #(vi
1627  .NONE/*)
1628    $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1629    ;;
1630  esac
1631  ;; #(vi
1632.no|.NONE/*)
1633  $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1634  ;;
1635*)
1636  ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1637  ;;
1638esac
1639])dnl
1640dnl ---------------------------------------------------------------------------
1641dnl CF_PKG_CONFIG version: 7 updated: 2011/04/29 04:53:22
1642dnl -------------
1643dnl Check for the package-config program, unless disabled by command-line.
1644AC_DEFUN([CF_PKG_CONFIG],
1645[
1646AC_MSG_CHECKING(if you want to use pkg-config)
1647AC_ARG_WITH(pkg-config,
1648	[  --with-pkg-config{=path} enable/disable use of pkg-config],
1649	[cf_pkg_config=$withval],
1650	[cf_pkg_config=yes])
1651AC_MSG_RESULT($cf_pkg_config)
1652
1653case $cf_pkg_config in #(vi
1654no) #(vi
1655	PKG_CONFIG=none
1656	;;
1657yes) #(vi
1658	CF_ACVERSION_CHECK(2.52,
1659		[AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
1660		[AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
1661	;;
1662*)
1663	PKG_CONFIG=$withval
1664	;;
1665esac
1666
1667test -z "$PKG_CONFIG" && PKG_CONFIG=none
1668if test "$PKG_CONFIG" != none ; then
1669	CF_PATH_SYNTAX(PKG_CONFIG)
1670fi
1671
1672AC_SUBST(PKG_CONFIG)
1673])dnl
1674dnl ---------------------------------------------------------------------------
1675dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
1676dnl -----------------
1677dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1678dnl
1679dnl	POSIX.1-1990				_POSIX_SOURCE
1680dnl	POSIX.1-1990 and			_POSIX_SOURCE and
1681dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
1682dnl		Bindings Option
1683dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
1684dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
1685dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
1686dnl
1687dnl Parameters:
1688dnl	$1 is the nominal value for _POSIX_C_SOURCE
1689AC_DEFUN([CF_POSIX_C_SOURCE],
1690[
1691cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1692
1693cf_save_CFLAGS="$CFLAGS"
1694cf_save_CPPFLAGS="$CPPFLAGS"
1695
1696CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1697CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1698
1699AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1700	CF_MSG_LOG(if the symbol is already defined go no further)
1701	AC_TRY_COMPILE([#include <sys/types.h>],[
1702#ifndef _POSIX_C_SOURCE
1703make an error
1704#endif],
1705	[cf_cv_posix_c_source=no],
1706	[cf_want_posix_source=no
1707	 case .$cf_POSIX_C_SOURCE in #(vi
1708	 .[[12]]??*) #(vi
1709		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1710		;;
1711	 .2) #(vi
1712		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1713		cf_want_posix_source=yes
1714		;;
1715	 .*)
1716		cf_want_posix_source=yes
1717		;;
1718	 esac
1719	 if test "$cf_want_posix_source" = yes ; then
1720		AC_TRY_COMPILE([#include <sys/types.h>],[
1721#ifdef _POSIX_SOURCE
1722make an error
1723#endif],[],
1724		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1725	 fi
1726	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1727	 CFLAGS="$cf_trim_CFLAGS"
1728	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1729	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1730	 AC_TRY_COMPILE([#include <sys/types.h>],[
1731#ifndef _POSIX_C_SOURCE
1732make an error
1733#endif],,
1734	 [cf_cv_posix_c_source=no])
1735	 CFLAGS="$cf_save_CFLAGS"
1736	 CPPFLAGS="$cf_save_CPPFLAGS"
1737	])
1738])
1739
1740if test "$cf_cv_posix_c_source" != no ; then
1741	CFLAGS="$cf_trim_CFLAGS"
1742	CPPFLAGS="$cf_trim_CPPFLAGS"
1743	CF_ADD_CFLAGS($cf_cv_posix_c_source)
1744fi
1745
1746])dnl
1747dnl ---------------------------------------------------------------------------
1748dnl CF_POSIX_SAVED_IDS version: 8 updated: 2012/10/04 20:12:20
1749dnl ------------------
1750dnl
1751dnl Check first if saved-ids are always supported.  Some systems
1752dnl may require runtime checks.
1753AC_DEFUN([CF_POSIX_SAVED_IDS],
1754[
1755AC_CHECK_HEADERS( \
1756sys/param.h \
1757)
1758
1759AC_CACHE_CHECK(if POSIX saved-ids are supported,cf_cv_posix_saved_ids,[
1760AC_TRY_LINK(
1761[
1762#include <unistd.h>
1763#ifdef HAVE_SYS_PARAM_H
1764#include <sys/param.h>		/* this may define "BSD" */
1765#endif
1766],[
1767#if defined(_POSIX_SAVED_IDS) && (_POSIX_SAVED_IDS > 0)
1768	void *p = (void *) seteuid;
1769	int x = seteuid(geteuid());
1770#elif defined(BSD) && (BSD >= 199103)
1771/* The BSD's may implement the runtime check - and it fails.
1772 * However, saved-ids work almost like POSIX (close enough for most uses).
1773 */
1774#else
1775make an error
1776#endif
1777],[cf_cv_posix_saved_ids=yes
1778],[
1779AC_TRY_RUN([
1780#ifdef HAVE_STDLIB_H
1781#include <stdlib.h>
1782#endif
1783#include <unistd.h>
1784int main()
1785{
1786	void *p = (void *) seteuid;
1787	long code = sysconf(_SC_SAVED_IDS);
1788	${cf_cv_main_return:-return}  ((code > 0) ? 0 : 1);
1789}],
1790	cf_cv_posix_saved_ids=yes,
1791	cf_cv_posix_saved_ids=no,
1792	cf_cv_posix_saved_ids=unknown)
1793])
1794])
1795
1796test "$cf_cv_posix_saved_ids" = yes && AC_DEFINE(HAVE_POSIX_SAVED_IDS,1,[Define to 1 if POSIX saved-ids are supported])
1797])
1798dnl ---------------------------------------------------------------------------
1799dnl CF_POSIX_WAIT version: 3 updated: 2012/10/04 20:12:20
1800dnl -------------
1801dnl Check for POSIX wait support
1802AC_DEFUN([CF_POSIX_WAIT],
1803[
1804AC_REQUIRE([AC_HEADER_SYS_WAIT])
1805AC_CACHE_CHECK(for POSIX wait functions,cf_cv_posix_wait,[
1806AC_TRY_LINK([
1807#include <stdlib.h>
1808#include <stdio.h>
1809#include <sys/types.h>
1810#ifdef HAVE_SYS_WAIT_H
1811#include <sys/wait.h>
1812#endif
1813],[
1814	int stat_loc;
1815	pid_t pid = waitpid(-1, &stat_loc, WNOHANG|WUNTRACED);
1816	pid_t pid2 = wait(&stat_loc);
1817],
1818[cf_cv_posix_wait=yes],
1819[cf_cv_posix_wait=no])
1820])
1821test "$cf_cv_posix_wait" = yes && AC_DEFINE(USE_POSIX_WAIT,1,[Define to 1 if we have POSIX wait functions])
1822])dnl
1823dnl ---------------------------------------------------------------------------
1824dnl CF_PROCFS_CWD version: 2 updated: 2007/03/12 20:39:04
1825dnl -------------
1826dnl Find /proc tree (may be in a different place) which implements the "cwd"
1827dnl link.
1828AC_DEFUN([CF_PROCFS_CWD],[
1829AC_CACHE_CHECK(for proc tree with cwd-support,cf_cv_procfs_cwd,[
1830cf_cv_procfs_cwd=no
1831for cf_path in /proc /compat/linux/proc /usr/compat/linux/proc
1832do
1833	if test -d $cf_path && \
1834	   test -d $cf_path/$$ && \
1835	   ( test -d $cf_path/$$/cwd || \
1836	     test -L $cf_path/$$/cwd ); then
1837		cf_cv_procfs_cwd=$cf_path
1838		break
1839	fi
1840done
1841])
1842])dnl
1843dnl ---------------------------------------------------------------------------
1844dnl CF_PROG_CC version: 3 updated: 2012/10/06 15:31:55
1845dnl ----------
1846dnl standard check for CC, plus followup sanity checks
1847dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
1848AC_DEFUN([CF_PROG_CC],[
1849ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
1850CF_GCC_VERSION
1851CF_ACVERSION_CHECK(2.52,
1852	[AC_PROG_CC_STDC],
1853	[CF_ANSI_CC_REQD])
1854CF_CC_ENV_FLAGS 
1855])dnl
1856dnl ---------------------------------------------------------------------------
1857dnl CF_PROG_GROFF version: 1 updated: 2013/01/02 20:37:18
1858dnl -------------
1859dnl Check if groff is available, for cases (such as html output) where nroff
1860dnl is not enough.
1861AC_DEFUN([CF_PROG_GROFF],[
1862AC_PATH_PROG(GROFF_PATH,groff,no)
1863if test "x$GROFF_PATH" = xno
1864then
1865	NROFF_NOTE=
1866	GROFF_NOTE="#"
1867else
1868	NROFF_NOTE="#"
1869	GROFF_NOTE=
1870fi
1871AC_SUBST(GROFF_PATH)
1872AC_SUBST(GROFF_NOTE)
1873AC_SUBST(NROFF_NOTE)
1874])dnl
1875dnl ---------------------------------------------------------------------------
1876dnl CF_REGEX version: 10 updated: 2012/10/04 20:12:20
1877dnl --------
1878dnl Attempt to determine if we've got one of the flavors of regular-expression
1879dnl code that we can support.
1880AC_DEFUN([CF_REGEX],
1881[
1882
1883cf_regex_func=no
1884
1885cf_regex_libs="regex re"
1886case $host_os in #(vi
1887mingw*)
1888	cf_regex_libs="gnurx $cf_regex_libs"
1889	;;
1890esac
1891
1892AC_CHECK_FUNC(regcomp,[cf_regex_func=regcomp],[
1893	for cf_regex_lib in $cf_regex_libs
1894	do
1895		AC_CHECK_LIB($cf_regex_lib,regcomp,[
1896				CF_ADD_LIB($cf_regex_lib)
1897				cf_regex_func=regcomp
1898				break])
1899	done
1900])
1901
1902if test "$cf_regex_func" = no ; then
1903	AC_CHECK_FUNC(compile,[cf_regex_func=compile],[
1904		AC_CHECK_LIB(gen,compile,[
1905				CF_ADD_LIB(gen)
1906				cf_regex_func=compile])])
1907fi
1908
1909if test "$cf_regex_func" = no ; then
1910	AC_MSG_WARN(cannot find regular expression library)
1911fi
1912
1913AC_CACHE_CHECK(for regular-expression headers,cf_cv_regex_hdrs,[
1914
1915cf_cv_regex_hdrs=no
1916case $cf_regex_func in #(vi
1917compile) #(vi
1918	for cf_regex_hdr in regexp.h regexpr.h
1919	do
1920		AC_TRY_LINK([#include <$cf_regex_hdr>],[
1921			char *p = compile("", "", "", 0);
1922			int x = step("", "");
1923		],[
1924			cf_cv_regex_hdrs=$cf_regex_hdr
1925			break
1926		])
1927	done
1928	;;
1929*)
1930	for cf_regex_hdr in regex.h
1931	do
1932		AC_TRY_LINK([#include <sys/types.h>
1933#include <$cf_regex_hdr>],[
1934			regex_t *p;
1935			int x = regcomp(p, "", 0);
1936			int y = regexec(p, "", 0, 0, 0);
1937			regfree(p);
1938		],[
1939			cf_cv_regex_hdrs=$cf_regex_hdr
1940			break
1941		])
1942	done
1943	;;
1944esac
1945
1946])
1947
1948case $cf_cv_regex_hdrs in #(vi
1949    no)	       AC_MSG_WARN(no regular expression header found) ;; #(vi
1950    regex.h)   AC_DEFINE(HAVE_REGEX_H_FUNCS,1,[Define to 1 to include regex.h for regular expressions]) ;; #(vi
1951    regexp.h)  AC_DEFINE(HAVE_REGEXP_H_FUNCS,1,[Define to 1 to include regexp.h for regular expressions]) ;; #(vi
1952    regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS,1,[Define to 1 to include regexpr.h for regular expressions]) ;;
1953esac
1954])dnl
1955dnl ---------------------------------------------------------------------------
1956dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
1957dnl ----------------
1958dnl Remove all -U and -D options that refer to the given symbol from a list
1959dnl of C compiler options.  This works around the problem that not all
1960dnl compilers process -U and -D options from left-to-right, so a -U option
1961dnl cannot be used to cancel the effect of a preceding -D option.
1962dnl
1963dnl $1 = target (which could be the same as the source variable)
1964dnl $2 = source (including '$')
1965dnl $3 = symbol to remove
1966define([CF_REMOVE_DEFINE],
1967[
1968$1=`echo "$2" | \
1969	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
1970		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
1971])dnl
1972dnl ---------------------------------------------------------------------------
1973dnl CF_RPATH_HACK version: 11 updated: 2013/09/01 13:02:00
1974dnl -------------
1975AC_DEFUN([CF_RPATH_HACK],
1976[
1977AC_REQUIRE([CF_LD_RPATH_OPT])
1978AC_MSG_CHECKING(for updated LDFLAGS)
1979if test -n "$LD_RPATH_OPT" ; then
1980	AC_MSG_RESULT(maybe)
1981
1982	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
1983	cf_rpath_list="/usr/lib /lib"
1984	if test "$cf_ldd_prog" != no
1985	then
1986		cf_rpath_oops=
1987
1988AC_TRY_LINK([#include <stdio.h>],
1989		[printf("Hello");],
1990		[cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
1991		 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
1992
1993		# If we passed the link-test, but get a "not found" on a given library,
1994		# this could be due to inept reconfiguration of gcc to make it only
1995		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
1996		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
1997		# /usr/local libraries.
1998		if test -n "$cf_rpath_oops"
1999		then
2000			for cf_rpath_src in $cf_rpath_oops
2001			do
2002				for cf_rpath_dir in \
2003					/usr/local \
2004					/usr/pkg \
2005					/opt/sfw
2006				do
2007					if test -f $cf_rpath_dir/lib/$cf_rpath_src
2008					then
2009						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
2010						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
2011						break
2012					fi
2013				done
2014			done
2015		fi
2016	fi
2017
2018	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2019
2020	CF_RPATH_HACK_2(LDFLAGS)
2021	CF_RPATH_HACK_2(LIBS)
2022
2023	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2024else
2025	AC_MSG_RESULT(no)
2026fi
2027AC_SUBST(EXTRA_LDFLAGS)
2028])dnl
2029dnl ---------------------------------------------------------------------------
2030dnl CF_RPATH_HACK_2 version: 6 updated: 2010/04/17 16:31:24
2031dnl ---------------
2032dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
2033dnl EXTRA_LDFLAGS for each -L option found.
2034dnl
2035dnl $cf_rpath_list contains a list of directories to ignore.
2036dnl
2037dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
2038dnl      but LIBS often has misplaced -L options.
2039AC_DEFUN([CF_RPATH_HACK_2],
2040[
2041CF_VERBOSE(...checking $1 [$]$1)
2042
2043cf_rpath_dst=
2044for cf_rpath_src in [$]$1
2045do
2046	case $cf_rpath_src in #(vi
2047	-L*) #(vi
2048
2049		# check if this refers to a directory which we will ignore
2050		cf_rpath_skip=no
2051		if test -n "$cf_rpath_list"
2052		then
2053			for cf_rpath_item in $cf_rpath_list
2054			do
2055				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
2056				then
2057					cf_rpath_skip=yes
2058					break
2059				fi
2060			done
2061		fi
2062
2063		if test "$cf_rpath_skip" = no
2064		then
2065			# transform the option
2066			if test "$LD_RPATH_OPT" = "-R " ; then
2067				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
2068			else
2069				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
2070			fi
2071
2072			# if we have not already added this, add it now
2073			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
2074			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
2075			then
2076				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
2077				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
2078			fi
2079		fi
2080		;;
2081	esac
2082	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
2083done
2084$1=$cf_rpath_dst
2085
2086CF_VERBOSE(...checked $1 [$]$1)
2087AC_SUBST(EXTRA_LDFLAGS)
2088])dnl
2089dnl ---------------------------------------------------------------------------
2090dnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
2091dnl -----------
2092dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
2093dnl programs need this test).
2094dnl
2095dnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
2096dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
2097dnl winsize declaration is left alone - we may revisit this if Apple choose to
2098dnl break that part of the interface as well.
2099AC_DEFUN([CF_SIGWINCH],
2100[
2101AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
2102	AC_TRY_COMPILE([
2103#include <sys/types.h>
2104#include <sys/signal.h>
2105],[int x = SIGWINCH],
2106	[cf_cv_define_sigwinch=yes],
2107	[AC_TRY_COMPILE([
2108#undef _XOPEN_SOURCE
2109#undef _POSIX_SOURCE
2110#undef _POSIX_C_SOURCE
2111#include <sys/types.h>
2112#include <sys/signal.h>
2113],[int x = SIGWINCH],
2114	[cf_cv_define_sigwinch=maybe],
2115	[cf_cv_define_sigwinch=no])
2116])
2117])
2118
2119if test "$cf_cv_define_sigwinch" = maybe ; then
2120AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
2121cf_cv_fixup_sigwinch=unknown
2122cf_sigwinch=32
2123while test $cf_sigwinch != 1
2124do
2125	AC_TRY_COMPILE([
2126#undef _XOPEN_SOURCE
2127#undef _POSIX_SOURCE
2128#undef _POSIX_C_SOURCE
2129#include <sys/types.h>
2130#include <sys/signal.h>
2131],[
2132#if SIGWINCH != $cf_sigwinch
2133make an error
2134#endif
2135int x = SIGWINCH],
2136	[cf_cv_fixup_sigwinch=$cf_sigwinch
2137	 break])
2138
2139cf_sigwinch=`expr $cf_sigwinch - 1`
2140done
2141])
2142
2143	if test "$cf_cv_fixup_sigwinch" != unknown ; then
2144		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
2145	fi
2146fi
2147])dnl
2148dnl ---------------------------------------------------------------------------
2149dnl CF_SIG_ATOMIC_T version: 3 updated: 2012/10/04 20:12:20
2150dnl ---------------
2151dnl signal handler, but there are some gcc depedencies in that recommendation.
2152dnl Try anyway.
2153AC_DEFUN([CF_SIG_ATOMIC_T],
2154[
2155AC_MSG_CHECKING(for signal global datatype)
2156AC_CACHE_VAL(cf_cv_sig_atomic_t,[
2157	for cf_type in \
2158		"volatile sig_atomic_t" \
2159		"sig_atomic_t" \
2160		"int"
2161	do
2162	AC_TRY_COMPILE([
2163#include <sys/types.h>
2164#include <signal.h>
2165#include <stdio.h>
2166
2167extern $cf_type x;
2168$cf_type x;
2169static void handler(int sig)
2170{
2171	x = 5;
2172}],
2173		[signal(SIGINT, handler);
2174		 x = 1],
2175		[cf_cv_sig_atomic_t=$cf_type],
2176		[cf_cv_sig_atomic_t=no])
2177		test "$cf_cv_sig_atomic_t" != no && break
2178	done
2179	])
2180AC_MSG_RESULT($cf_cv_sig_atomic_t)
2181test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
2182])dnl
2183dnl ---------------------------------------------------------------------------
2184dnl CF_STRUCT_LASTLOG version: 2 updated: 2012/10/04 20:12:20
2185dnl -----------------
2186dnl Check for header defining struct lastlog, ensure that its .ll_time member
2187dnl is compatible with time().
2188AC_DEFUN([CF_STRUCT_LASTLOG],
2189[
2190AC_CHECK_HEADERS(lastlog.h)
2191AC_CACHE_CHECK(for struct lastlog,cf_cv_struct_lastlog,[
2192AC_TRY_RUN([
2193#include <sys/types.h>
2194#include <time.h>
2195#include <lastlog.h>
2196
2197int main()
2198{
2199	struct lastlog data;
2200	return (sizeof(data.ll_time) != sizeof(time_t));
2201}],[
2202cf_cv_struct_lastlog=yes],[
2203cf_cv_struct_lastlog=no],[
2204cf_cv_struct_lastlog=unknown])])
2205
2206test $cf_cv_struct_lastlog != no && AC_DEFINE(USE_STRUCT_LASTLOG,1,[Define to 1 if we have struct lastlog])
2207])dnl
2208dnl ---------------------------------------------------------------------------
2209dnl CF_SVR4 version: 5 updated: 2012/10/04 05:24:07
2210dnl -------
2211dnl Check if this is an SVR4 system.  We need the definition for xterm
2212AC_DEFUN([CF_SVR4],
2213[
2214AC_CHECK_LIB(elf, elf_begin,[
2215AC_CACHE_CHECK(if this is an SVR4 system, cf_cv_svr4,[
2216AC_TRY_COMPILE([
2217#if defined(__CYGWIN__)
2218make an error
2219#endif
2220#include <elf.h>
2221#include <sys/termio.h>
2222],[
2223static struct termio d_tio;
2224	d_tio.c_cc[VINTR] = 0;
2225	d_tio.c_cc[VQUIT] = 0;
2226	d_tio.c_cc[VERASE] = 0;
2227	d_tio.c_cc[VKILL] = 0;
2228	d_tio.c_cc[VEOF] = 0;
2229	d_tio.c_cc[VEOL] = 0;
2230	d_tio.c_cc[VMIN] = 0;
2231	d_tio.c_cc[VTIME] = 0;
2232	d_tio.c_cc[VLNEXT] = 0;
2233],
2234[cf_cv_svr4=yes],
2235[cf_cv_svr4=no])
2236])
2237])
2238test "$cf_cv_svr4" = yes && AC_DEFINE(SVR4,1,[Define to 1 if this is an SVR4 system])
2239])dnl
2240dnl ---------------------------------------------------------------------------
2241dnl CF_SYSV version: 15 updated: 2012/10/04 05:24:07
2242dnl -------
2243dnl Check if this is a SYSV platform, e.g., as used in <X11/Xos.h>, and whether
2244dnl defining it will be helpful.  The following features are used to check:
2245dnl
2246dnl a) bona-fide SVSV doesn't use const for sys_errlist[].  Since this is a
2247dnl legacy (pre-ANSI) feature, const should not apply.  Modern systems only
2248dnl declare strerror().  Xos.h declares the legacy form of str_errlist[], and
2249dnl a compile-time error will result from trying to assign to a const array.
2250dnl
2251dnl b) compile with headers that exist on SYSV hosts.
2252dnl
2253dnl c) compile with type definitions that differ on SYSV hosts from standard C.
2254AC_DEFUN([CF_SYSV],
2255[
2256AC_CHECK_HEADERS( \
2257termios.h \
2258stdlib.h \
2259X11/Intrinsic.h \
2260)
2261
2262AC_REQUIRE([CF_SYS_ERRLIST])
2263
2264AC_CACHE_CHECK(if we should define SYSV,cf_cv_sysv,[
2265AC_TRY_COMPILE([
2266#undef  SYSV
2267#define SYSV 1			/* get Xos.h to declare sys_errlist[] */
2268#ifdef HAVE_STDLIB_H
2269#include <stdlib.h>		/* look for wchar_t */
2270#endif
2271#ifdef HAVE_X11_INTRINSIC_H
2272#include <X11/Intrinsic.h>	/* Intrinsic.h has other traps... */
2273#endif
2274#ifdef HAVE_TERMIOS_H		/* needed for HPUX 10.20 */
2275#include <termios.h>
2276#define STRUCT_TERMIOS struct termios
2277#else
2278#define STRUCT_TERMIOS struct termio
2279#endif
2280#include <curses.h>
2281#include <term.h>		/* eliminate most BSD hacks */
2282#include <errno.h>		/* declare sys_errlist on older systems */
2283#include <sys/termio.h>		/* eliminate most of the remaining ones */
2284],[
2285static STRUCT_TERMIOS d_tio;
2286	d_tio.c_cc[VINTR] = 0;
2287	d_tio.c_cc[VQUIT] = 0;
2288	d_tio.c_cc[VERASE] = 0;
2289	d_tio.c_cc[VKILL] = 0;
2290	d_tio.c_cc[VEOF] = 0;
2291	d_tio.c_cc[VEOL] = 0;
2292	d_tio.c_cc[VMIN] = 0;
2293	d_tio.c_cc[VTIME] = 0;
2294#if defined(HAVE_SYS_ERRLIST) && !defined(DECL_SYS_ERRLIST)
2295sys_errlist[0] = "";		/* Cygwin mis-declares this */
2296#endif
2297],
2298[cf_cv_sysv=yes],
2299[cf_cv_sysv=no])
2300])
2301test "$cf_cv_sysv" = yes && AC_DEFINE(SYSV,1,[Define to 1 if this is an SYSV system])
2302])dnl
2303dnl ---------------------------------------------------------------------------
2304dnl CF_SYSV_UTMP version: 6 updated: 2012/10/04 20:12:20
2305dnl ------------
2306dnl Check if this is a SYSV flavor of UTMP
2307AC_DEFUN([CF_SYSV_UTMP],
2308[
2309AC_CACHE_CHECK(if $cf_cv_have_utmp is SYSV flavor,cf_cv_sysv_utmp,[
2310test "$cf_cv_have_utmp" = "utmp" && cf_prefix="ut" || cf_prefix="utx"
2311AC_TRY_LINK([
2312#include <sys/types.h>
2313#include <${cf_cv_have_utmp}.h>],[
2314struct $cf_cv_have_utmp x;
2315	set${cf_prefix}ent ();
2316	get${cf_prefix}id(&x);
2317	put${cf_prefix}line(&x);
2318	end${cf_prefix}ent();],
2319	[cf_cv_sysv_utmp=yes],
2320	[cf_cv_sysv_utmp=no])
2321])
2322test $cf_cv_sysv_utmp = yes && AC_DEFINE(USE_SYSV_UTMP,1,[Define to 1 if utmp is SYSV flavor])
2323])dnl
2324dnl ---------------------------------------------------------------------------
2325dnl CF_SYS_ERRLIST version: 6 updated: 2001/12/30 13:03:23
2326dnl --------------
2327dnl Check for declaration of sys_nerr and sys_errlist in one of stdio.h and
2328dnl errno.h.  Declaration of sys_errlist on BSD4.4 interferes with our
2329dnl declaration.  Reported by Keith Bostic.
2330AC_DEFUN([CF_SYS_ERRLIST],
2331[
2332    CF_CHECK_ERRNO(sys_nerr)
2333    CF_CHECK_ERRNO(sys_errlist)
2334])dnl
2335dnl ---------------------------------------------------------------------------
2336dnl CF_TERMIO_C_ISPEED version: 3 updated: 2012/10/04 20:12:20
2337dnl ------------------
2338dnl Check for SGI's broken redefinition of baud rates introduced in IRIX 6.5
2339dnl (there doesn't appear to be a useful predefined symbol).
2340AC_DEFUN([CF_TERMIO_C_ISPEED],
2341[
2342AC_CACHE_CHECK(for IRIX 6.5 baud-rate redefinitions,cf_cv_termio_c_ispeed,[
2343AC_TRY_COMPILE([
2344#include <sys/types.h>
2345#include <sys/termio.h>],[
2346struct termio foo;
2347foo.c_ispeed = B38400;
2348foo.c_ospeed = B9600;
2349],[cf_cv_termio_c_ispeed=yes
2350],[cf_cv_termio_c_ispeed=no])
2351])
2352test "$cf_cv_termio_c_ispeed" = yes && AC_DEFINE(HAVE_TERMIO_C_ISPEED,1,[define 1 if we have IRIX 6.5 baud-rate redefinitions])
2353])dnl
2354dnl ---------------------------------------------------------------------------
2355dnl CF_TRIM_X_LIBS version: 2 updated: 2013/07/09 21:27:22
2356dnl --------------
2357dnl Trim extra base X libraries added as a workaround for inconsistent library
2358dnl dependencies returned by "new" pkg-config files.
2359AC_DEFUN([CF_TRIM_X_LIBS],[
2360	for cf_trim_lib in Xmu Xt X11
2361	do
2362		case "$LIBS" in
2363		*-l$cf_trim_lib\ *-l$cf_trim_lib*)
2364			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
2365			CF_VERBOSE(..trimmed $LIBS)
2366			;;
2367		esac
2368	done
2369])
2370dnl ---------------------------------------------------------------------------
2371dnl CF_TRY_PKG_CONFIG version: 5 updated: 2013/07/06 21:27:06
2372dnl -----------------
2373dnl This is a simple wrapper to use for pkg-config, for libraries which may be
2374dnl available in that form.
2375dnl
2376dnl $1 = package name
2377dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
2378dnl $3 = logic to use if pkg-config does not have the package
2379AC_DEFUN([CF_TRY_PKG_CONFIG],[
2380AC_REQUIRE([CF_PKG_CONFIG])
2381
2382if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
2383	CF_VERBOSE(found package $1)
2384	cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
2385	cf_pkgconfig_libs="`$PKG_CONFIG --libs   $1 2>/dev/null`"
2386	CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
2387	CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
2388	CF_ADD_CFLAGS($cf_pkgconfig_incs)
2389	CF_ADD_LIBS($cf_pkgconfig_libs)
2390	ifelse([$2],,:,[$2])
2391else
2392	cf_pkgconfig_incs=
2393	cf_pkgconfig_libs=
2394	ifelse([$3],,:,[$3])
2395fi
2396])
2397dnl ---------------------------------------------------------------------------
2398dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
2399dnl -------------------
2400dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
2401dnl can define it successfully.
2402AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
2403AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
2404	AC_TRY_COMPILE([
2405#include <stdlib.h>
2406#include <string.h>
2407#include <sys/types.h>
2408],[
2409#ifndef _XOPEN_SOURCE
2410make an error
2411#endif],
2412	[cf_cv_xopen_source=no],
2413	[cf_save="$CPPFLAGS"
2414	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2415	 AC_TRY_COMPILE([
2416#include <stdlib.h>
2417#include <string.h>
2418#include <sys/types.h>
2419],[
2420#ifdef _XOPEN_SOURCE
2421make an error
2422#endif],
2423	[cf_cv_xopen_source=no],
2424	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
2425	CPPFLAGS="$cf_save"
2426	])
2427])
2428
2429if test "$cf_cv_xopen_source" != no ; then
2430	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
2431	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
2432	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
2433	CF_ADD_CFLAGS($cf_temp_xopen_source)
2434fi
2435])
2436dnl ---------------------------------------------------------------------------
2437dnl CF_TTY_GROUP version: 8 updated: 2012/10/04 20:12:20
2438dnl ------------
2439dnl Check if the system has a tty-group defined.  This is used in xterm when
2440dnl setting pty ownership.
2441AC_DEFUN([CF_TTY_GROUP],
2442[
2443AC_MSG_CHECKING(for explicit tty group name)
2444AC_ARG_WITH(tty-group,
2445	[  --with-tty-group=XXX    use XXX for the tty-group],
2446	[cf_tty_group=$withval],
2447	[cf_tty_group=auto...])
2448test -z "$cf_tty_group"    && cf_tty_group=auto...
2449test "$cf_tty_group" = yes && cf_tty_group=auto...
2450AC_MSG_RESULT($cf_tty_group)
2451
2452if test "$cf_tty_group" = "auto..." ; then
2453AC_CACHE_CHECK(for tty group name,cf_cv_tty_group_name,[
2454
2455# If we are configuring as root, it is hard to get a clue about the tty group.
2456# But we'll guess based on how our connection is set up - assuming it is done
2457# properly.
2458
2459cf_uid=`id | sed -e 's/^[^=]*=//' -e 's/(.*$//'`
2460# )vi
2461if test "$cf_uid" != 0 ; then
2462cf_cv_tty_group_name=
2463cf_tty_name=`tty`
2464test "$cf_tty_name" = "not a tty" && cf_tty_name=/dev/tty
2465test -z "$cf_tty_name" && cf_tty_name=/dev/tty
2466if test -c "$cf_tty_name"
2467then
2468	cf_option="-l -L"
2469
2470	# Expect listing to have fields like this:
2471	#-rwxrwxrwx   1 user      group       34293 Jul 18 16:29 pathname
2472	ls $cf_option $cf_tty_name >conftest.out
2473	read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
2474	if test -z "$cf_rest" ; then
2475		cf_option="$cf_option -g"
2476		ls $cf_option $cf_tty_name >conftest.out
2477		read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
2478	fi
2479	rm -f conftest.out
2480	cf_cv_tty_group_name=$cf_grp
2481fi
2482fi
2483
2484# If we cannot deduce the tty group, fall back on hardcoded cases
2485
2486if test -z "$cf_cv_tty_group_name"
2487then
2488case $host_os in #(vi
2489osf*) #(vi
2490	cf_cv_tty_group_name="terminal"
2491	;;
2492*)
2493	cf_cv_tty_group_name="unknown"
2494	if ( egrep '^tty:' /etc/group 2>/dev/null 1>/dev/null ) then
2495		cf_cv_tty_group_name="tty"
2496	fi
2497	;;
2498esac
2499fi
2500])
2501cf_tty_group="$cf_cv_tty_group_name"
2502else
2503	# if configure option, always do this
2504	AC_DEFINE(USE_TTY_GROUP,1,[Define to 1 if we have a tty groupname])
2505fi
2506
2507AC_DEFINE_UNQUOTED(TTY_GROUP_NAME,"$cf_tty_group",[Define to the name use for tty group])
2508
2509# This is only a double-check that the group-name we obtained above really
2510# does apply to the device.  We cannot perform this test if we are in batch
2511# mode, or if we are cross-compiling.
2512
2513AC_CACHE_CHECK(if we may use the $cf_tty_group group,cf_cv_tty_group,[
2514cf_tty_name=`tty`
2515if test "$cf_tty_name" != "not a tty"
2516then
2517AC_TRY_RUN([
2518#include <unistd.h>
2519#include <sys/types.h>
2520#include <sys/stat.h>
2521#include <grp.h>
2522int main()
2523{
2524	struct stat sb;
2525	struct group *ttygrp = getgrnam(TTY_GROUP_NAME);
2526	char *name = ttyname(0);
2527
2528	endgrent();
2529	if (ttygrp != 0
2530	 && name != 0
2531	 && stat(name, &sb) == 0
2532	 && sb.st_gid != getgid()
2533	 && sb.st_gid == ttygrp->gr_gid) {
2534		${cf_cv_main_return:-return} (0);
2535	}
2536	${cf_cv_main_return:-return} (1);
2537}
2538	],
2539	[cf_cv_tty_group=yes],
2540	[cf_cv_tty_group=no],
2541	[cf_cv_tty_group=unknown])
2542elif test "$cross_compiling" = yes; then
2543	cf_cv_tty_group=unknown
2544else
2545	cf_cv_tty_group=yes
2546fi
2547])
2548
2549if test $cf_cv_tty_group = no ; then
2550	AC_MSG_WARN(Cannot use $cf_tty_group group)
2551else
2552	AC_DEFINE(USE_TTY_GROUP)
2553fi
2554])dnl
2555dnl ---------------------------------------------------------------------------
2556dnl CF_TYPE_CC_T version: 2 updated: 2012/10/04 20:12:20
2557dnl ------------
2558dnl	Check for cc_t type, used in termio.
2559AC_DEFUN([CF_TYPE_CC_T],
2560[
2561AC_MSG_CHECKING(for cc_t in <termios.h> or <termio.h>)
2562AC_CACHE_VAL(cf_cv_type_cc_t,[
2563	AC_TRY_COMPILE([
2564#include <sys/types.h>
2565#if defined(HAVE_TERMIOS_H)
2566#include <termios.h>
2567#else
2568#include <termio.h>
2569#include <sys/ioctl.h>
2570#endif
2571],
2572		[cc_t x],
2573		[cf_cv_type_cc_t=yes],
2574		[cf_cv_type_cc_t=no])
2575	])
2576AC_MSG_RESULT($cf_cv_type_cc_t)
2577test $cf_cv_type_cc_t = no && AC_DEFINE(cc_t, unsigned char,[Define to cc_t type used in termio])
2578])dnl
2579dnl ---------------------------------------------------------------------------
2580dnl CF_TYPE_FD_MASK version: 3 updated: 2012/10/04 06:57:36
2581dnl ---------------
2582dnl Check for the declaration of fd_mask, which is like fd_set, associated
2583dnl with select().  The check for fd_set should have pulled in this as well,
2584dnl but there is a special case for Mac OS X, possibly other BSD-derived
2585dnl platforms.
2586AC_DEFUN([CF_TYPE_FD_MASK],
2587[
2588AC_REQUIRE([CF_TYPE_FD_SET])
2589
2590AC_CACHE_CHECK(for declaration of fd_mask,cf_cv_type_fd_mask,[
2591    if test x$cf_cv_type_fd_set = xX11/Xpoll.h ; then
2592        AC_TRY_COMPILE([
2593#include <X11/Xpoll.h>],[fd_mask x],,
2594        [CF_MSG_LOG(if we must define CSRG_BASED)
2595# Xosdefs.h on Mac OS X may not define this (but it should).
2596            AC_TRY_COMPILE([
2597#define CSRG_BASED
2598#include <X11/Xpoll.h>],[fd_mask x],
2599        cf_cv_type_fd_mask=CSRG_BASED)])
2600    else
2601        cf_cv_type_fd_mask=$cf_cv_type_fd_set
2602    fi
2603])
2604if test x$cf_cv_type_fd_mask = xCSRG_BASED ; then
2605    AC_DEFINE(CSRG_BASED,1,[Define to 1 if needed for declaring fd_mask()])
2606fi
2607])dnl
2608dnl ---------------------------------------------------------------------------
2609dnl CF_TYPE_FD_SET version: 5 updated: 2012/10/04 20:12:20
2610dnl --------------
2611dnl Check for the declaration of fd_set.  Some platforms declare it in
2612dnl <sys/types.h>, and some in <sys/select.h>, which requires <sys/types.h>.
2613dnl Finally, if we are using this for an X application, Xpoll.h may include
2614dnl <sys/select.h>, so we don't want to do it twice.
2615AC_DEFUN([CF_TYPE_FD_SET],
2616[
2617AC_CHECK_HEADERS(X11/Xpoll.h)
2618
2619AC_CACHE_CHECK(for declaration of fd_set,cf_cv_type_fd_set,
2620	[CF_MSG_LOG(sys/types alone)
2621AC_TRY_COMPILE([
2622#include <sys/types.h>],
2623	[fd_set x],
2624	[cf_cv_type_fd_set=sys/types.h],
2625	[CF_MSG_LOG(X11/Xpoll.h)
2626AC_TRY_COMPILE([
2627#ifdef HAVE_X11_XPOLL_H
2628#include <X11/Xpoll.h>
2629#endif],
2630	[fd_set x],
2631	[cf_cv_type_fd_set=X11/Xpoll.h],
2632	[CF_MSG_LOG(sys/select.h)
2633AC_TRY_COMPILE([
2634#include <sys/types.h>
2635#include <sys/select.h>],
2636	[fd_set x],
2637	[cf_cv_type_fd_set=sys/select.h],
2638	[cf_cv_type_fd_set=unknown])])])])
2639if test $cf_cv_type_fd_set = sys/select.h ; then
2640	AC_DEFINE(USE_SYS_SELECT_H,1,[Define to 1 to include sys/select.h to declare fd_set])
2641fi
2642])
2643dnl ---------------------------------------------------------------------------
2644dnl CF_UNDO_CFLAGS version: 1 updated: 2011/07/02 09:27:51
2645dnl --------------
2646dnl Remove flags from $CFLAGS or similar shell variable using sed.
2647dnl $1 = variable
2648dnl $2 = message
2649dnl $3 = pattern to remove
2650AC_DEFUN([CF_UNDO_CFLAGS],
2651[
2652	CF_VERBOSE(removing $2 flags from $1)
2653	$1=`echo "[$]$1" | sed -e 's/$3//'`
2654	CF_VERBOSE(...result [$]$1)
2655])dnl
2656dnl ---------------------------------------------------------------------------
2657dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
2658dnl --------
2659dnl Make an uppercase version of a variable
2660dnl $1=uppercase($2)
2661AC_DEFUN([CF_UPPER],
2662[
2663$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2664])dnl
2665dnl ---------------------------------------------------------------------------
2666dnl CF_UTEMPTER version: 4 updated: 2012/10/04 20:12:20
2667dnl -----------
2668dnl Try to link with utempter library
2669AC_DEFUN([CF_UTEMPTER],
2670[
2671AC_CACHE_CHECK(if we can link with utempter library,cf_cv_have_utempter,[
2672cf_save_LIBS="$LIBS"
2673CF_ADD_LIB(utempter)
2674AC_TRY_LINK([
2675#include <utempter.h>
2676],[
2677	addToUtmp("/dev/tty", 0, 1);
2678	removeFromUtmp();
2679],[
2680	cf_cv_have_utempter=yes],[
2681	cf_cv_have_utempter=no])
2682LIBS="$cf_save_LIBS"
2683])
2684if test "$cf_cv_have_utempter" = yes ; then
2685	AC_DEFINE(USE_UTEMPTER,1,[Define to 1 if we can/should link with utempter])
2686	CF_ADD_LIB(utempter)
2687fi
2688])dnl
2689dnl ---------------------------------------------------------------------------
2690dnl CF_UTMP version: 10 updated: 2012/10/04 20:12:20
2691dnl -------
2692dnl Check for UTMP/UTMPX headers
2693AC_DEFUN([CF_UTMP],
2694[
2695AC_REQUIRE([CF_LASTLOG])
2696
2697AC_CACHE_CHECK(for utmp implementation,cf_cv_have_utmp,[
2698	cf_cv_have_utmp=no
2699for cf_header in utmpx utmp ; do
2700cf_utmp_includes="
2701#include <sys/types.h>
2702#include <${cf_header}.h>
2703#define getutent getutxent
2704#ifdef USE_LASTLOG
2705#include <lastlog.h>	/* may conflict with utmpx.h on Linux */
2706#endif
2707"
2708	AC_TRY_COMPILE([$cf_utmp_includes],
2709	[struct $cf_header x;
2710	 char *name = x.ut_name; /* utmp.h and compatible definitions */
2711	],
2712	[cf_cv_have_utmp=$cf_header
2713	 break],
2714	[
2715	AC_TRY_COMPILE([$cf_utmp_includes],
2716	[struct $cf_header x;
2717	 char *name = x.ut_user; /* utmpx.h must declare this */
2718	],
2719	[cf_cv_have_utmp=$cf_header
2720	 break
2721	])])
2722done
2723])
2724
2725if test $cf_cv_have_utmp != no ; then
2726	AC_DEFINE(HAVE_UTMP,1,[Define to 1 if the utmp interface is available])
2727	test $cf_cv_have_utmp = utmpx && AC_DEFINE(UTMPX_FOR_UTMP,1,[Define if we have utmpx interface])
2728	CF_UTMP_UT_HOST
2729	CF_UTMP_UT_SYSLEN
2730	CF_UTMP_UT_NAME
2731	CF_UTMP_UT_XSTATUS
2732	CF_UTMP_UT_XTIME
2733	CF_UTMP_UT_SESSION
2734	CF_SYSV_UTMP
2735fi
2736])dnl
2737dnl ---------------------------------------------------------------------------
2738dnl CF_UTMP_GROUP version: 1 updated: 2005/10/06 20:29:29
2739dnl -------------
2740dnl Find the utmp/utmpx file and determine its group to allow setgid programs
2741dnl to manipulate it, e.g., when there is no intermediary.
2742AC_DEFUN([CF_UTMP_GROUP],[
2743AC_REQUIRE([CF_UTMP])
2744if test $cf_cv_have_utmp != no ; then
2745AC_CACHE_CHECK(for utmp/utmpx group,cf_cv_utmp_group,[
2746for cf_utmp_path in /var/adm /var/run
2747do
2748	for cf_utmp_file in utmpx utmp
2749	do
2750		if test -f $cf_utmp_path/$cf_utmp_file
2751		then
2752			cf_cv_utmp_group=root
2753
2754			cf_option="-l -L"
2755
2756			# Expect listing to have fields like this:
2757			#-r--r--r--   1 user      group       34293 Jul 18 16:29 pathname
2758			ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
2759			read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
2760			if test -z "$cf_rest" ; then
2761				cf_option="$cf_option -g"
2762				ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
2763				read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
2764			fi
2765			rm -f conftest
2766
2767			# If we have a pathname, and the date fields look right, assume we've
2768			# captured the group as well.
2769			if test -n "$cf_rest" ; then
2770				cf_test=`echo "${cf_date2}${cf_date3}" | sed -e 's/[[0-9:]]//g'`
2771				if test -z "$cf_test" ; then
2772					cf_cv_utmp_group=$cf_grp;
2773				fi
2774			fi
2775			break
2776		fi
2777	done
2778	test -n "$cf_cv_utmp_group" && break
2779done
2780])
2781else
2782	AC_MSG_ERROR(cannot find utmp group)
2783fi
2784])dnl
2785dnl ---------------------------------------------------------------------------
2786dnl CF_UTMP_UT_HOST version: 8 updated: 2012/10/04 20:12:20
2787dnl ---------------
2788dnl Check if UTMP/UTMPX struct defines ut_host member
2789AC_DEFUN([CF_UTMP_UT_HOST],
2790[
2791if test $cf_cv_have_utmp != no ; then
2792AC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_host is declared)
2793AC_CACHE_VAL(cf_cv_have_utmp_ut_host,[
2794	AC_TRY_COMPILE([
2795#include <sys/types.h>
2796#include <${cf_cv_have_utmp}.h>],
2797	[struct $cf_cv_have_utmp x; char *y = &x.ut_host[0]],
2798	[cf_cv_have_utmp_ut_host=yes],
2799	[cf_cv_have_utmp_ut_host=no])
2800	])
2801AC_MSG_RESULT($cf_cv_have_utmp_ut_host)
2802test $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])
2803fi
2804])dnl
2805dnl ---------------------------------------------------------------------------
2806dnl CF_UTMP_UT_NAME version: 5 updated: 2012/10/04 20:12:20
2807dnl ---------------
2808dnl Check if UTMP/UTMPX struct defines ut_name member
2809AC_DEFUN([CF_UTMP_UT_NAME],
2810[
2811if test $cf_cv_have_utmp != no ; then
2812AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_name is declared,cf_cv_have_utmp_ut_name,[
2813	cf_cv_have_utmp_ut_name=no
2814cf_utmp_includes="
2815#include <sys/types.h>
2816#include <${cf_cv_have_utmp}.h>
2817#define getutent getutxent
2818#ifdef USE_LASTLOG
2819#include <lastlog.h>		/* may conflict with utmpx.h on Linux */
2820#endif
2821"
2822for cf_header in ut_name ut_user ; do
2823	AC_TRY_COMPILE([$cf_utmp_includes],
2824	[struct $cf_cv_have_utmp x;
2825	 char *name = x.$cf_header;
2826	],
2827	[cf_cv_have_utmp_ut_name=$cf_header
2828	 break])
2829done
2830])
2831
2832case $cf_cv_have_utmp_ut_name in #(vi
2833no) #(vi
2834	AC_MSG_ERROR(Cannot find declaration for ut.ut_name)
2835	;;
2836ut_user)
2837	AC_DEFINE(ut_name,ut_user,[Define to rename UTMP/UTMPX struct ut_name member])
2838	;;
2839esac
2840fi
2841])dnl
2842dnl ---------------------------------------------------------------------------
2843dnl CF_UTMP_UT_SESSION version: 6 updated: 2012/10/04 20:12:20
2844dnl ------------------
2845dnl Check if UTMP/UTMPX struct defines ut_session member
2846AC_DEFUN([CF_UTMP_UT_SESSION],
2847[
2848if test $cf_cv_have_utmp != no ; then
2849AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_session is declared, cf_cv_have_utmp_ut_session,[
2850	AC_TRY_COMPILE([
2851#include <sys/types.h>
2852#include <${cf_cv_have_utmp}.h>],
2853	[struct $cf_cv_have_utmp x; long y = x.ut_session],
2854	[cf_cv_have_utmp_ut_session=yes],
2855	[cf_cv_have_utmp_ut_session=no])
2856])
2857if test $cf_cv_have_utmp_ut_session != no ; then
2858	AC_DEFINE(HAVE_UTMP_UT_SESSION,1,[Define to 1 if UTMP/UTMPX struct defines ut_session member])
2859fi
2860fi
2861])dnl
2862dnl ---------------------------------------------------------------------------
2863dnl CF_UTMP_UT_SYSLEN version: 2 updated: 2012/10/04 20:12:20
2864dnl -----------------
2865dnl Check if UTMP/UTMPX struct defines ut_syslen member
2866AC_DEFUN([CF_UTMP_UT_SYSLEN],
2867[
2868if test $cf_cv_have_utmp != no ; then
2869AC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_syslen is declared)
2870AC_CACHE_VAL(cf_cv_have_utmp_ut_syslen,[
2871	AC_TRY_COMPILE([
2872#include <sys/types.h>
2873#include <${cf_cv_have_utmp}.h>],
2874	[struct $cf_cv_have_utmp x; int y = x.ut_syslen],
2875	[cf_cv_have_utmp_ut_syslen=yes],
2876	[cf_cv_have_utmp_ut_syslen=no])
2877	])
2878AC_MSG_RESULT($cf_cv_have_utmp_ut_syslen)
2879test $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])
2880fi
2881])dnl
2882dnl ---------------------------------------------------------------------------
2883dnl CF_UTMP_UT_XSTATUS version: 4 updated: 2012/10/04 20:12:20
2884dnl ------------------
2885dnl Check for known variants on the UTMP/UTMPX struct's exit-status as reported
2886dnl by various people:
2887dnl
2888dnl	ut_exit.__e_exit (HPUX 11 - David Ellement, also in glibc2)
2889dnl	ut_exit.e_exit (SVR4)
2890dnl	ut_exit.ut_e_exit (os390 - Greg Smith)
2891dnl	ut_exit.ut_exit (Tru64 4.0f - Jeremie Petit, 4.0e - Tomas Vanhala)
2892dnl
2893dnl Note: utmp_xstatus is not a conventional compatibility definition in the
2894dnl system header files.
2895AC_DEFUN([CF_UTMP_UT_XSTATUS],
2896[
2897if test $cf_cv_have_utmp != no ; then
2898AC_CACHE_CHECK(for exit-status in $cf_cv_have_utmp,cf_cv_have_utmp_ut_xstatus,[
2899for cf_result in \
2900	ut_exit.__e_exit \
2901	ut_exit.e_exit \
2902	ut_exit.ut_e_exit \
2903	ut_exit.ut_exit
2904do
2905AC_TRY_COMPILE([
2906#include <sys/types.h>
2907#include <${cf_cv_have_utmp}.h>],
2908	[struct $cf_cv_have_utmp x; long y = x.$cf_result = 0],
2909	[cf_cv_have_utmp_ut_xstatus=$cf_result
2910	 break],
2911	[cf_cv_have_utmp_ut_xstatus=no])
2912done
2913])
2914if test $cf_cv_have_utmp_ut_xstatus != no ; then
2915	AC_DEFINE(HAVE_UTMP_UT_XSTATUS,1,[Define to 1 if UTMP/UTMPX has exit-status member])
2916	AC_DEFINE_UNQUOTED(ut_xstatus,$cf_cv_have_utmp_ut_xstatus,[Define if needed to rename member ut_xstatus of UTMP/UTMPX])
2917fi
2918fi
2919])dnl
2920dnl ---------------------------------------------------------------------------
2921dnl CF_UTMP_UT_XTIME version: 9 updated: 2012/10/04 20:12:20
2922dnl ----------------
2923dnl Check if UTMP/UTMPX struct defines ut_xtime member
2924AC_DEFUN([CF_UTMP_UT_XTIME],
2925[
2926if test $cf_cv_have_utmp != no ; then
2927AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_xtime is declared, cf_cv_have_utmp_ut_xtime,[
2928	AC_TRY_COMPILE([
2929#include <sys/types.h>
2930#include <${cf_cv_have_utmp}.h>],
2931	[struct $cf_cv_have_utmp x; long y = x.ut_xtime = 0],
2932	[cf_cv_have_utmp_ut_xtime=yes],
2933	[AC_TRY_COMPILE([
2934#include <sys/types.h>
2935#include <${cf_cv_have_utmp}.h>],
2936	[struct $cf_cv_have_utmp x; long y = x.ut_tv.tv_sec],
2937	[cf_cv_have_utmp_ut_xtime=define],
2938	[cf_cv_have_utmp_ut_xtime=no])
2939	])
2940])
2941if test $cf_cv_have_utmp_ut_xtime != no ; then
2942	AC_DEFINE(HAVE_UTMP_UT_XTIME,1,[Define to 1 if UTMP/UTMPX struct defines ut_xtime member])
2943	if test $cf_cv_have_utmp_ut_xtime = define ; then
2944		AC_DEFINE(ut_xtime,ut_tv.tv_sec,[Define if needed to alternate name for utmpx.ut_xtime member])
2945	fi
2946fi
2947fi
2948])dnl
2949dnl ---------------------------------------------------------------------------
2950dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
2951dnl ----------
2952dnl Use AC_VERBOSE w/o the warnings
2953AC_DEFUN([CF_VERBOSE],
2954[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
2955CF_MSG_LOG([$1])
2956])dnl
2957dnl ---------------------------------------------------------------------------
2958dnl CF_WITH_APP_CLASS version: 2 updated: 2012/10/04 04:29:52
2959dnl -----------------
2960dnl Handle configure option "--with-app-class", setting the $APP_CLASS
2961dnl variable, used for X resources.
2962dnl
2963dnl $1 = default value.
2964AC_DEFUN([CF_WITH_APP_CLASS],[
2965AC_MSG_CHECKING(for X applications class)
2966AC_ARG_WITH(app-class,
2967	[  --with-app-class=XXX    override X applications class (default $1)],
2968	[APP_CLASS=$withval],
2969	[APP_CLASS=$1])
2970
2971case x$APP_CLASS in #(vi
2972*[[/@,%]]*) #(vi
2973	AC_MSG_WARN(X applications class cannot contain punctuation)
2974	APP_CLASS=$1
2975	;;
2976x[[A-Z]]*) #(vi
2977	;;
2978*)
2979	AC_MSG_WARN([X applications class must start with capital, ignoring $APP_CLASS])
2980	APP_CLASS=$1
2981	;;
2982esac
2983
2984AC_MSG_RESULT($APP_CLASS)
2985
2986AC_SUBST(APP_CLASS)
2987])dnl
2988dnl ---------------------------------------------------------------------------
2989dnl CF_WITH_APP_DEFAULTS version: 5 updated: 2012/10/04 04:29:52
2990dnl --------------------
2991dnl Handle configure option "--with-app-defaults", setting these shell
2992dnl variables:
2993dnl
2994dnl $APPSDIR is the option value, used for installing app-defaults files.
2995dnl $no_appsdir is a "#" (comment) if "--without-app-defaults" is given.
2996dnl
2997dnl Most Linux's use this:
2998dnl 	/usr/share/X11/app-defaults
2999dnl Debian uses this:
3000dnl 	/etc/X11/app-defaults
3001dnl DragonFlyBSD ports uses this:
3002dnl 	/usr/pkg/lib/X11/app-defaults
3003dnl FreeBSD ports use these:
3004dnl 	/usr/local/lib/X11/app-defaults
3005dnl 	/usr/local/share/X11/app-defaults
3006dnl Mandriva has these:
3007dnl 	/usr/lib/X11/app-defaults
3008dnl 	/usr/lib64/X11/app-defaults
3009dnl NetBSD has these
3010dnl 	/usr/X11R7/lib/X11/app-defaults
3011dnl OpenSolaris uses
3012dnl 	32-bit:
3013dnl 	/usr/X11/etc/X11/app-defaults
3014dnl 	/usr/X11/share/X11/app-defaults
3015dnl 	/usr/X11/lib/X11/app-defaults
3016dnl	64-bit:
3017dnl 	/usr/X11/etc/X11/app-defaults
3018dnl 	/usr/X11/share/X11/app-defaults (I mkdir'd this)
3019dnl 	/usr/X11/lib/amd64/X11/app-defaults
3020dnl Solaris10 uses (in this order):
3021dnl 	/usr/openwin/lib/X11/app-defaults
3022dnl 	/usr/X11/lib/X11/app-defaults
3023AC_DEFUN([CF_WITH_APP_DEFAULTS],[
3024AC_MSG_CHECKING(for directory to install resource files)
3025AC_ARG_WITH(app-defaults,
3026	[  --with-app-defaults=DIR directory in which to install resource files (EPREFIX/lib/X11/app-defaults)],
3027	[APPSDIR=$withval],
3028	[APPSDIR='${exec_prefix}/lib/X11/app-defaults'])
3029
3030if test "x[$]APPSDIR" = xauto
3031then
3032	APPSDIR='${exec_prefix}/lib/X11/app-defaults'
3033	for cf_path in \
3034		/usr/share/X11/app-defaults \
3035		/usr/X11/share/X11/app-defaults \
3036		/usr/X11/lib/X11/app-defaults \
3037		/usr/lib/X11/app-defaults \
3038		/etc/X11/app-defaults \
3039		/usr/pkg/lib/X11/app-defaults \
3040		/usr/X11R7/lib/X11/app-defaults \
3041		/usr/X11R6/lib/X11/app-defaults \
3042		/usr/X11R5/lib/X11/app-defaults \
3043		/usr/X11R4/lib/X11/app-defaults \
3044		/usr/local/lib/X11/app-defaults \
3045		/usr/local/share/X11/app-defaults \
3046		/usr/lib64/X11/app-defaults
3047	do
3048		if test -d "$cf_path" ; then
3049			APPSDIR="$cf_path"
3050			break
3051		fi
3052	done
3053else
3054	cf_path=$APPSDIR
3055	CF_PATH_SYNTAX(cf_path)
3056fi
3057
3058AC_MSG_RESULT($APPSDIR)
3059AC_SUBST(APPSDIR)
3060
3061no_appsdir=
3062if test "$APPSDIR" = no
3063then
3064	no_appsdir="#"
3065else
3066	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(APPSDIR)"
3067fi
3068AC_SUBST(no_appsdir)
3069])dnl
3070dnl ---------------------------------------------------------------------------
3071dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
3072dnl ----------------
3073dnl Configure-option for dbmalloc.  The optional parameter is used to override
3074dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3075AC_DEFUN([CF_WITH_DBMALLOC],[
3076CF_NO_LEAKS_OPTION(dbmalloc,
3077	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
3078	[USE_DBMALLOC])
3079
3080if test "$with_dbmalloc" = yes ; then
3081	AC_CHECK_HEADER(dbmalloc.h,
3082		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
3083fi
3084])dnl
3085dnl ---------------------------------------------------------------------------
3086dnl CF_WITH_DESKTOP_CATEGORY version: 4 updated: 2013/01/01 10:50:14
3087dnl ------------------------
3088dnl Taking into account the absence of standardization of desktop categories
3089dnl take a look to see whether other applications on the current system are
3090dnl assigned any/all of a set of suggested categories.
3091dnl
3092dnl $1 = program name
3093dnl $2 = case-pattern to match comparable desktop files to obtain category
3094dnl      This pattern may contain wildcards.
3095dnl $3 = suggested categories, also a case-pattern but without wildcards,
3096dnl      since it doubles as a default value for a shell case-statement.
3097dnl $4 = categories to use if no match is found on the build-machine for the
3098dnl      --with-desktop-category "auto" setting.
3099dnl
3100dnl The macro tells the configure script to substitute the $DESKTOP_CATEGORY
3101dnl value.
3102AC_DEFUN([CF_WITH_DESKTOP_CATEGORY],[
3103AC_REQUIRE([CF_DISABLE_DESKTOP])
3104
3105if test -z "$desktop_utils"
3106then
3107	AC_MSG_CHECKING(for requested desktop-category)
3108	AC_ARG_WITH(desktop-category,
3109		[  --with-desktop-category=XXX  one or more desktop catgories or auto],
3110		[cf_desktop_want=$withval],
3111		[cf_desktop_want=auto])
3112	AC_MSG_RESULT($cf_desktop_want)
3113
3114	if test "$cf_desktop_want" = auto
3115	then
3116		rm -rf conftest*
3117		cf_desktop_also=
3118		for cf_desktop_dir in  \
3119			/usr/share/app-install \
3120			/usr/share/applications
3121		do
3122			if test -d $cf_desktop_dir
3123			then
3124				find $cf_desktop_dir -name '*.desktop' | \
3125				while true
3126				do
3127					read cf_desktop_path
3128					test -z "$cf_desktop_path" && break
3129					cf_desktop_name=`basename $cf_desktop_path .desktop`
3130					case $cf_desktop_name in #(vi
3131					$1|*-$1|$2)
3132						CF_VERBOSE(inspect $cf_desktop_path)
3133						egrep '^Categories=' $cf_desktop_path | \
3134							tr ';' '\n' | \
3135							sed -e 's%^.*=%%' -e '/^$/d' >>conftest.1
3136						;;
3137					esac
3138				done
3139			fi
3140		done
3141		if test -s conftest.1
3142		then
3143			cf_desktop_last=
3144			sort conftest.1 | \
3145			while true
3146			do
3147				read cf_desktop_this
3148				test -z "$cf_desktop_this" && break
3149				case $cf_desktop_this in #(vi
3150				Qt*|GTK*|KDE*|GNOME*|*XFCE*|*Xfce*) #(vi
3151					;;
3152				$3)
3153					test "x$cf_desktop_last" != "x$cf_desktop_this" && echo $cf_desktop_this >>conftest.2
3154					;;
3155				esac
3156				cf_desktop_last=$cf_desktop_this
3157			done
3158			cf_desktop_want=`cat conftest.2 | tr '\n' ';'`
3159		fi
3160		if test -n "$cf_desktop_want"
3161		then
3162			if test "$cf_desktop_want" = auto
3163			then
3164				cf_desktop_want=
3165			else
3166				# do a sanity check on the semicolon-separated list, ignore on failure
3167				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/[[^;]]//g'`
3168				test -z "$cf_desktop_test" && cf_desktop_want=
3169				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/^.*;$/./g'`
3170				test -z "$cf_desktop_test" && cf_desktop_want=
3171			fi
3172		fi
3173		if test -z "$cf_desktop_want"
3174		then
3175			cf_desktop_want="ifelse([$4],,ifelse([$3],,[Application;],[`echo "$3" | sed -e 's/\*//g' -e 's/|/;/g' -e 's/[[;]]*$/;/g'`]),[$4])"
3176			CF_VERBOSE(no usable value found for desktop category, using $cf_desktop_want)
3177		fi
3178	fi
3179	DESKTOP_CATEGORY=`echo "$cf_desktop_want" | sed -e 's/[[ ,]]/;/g'`
3180	CF_VERBOSE(will use Categories=$DESKTOP_CATEGORY)
3181	AC_SUBST(DESKTOP_CATEGORY)
3182fi
3183])
3184dnl ---------------------------------------------------------------------------
3185dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
3186dnl ---------------
3187dnl Configure-option for dmalloc.  The optional parameter is used to override
3188dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3189AC_DEFUN([CF_WITH_DMALLOC],[
3190CF_NO_LEAKS_OPTION(dmalloc,
3191	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
3192	[USE_DMALLOC])
3193
3194if test "$with_dmalloc" = yes ; then
3195	AC_CHECK_HEADER(dmalloc.h,
3196		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
3197fi
3198])dnl
3199dnl ---------------------------------------------------------------------------
3200dnl CF_WITH_ICONDIR version: 5 updated: 2012/07/22 09:18:02
3201dnl ---------------
3202dnl Handle configure option "--with-icondir", setting these shell variables:
3203dnl
3204dnl $ICONDIR is the option value, used for installing icon files.
3205dnl $no_icondir is a "#" (comment) if "--without-icondir" is given.
3206AC_DEFUN([CF_WITH_ICONDIR],[
3207AC_MSG_CHECKING(for directory to install icons)
3208AC_ARG_WITH(icondir,
3209	[  --with-icondir=DIR      directory in which to install icons for desktop],
3210	[ICONDIR=$withval],
3211	[test -z "$ICONDIR" && ICONDIR=no])
3212
3213if test "x[$]ICONDIR" = xauto
3214then
3215	ICONDIR='${datadir}/icons'
3216	for cf_path in \
3217		/usr/share/icons \
3218		/usr/X11R6/share/icons
3219	do
3220		if test -d "$cf_path" ; then
3221			ICONDIR="$cf_path"
3222			break
3223		fi
3224	done
3225else
3226	cf_path=$ICONDIR
3227	CF_PATH_SYNTAX(cf_path)
3228fi
3229AC_MSG_RESULT($ICONDIR)
3230AC_SUBST(ICONDIR)
3231
3232no_icondir=
3233if test "$ICONDIR" = no
3234then
3235	no_icondir="#"
3236else
3237	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(ICONDIR)"
3238fi
3239AC_SUBST(no_icondir)
3240])dnl
3241dnl ---------------------------------------------------------------------------
3242dnl CF_WITH_ICON_NAME version: 2 updated: 2013/05/27 18:34:42
3243dnl -----------------
3244dnl Allow a default icon-name to be overridden.
3245dnl $1 = default icon name
3246AC_DEFUN([CF_WITH_ICON_NAME],[
3247AC_MSG_CHECKING(for the icon name)
3248AC_ARG_WITH(icon-name,
3249	[  --with-icon-name=XXXX   override icon name (default: $1)],
3250	[ICON_NAME="$withval"],
3251	[ICON_NAME=$1])
3252case "x$ICON_NAME" in
3253xyes|xno|x)
3254	ICON_NAME=$1
3255	;;
3256esac
3257AC_SUBST(ICON_NAME)
3258AC_MSG_RESULT($ICON_NAME)
3259])dnl
3260dnl ---------------------------------------------------------------------------
3261dnl CF_WITH_ICON_SYMLINK version: 1 updated: 2013/05/27 18:34:42
3262dnl --------------------
3263dnl Workaround for systems which are (mis)configured to map all icon references
3264dnl for xterm into "xterm" name.  For instance, recent (2013) KDE ignores both
3265dnl the name given in the .desktop file (xterm-color) and the application name
3266dnl (xterm-dev).
3267dnl
3268dnl $1 = default icon name to use if symlink is wanted
3269AC_DEFUN([CF_WITH_ICON_SYMLINK],[
3270AC_MSG_CHECKING(for icon symlink to use)
3271AC_ARG_WITH(icon-symlink,
3272	[  --with-icon-symlink=XXX make symbolic link for icon name (default: $1)],
3273	[ICON_SYMLINK="$withval"],
3274	[ICON_SYMLINK=NONE])
3275case "x$ICON_SYMLINK" in
3276xyes)
3277	ICON_SYMLINK=$1
3278	;;
3279xno|x)
3280	ICON_SYMLINK=NONE
3281	;;
3282esac
3283AC_SUBST(ICON_SYMLINK)
3284AC_MSG_RESULT($ICON_SYMLINK)
3285])dnl
3286dnl ---------------------------------------------------------------------------
3287dnl CF_WITH_ICON_THEME version: 9 updated: 2013/04/17 05:31:24
3288dnl ------------------
3289dnl If asked, check for prerequisites and setup symbols to permit installing
3290dnl one or more application icons in the Red Hat icon-theme directory
3291dnl hierarchy. 
3292dnl
3293dnl If the prerequisites are missing, give a warning and revert to the long-
3294dnl standing pixmaps directory.
3295dnl
3296dnl Parameters:
3297dnl
3298dnl $1 = application icon.  This can be a list, and is not optional.
3299dnl $2 = default theme (defaults to hicolor)
3300dnl $3 = formats (defaults to list [.svg .png .xpm])
3301dnl $4 = alternate icon if no theme is used (defaults to $1).
3302dnl
3303dnl Result:
3304dnl ICON_NAME = basename of first item in $1
3305dnl ICON_LIST = reprocessed $1
3306dnl ICON_THEME = reprocessed $2
3307dnl ICON_FORMAT = reprocessed $3
3308AC_DEFUN([CF_WITH_ICON_THEME],
3309[
3310ifelse([$1],,[
3311	AC_MSG_ERROR([macro [CF_WITH_ICON_THEME] requires application-icon name])
3312],[
3313
3314CF_WITH_PIXMAPDIR
3315CF_WITH_ICONDIR
3316
3317AC_MSG_CHECKING(if icon theme should be used)
3318AC_ARG_WITH(icon-theme,
3319	[  --with-icon-theme=XXX   install icons into desktop theme (hicolor)],
3320	[ICON_THEME=$withval],
3321	[ICON_THEME=no])
3322
3323case "x$ICON_THEME" in #(vi
3324xno) #(vi
3325	;;
3326x|xyes)
3327	ICON_THEME=ifelse([$2],,hicolor,$2)
3328	;;
3329esac
3330AC_MSG_RESULT($ICON_THEME)
3331
3332if test "x$ICON_THEME" = xno
3333then
3334	if test "x$ICONDIR" != xno
3335	then
3336		CF_VERBOSE(ignoring icondir without theme)
3337		no_icondir="#"
3338	fi
3339else
3340	if test "x$ICONDIR" = xno
3341	then
3342		AC_MSG_ERROR(icondir must be set for icon theme)
3343	fi
3344fi
3345
3346: ${ICON_FORMAT:=ifelse([$3],,[".svg .png .xpm"],[$3])}
3347
3348# ICON_NAME=
3349ICON_LIST=
3350
3351ifelse([$4],,[cf_icon_list=$1],[
3352if test "x$ICON_THEME" != xno
3353then
3354	cf_icon_list="$1"
3355else
3356	cf_icon_list="$4"
3357fi
3358])
3359
3360AC_MSG_CHECKING([for icon(s) to install])
3361for cf_name in $cf_icon_list
3362do
3363	CF_VERBOSE(using $ICON_FORMAT)
3364	for cf_suffix in $ICON_FORMAT
3365	do
3366		cf_icon="${cf_name}${cf_suffix}"
3367		cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
3368		if test ! -f "${cf_left}"
3369		then
3370			if test "x$srcdir" != "x."
3371			then
3372				cf_icon="${srcdir}/${cf_left}"
3373				cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
3374				if test ! -f "${cf_left}"
3375				then
3376					continue
3377				fi
3378			else
3379				continue
3380			fi
3381		fi
3382		if test "x$ICON_THEME" != xno
3383		then
3384			cf_base=`basename $cf_left`
3385			cf_trim=`echo "$cf_base" | sed -e 's/_[[0-9]][[0-9]]x[[0-9]][[0-9]]\././'`
3386			case "x${cf_base}" in #(vi
3387			*:*) #(vi
3388				cf_next=$cf_base
3389				# user-defined mapping
3390				;;
3391			*.png) #(vi
3392				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'`
3393				if test -z "$cf_size"
3394				then
3395					AC_MSG_WARN(cannot determine size of $cf_left)
3396					continue
3397				fi
3398				cf_next="$cf_size/apps/$cf_trim"
3399				;;
3400			*.svg) #(vi
3401				cf_next="scalable/apps/$cf_trim"
3402				;;
3403			*.xpm)
3404				CF_VERBOSE(ignored XPM file in icon theme)
3405				continue
3406				;;
3407			*_[[0-9]][[0-9]]*x[[0-9]][[0-9]]*.*) #(vi
3408				cf_size=`echo "$cf_left"|sed -e 's/^.*_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\..*$/\1/'`
3409				cf_left=`echo "$cf_left"|sed -e 's/^\(.*\)_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\(\..*\)$/\1\3/'`
3410				cf_next="$cf_size/apps/$cf_base"
3411				;;
3412			esac
3413			CF_VERBOSE(adding $cf_next)
3414			cf_icon="${cf_icon}:${cf_next}"
3415		fi
3416		test -n "$ICON_LIST" && ICON_LIST="$ICON_LIST "
3417		ICON_LIST="$ICON_LIST${cf_icon}"
3418		if test -z "$ICON_NAME"
3419		then
3420			ICON_NAME=`basename $cf_icon | sed -e 's/[[.:]].*//'`
3421		fi
3422	done
3423done
3424
3425if test -n "$verbose"
3426then
3427	AC_MSG_CHECKING(result)
3428fi
3429AC_MSG_RESULT($ICON_LIST)
3430
3431if test -z "$ICON_LIST"
3432then
3433	AC_MSG_ERROR(no icons found)
3434fi
3435])
3436
3437AC_MSG_CHECKING(for icon name)
3438AC_MSG_RESULT($ICON_NAME)
3439
3440AC_SUBST(ICON_FORMAT)
3441AC_SUBST(ICON_THEME)
3442AC_SUBST(ICON_LIST)
3443AC_SUBST(ICON_NAME)
3444])dnl
3445dnl ---------------------------------------------------------------------------
3446dnl CF_WITH_IMAKE_CFLAGS version: 9 updated: 2010/05/26 05:38:42
3447dnl --------------------
3448dnl xterm and similar programs build more readily when propped up with imake's
3449dnl hand-tuned definitions.  If we do not use imake, provide fallbacks for the
3450dnl most common definitions that we're not likely to do by autoconf tests.
3451AC_DEFUN([CF_WITH_IMAKE_CFLAGS],[
3452AC_REQUIRE([CF_ENABLE_NARROWPROTO])
3453
3454AC_MSG_CHECKING(if we should use imake to help)
3455CF_ARG_DISABLE(imake,
3456	[  --disable-imake         disable use of imake for definitions],
3457	[enable_imake=no],
3458	[enable_imake=yes])
3459AC_MSG_RESULT($enable_imake)
3460
3461if test "$enable_imake" = yes ; then
3462	CF_IMAKE_CFLAGS(ifelse([$1],,,[$1]))
3463fi
3464
3465if test -n "$IMAKE" && test -n "$IMAKE_CFLAGS" ; then
3466	CF_ADD_CFLAGS($IMAKE_CFLAGS)
3467else
3468	IMAKE_CFLAGS=
3469	IMAKE_LOADFLAGS=
3470	CF_VERBOSE(make fallback definitions)
3471
3472	# We prefer config.guess' values when we can get them, to avoid
3473	# inconsistent results with uname (AIX for instance).  However,
3474	# config.guess is not always consistent either.
3475	case $host_os in
3476	*[[0-9]].[[0-9]]*)
3477		UNAME_RELEASE="$host_os"
3478		;;
3479	*)
3480		UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
3481		;;
3482	esac
3483
3484	case .$UNAME_RELEASE in
3485	*[[0-9]].[[0-9]]*)
3486		OSMAJORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/\..*//'`
3487		OSMINORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/^[[^.]]*\.//' -e 's/\..*//' -e 's/[[^0-9]].*//' `
3488		test -z "$OSMAJORVERSION" && OSMAJORVERSION=1
3489		test -z "$OSMINORVERSION" && OSMINORVERSION=0
3490		IMAKE_CFLAGS="-DOSMAJORVERSION=$OSMAJORVERSION -DOSMINORVERSION=$OSMINORVERSION $IMAKE_CFLAGS"
3491		;;
3492	esac
3493
3494	# FUNCPROTO is standard with X11R6, but XFree86 drops it, leaving some
3495	# fallback/fragments for NeedPrototypes, etc.
3496	IMAKE_CFLAGS="-DFUNCPROTO=15 $IMAKE_CFLAGS"
3497
3498	# If this is not set properly, Xaw's scrollbars will not work
3499	if test "$enable_narrowproto" = yes ; then
3500		IMAKE_CFLAGS="-DNARROWPROTO=1 $IMAKE_CFLAGS"
3501	fi
3502
3503	# Other special definitions:
3504	case $host_os in
3505	aix*)
3506		# imake on AIX 5.1 defines AIXV3.  really.
3507		IMAKE_CFLAGS="-DAIXV3 -DAIXV4 $IMAKE_CFLAGS"
3508		;;
3509	irix[[56]].*) #(vi
3510		# these are needed to make SIGWINCH work in xterm
3511		IMAKE_CFLAGS="-DSYSV -DSVR4 $IMAKE_CFLAGS"
3512		;;
3513	esac
3514
3515	CF_ADD_CFLAGS($IMAKE_CFLAGS)
3516
3517	AC_SUBST(IMAKE_CFLAGS)
3518	AC_SUBST(IMAKE_LOADFLAGS)
3519fi
3520])dnl
3521dnl ---------------------------------------------------------------------------
3522dnl CF_WITH_PCRE version: 10 updated: 2012/10/04 20:12:20
3523dnl ------------
3524dnl Add PCRE (Perl-compatible regular expressions) to the build if it is
3525dnl available and the user requests it.  Assume the application will otherwise
3526dnl use the POSIX interface.
3527dnl
3528dnl TODO allow $withval to specify package location
3529AC_DEFUN([CF_WITH_PCRE],
3530[
3531AC_REQUIRE([CF_PKG_CONFIG])
3532
3533AC_MSG_CHECKING(if you want to use PCRE for regular-expressions)
3534AC_ARG_WITH(pcre,
3535	[  --with-pcre             use PCRE for regular-expressions])
3536test -z "$with_pcre" && with_pcre=no
3537AC_MSG_RESULT($with_pcre)
3538
3539if test "$with_pcre" != no ; then
3540	CF_TRY_PKG_CONFIG(libpcre,,[
3541		AC_CHECK_LIB(pcre,pcre_compile,,
3542			AC_MSG_ERROR(Cannot find PCRE library))])
3543
3544		AC_DEFINE(HAVE_LIB_PCRE,1,[Define to 1 if we can/should compile with the PCRE library])
3545
3546		case $LIBS in #(vi
3547		*pcreposix*) #(vi
3548			;;
3549		*)
3550			AC_CHECK_LIB(pcreposix,pcreposix_regcomp,
3551				[AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we should include pcreposix.h])
3552				 CF_ADD_LIB(pcreposix)],
3553				[AC_CHECK_LIB(pcreposix,regcomp,[
3554					AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we should include pcreposix.h])
3555					CF_ADD_LIB(pcreposix)],
3556					AC_MSG_ERROR(Cannot find PCRE POSIX library)]))
3557			;;
3558		esac
3559fi
3560])dnl
3561dnl ---------------------------------------------------------------------------
3562dnl CF_WITH_PIXMAPDIR version: 3 updated: 2012/07/22 09:18:02
3563dnl -----------------
3564dnl Handle configure option "--with-pixmapdir", setting these shell variables:
3565dnl
3566dnl $PIXMAPDIR is the option value, used for installing pixmap files.
3567dnl $no_pixmapdir is a "#" (comment) if "--without-pixmapdir" is given.
3568AC_DEFUN([CF_WITH_PIXMAPDIR],[
3569AC_MSG_CHECKING(for directory to install pixmaps)
3570AC_ARG_WITH(pixmapdir,
3571	[  --with-pixmapdir=DIR    directory in which to install pixmaps (DATADIR/pixmaps)],
3572	[PIXMAPDIR=$withval],
3573	[test -z "$PIXMAPDIR" && PIXMAPDIR='${datadir}/pixmaps'])
3574
3575if test "x[$]PIXMAPDIR" = xauto
3576then
3577	PIXMAPDIR='${datadir}/pixmaps'
3578	for cf_path in \
3579		/usr/share/pixmaps \
3580		/usr/X11R6/share/pixmaps
3581	do
3582		if test -d "$cf_path" ; then
3583			PIXMAPDIR="$cf_path"
3584			break
3585		fi
3586	done
3587else
3588	cf_path=$PIXMAPDIR
3589	CF_PATH_SYNTAX(cf_path)
3590fi
3591AC_MSG_RESULT($PIXMAPDIR)
3592AC_SUBST(PIXMAPDIR)
3593
3594no_pixmapdir=
3595if test "$PIXMAPDIR" = no
3596then
3597	no_pixmapdir="#"
3598else
3599	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(PIXMAPDIR)"
3600fi
3601AC_SUBST(no_pixmapdir)
3602])dnl
3603dnl ---------------------------------------------------------------------------
3604dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
3605dnl ----------------
3606AC_DEFUN([CF_WITH_VALGRIND],[
3607CF_NO_LEAKS_OPTION(valgrind,
3608	[  --with-valgrind         test: use valgrind],
3609	[USE_VALGRIND])
3610])dnl
3611dnl ---------------------------------------------------------------------------
3612dnl CF_WITH_XPM version: 3 updated: 2012/10/04 06:57:36
3613dnl -----------
3614dnl Test for Xpm library, update compiler/loader flags if it is wanted and
3615dnl found.
3616dnl
3617dnl Also sets ICON_SUFFIX
3618AC_DEFUN([CF_WITH_XPM],
3619[
3620ICON_SUFFIX=.xbm
3621
3622cf_save_cppflags="${CPPFLAGS}"
3623cf_save_ldflags="${LDFLAGS}"
3624
3625AC_MSG_CHECKING(if you want to use the Xpm library for colored icon)
3626AC_ARG_WITH(xpm,
3627[  --with-xpm=DIR          use Xpm library for colored icon, may specify path],
3628	[cf_Xpm_library="$withval"],
3629	[cf_Xpm_library=yes])
3630AC_MSG_RESULT($cf_Xpm_library)
3631
3632if test "$cf_Xpm_library" != no ; then
3633    if test "$cf_Xpm_library" != yes ; then
3634	CPPFLAGS="$CPPFLAGS -I$withval/include"
3635	LDFLAGS="$LDFLAGS -L$withval/lib"
3636    fi
3637    AC_CHECK_HEADER(X11/xpm.h,[
3638	AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData,[
3639	    AC_DEFINE(HAVE_LIBXPM,1,[Define to 1 if we should use Xpm library])
3640	    ICON_SUFFIX=.xpm
3641	    LIBS="-lXpm $LIBS"],
3642	    [CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"],
3643	    [-lX11 $X_LIBS])],
3644	[CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"])
3645fi
3646
3647AC_SUBST(ICON_SUFFIX)
3648])dnl
3649dnl ---------------------------------------------------------------------------
3650dnl CF_XBOOL_RESULT version: 2 updated: 2012/10/04 06:57:36
3651dnl ---------------
3652dnl Translate an autoconf boolean yes/no into X11's booleans, e.g., True/False.
3653dnl Allow for more than two values, e.g., "maybe", still using the same leading
3654dnl capital convention.
3655dnl
3656dnl $1 = symbol to define
3657dnl $2 = symbol holding value
3658dnl $3 = description
3659define([CF_XBOOL_RESULT],[
3660AC_MSG_RESULT([$]$2)
3661case [$]$2 in #(vi
3662yes) #(vi
3663	$2=true
3664	;;
3665no) #(vi
3666	$2=false
3667	;;
3668esac
3669cf_xbool1=`echo "[$]$2"|sed -e 's/^\(.\).*/\1/'`
3670CF_UPPER(cf_xbool1,$cf_xbool1)
3671cf_xbool2=`echo "[$]$2"|sed -e 's/^.//'`
3672$2=${cf_xbool1}${cf_xbool2}
3673AC_DEFINE_UNQUOTED($1,[$]$2,$3)
3674AC_SUBST($2)
3675])
3676dnl ---------------------------------------------------------------------------
3677dnl CF_XKB_BELL_EXT version: 4 updated: 2012/10/04 20:12:20
3678dnl ---------------
3679dnl Check for XKB bell extension
3680AC_DEFUN([CF_XKB_BELL_EXT],[
3681AC_CACHE_CHECK(for XKB Bell extension, cf_cv_xkb_bell_ext,[
3682AC_TRY_LINK([
3683#include <X11/Intrinsic.h>
3684#include <X11/XKBlib.h>		/* has the prototype */
3685#include <X11/extensions/XKBbells.h>	/* has the XkbBI_xxx definitions */
3686],[
3687	int x = (XkbBI_Info |XkbBI_MinorError |XkbBI_MajorError |XkbBI_TerminalBell |XkbBI_MarginBell);
3688	Atom y;
3689	XkbBell((Display *)0, (Widget)0, 0, y);
3690],[cf_cv_xkb_bell_ext=yes],[cf_cv_xkb_bell_ext=no])
3691])
3692test "$cf_cv_xkb_bell_ext" = yes && AC_DEFINE(HAVE_XKB_BELL_EXT,1,[Define 1 if we have XKB Bell extension])
3693])
3694dnl ---------------------------------------------------------------------------
3695dnl CF_XKB_KEYCODE_TO_KEYSYM version: 2 updated: 2012/09/28 20:23:33
3696dnl ------------------------
3697dnl Some older vendor-unix systems made a practice of delivering fragments of
3698dnl Xkb, requiring test-compiles.
3699AC_DEFUN([CF_XKB_KEYCODE_TO_KEYSYM],[
3700AC_CACHE_CHECK(if we can use XkbKeycodeToKeysym, cf_cv_xkb_keycode_to_keysym,[
3701AC_TRY_COMPILE([
3702#include <X11/Xlib.h>
3703#include <X11/XKBlib.h>
3704],[
3705    KeySym keysym = XkbKeycodeToKeysym((Display *)0, 0, 0, 0);
3706],[
3707cf_cv_xkb_keycode_to_keysym=yes
3708],[
3709cf_cv_xkb_keycode_to_keysym=no
3710])
3711])
3712
3713if test $cf_cv_xkb_keycode_to_keysym = yes
3714then
3715	AC_CHECK_FUNCS(XkbKeycodeToKeysym)
3716fi
3717])
3718dnl ---------------------------------------------------------------------------
3719dnl CF_XKB_QUERY_EXTENSION version: 2 updated: 2012/09/28 20:23:46
3720dnl ----------------------
3721dnl see ifdef in scrollbar.c - iron out here
3722AC_DEFUN([CF_XKB_QUERY_EXTENSION],[
3723AC_CACHE_CHECK(if we can use XkbQueryExtension, cf_cv_xkb_query_extension,[
3724AC_TRY_COMPILE([
3725#include <X11/Xlib.h>
3726#include <X11/extensions/XKB.h>
3727#include <X11/XKBlib.h>
3728],[
3729	int xkbmajor = XkbMajorVersion;
3730	int xkbminor = XkbMinorVersion;
3731	int xkbopcode, xkbevent, xkberror;
3732
3733	if (XkbLibraryVersion(&xkbmajor, &xkbminor)
3734	    && XkbQueryExtension((Display *)0,
3735				 &xkbopcode,
3736				 &xkbevent,
3737				 &xkberror,
3738				 &xkbmajor,
3739				 &xkbminor))
3740		 return 0;
3741],[
3742cf_cv_xkb_query_extension=yes
3743],[
3744cf_cv_xkb_query_extension=no
3745])
3746])
3747
3748if test $cf_cv_xkb_query_extension = yes
3749then
3750	AC_CHECK_FUNCS(XkbQueryExtension)
3751fi
3752])
3753dnl ---------------------------------------------------------------------------
3754dnl CF_XOPEN_SOURCE version: 46 updated: 2014/02/09 19:30:15
3755dnl ---------------
3756dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3757dnl or adapt to the vendor's definitions to get equivalent functionality,
3758dnl without losing the common non-POSIX features.
3759dnl
3760dnl Parameters:
3761dnl	$1 is the nominal value for _XOPEN_SOURCE
3762dnl	$2 is the nominal value for _POSIX_C_SOURCE
3763AC_DEFUN([CF_XOPEN_SOURCE],[
3764AC_REQUIRE([AC_CANONICAL_HOST])
3765
3766cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
3767cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
3768cf_xopen_source=
3769
3770case $host_os in #(vi
3771aix[[4-7]]*) #(vi
3772	cf_xopen_source="-D_ALL_SOURCE"
3773	;;
3774cygwin|msys) #(vi
3775	cf_XOPEN_SOURCE=600
3776	;;
3777darwin[[0-8]].*) #(vi
3778	cf_xopen_source="-D_APPLE_C_SOURCE"
3779	;;
3780darwin*) #(vi
3781	cf_xopen_source="-D_DARWIN_C_SOURCE"
3782	cf_XOPEN_SOURCE=
3783	;;
3784freebsd*|dragonfly*) #(vi
3785	# 5.x headers associate
3786	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
3787	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
3788	cf_POSIX_C_SOURCE=200112L
3789	cf_XOPEN_SOURCE=600
3790	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3791	;;
3792hpux11*) #(vi
3793	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3794	;;
3795hpux*) #(vi
3796	cf_xopen_source="-D_HPUX_SOURCE"
3797	;;
3798irix[[56]].*) #(vi
3799	cf_xopen_source="-D_SGI_SOURCE"
3800	cf_XOPEN_SOURCE=
3801	;;
3802linux*|gnu*|mint*|k*bsd*-gnu) #(vi
3803	CF_GNU_SOURCE
3804	;;
3805mirbsd*) #(vi
3806	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
3807	cf_XOPEN_SOURCE=
3808	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3809	;;
3810netbsd*) #(vi
3811	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
3812	;;
3813openbsd[[4-9]]*) #(vi
3814	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
3815	cf_xopen_source="-D_BSD_SOURCE"
3816	cf_XOPEN_SOURCE=600
3817	;;
3818openbsd*) #(vi
3819	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3820	;;
3821osf[[45]]*) #(vi
3822	cf_xopen_source="-D_OSF_SOURCE"
3823	;;
3824nto-qnx*) #(vi
3825	cf_xopen_source="-D_QNX_SOURCE"
3826	;;
3827sco*) #(vi
3828	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
3829	;;
3830solaris2.*) #(vi
3831	cf_xopen_source="-D__EXTENSIONS__"
3832	cf_cv_xopen_source=broken
3833	;;
3834*)
3835	CF_TRY_XOPEN_SOURCE
3836	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3837	;;
3838esac
3839
3840if test -n "$cf_xopen_source" ; then
3841	CF_ADD_CFLAGS($cf_xopen_source)
3842fi
3843
3844dnl In anything but the default case, we may have system-specific setting
3845dnl which is still not guaranteed to provide all of the entrypoints that
3846dnl _XOPEN_SOURCE would yield.
3847if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
3848	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
3849	AC_TRY_COMPILE([#include <stdlib.h>],[
3850#ifndef _XOPEN_SOURCE
3851make an error
3852#endif],
3853	[cf_XOPEN_SOURCE_set=yes],
3854	[cf_XOPEN_SOURCE_set=no])
3855	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
3856	if test $cf_XOPEN_SOURCE_set = yes
3857	then
3858		AC_TRY_COMPILE([#include <stdlib.h>],[
3859#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
3860make an error
3861#endif],
3862		[cf_XOPEN_SOURCE_set_ok=yes],
3863		[cf_XOPEN_SOURCE_set_ok=no])
3864		if test $cf_XOPEN_SOURCE_set_ok = no
3865		then
3866			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
3867		fi
3868	else
3869		CF_TRY_XOPEN_SOURCE
3870	fi
3871fi
3872])
3873dnl ---------------------------------------------------------------------------
3874dnl CF_X_ATHENA version: 21 updated: 2013/07/06 21:27:06
3875dnl -----------
3876dnl Check for Xaw (Athena) libraries
3877dnl
3878dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
3879AC_DEFUN([CF_X_ATHENA],
3880[
3881cf_x_athena=${cf_x_athena:-Xaw}
3882
3883AC_MSG_CHECKING(if you want to link with Xaw 3d library)
3884withval=
3885AC_ARG_WITH(Xaw3d,
3886	[  --with-Xaw3d            link with Xaw 3d library])
3887if test "$withval" = yes ; then
3888	cf_x_athena=Xaw3d
3889	AC_MSG_RESULT(yes)
3890else
3891	AC_MSG_RESULT(no)
3892fi
3893
3894AC_MSG_CHECKING(if you want to link with neXT Athena library)
3895withval=
3896AC_ARG_WITH(neXtaw,
3897	[  --with-neXtaw           link with neXT Athena library])
3898if test "$withval" = yes ; then
3899	cf_x_athena=neXtaw
3900	AC_MSG_RESULT(yes)
3901else
3902	AC_MSG_RESULT(no)
3903fi
3904
3905AC_MSG_CHECKING(if you want to link with Athena-Plus library)
3906withval=
3907AC_ARG_WITH(XawPlus,
3908	[  --with-XawPlus          link with Athena-Plus library])
3909if test "$withval" = yes ; then
3910	cf_x_athena=XawPlus
3911	AC_MSG_RESULT(yes)
3912else
3913	AC_MSG_RESULT(no)
3914fi
3915
3916cf_x_athena_lib=""
3917
3918if test "$PKG_CONFIG" != none ; then
3919	cf_athena_list=
3920	test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
3921	for cf_athena_pkg in \
3922		$cf_athena_list \
3923		${cf_x_athena} \
3924		${cf_x_athena}-devel \
3925		lib${cf_x_athena} \
3926		lib${cf_x_athena}-devel
3927	do
3928		CF_TRY_PKG_CONFIG($cf_athena_pkg,[
3929			cf_x_athena_lib="$cf_pkgconfig_libs"
3930			CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
3931			AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
3932
3933			CF_TRIM_X_LIBS
3934
3935AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
3936AC_TRY_LINK([
3937#include <X11/Xmu/CharSet.h>
3938],[
3939int check = XmuCompareISOLatin1("big", "small")
3940],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
3941
3942			if test "$cf_cv_xaw_compat" = no
3943			then
3944				# workaround for broken ".pc" files...
3945				case "$cf_x_athena_lib" in #(vi
3946				*-lXmu*) #(vi
3947					;;
3948				*)
3949					CF_VERBOSE(work around broken package)
3950					cf_save_xmu="$LIBS"
3951					cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
3952					CF_TRY_PKG_CONFIG(xmu,[
3953							LIBS="$cf_save_xmu"
3954							CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
3955						],[
3956							CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
3957						])
3958					CF_TRIM_X_LIBS
3959					;;
3960				esac
3961			fi
3962
3963			break])
3964	done
3965fi
3966
3967if test -z "$cf_x_athena_lib" ; then
3968	CF_X_EXT
3969	CF_X_TOOLKIT
3970	CF_X_ATHENA_CPPFLAGS($cf_x_athena)
3971	CF_X_ATHENA_LIBS($cf_x_athena)
3972fi
3973])dnl
3974dnl ---------------------------------------------------------------------------
3975dnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
3976dnl --------------------
3977dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
3978dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
3979AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
3980[
3981cf_x_athena_root=ifelse([$1],,Xaw,[$1])
3982cf_x_athena_inc=""
3983
3984for cf_path in default \
3985	/usr/contrib/X11R6 \
3986	/usr/contrib/X11R5 \
3987	/usr/lib/X11R5 \
3988	/usr/local
3989do
3990	if test -z "$cf_x_athena_inc" ; then
3991		cf_save="$CPPFLAGS"
3992		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
3993		if test $cf_path != default ; then
3994			CPPFLAGS="$cf_save -I$cf_path/include"
3995			AC_MSG_CHECKING(for $cf_test in $cf_path)
3996		else
3997			AC_MSG_CHECKING(for $cf_test)
3998		fi
3999		AC_TRY_COMPILE([
4000#include <X11/Intrinsic.h>
4001#include <$cf_test>],[],
4002			[cf_result=yes],
4003			[cf_result=no])
4004		AC_MSG_RESULT($cf_result)
4005		if test "$cf_result" = yes ; then
4006			cf_x_athena_inc=$cf_path
4007			break
4008		else
4009			CPPFLAGS="$cf_save"
4010		fi
4011	fi
4012done
4013
4014if test -z "$cf_x_athena_inc" ; then
4015	AC_MSG_WARN(
4016[Unable to successfully find Athena header files with test program])
4017elif test "$cf_x_athena_inc" != default ; then
4018	CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
4019fi
4020])
4021dnl ---------------------------------------------------------------------------
4022dnl CF_X_ATHENA_LIBS version: 12 updated: 2011/07/17 19:55:02
4023dnl ----------------
4024dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
4025dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
4026AC_DEFUN([CF_X_ATHENA_LIBS],
4027[AC_REQUIRE([CF_X_TOOLKIT])
4028cf_x_athena_root=ifelse([$1],,Xaw,[$1])
4029cf_x_athena_lib=""
4030
4031for cf_path in default \
4032	/usr/contrib/X11R6 \
4033	/usr/contrib/X11R5 \
4034	/usr/lib/X11R5 \
4035	/usr/local
4036do
4037	for cf_lib in \
4038		${cf_x_athena_root} \
4039		${cf_x_athena_root}7 \
4040		${cf_x_athena_root}6
4041	do
4042	for cf_libs in \
4043		"-l$cf_lib -lXmu" \
4044		"-l$cf_lib -lXpm -lXmu" \
4045		"-l${cf_lib}_s -lXmu_s"
4046	do
4047		if test -z "$cf_x_athena_lib" ; then
4048			cf_save="$LIBS"
4049			cf_test=XawSimpleMenuAddGlobalActions
4050			if test $cf_path != default ; then
4051				CF_ADD_LIBS(-L$cf_path/lib $cf_libs)
4052				AC_MSG_CHECKING(for $cf_libs in $cf_path)
4053			else
4054				CF_ADD_LIBS($cf_libs)
4055				AC_MSG_CHECKING(for $cf_test in $cf_libs)
4056			fi
4057			AC_TRY_LINK([
4058#include <X11/Intrinsic.h>
4059#include <X11/$cf_x_athena_root/SimpleMenu.h>
4060],[
4061$cf_test((XtAppContext) 0)],
4062				[cf_result=yes],
4063				[cf_result=no])
4064			AC_MSG_RESULT($cf_result)
4065			if test "$cf_result" = yes ; then
4066				cf_x_athena_lib="$cf_libs"
4067				break
4068			fi
4069			LIBS="$cf_save"
4070		fi
4071	done # cf_libs
4072		test -n "$cf_x_athena_lib" && break
4073	done # cf_lib
4074done
4075
4076if test -z "$cf_x_athena_lib" ; then
4077	AC_MSG_ERROR(
4078[Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
4079fi
4080
4081CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
4082AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
4083])
4084dnl ---------------------------------------------------------------------------
4085dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
4086dnl --------
4087AC_DEFUN([CF_X_EXT],[
4088CF_TRY_PKG_CONFIG(Xext,,[
4089	AC_CHECK_LIB(Xext,XextCreateExtension,
4090		[CF_ADD_LIB(Xext)])])
4091])dnl
4092dnl ---------------------------------------------------------------------------
4093dnl CF_X_FONTCONFIG version: 5 updated: 2013/07/06 21:27:06
4094dnl ---------------
4095dnl Check for fontconfig library, a dependency of the X FreeType library.
4096AC_DEFUN([CF_X_FONTCONFIG],
4097[
4098AC_REQUIRE([CF_X_FREETYPE])
4099
4100if test "$cf_cv_found_freetype" = yes ; then
4101AC_CACHE_CHECK(for usable Xft/fontconfig package,cf_cv_xft_compat,[
4102AC_TRY_LINK([
4103#include <X11/Xft/Xft.h>
4104],[
4105	XftPattern *pat;
4106	XftPatternBuild(pat,
4107					XFT_FAMILY, XftTypeString, "mono",
4108					(void *) 0);
4109],[cf_cv_xft_compat=yes],[cf_cv_xft_compat=no])
4110])
4111
4112if test "$cf_cv_xft_compat" = no
4113then
4114	# workaround for broken ".pc" files used for Xft.
4115	case "$cf_cv_x_freetype_libs" in #(vi
4116	*-lfontconfig*) #(vi
4117		;;
4118	*)
4119		CF_VERBOSE(work around broken package)
4120		cf_save_fontconfig="$LIBS"
4121		CF_TRY_PKG_CONFIG(fontconfig,[
4122				CF_ADD_CFLAGS($cf_pkgconfig_incs)
4123				LIBS="$cf_save_fontconfig"
4124				CF_ADD_LIB_AFTER(-lXft,$cf_pkgconfig_libs)
4125			],[
4126				CF_ADD_LIB_AFTER(-lXft,-lfontconfig)
4127			])
4128		;;
4129	esac
4130fi
4131fi
4132])dnl
4133dnl ---------------------------------------------------------------------------
4134dnl CF_X_FREETYPE version: 26 updated: 2012/10/04 20:12:20
4135dnl -------------
4136dnl Check for X FreeType headers and libraries (XFree86 4.x, etc).
4137dnl
4138dnl First check for the appropriate config program, since the developers for
4139dnl these libraries change their configuration (and config program) more or
4140dnl less randomly.  If we cannot find the config program, do not bother trying
4141dnl to guess the latest variation of include/lib directories.
4142dnl
4143dnl If either or both of these configure-script options are not given, rely on
4144dnl the output of the config program to provide the cflags/libs options:
4145dnl	--with-freetype-cflags
4146dnl	--with-freetype-libs
4147AC_DEFUN([CF_X_FREETYPE],
4148[
4149AC_REQUIRE([CF_PKG_CONFIG])
4150
4151cf_cv_x_freetype_incs=no
4152cf_cv_x_freetype_libs=no
4153cf_extra_freetype_libs=
4154FREETYPE_CONFIG=none
4155FREETYPE_PARAMS=
4156
4157AC_MSG_CHECKING(for FreeType configuration script)
4158AC_ARG_WITH(freetype-config,
4159	[  --with-freetype-config  configure script to use for FreeType],
4160	[cf_cv_x_freetype_cfgs="$withval"],
4161	[cf_cv_x_freetype_cfgs=auto])
4162test -z $cf_cv_x_freetype_cfgs && cf_cv_x_freetype_cfgs=auto
4163test $cf_cv_x_freetype_cfgs = no && cf_cv_x_freetype_cfgs=none
4164AC_MSG_RESULT($cf_cv_x_freetype_cfgs)
4165
4166case $cf_cv_x_freetype_cfgs in
4167none) #(vi
4168	AC_MSG_CHECKING(if you specified -D/-I options for FreeType)
4169	AC_ARG_WITH(freetype-cflags,
4170		[  --with-freetype-cflags  -D/-I options for compiling with FreeType],
4171		[cf_cv_x_freetype_incs="$with_freetype_cflags"],
4172		[cf_cv_x_freetype_incs=no])
4173	AC_MSG_RESULT($cf_cv_x_freetype_incs)
4174
4175	AC_MSG_CHECKING(if you specified -L/-l options for FreeType)
4176	AC_ARG_WITH(freetype-libs,
4177		[  --with-freetype-libs    -L/-l options to link FreeType],
4178		[cf_cv_x_freetype_libs="$with_freetype_libs"],
4179		[cf_cv_x_freetype_libs=no])
4180	AC_MSG_RESULT($cf_cv_x_freetype_libs)
4181	;;
4182auto) #(vi
4183	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
4184		FREETYPE_CONFIG=$PKG_CONFIG
4185		FREETYPE_PARAMS=xft
4186	else
4187		AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, none)
4188		if test "$FREETYPE_CONFIG" != none; then
4189			FREETYPE_CONFIG=$FREETYPE_CONFIG
4190			cf_extra_freetype_libs="-lXft"
4191		else
4192			AC_PATH_PROG(FREETYPE_OLD_CONFIG, xft-config, none)
4193			if test "$FREETYPE_OLD_CONFIG" != none; then
4194				FREETYPE_CONFIG=$FREETYPE_OLD_CONFIG
4195			fi
4196		fi
4197	fi
4198	;;
4199pkg*) #(vi
4200	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
4201		FREETYPE_CONFIG=$cf_cv_x_freetype_cfgs
4202		FREETYPE_PARAMS=xft
4203	else
4204		AC_MSG_WARN(cannot find pkg-config for Xft)
4205	fi
4206	;;
4207*) #(vi
4208	AC_PATH_PROG(FREETYPE_XFT_CONFIG, $cf_cv_x_freetype_cfgs, none)
4209	if test "$FREETYPE_XFT_CONFIG" != none; then
4210		FREETYPE_CONFIG=$FREETYPE_XFT_CONFIG
4211	else
4212		AC_MSG_WARN(cannot find config script for Xft)
4213	fi
4214	;;
4215esac
4216
4217if test "$FREETYPE_CONFIG" != none ; then
4218	AC_MSG_CHECKING(for FreeType config)
4219	AC_MSG_RESULT($FREETYPE_CONFIG $FREETYPE_PARAMS)
4220
4221	if test "$cf_cv_x_freetype_incs" = no ; then
4222		AC_MSG_CHECKING(for $FREETYPE_CONFIG cflags)
4223		cf_cv_x_freetype_incs="`$FREETYPE_CONFIG $FREETYPE_PARAMS --cflags 2>/dev/null`"
4224		AC_MSG_RESULT($cf_cv_x_freetype_incs)
4225	fi
4226
4227	if test "$cf_cv_x_freetype_libs" = no ; then
4228		AC_MSG_CHECKING(for $FREETYPE_CONFIG libs)
4229		cf_cv_x_freetype_libs="$cf_extra_freetype_libs `$FREETYPE_CONFIG $FREETYPE_PARAMS --libs 2>/dev/null`"
4230		AC_MSG_RESULT($cf_cv_x_freetype_libs)
4231	fi
4232fi
4233
4234if test "$cf_cv_x_freetype_incs" = no ; then
4235	cf_cv_x_freetype_incs=
4236fi
4237
4238if test "$cf_cv_x_freetype_libs" = no ; then
4239	cf_cv_x_freetype_libs=-lXft
4240fi
4241
4242AC_MSG_CHECKING(if we can link with FreeType libraries)
4243
4244cf_save_LIBS="$LIBS"
4245cf_save_INCS="$CPPFLAGS"
4246
4247CF_ADD_LIBS($cf_cv_x_freetype_libs)
4248CPPFLAGS="$CPPFLAGS $cf_cv_x_freetype_incs"
4249
4250AC_TRY_LINK([
4251#include <X11/Xlib.h>
4252#include <X11/extensions/Xrender.h>
4253#include <X11/Xft/Xft.h>],[
4254	XftPattern  *pat = XftNameParse ("name");],
4255	[cf_cv_found_freetype=yes],
4256	[cf_cv_found_freetype=no])
4257AC_MSG_RESULT($cf_cv_found_freetype)
4258
4259LIBS="$cf_save_LIBS"
4260CPPFLAGS="$cf_save_INCS"
4261
4262if test "$cf_cv_found_freetype" = yes ; then
4263	CF_ADD_LIBS($cf_cv_x_freetype_libs)
4264	CF_ADD_CFLAGS($cf_cv_x_freetype_incs)
4265	AC_DEFINE(XRENDERFONT,1,[Define to 1 if we can/should link with FreeType libraries])
4266
4267AC_CHECK_FUNCS( \
4268	XftDrawCharSpec \
4269	XftDrawSetClip \
4270	XftDrawSetClipRectangles \
4271)
4272
4273else
4274	AC_MSG_WARN(No libraries found for FreeType)
4275	CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
4276fi
4277
4278# FIXME: revisit this if needed
4279AC_SUBST(HAVE_TYPE_FCCHAR32)
4280AC_SUBST(HAVE_TYPE_XFTCHARSPEC)
4281])
4282dnl ---------------------------------------------------------------------------
4283dnl CF_X_TOOLKIT version: 21 updated: 2012/10/04 06:57:36
4284dnl ------------
4285dnl Check for X Toolkit libraries
4286dnl
4287AC_DEFUN([CF_X_TOOLKIT],
4288[
4289AC_REQUIRE([AC_PATH_XTRA])
4290AC_REQUIRE([CF_CHECK_CACHE])
4291
4292cf_have_X_LIBS=no
4293
4294CF_TRY_PKG_CONFIG(xt,[
4295
4296	case "x$LIBS" in #(vi
4297	*-lX11*) #(vi
4298		;;
4299	*)
4300# we have an "xt" package, but it may omit Xt's dependency on X11
4301AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
4302AC_TRY_LINK([
4303#include <X11/Xlib.h>
4304],[
4305	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
4306	int rc2 = XClearWindow((Display*) 0, (Window) 0);
4307	int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
4308	int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
4309],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
4310		if test "$cf_cv_xt_x11_compat" = no
4311		then
4312			CF_VERBOSE(work around broken X11 dependency)
4313			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.
4314			CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
4315		fi
4316		;;
4317	esac
4318
4319AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
4320AC_TRY_LINK([
4321#include <X11/Shell.h>
4322],[int num = IceConnectionNumber(0)
4323],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
4324
4325	if test "$cf_cv_xt_ice_compat" = no
4326	then
4327		# workaround for broken ".pc" files used for X Toolkit.
4328		case "x$X_PRE_LIBS" in #(vi
4329		*-lICE*)
4330			case "x$LIBS" in #(vi
4331			*-lICE*) #(vi
4332				;;
4333			*)
4334				CF_VERBOSE(work around broken ICE dependency)
4335				CF_TRY_PKG_CONFIG(ice,
4336					[CF_TRY_PKG_CONFIG(sm)],
4337					[CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
4338				;;
4339			esac
4340			;;
4341		esac
4342	fi
4343
4344	cf_have_X_LIBS=yes
4345],[
4346
4347	LDFLAGS="$X_LIBS $LDFLAGS"
4348	CF_CHECK_CFLAGS($X_CFLAGS)
4349
4350	AC_CHECK_FUNC(XOpenDisplay,,[
4351	AC_CHECK_LIB(X11,XOpenDisplay,
4352		[CF_ADD_LIB(X11)],,
4353		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
4354
4355	AC_CHECK_FUNC(XtAppInitialize,,[
4356	AC_CHECK_LIB(Xt, XtAppInitialize,
4357		[AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
4358		 cf_have_X_LIBS=Xt
4359		 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
4360		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
4361])
4362
4363if test $cf_have_X_LIBS = no ; then
4364	AC_MSG_WARN(
4365[Unable to successfully link X Toolkit library (-lXt) with
4366test program.  You will have to check and add the proper libraries by hand
4367to makefile.])
4368fi
4369])dnl
4370dnl ---------------------------------------------------------------------------
4371dnl CF__GRANTPT_BODY version: 4 updated: 2012/05/07 19:39:45
4372dnl ----------------
4373dnl Body for workability check of grantpt.
4374define([CF__GRANTPT_BODY],[
4375	int code = 0;
4376	int rc;
4377	int pty;
4378	int tty;
4379	char *slave;
4380	struct termios tio;
4381
4382	signal(SIGALRM, my_timeout);
4383
4384	if (alarm(2) == 9)
4385		failed(9);
4386	else if ((pty = posix_openpt(O_RDWR)) < 0)
4387		failed(1);
4388	else if ((rc = grantpt(pty)) < 0)
4389		failed(2);
4390	else if ((rc = unlockpt(pty)) < 0)
4391		failed(3);
4392	else if ((slave = ptsname(pty)) == 0)
4393		failed(4);
4394#if (CONFTEST == 3) || defined(CONFTEST_isatty)
4395	else if (!isatty(pty))
4396		failed(4);
4397#endif
4398#if CONFTEST >= 4
4399    else if ((rc = tcgetattr(pty, &tio)) < 0)
4400		failed(20);
4401    else if ((rc = tcsetattr(pty, TCSAFLUSH, &tio)) < 0)
4402		failed(21);
4403#endif
4404	/* BSD posix_openpt does not treat pty as a terminal until slave is opened.
4405	 * Linux does treat it that way.
4406	 */
4407	else if ((tty = open(slave, O_RDWR)) < 0)
4408		failed(5);
4409#ifdef CONFTEST
4410#ifdef I_PUSH
4411#if (CONFTEST == 0) || defined(CONFTEST_ptem)
4412    else if ((rc = ioctl(tty, I_PUSH, "ptem")) < 0)
4413		failed(10);
4414#endif
4415#if (CONFTEST == 1) || defined(CONFTEST_ldterm)
4416    else if ((rc = ioctl(tty, I_PUSH, "ldterm")) < 0)
4417		failed(11);
4418#endif
4419#if (CONFTEST == 2) || defined(CONFTEST_ttcompat)
4420    else if ((rc = ioctl(tty, I_PUSH, "ttcompat")) < 0)
4421		failed(12);
4422#endif
4423#endif /* I_PUSH */
4424#if CONFTEST >= 5
4425    else if ((rc = tcgetattr(tty, &tio)) < 0)
4426		failed(30);
4427    else if ((rc = tcsetattr(tty, TCSAFLUSH, &tio)) < 0)
4428		failed(31);
4429#endif
4430#endif /* CONFTEST */
4431
4432	${cf_cv_main_return:-return}(code);
4433])
4434dnl ---------------------------------------------------------------------------
4435dnl CF__GRANTPT_HEAD version: 3 updated: 2012/01/29 17:13:14
4436dnl ----------------
4437dnl Headers for workability check of grantpt.
4438define([CF__GRANTPT_HEAD],[
4439#include <stdlib.h>
4440#include <termios.h>
4441#include <unistd.h>
4442#include <signal.h>
4443#include <fcntl.h>
4444#include <errno.h>
4445
4446#ifndef HAVE_POSIX_OPENPT
4447#undef posix_openpt
4448#define posix_openpt(mode) open("/dev/ptmx", mode)
4449#endif
4450
4451#ifdef HAVE_STROPTS_H
4452#include <stropts.h>
4453#endif
4454
4455static void failed(int code)
4456{
4457	perror("conftest");
4458	exit(code);
4459}
4460
4461static void my_timeout(int sig)
4462{
4463	exit(99);
4464}
4465])
4466