aclocal.m4 revision a1f3da82
1dnl $XTermId: aclocal.m4,v 1.295 2011/02/19 01:30:06 Thierry.Reding Exp $
2dnl
3dnl ---------------------------------------------------------------------------
4dnl
5dnl Copyright 1997-2010,2011 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_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
62dnl -------------
63dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
64dnl The second parameter if given makes this macro verbose.
65dnl
66dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
67dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
68dnl confused by the quotes (which require backslashes to keep them usable).
69AC_DEFUN([CF_ADD_CFLAGS],
70[
71cf_fix_cppflags=no
72cf_new_cflags=
73cf_new_cppflags=
74cf_new_extra_cppflags=
75
76for cf_add_cflags in $1
77do
78case $cf_fix_cppflags in
79no)
80	case $cf_add_cflags in #(vi
81	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
82		case $cf_add_cflags in
83		-D*)
84			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
85
86			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
87				&& test -z "${cf_tst_cflags}" \
88				&& cf_fix_cppflags=yes
89
90			if test $cf_fix_cppflags = yes ; then
91				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
92				continue
93			elif test "${cf_tst_cflags}" = "\"'" ; then
94				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
95				continue
96			fi
97			;;
98		esac
99		case "$CPPFLAGS" in
100		*$cf_add_cflags) #(vi
101			;;
102		*) #(vi
103			case $cf_add_cflags in #(vi
104			-D*)
105				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
106				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
107				;;
108			esac
109			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
110			;;
111		esac
112		;;
113	*)
114		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
115		;;
116	esac
117	;;
118yes)
119	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
120
121	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
122
123	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
124		&& test -z "${cf_tst_cflags}" \
125		&& cf_fix_cppflags=no
126	;;
127esac
128done
129
130if test -n "$cf_new_cflags" ; then
131	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
132	CFLAGS="$CFLAGS $cf_new_cflags"
133fi
134
135if test -n "$cf_new_cppflags" ; then
136	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
137	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
138fi
139
140if test -n "$cf_new_extra_cppflags" ; then
141	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
142	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
143fi
144
145AC_SUBST(EXTRA_CPPFLAGS)
146
147])dnl
148dnl ---------------------------------------------------------------------------
149dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
150dnl ----------
151dnl Add a library, used to enforce consistency.
152dnl
153dnl $1 = library to add, without the "-l"
154dnl $2 = variable to update (default $LIBS)
155AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
156dnl ---------------------------------------------------------------------------
157dnl CF_ADD_LIBS version: 1 updated: 2010/06/02 05:03:05
158dnl -----------
159dnl Add one or more libraries, used to enforce consistency.
160dnl
161dnl $1 = libraries to add, with the "-l", etc.
162dnl $2 = variable to update (default $LIBS)
163AC_DEFUN([CF_ADD_LIBS],[ifelse($2,,LIBS,[$2])="$1 [$]ifelse($2,,LIBS,[$2])"])dnl
164dnl ---------------------------------------------------------------------------
165dnl CF_ADD_LIB_AFTER version: 2 updated: 2010/11/08 20:33:46
166dnl ----------------
167dnl Add a given library after another, e.g., following the one it satisfies a
168dnl dependency for.
169dnl
170dnl $1 = the first library
171dnl $2 = its dependency
172AC_DEFUN([CF_ADD_LIB_AFTER],[
173CF_VERBOSE(...before $LIBS)
174LIBS=`echo "$LIBS" | sed -e "s/[[ 	]][[ 	]]*/ /g" -e "s,$1 ,$1 $2 ," -e 's/  / /g'`
175CF_VERBOSE(...after  $LIBS)
176])dnl
177dnl ---------------------------------------------------------------------------
178dnl CF_ANSI_CC_CHECK version: 10 updated: 2010/10/23 15:52:32
179dnl ----------------
180dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
181dnl in the sharutils 4.2 distribution.
182AC_DEFUN([CF_ANSI_CC_CHECK],
183[
184AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
185cf_cv_ansi_cc=no
186cf_save_CFLAGS="$CFLAGS"
187cf_save_CPPFLAGS="$CPPFLAGS"
188# Don't try gcc -ansi; that turns off useful extensions and
189# breaks some systems' header files.
190# AIX			-qlanglvl=ansi
191# Ultrix and OSF/1	-std1
192# HP-UX			-Aa -D_HPUX_SOURCE
193# SVR4			-Xc
194# UnixWare 1.2		(cannot use -Xc, since ANSI/POSIX clashes)
195for cf_arg in "-DCC_HAS_PROTOS" \
196	"" \
197	-qlanglvl=ansi \
198	-std1 \
199	-Ae \
200	"-Aa -D_HPUX_SOURCE" \
201	-Xc
202do
203	CF_ADD_CFLAGS($cf_arg)
204	AC_TRY_COMPILE(
205[
206#ifndef CC_HAS_PROTOS
207#if !defined(__STDC__) || (__STDC__ != 1)
208choke me
209#endif
210#endif
211],[
212	int test (int i, double x);
213	struct s1 {int (*f) (int a);};
214	struct s2 {int (*f) (double a);};],
215	[cf_cv_ansi_cc="$cf_arg"; break])
216done
217CFLAGS="$cf_save_CFLAGS"
218CPPFLAGS="$cf_save_CPPFLAGS"
219])
220
221if test "$cf_cv_ansi_cc" != "no"; then
222if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
223	CF_ADD_CFLAGS($cf_cv_ansi_cc)
224else
225	AC_DEFINE(CC_HAS_PROTOS)
226fi
227fi
228])dnl
229dnl ---------------------------------------------------------------------------
230dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
231dnl --------------
232dnl Allow user to disable a normally-on option.
233AC_DEFUN([CF_ARG_DISABLE],
234[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
235dnl ---------------------------------------------------------------------------
236dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
237dnl -------------
238dnl Allow user to enable a normally-off option.
239AC_DEFUN([CF_ARG_ENABLE],
240[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
241dnl ---------------------------------------------------------------------------
242dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
243dnl -------------
244dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
245dnl values.
246dnl
247dnl Parameters:
248dnl $1 = option name
249dnl $2 = help-string
250dnl $3 = action to perform if option is not default
251dnl $4 = action if perform if option is default
252dnl $5 = default option value (either 'yes' or 'no')
253AC_DEFUN([CF_ARG_OPTION],
254[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
255  if test "$enableval" != "$5" ; then
256ifelse([$3],,[    :]dnl
257,[    $3]) ifelse([$4],,,[
258  else
259    $4])
260  fi],[enableval=$5 ifelse([$4],,,[
261  $4
262])dnl
263  ])])dnl
264dnl ---------------------------------------------------------------------------
265dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
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")
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_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57
380dnl ---------------
381dnl You can always use "make -n" to see the actual options, but it's hard to
382dnl pick out/analyze warning messages when the compile-line is long.
383dnl
384dnl Sets:
385dnl	ECHO_LT - symbol to control if libtool is verbose
386dnl	ECHO_LD - symbol to prefix "cc -o" lines
387dnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
388dnl	SHOW_CC - symbol to put before explicit "cc -c" lines
389dnl	ECHO_CC - symbol to put before any "cc" line
390dnl
391AC_DEFUN([CF_DISABLE_ECHO],[
392AC_MSG_CHECKING(if you want to see long compiling messages)
393CF_ARG_DISABLE(echo,
394	[  --disable-echo          display "compiling" commands],
395	[
396    ECHO_LT='--silent'
397    ECHO_LD='@echo linking [$]@;'
398    RULE_CC='@echo compiling [$]<'
399    SHOW_CC='@echo compiling [$]@'
400    ECHO_CC='@'
401],[
402    ECHO_LT=''
403    ECHO_LD=''
404    RULE_CC=''
405    SHOW_CC=''
406    ECHO_CC=''
407])
408AC_MSG_RESULT($enableval)
409AC_SUBST(ECHO_LT)
410AC_SUBST(ECHO_LD)
411AC_SUBST(RULE_CC)
412AC_SUBST(SHOW_CC)
413AC_SUBST(ECHO_CC)
414])dnl
415dnl ---------------------------------------------------------------------------
416dnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
417dnl ---------------------
418dnl The rpath-hack makes it simpler to build programs, particularly with the
419dnl *BSD ports which may have essential libraries in unusual places.  But it
420dnl can interfere with building an executable for the base system.  Use this
421dnl option in that case.
422AC_DEFUN([CF_DISABLE_RPATH_HACK],
423[
424AC_MSG_CHECKING(if rpath-hack should be disabled)
425CF_ARG_DISABLE(rpath-hack,
426	[  --disable-rpath-hack    don't add rpath options for additional libraries],
427	[cf_disable_rpath_hack=yes],
428	[cf_disable_rpath_hack=no])
429AC_MSG_RESULT($cf_disable_rpath_hack)
430if test "$cf_disable_rpath_hack" = no ; then
431	CF_RPATH_HACK
432fi
433])
434dnl ---------------------------------------------------------------------------
435dnl CF_ENABLE_NARROWPROTO version: 3 updated: 2006/02/12 17:46:00
436dnl ---------------------
437dnl If this is not set properly, Xaw's scrollbars will not work.
438dnl The so-called "modular" configuration for X.org omits most of the
439dnl configure checks that would be needed to provide compatibility with
440dnl older X builds.  This one breaks things noticeably.
441AC_DEFUN([CF_ENABLE_NARROWPROTO],
442[
443AC_MSG_CHECKING(if you want narrow prototypes for X libraries)
444
445case `$ac_config_guess` in #(vi
446*cygwin*|*freebsd*|*gnu*|*irix5*|*irix6*|*linux-gnu*|*netbsd*|*openbsd*|*qnx*|*sco*|*sgi*) #(vi
447	cf_default_narrowproto=yes
448	;;
449*)
450	cf_default_narrowproto=no
451	;;
452esac
453
454CF_ARG_OPTION(narrowproto,
455	[  --enable-narrowproto    enable narrow prototypes for X libraries],
456	[enable_narrowproto=$enableval],
457	[enable_narrowproto=$cf_default_narrowproto],
458	[$cf_default_narrowproto])
459AC_MSG_RESULT($enable_narrowproto)
460])
461dnl ---------------------------------------------------------------------------
462dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
463dnl --------
464dnl Check if 'errno' is declared in <errno.h>
465AC_DEFUN([CF_ERRNO],
466[
467CF_CHECK_ERRNO(errno)
468])dnl
469dnl ---------------------------------------------------------------------------
470dnl CF_FUNC_MEMMOVE version: 7 updated: 2006/12/16 12:33:30
471dnl ---------------
472dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
473dnl is found, add our own version of memmove to the list of objects.
474AC_DEFUN([CF_FUNC_MEMMOVE],
475[
476AC_CHECK_FUNC(memmove,,[
477AC_CHECK_FUNC(bcopy,[
478	AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
479		AC_TRY_RUN([
480int main() {
481	static char data[] = "abcdefghijklmnopqrstuwwxyz";
482	char temp[40];
483	bcopy(data, temp, sizeof(data));
484	bcopy(temp+10, temp, 15);
485	bcopy(temp+5, temp+15, 10);
486	${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
487}
488		],
489		[cf_cv_good_bcopy=yes],
490		[cf_cv_good_bcopy=no],
491		[cf_cv_good_bcopy=unknown])
492		])
493	],[cf_cv_good_bcopy=no])
494	if test "$cf_cv_good_bcopy" = yes ; then
495		AC_DEFINE(USE_OK_BCOPY)
496	else
497		AC_DEFINE(USE_MY_MEMMOVE)
498	fi
499])])dnl
500dnl ---------------------------------------------------------------------------
501dnl CF_FUNC_TGETENT version: 15 updated: 2010/06/04 20:54:56
502dnl ---------------
503dnl Check for tgetent function in termcap library.  If we cannot find this,
504dnl we'll use the $LINES and $COLUMNS environment variables to pass screen
505dnl size information to subprocesses.  (We cannot use terminfo's compatibility
506dnl function, since it cannot provide the termcap-format data).
507dnl
508dnl If the --disable-full-tgetent option is given, we'll settle for the first
509dnl tgetent function we find.  Since the search list in that case does not
510dnl include the termcap library, that allows us to default to terminfo.
511AC_DEFUN([CF_FUNC_TGETENT],
512[
513# compute a reasonable value for $TERM to give tgetent(), since we may be
514# running in 'screen', which sets $TERMCAP to a specific entry that is not
515# necessarily in /etc/termcap - unsetenv is not portable, so we cannot simply
516# discard $TERMCAP.
517cf_TERMVAR=vt100
518test -n "$TERMCAP" && cf_TERMVAR="$TERM"
519test -z "$cf_TERMVAR" && cf_TERMVAR=vt100
520
521AC_MSG_CHECKING(if we want full tgetent function)
522CF_ARG_DISABLE(full-tgetent,
523	[  --disable-full-tgetent  disable check for full tgetent function],
524	cf_full_tgetent=no,
525	cf_full_tgetent=yes,yes)
526AC_MSG_RESULT($cf_full_tgetent)
527
528if test "$cf_full_tgetent" = yes ; then
529	cf_test_message="full tgetent"
530else
531	cf_test_message="tgetent"
532fi
533
534AC_CACHE_CHECK(for $cf_test_message function,cf_cv_lib_tgetent,[
535cf_save_LIBS="$LIBS"
536cf_cv_lib_tgetent=no
537if test "$cf_full_tgetent" = yes ; then
538	cf_TERMLIB="termcap termlib ncurses curses"
539	cf_TERMTST="buffer[[0]] == 0"
540else
541	cf_TERMLIB="termlib ncurses curses"
542	cf_TERMTST="0"
543fi
544for cf_termlib in '' $cf_TERMLIB ; do
545	LIBS="$cf_save_LIBS"
546	test -n "$cf_termlib" && CF_ADD_LIB($cf_termlib)
547	AC_TRY_RUN([
548/* terminfo implementations ignore the buffer argument, making it useless for
549 * the xterm application, which uses this information to make a new TERMCAP
550 * environment variable.
551 */
552int main()
553{
554	char buffer[1024];
555	buffer[0] = 0;
556	tgetent(buffer, "$cf_TERMVAR");
557	${cf_cv_main_return:-return} ($cf_TERMTST); }],
558	[echo "yes, there is a termcap/tgetent in $cf_termlib" 1>&AC_FD_CC
559	 if test -n "$cf_termlib" ; then
560	 	cf_cv_lib_tgetent="-l$cf_termlib"
561	 else
562	 	cf_cv_lib_tgetent=yes
563	 fi
564	 break],
565	[echo "no, there is no termcap/tgetent in $cf_termlib" 1>&AC_FD_CC],
566	[echo "cross-compiling, cannot verify if a termcap/tgetent is present in $cf_termlib" 1>&AC_FD_CC])
567done
568LIBS="$cf_save_LIBS"
569])
570
571# If we found a working tgetent(), set LIBS and check for termcap.h.
572# (LIBS cannot be set inside AC_CACHE_CHECK; the commands there should
573# not have side effects other than setting the cache variable, because
574# they are not executed when a cached value exists.)
575if test "$cf_cv_lib_tgetent" != no ; then
576	test "$cf_cv_lib_tgetent" != yes && CF_ADD_LIBS($cf_cv_lib_tgetent)
577	AC_DEFINE(USE_TERMCAP)
578	if test "$cf_full_tgetent" = no ; then
579		AC_TRY_COMPILE([
580#include <termcap.h>],[
581#ifdef NCURSES_VERSION
582make an error
583#endif],[AC_DEFINE(HAVE_TERMCAP_H)])
584	else
585		AC_CHECK_HEADERS(termcap.h)
586	fi
587else
588        # If we didn't find a tgetent() that supports the buffer
589        # argument, look again to see whether we can find even
590        # a crippled one.  A crippled tgetent() is still useful to
591        # validate values for the TERM environment variable given to
592        # child processes.
593	AC_CACHE_CHECK(for partial tgetent function,cf_cv_lib_part_tgetent,[
594	cf_cv_lib_part_tgetent=no
595	for cf_termlib in $cf_TERMLIB ; do
596		LIBS="$cf_save_LIBS -l$cf_termlib"
597		AC_TRY_LINK([],[tgetent(0, "$cf_TERMVAR")],
598			[echo "there is a terminfo/tgetent in $cf_termlib" 1>&AC_FD_CC
599			 cf_cv_lib_part_tgetent="-l$cf_termlib"
600			 break])
601	done
602	LIBS="$cf_save_LIBS"
603	])
604
605	if test "$cf_cv_lib_part_tgetent" != no ; then
606		CF_ADD_LIBS($cf_cv_lib_part_tgetent)
607		AC_CHECK_HEADERS(termcap.h)
608
609                # If this is linking against ncurses, we'll trigger the
610                # ifdef in resize.c that turns the termcap stuff back off.
611		AC_DEFINE(USE_TERMINFO)
612	fi
613fi
614])dnl
615dnl ---------------------------------------------------------------------------
616dnl CF_GCC_ATTRIBUTES version: 14 updated: 2010/10/23 15:52:32
617dnl -----------------
618dnl Test for availability of useful gcc __attribute__ directives to quiet
619dnl compiler warnings.  Though useful, not all are supported -- and contrary
620dnl to documentation, unrecognized directives cause older compilers to barf.
621AC_DEFUN([CF_GCC_ATTRIBUTES],
622[
623if test "$GCC" = yes
624then
625cat > conftest.i <<EOF
626#ifndef GCC_PRINTF
627#define GCC_PRINTF 0
628#endif
629#ifndef GCC_SCANF
630#define GCC_SCANF 0
631#endif
632#ifndef GCC_NORETURN
633#define GCC_NORETURN /* nothing */
634#endif
635#ifndef GCC_UNUSED
636#define GCC_UNUSED /* nothing */
637#endif
638EOF
639if test "$GCC" = yes
640then
641	AC_CHECKING([for $CC __attribute__ directives])
642cat > conftest.$ac_ext <<EOF
643#line __oline__ "${as_me:-configure}"
644#include "confdefs.h"
645#include "conftest.h"
646#include "conftest.i"
647#if	GCC_PRINTF
648#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
649#else
650#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
651#endif
652#if	GCC_SCANF
653#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
654#else
655#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
656#endif
657extern void wow(char *,...) GCC_SCANFLIKE(1,2);
658extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
659extern void foo(void) GCC_NORETURN;
660int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
661EOF
662	cf_printf_attribute=no
663	cf_scanf_attribute=no
664	for cf_attribute in scanf printf unused noreturn
665	do
666		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
667		cf_directive="__attribute__(($cf_attribute))"
668		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
669
670		case $cf_attribute in #(vi
671		printf) #(vi
672			cf_printf_attribute=yes
673			cat >conftest.h <<EOF
674#define GCC_$cf_ATTRIBUTE 1
675EOF
676			;;
677		scanf) #(vi
678			cf_scanf_attribute=yes
679			cat >conftest.h <<EOF
680#define GCC_$cf_ATTRIBUTE 1
681EOF
682			;;
683		*) #(vi
684			cat >conftest.h <<EOF
685#define GCC_$cf_ATTRIBUTE $cf_directive
686EOF
687			;;
688		esac
689
690		if AC_TRY_EVAL(ac_compile); then
691			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
692			cat conftest.h >>confdefs.h
693			case $cf_attribute in #(vi
694			printf) #(vi
695				if test "$cf_printf_attribute" = no ; then
696					cat >>confdefs.h <<EOF
697#define GCC_PRINTFLIKE(fmt,var) /* nothing */
698EOF
699				else
700					cat >>confdefs.h <<EOF
701#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
702EOF
703				fi
704				;;
705			scanf) #(vi
706				if test "$cf_scanf_attribute" = no ; then
707					cat >>confdefs.h <<EOF
708#define GCC_SCANFLIKE(fmt,var) /* nothing */
709EOF
710				else
711					cat >>confdefs.h <<EOF
712#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
713EOF
714				fi
715				;;
716			esac
717		fi
718	done
719else
720	fgrep define conftest.i >>confdefs.h
721fi
722rm -rf conftest*
723fi
724])dnl
725dnl ---------------------------------------------------------------------------
726dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
727dnl --------------
728dnl Find version of gcc
729AC_DEFUN([CF_GCC_VERSION],[
730AC_REQUIRE([AC_PROG_CC])
731GCC_VERSION=none
732if test "$GCC" = yes ; then
733	AC_MSG_CHECKING(version of $CC)
734	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
735	test -z "$GCC_VERSION" && GCC_VERSION=unknown
736	AC_MSG_RESULT($GCC_VERSION)
737fi
738])dnl
739dnl ---------------------------------------------------------------------------
740dnl CF_GCC_WARNINGS version: 27 updated: 2010/10/23 15:52:32
741dnl ---------------
742dnl Check if the compiler supports useful warning options.  There's a few that
743dnl we don't use, simply because they're too noisy:
744dnl
745dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
746dnl	-Wredundant-decls (system headers make this too noisy)
747dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
748dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
749dnl		is enabled for ncurses using "--enable-const".
750dnl	-pedantic
751dnl
752dnl Parameter:
753dnl	$1 is an optional list of gcc warning flags that a particular
754dnl		application might want to use, e.g., "no-unused" for
755dnl		-Wno-unused
756dnl Special:
757dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
758dnl
759AC_DEFUN([CF_GCC_WARNINGS],
760[
761AC_REQUIRE([CF_GCC_VERSION])
762CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
763
764cat > conftest.$ac_ext <<EOF
765#line __oline__ "${as_me:-configure}"
766int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
767EOF
768
769if test "$INTEL_COMPILER" = yes
770then
771# The "-wdXXX" options suppress warnings:
772# remark #1419: external declaration in primary source file
773# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
774# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
775# remark #193: zero used for undefined preprocessing identifier
776# remark #593: variable "curs_sb_left_arrow" was set but never used
777# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
778# remark #869: parameter "tw" was never referenced
779# remark #981: operands are evaluated in unspecified order
780# warning #279: controlling expression is constant
781
782	AC_CHECKING([for $CC warning options])
783	cf_save_CFLAGS="$CFLAGS"
784	EXTRA_CFLAGS="-Wall"
785	for cf_opt in \
786		wd1419 \
787		wd1683 \
788		wd1684 \
789		wd193 \
790		wd593 \
791		wd279 \
792		wd810 \
793		wd869 \
794		wd981
795	do
796		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
797		if AC_TRY_EVAL(ac_compile); then
798			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
799			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
800		fi
801	done
802	CFLAGS="$cf_save_CFLAGS"
803
804elif test "$GCC" = yes
805then
806	AC_CHECKING([for $CC warning options])
807	cf_save_CFLAGS="$CFLAGS"
808	EXTRA_CFLAGS=
809	cf_warn_CONST=""
810	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
811	for cf_opt in W Wall \
812		Wbad-function-cast \
813		Wcast-align \
814		Wcast-qual \
815		Winline \
816		Wmissing-declarations \
817		Wmissing-prototypes \
818		Wnested-externs \
819		Wpointer-arith \
820		Wshadow \
821		Wstrict-prototypes \
822		Wundef $cf_warn_CONST $1
823	do
824		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
825		if AC_TRY_EVAL(ac_compile); then
826			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
827			case $cf_opt in #(vi
828			Wcast-qual) #(vi
829				CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
830				;;
831			Winline) #(vi
832				case $GCC_VERSION in
833				[[34]].*)
834					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
835					continue;;
836				esac
837				;;
838			esac
839			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
840		fi
841	done
842	CFLAGS="$cf_save_CFLAGS"
843fi
844rm -rf conftest*
845
846AC_SUBST(EXTRA_CFLAGS)
847])dnl
848dnl ---------------------------------------------------------------------------
849dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
850dnl -------------
851dnl Check if we must define _GNU_SOURCE to get a reasonable value for
852dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
853dnl (or misfeature) of glibc2, which breaks portability of many applications,
854dnl since it is interwoven with GNU extensions.
855dnl
856dnl Well, yes we could work around it...
857AC_DEFUN([CF_GNU_SOURCE],
858[
859AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
860AC_TRY_COMPILE([#include <sys/types.h>],[
861#ifndef _XOPEN_SOURCE
862make an error
863#endif],
864	[cf_cv_gnu_source=no],
865	[cf_save="$CPPFLAGS"
866	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
867	 AC_TRY_COMPILE([#include <sys/types.h>],[
868#ifdef _XOPEN_SOURCE
869make an error
870#endif],
871	[cf_cv_gnu_source=no],
872	[cf_cv_gnu_source=yes])
873	CPPFLAGS="$cf_save"
874	])
875])
876test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
877])dnl
878dnl ---------------------------------------------------------------------------
879dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
880dnl ---------------
881dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
882AC_DEFUN([CF_HELP_MESSAGE],
883[AC_DIVERT_HELP([$1])dnl
884])dnl
885dnl ---------------------------------------------------------------------------
886dnl CF_IMAKE_CFLAGS version: 31 updated: 2010/05/26 05:38:42
887dnl ---------------
888dnl Use imake to obtain compiler flags.  We could, in principle, write tests to
889dnl get these, but if imake is properly configured there is no point in doing
890dnl this.
891dnl
892dnl Parameters (used in constructing a sample Imakefile):
893dnl	$1 = optional value to append to $IMAKE_CFLAGS
894dnl	$2 = optional value to append to $IMAKE_LOADFLAGS
895AC_DEFUN([CF_IMAKE_CFLAGS],
896[
897AC_PATH_PROGS(IMAKE,xmkmf imake)
898
899if test -n "$IMAKE" ; then
900
901case $IMAKE in # (vi
902*/imake)
903	cf_imake_opts="-DUseInstalled=YES" # (vi
904	;;
905*/util/xmkmf)
906	# A single parameter tells xmkmf where the config-files are:
907	cf_imake_opts="`echo $IMAKE|sed -e s,/config/util/xmkmf,,`" # (vi
908	;;
909*)
910	cf_imake_opts=
911	;;
912esac
913
914# If it's installed properly, imake (or its wrapper, xmkmf) will point to the
915# config directory.
916if mkdir conftestdir; then
917	CDPATH=; export CDPATH
918	cf_makefile=`cd $srcdir;pwd`/Imakefile
919	cd conftestdir
920
921	cat >fix_cflags.sed <<'CF_EOF'
922s/\\//g
923s/[[ 	]][[ 	]]*/ /g
924s/"//g
925:pack
926s/\(=[[^ ]][[^ ]]*\) \([[^-]]\)/\1	\2/g
927t pack
928s/\(-D[[a-zA-Z0-9_]][[a-zA-Z0-9_]]*\)=\([[^\'0-9 ]][[^ ]]*\)/\1='\\"\2\\"'/g
929s/^IMAKE[[ ]]/IMAKE_CFLAGS="/
930s/	/ /g
931s/$/"/
932CF_EOF
933
934	cat >fix_lflags.sed <<'CF_EOF'
935s/^IMAKE[[ 	]]*/IMAKE_LOADFLAGS="/
936s/$/"/
937CF_EOF
938
939	echo >./Imakefile
940	test -f $cf_makefile && cat $cf_makefile >>./Imakefile
941
942	cat >> ./Imakefile <<'CF_EOF'
943findstddefs:
944	@echo IMAKE ${ALLDEFINES}ifelse([$1],,,[ $1])       | sed -f fix_cflags.sed
945	@echo IMAKE ${EXTRA_LOAD_FLAGS}ifelse([$2],,,[ $2]) | sed -f fix_lflags.sed
946CF_EOF
947
948	if ( $IMAKE $cf_imake_opts 1>/dev/null 2>&AC_FD_CC && test -f Makefile)
949	then
950		CF_VERBOSE(Using $IMAKE $cf_imake_opts)
951	else
952		# sometimes imake doesn't have the config path compiled in.  Find it.
953		cf_config=
954		for cf_libpath in $X_LIBS $LIBS ; do
955			case $cf_libpath in # (vi
956			-L*)
957				cf_libpath=`echo .$cf_libpath | sed -e 's/^...//'`
958				cf_libpath=$cf_libpath/X11/config
959				if test -d $cf_libpath ; then
960					cf_config=$cf_libpath
961					break
962				fi
963				;;
964			esac
965		done
966		if test -z "$cf_config" ; then
967			AC_MSG_WARN(Could not find imake config-directory)
968		else
969			cf_imake_opts="$cf_imake_opts -I$cf_config"
970			if ( $IMAKE -v $cf_imake_opts 2>&AC_FD_CC)
971			then
972				CF_VERBOSE(Using $IMAKE $cf_config)
973			else
974				AC_MSG_WARN(Cannot run $IMAKE)
975			fi
976		fi
977	fi
978
979	# GNU make sometimes prints "make[1]: Entering...", which
980	# would confuse us.
981	eval `make findstddefs 2>/dev/null | grep -v make`
982
983	cd ..
984	rm -rf conftestdir
985
986	# We use ${ALLDEFINES} rather than ${STD_DEFINES} because the former
987	# declares XTFUNCPROTO there.  However, some vendors (e.g., SGI) have
988	# modified it to support site.cf, adding a kludge for the /usr/include
989	# directory.  Try to filter that out, otherwise gcc won't find its
990	# headers.
991	if test -n "$GCC" ; then
992	    if test -n "$IMAKE_CFLAGS" ; then
993		cf_nostdinc=""
994		cf_std_incl=""
995		cf_cpp_opts=""
996		for cf_opt in $IMAKE_CFLAGS
997		do
998		    case "$cf_opt" in
999		    -nostdinc) #(vi
1000			cf_nostdinc="$cf_opt"
1001			;;
1002		    -I/usr/include) #(vi
1003			cf_std_incl="$cf_opt"
1004			;;
1005		    *) #(vi
1006			cf_cpp_opts="$cf_cpp_opts $cf_opt"
1007			;;
1008		    esac
1009		done
1010		if test -z "$cf_nostdinc" ; then
1011		    IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl"
1012		elif test -z "$cf_std_incl" ; then
1013		    IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc"
1014		else
1015		    CF_VERBOSE(suppressed \"$cf_nostdinc\" and \"$cf_std_incl\")
1016		    IMAKE_CFLAGS="$cf_cpp_opts"
1017		fi
1018	    fi
1019	fi
1020fi
1021
1022# Some imake configurations define PROJECTROOT with an empty value.  Remove
1023# the empty definition.
1024case $IMAKE_CFLAGS in
1025*-DPROJECTROOT=/*)
1026	;;
1027*)
1028	IMAKE_CFLAGS=`echo "$IMAKE_CFLAGS" |sed -e "s,-DPROJECTROOT=[[ 	]], ,"`
1029	;;
1030esac
1031
1032fi
1033
1034CF_VERBOSE(IMAKE_CFLAGS $IMAKE_CFLAGS)
1035CF_VERBOSE(IMAKE_LOADFLAGS $IMAKE_LOADFLAGS)
1036
1037AC_SUBST(IMAKE_CFLAGS)
1038AC_SUBST(IMAKE_LOADFLAGS)
1039])dnl
1040dnl ---------------------------------------------------------------------------
1041dnl CF_INPUT_METHOD version: 3 updated: 2000/04/11 23:46:57
1042dnl ---------------
1043dnl Check if the X libraries support input-method
1044AC_DEFUN([CF_INPUT_METHOD],
1045[
1046AC_CACHE_CHECK([if X libraries support input-method],cf_cv_input_method,[
1047AC_TRY_LINK([
1048#include <X11/IntrinsicP.h>
1049#include <X11/Xatom.h>
1050#include <X11/Xutil.h>
1051#include <X11/Xmu/Atoms.h>
1052#include <X11/Xmu/Converters.h>
1053#include <X11/Xaw/XawImP.h>
1054],[
1055{
1056	XIM xim;
1057	XIMStyles *xim_styles = 0;
1058	XIMStyle input_style;
1059	Widget w = 0;
1060
1061	XSetLocaleModifiers("@im=none");
1062	xim = XOpenIM(XtDisplay(w), NULL, NULL, NULL);
1063	XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);
1064	XCloseIM(xim);
1065	input_style = (XIMPreeditNothing | XIMStatusNothing);
1066}
1067],
1068[cf_cv_input_method=yes],
1069[cf_cv_input_method=no])])
1070])dnl
1071dnl ---------------------------------------------------------------------------
1072dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
1073dnl -----------------
1074dnl Check if the given compiler is really the Intel compiler for Linux.  It
1075dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1076dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1077dnl
1078dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1079dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1080dnl the wrappers for gcc and g++ warnings.
1081dnl
1082dnl $1 = GCC (default) or GXX
1083dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1084dnl $3 = CFLAGS (default) or CXXFLAGS
1085AC_DEFUN([CF_INTEL_COMPILER],[
1086ifelse([$2],,INTEL_COMPILER,[$2])=no
1087
1088if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1089	case $host_os in
1090	linux*|gnu*)
1091		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
1092		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1093		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1094		AC_TRY_COMPILE([],[
1095#ifdef __INTEL_COMPILER
1096#else
1097make an error
1098#endif
1099],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1100cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
1101],[])
1102		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1103		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1104		;;
1105	esac
1106fi
1107])dnl
1108dnl ---------------------------------------------------------------------------
1109dnl CF_LASTLOG version: 4 updated: 2002/10/27 23:21:42
1110dnl ----------
1111dnl Check for header defining _PATH_LASTLOG, or failing that, see if the lastlog
1112dnl file exists.
1113AC_DEFUN([CF_LASTLOG],
1114[
1115AC_CHECK_HEADERS(lastlog.h paths.h)
1116AC_CACHE_CHECK(for lastlog path,cf_cv_path_lastlog,[
1117AC_TRY_COMPILE([
1118#include <sys/types.h>
1119#ifdef HAVE_LASTLOG_H
1120#include <lastlog.h>
1121#else
1122#ifdef HAVE_PATHS_H
1123#include <paths.h>
1124#endif
1125#endif],[char *path = _PATH_LASTLOG],
1126	[cf_cv_path_lastlog="_PATH_LASTLOG"],
1127	[if test -f /usr/adm/lastlog ; then
1128	 	cf_cv_path_lastlog=/usr/adm/lastlog
1129	else
1130		cf_cv_path_lastlog=no
1131	fi])
1132])
1133test $cf_cv_path_lastlog != no && AC_DEFINE(USE_LASTLOG)
1134])dnl
1135dnl ---------------------------------------------------------------------------
1136dnl CF_LD_RPATH_OPT version: 3 updated: 2010/06/02 05:03:05
1137dnl ---------------
1138dnl For the given system and compiler, find the compiler flags to pass to the
1139dnl loader to use the "rpath" feature.
1140AC_DEFUN([CF_LD_RPATH_OPT],
1141[
1142AC_REQUIRE([CF_CHECK_CACHE])
1143
1144LD_RPATH_OPT=
1145AC_MSG_CHECKING(for an rpath option)
1146case $cf_cv_system_name in #(vi
1147irix*) #(vi
1148	if test "$GCC" = yes; then
1149		LD_RPATH_OPT="-Wl,-rpath,"
1150	else
1151		LD_RPATH_OPT="-rpath "
1152	fi
1153	;;
1154linux*|gnu*|k*bsd*-gnu) #(vi
1155	LD_RPATH_OPT="-Wl,-rpath,"
1156	;;
1157openbsd[[2-9]].*) #(vi
1158	LD_RPATH_OPT="-Wl,-rpath,"
1159	;;
1160freebsd*) #(vi
1161	LD_RPATH_OPT="-rpath "
1162	;;
1163netbsd*) #(vi
1164	LD_RPATH_OPT="-Wl,-rpath,"
1165	;;
1166osf*|mls+*) #(vi
1167	LD_RPATH_OPT="-rpath "
1168	;;
1169solaris2*) #(vi
1170	LD_RPATH_OPT="-R"
1171	;;
1172*)
1173	;;
1174esac
1175AC_MSG_RESULT($LD_RPATH_OPT)
1176
1177case "x$LD_RPATH_OPT" in #(vi
1178x-R*)
1179	AC_MSG_CHECKING(if we need a space after rpath option)
1180	cf_save_LIBS="$LIBS"
1181	CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
1182	AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1183	LIBS="$cf_save_LIBS"
1184	AC_MSG_RESULT($cf_rpath_space)
1185	test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
1186	;;
1187esac
1188])dnl
1189dnl ---------------------------------------------------------------------------
1190dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
1191dnl ------------
1192dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
1193dnl a monocase filesystem.
1194AC_DEFUN([CF_MAKE_TAGS],[
1195AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1196
1197AC_CHECK_PROGS(CTAGS, exctags ctags)
1198AC_CHECK_PROGS(ETAGS, exetags etags)
1199
1200AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1201
1202if test "$cf_cv_mixedcase" = yes ; then
1203	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1204else
1205	MAKE_UPPER_TAGS=no
1206fi
1207
1208if test "$MAKE_UPPER_TAGS" = yes ; then
1209	MAKE_UPPER_TAGS=
1210else
1211	MAKE_UPPER_TAGS="#"
1212fi
1213
1214if test "$MAKE_LOWER_TAGS" = yes ; then
1215	MAKE_LOWER_TAGS=
1216else
1217	MAKE_LOWER_TAGS="#"
1218fi
1219
1220AC_SUBST(CTAGS)
1221AC_SUBST(ETAGS)
1222
1223AC_SUBST(MAKE_UPPER_TAGS)
1224AC_SUBST(MAKE_LOWER_TAGS)
1225])dnl
1226dnl ---------------------------------------------------------------------------
1227dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
1228dnl ----------------------
1229dnl Check if the file-system supports mixed-case filenames.  If we're able to
1230dnl create a lowercase name and see it as uppercase, it doesn't support that.
1231AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1232[
1233AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1234if test "$cross_compiling" = yes ; then
1235	case $target_alias in #(vi
1236	*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
1237		cf_cv_mixedcase=no
1238		;;
1239	*)
1240		cf_cv_mixedcase=yes
1241		;;
1242	esac
1243else
1244	rm -f conftest CONFTEST
1245	echo test >conftest
1246	if test -f CONFTEST ; then
1247		cf_cv_mixedcase=no
1248	else
1249		cf_cv_mixedcase=yes
1250	fi
1251	rm -f conftest CONFTEST
1252fi
1253])
1254test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
1255])dnl
1256dnl ---------------------------------------------------------------------------
1257dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1258dnl ----------
1259dnl Write a debug message to config.log, along with the line number in the
1260dnl configure script.
1261AC_DEFUN([CF_MSG_LOG],[
1262echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1263])dnl
1264dnl ---------------------------------------------------------------------------
1265dnl CF_PATHSEP version: 5 updated: 2010/05/26 05:38:42
1266dnl ----------
1267dnl Provide a value for the $PATH and similar separator
1268AC_DEFUN([CF_PATHSEP],
1269[
1270	case $cf_cv_system_name in
1271	os2*)	PATH_SEPARATOR=';'  ;;
1272	*)	PATH_SEPARATOR=':'  ;;
1273	esac
1274ifelse([$1],,,[$1=$PATH_SEPARATOR])
1275	AC_SUBST(PATH_SEPARATOR)
1276])dnl
1277dnl ---------------------------------------------------------------------------
1278dnl CF_PATH_PROG version: 8 updated: 2010/10/23 16:12:25
1279dnl ------------
1280dnl Check for a given program, defining corresponding symbol.
1281dnl	$1 = environment variable, which is suffixed by "_PATH" in the #define.
1282dnl	$2 = program name to find.
1283dnl	$3 = optional list of additional program names to test.
1284dnl
1285dnl If there is more than one token in the result, #define the remaining tokens
1286dnl to $1_ARGS.  We need this for 'install' in particular.
1287dnl
1288dnl FIXME: we should allow this to be overridden by environment variables
1289dnl
1290AC_DEFUN([CF_PATH_PROG],[
1291AC_REQUIRE([CF_PATHSEP])
1292test -z "[$]$1" && $1=$2
1293AC_PATH_PROGS($1,[$]$1 $2 $3,[$]$1)
1294
1295cf_path_prog=""
1296cf_path_args=""
1297IFS="${IFS:- 	}"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
1298for cf_temp in $ac_cv_path_$1
1299do
1300	if test -z "$cf_path_prog" ; then
1301		if test "$with_full_paths" = yes ; then
1302			CF_PATH_SYNTAX(cf_temp,break)
1303			cf_path_prog="$cf_temp"
1304		else
1305			cf_path_prog="`basename $cf_temp`"
1306		fi
1307	elif test -z "$cf_path_args" ; then
1308		cf_path_args="$cf_temp"
1309	else
1310		cf_path_args="$cf_path_args $cf_temp"
1311	fi
1312done
1313IFS="$cf_save_ifs"
1314
1315if test -n "$cf_path_prog" ; then
1316	CF_MSG_LOG(defining path for ${cf_path_prog})
1317	AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog")
1318	test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args")
1319fi
1320])dnl
1321dnl ---------------------------------------------------------------------------
1322dnl CF_PATH_SYNTAX version: 13 updated: 2010/05/26 05:38:42
1323dnl --------------
1324dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1325dnl begins with one of the prefix/exec_prefix variables, and then again if the
1326dnl result begins with 'NONE'.  This is necessary to work around autoconf's
1327dnl delayed evaluation of those symbols.
1328AC_DEFUN([CF_PATH_SYNTAX],[
1329if test "x$prefix" != xNONE; then
1330  cf_path_syntax="$prefix"
1331else
1332  cf_path_syntax="$ac_default_prefix"
1333fi
1334
1335case ".[$]$1" in #(vi
1336.\[$]\(*\)*|.\'*\'*) #(vi
1337  ;;
1338..|./*|.\\*) #(vi
1339  ;;
1340.[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
1341  ;;
1342.\[$]{*prefix}*) #(vi
1343  eval $1="[$]$1"
1344  case ".[$]$1" in #(vi
1345  .NONE/*)
1346    $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1347    ;;
1348  esac
1349  ;; #(vi
1350.no|.NONE/*)
1351  $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1352  ;;
1353*)
1354  ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1355  ;;
1356esac
1357])dnl
1358dnl ---------------------------------------------------------------------------
1359dnl CF_PKG_CONFIG version: 4 updated: 2011/02/18 20:26:24
1360dnl -------------
1361dnl Check for the package-config program, unless disabled by command-line.
1362AC_DEFUN([CF_PKG_CONFIG],
1363[
1364AC_MSG_CHECKING(if you want to use pkg-config)
1365AC_ARG_WITH(pkg-config,
1366	[  --with-pkg-config{=path} enable/disable use of pkg-config],
1367	[cf_pkg_config=$withval],
1368	[cf_pkg_config=yes])
1369AC_MSG_RESULT($cf_pkg_config)
1370
1371case $cf_pkg_config in #(vi
1372no) #(vi
1373	PKG_CONFIG=none
1374	;;
1375yes) #(vi
1376	AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)
1377	;;
1378*)
1379	PKG_CONFIG=$withval
1380	;;
1381esac
1382
1383test -z "$PKG_CONFIG" && PKG_CONFIG=none
1384if test "$PKG_CONFIG" != none ; then
1385	CF_PATH_SYNTAX(PKG_CONFIG)
1386fi
1387
1388AC_SUBST(PKG_CONFIG)
1389])dnl
1390dnl ---------------------------------------------------------------------------
1391dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
1392dnl -----------------
1393dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1394dnl
1395dnl	POSIX.1-1990				_POSIX_SOURCE
1396dnl	POSIX.1-1990 and			_POSIX_SOURCE and
1397dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
1398dnl		Bindings Option
1399dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
1400dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
1401dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
1402dnl
1403dnl Parameters:
1404dnl	$1 is the nominal value for _POSIX_C_SOURCE
1405AC_DEFUN([CF_POSIX_C_SOURCE],
1406[
1407cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1408
1409cf_save_CFLAGS="$CFLAGS"
1410cf_save_CPPFLAGS="$CPPFLAGS"
1411
1412CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1413CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1414
1415AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1416	CF_MSG_LOG(if the symbol is already defined go no further)
1417	AC_TRY_COMPILE([#include <sys/types.h>],[
1418#ifndef _POSIX_C_SOURCE
1419make an error
1420#endif],
1421	[cf_cv_posix_c_source=no],
1422	[cf_want_posix_source=no
1423	 case .$cf_POSIX_C_SOURCE in #(vi
1424	 .[[12]]??*) #(vi
1425		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1426		;;
1427	 .2) #(vi
1428		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1429		cf_want_posix_source=yes
1430		;;
1431	 .*)
1432		cf_want_posix_source=yes
1433		;;
1434	 esac
1435	 if test "$cf_want_posix_source" = yes ; then
1436		AC_TRY_COMPILE([#include <sys/types.h>],[
1437#ifdef _POSIX_SOURCE
1438make an error
1439#endif],[],
1440		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1441	 fi
1442	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1443	 CFLAGS="$cf_trim_CFLAGS"
1444	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1445	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1446	 AC_TRY_COMPILE([#include <sys/types.h>],[
1447#ifndef _POSIX_C_SOURCE
1448make an error
1449#endif],,
1450	 [cf_cv_posix_c_source=no])
1451	 CFLAGS="$cf_save_CFLAGS"
1452	 CPPFLAGS="$cf_save_CPPFLAGS"
1453	])
1454])
1455
1456if test "$cf_cv_posix_c_source" != no ; then
1457	CFLAGS="$cf_trim_CFLAGS"
1458	CPPFLAGS="$cf_trim_CPPFLAGS"
1459	CF_ADD_CFLAGS($cf_cv_posix_c_source)
1460fi
1461
1462])dnl
1463dnl ---------------------------------------------------------------------------
1464dnl CF_POSIX_SAVED_IDS version: 7 updated: 2007/03/14 16:43:53
1465dnl ------------------
1466dnl
1467dnl Check first if saved-ids are always supported.  Some systems
1468dnl may require runtime checks.
1469AC_DEFUN([CF_POSIX_SAVED_IDS],
1470[
1471AC_CHECK_HEADERS( \
1472sys/param.h \
1473)
1474
1475AC_CACHE_CHECK(if POSIX saved-ids are supported,cf_cv_posix_saved_ids,[
1476AC_TRY_LINK(
1477[
1478#include <unistd.h>
1479#ifdef HAVE_SYS_PARAM_H
1480#include <sys/param.h>		/* this may define "BSD" */
1481#endif
1482],[
1483#if defined(_POSIX_SAVED_IDS) && (_POSIX_SAVED_IDS > 0)
1484	void *p = (void *) seteuid;
1485	int x = seteuid(geteuid());
1486#elif defined(BSD) && (BSD >= 199103)
1487/* The BSD's may implement the runtime check - and it fails.
1488 * However, saved-ids work almost like POSIX (close enough for most uses).
1489 */
1490#else
1491make an error
1492#endif
1493],[cf_cv_posix_saved_ids=yes
1494],[
1495AC_TRY_RUN([
1496#ifdef HAVE_STDLIB_H
1497#include <stdlib.h>
1498#endif
1499#include <unistd.h>
1500int main()
1501{
1502	void *p = (void *) seteuid;
1503	long code = sysconf(_SC_SAVED_IDS);
1504	${cf_cv_main_return:-return}  ((code > 0) ? 0 : 1);
1505}],
1506	cf_cv_posix_saved_ids=yes,
1507	cf_cv_posix_saved_ids=no,
1508	cf_cv_posix_saved_ids=unknown)
1509])
1510])
1511
1512test "$cf_cv_posix_saved_ids" = yes && AC_DEFINE(HAVE_POSIX_SAVED_IDS)
1513])
1514dnl ---------------------------------------------------------------------------
1515dnl CF_POSIX_WAIT version: 2 updated: 2000/05/29 16:16:04
1516dnl -------------
1517dnl Check for POSIX wait support
1518AC_DEFUN([CF_POSIX_WAIT],
1519[
1520AC_REQUIRE([AC_HEADER_SYS_WAIT])
1521AC_CACHE_CHECK(for POSIX wait functions,cf_cv_posix_wait,[
1522AC_TRY_LINK([
1523#include <stdlib.h>
1524#include <stdio.h>
1525#include <sys/types.h>
1526#ifdef HAVE_SYS_WAIT_H
1527#include <sys/wait.h>
1528#endif
1529],[
1530	int stat_loc;
1531	pid_t pid = waitpid(-1, &stat_loc, WNOHANG|WUNTRACED);
1532	pid_t pid2 = wait(&stat_loc);
1533],
1534[cf_cv_posix_wait=yes],
1535[cf_cv_posix_wait=no])
1536])
1537test "$cf_cv_posix_wait" = yes && AC_DEFINE(USE_POSIX_WAIT)
1538])dnl
1539dnl ---------------------------------------------------------------------------
1540dnl CF_PROCFS_CWD version: 2 updated: 2007/03/12 20:39:04
1541dnl -------------
1542dnl Find /proc tree (may be in a different place) which implements the "cwd"
1543dnl link.
1544AC_DEFUN([CF_PROCFS_CWD],[
1545AC_CACHE_CHECK(for proc tree with cwd-support,cf_cv_procfs_cwd,[
1546cf_cv_procfs_cwd=no
1547for cf_path in /proc /compat/linux/proc /usr/compat/linux/proc
1548do
1549	if test -d $cf_path && \
1550	   test -d $cf_path/$$ && \
1551	   ( test -d $cf_path/$$/cwd || \
1552	     test -L $cf_path/$$/cwd ); then
1553		cf_cv_procfs_cwd=$cf_path
1554		break
1555	fi
1556done
1557])
1558])dnl
1559dnl ---------------------------------------------------------------------------
1560dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
1561dnl --------------
1562dnl Check if C (preprocessor) -U and -D options are processed in the order
1563dnl given rather than by type of option.  Some compilers insist on apply all
1564dnl of the -U options after all of the -D options.  Others allow mixing them,
1565dnl and may predefine symbols that conflict with those we define.
1566AC_DEFUN([CF_PROG_CC_U_D],
1567[
1568AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
1569	cf_save_CPPFLAGS="$CPPFLAGS"
1570	CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
1571	AC_TRY_COMPILE([],[
1572#ifndef U_D_OPTIONS
1573make an undefined-error
1574#endif
1575#ifdef  D_U_OPTIONS
1576make a defined-error
1577#endif
1578	],[
1579	cf_cv_cc_u_d_options=yes],[
1580	cf_cv_cc_u_d_options=no])
1581	CPPFLAGS="$cf_save_CPPFLAGS"
1582])
1583])dnl
1584dnl ---------------------------------------------------------------------------
1585dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
1586dnl -----------
1587dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
1588AC_DEFUN([CF_PROG_EXT],
1589[
1590AC_REQUIRE([CF_CHECK_CACHE])
1591case $cf_cv_system_name in
1592os2*)
1593    CFLAGS="$CFLAGS -Zmt"
1594    CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
1595    CXXFLAGS="$CXXFLAGS -Zmt"
1596    # autoconf's macro sets -Zexe and suffix both, which conflict:w
1597    LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
1598    ac_cv_exeext=.exe
1599    ;;
1600esac
1601
1602AC_EXEEXT
1603AC_OBJEXT
1604
1605PROG_EXT="$EXEEXT"
1606AC_SUBST(PROG_EXT)
1607test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
1608])dnl
1609dnl ---------------------------------------------------------------------------
1610dnl CF_REGEX version: 8 updated: 2010/08/07 14:09:44
1611dnl --------
1612dnl Attempt to determine if we've got one of the flavors of regular-expression
1613dnl code that we can support.
1614AC_DEFUN([CF_REGEX],
1615[
1616
1617cf_regex_func=no
1618
1619cf_regex_libs="regex re"
1620case $host_os in #(vi
1621mingw*)
1622	cf_regex_libs="regex.dll $cf_regex_libs"
1623	;;
1624esac
1625
1626AC_CHECK_FUNC(regcomp,[cf_regex_func=regcomp],[
1627	for cf_regex_lib in $cf_regex_libs
1628	do
1629		AC_CHECK_LIB($cf_regex_lib,regcomp,[
1630				CF_ADD_LIB($cf_regex_lib)
1631				cf_regex_func=regcomp
1632				break])
1633	done
1634])
1635
1636if test "$cf_regex_func" = no ; then
1637	AC_CHECK_FUNC(compile,[cf_regex_func=compile],[
1638		AC_CHECK_LIB(gen,compile,[
1639				CF_ADD_LIB(gen)
1640				cf_regex_func=compile])])
1641fi
1642
1643if test "$cf_regex_func" = no ; then
1644	AC_MSG_WARN(cannot find regular expression library)
1645fi
1646
1647AC_CACHE_CHECK(for regular-expression headers,cf_cv_regex_hdrs,[
1648
1649cf_cv_regex_hdrs=no
1650case $cf_regex_func in #(vi
1651compile) #(vi
1652	for cf_regex_hdr in regexp.h regexpr.h
1653	do
1654		AC_TRY_LINK([#include <$cf_regex_hdr>],[
1655			char *p = compile("", "", "", 0);
1656			int x = step("", "");
1657		],[
1658			cf_cv_regex_hdrs=$cf_regex_hdr
1659			break
1660		])
1661	done
1662	;;
1663*)
1664	for cf_regex_hdr in regex.h
1665	do
1666		AC_TRY_LINK([#include <sys/types.h>
1667#include <$cf_regex_hdr>],[
1668			regex_t *p;
1669			int x = regcomp(p, "", 0);
1670			int y = regexec(p, "", 0, 0, 0);
1671			regfree(p);
1672		],[
1673			cf_cv_regex_hdrs=$cf_regex_hdr
1674			break
1675		])
1676	done
1677	;;
1678esac
1679
1680])
1681
1682case $cf_cv_regex_hdrs in #(vi
1683    no)	       AC_MSG_WARN(no regular expression header found) ;; #(vi
1684    regex.h)   AC_DEFINE(HAVE_REGEX_H_FUNCS) ;; #(vi
1685    regexp.h)  AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;; #(vi
1686    regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;;
1687esac
1688])dnl
1689dnl ---------------------------------------------------------------------------
1690dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
1691dnl ----------------
1692dnl Remove all -U and -D options that refer to the given symbol from a list
1693dnl of C compiler options.  This works around the problem that not all
1694dnl compilers process -U and -D options from left-to-right, so a -U option
1695dnl cannot be used to cancel the effect of a preceding -D option.
1696dnl
1697dnl $1 = target (which could be the same as the source variable)
1698dnl $2 = source (including '$')
1699dnl $3 = symbol to remove
1700define([CF_REMOVE_DEFINE],
1701[
1702$1=`echo "$2" | \
1703	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
1704		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
1705])dnl
1706dnl ---------------------------------------------------------------------------
1707dnl CF_RPATH_HACK version: 9 updated: 2011/02/13 13:31:33
1708dnl -------------
1709AC_DEFUN([CF_RPATH_HACK],
1710[
1711AC_REQUIRE([CF_LD_RPATH_OPT])
1712AC_MSG_CHECKING(for updated LDFLAGS)
1713if test -n "$LD_RPATH_OPT" ; then
1714	AC_MSG_RESULT(maybe)
1715
1716	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
1717	cf_rpath_list="/usr/lib /lib"
1718	if test "$cf_ldd_prog" != no
1719	then
1720		cf_rpath_oops=
1721
1722AC_TRY_LINK([#include <stdio.h>],
1723		[printf("Hello");],
1724		[cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort -u`
1725		 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort -u`])
1726
1727		# If we passed the link-test, but get a "not found" on a given library,
1728		# this could be due to inept reconfiguration of gcc to make it only
1729		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
1730		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
1731		# /usr/local libraries.
1732		if test -n "$cf_rpath_oops"
1733		then
1734			for cf_rpath_src in $cf_rpath_oops
1735			do
1736				for cf_rpath_dir in \
1737					/usr/local \
1738					/usr/pkg \
1739					/opt/sfw
1740				do
1741					if test -f $cf_rpath_dir/lib/$cf_rpath_src
1742					then
1743						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
1744						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
1745						break
1746					fi
1747				done
1748			done
1749		fi
1750	fi
1751
1752	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
1753
1754	CF_RPATH_HACK_2(LDFLAGS)
1755	CF_RPATH_HACK_2(LIBS)
1756
1757	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
1758fi
1759AC_SUBST(EXTRA_LDFLAGS)
1760])dnl
1761dnl ---------------------------------------------------------------------------
1762dnl CF_RPATH_HACK_2 version: 6 updated: 2010/04/17 16:31:24
1763dnl ---------------
1764dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
1765dnl EXTRA_LDFLAGS for each -L option found.
1766dnl
1767dnl $cf_rpath_list contains a list of directories to ignore.
1768dnl
1769dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
1770dnl      but LIBS often has misplaced -L options.
1771AC_DEFUN([CF_RPATH_HACK_2],
1772[
1773CF_VERBOSE(...checking $1 [$]$1)
1774
1775cf_rpath_dst=
1776for cf_rpath_src in [$]$1
1777do
1778	case $cf_rpath_src in #(vi
1779	-L*) #(vi
1780
1781		# check if this refers to a directory which we will ignore
1782		cf_rpath_skip=no
1783		if test -n "$cf_rpath_list"
1784		then
1785			for cf_rpath_item in $cf_rpath_list
1786			do
1787				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
1788				then
1789					cf_rpath_skip=yes
1790					break
1791				fi
1792			done
1793		fi
1794
1795		if test "$cf_rpath_skip" = no
1796		then
1797			# transform the option
1798			if test "$LD_RPATH_OPT" = "-R " ; then
1799				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
1800			else
1801				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
1802			fi
1803
1804			# if we have not already added this, add it now
1805			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
1806			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
1807			then
1808				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
1809				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
1810			fi
1811		fi
1812		;;
1813	esac
1814	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
1815done
1816$1=$cf_rpath_dst
1817
1818CF_VERBOSE(...checked $1 [$]$1)
1819AC_SUBST(EXTRA_LDFLAGS)
1820])dnl
1821dnl ---------------------------------------------------------------------------
1822dnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
1823dnl -----------
1824dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
1825dnl programs need this test).
1826dnl
1827dnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
1828dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
1829dnl winsize declaration is left alone - we may revisit this if Apple choose to
1830dnl break that part of the interface as well.
1831AC_DEFUN([CF_SIGWINCH],
1832[
1833AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
1834	AC_TRY_COMPILE([
1835#include <sys/types.h>
1836#include <sys/signal.h>
1837],[int x = SIGWINCH],
1838	[cf_cv_define_sigwinch=yes],
1839	[AC_TRY_COMPILE([
1840#undef _XOPEN_SOURCE
1841#undef _POSIX_SOURCE
1842#undef _POSIX_C_SOURCE
1843#include <sys/types.h>
1844#include <sys/signal.h>
1845],[int x = SIGWINCH],
1846	[cf_cv_define_sigwinch=maybe],
1847	[cf_cv_define_sigwinch=no])
1848])
1849])
1850
1851if test "$cf_cv_define_sigwinch" = maybe ; then
1852AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
1853cf_cv_fixup_sigwinch=unknown
1854cf_sigwinch=32
1855while test $cf_sigwinch != 1
1856do
1857	AC_TRY_COMPILE([
1858#undef _XOPEN_SOURCE
1859#undef _POSIX_SOURCE
1860#undef _POSIX_C_SOURCE
1861#include <sys/types.h>
1862#include <sys/signal.h>
1863],[
1864#if SIGWINCH != $cf_sigwinch
1865make an error
1866#endif
1867int x = SIGWINCH],
1868	[cf_cv_fixup_sigwinch=$cf_sigwinch
1869	 break])
1870
1871cf_sigwinch=`expr $cf_sigwinch - 1`
1872done
1873])
1874
1875	if test "$cf_cv_fixup_sigwinch" != unknown ; then
1876		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
1877	fi
1878fi
1879])dnl
1880dnl ---------------------------------------------------------------------------
1881dnl CF_SIG_ATOMIC_T version: 2 updated: 2005/09/18 17:27:12
1882dnl ---------------
1883dnl signal handler, but there are some gcc depedencies in that recommendation.
1884dnl Try anyway.
1885AC_DEFUN([CF_SIG_ATOMIC_T],
1886[
1887AC_MSG_CHECKING(for signal global datatype)
1888AC_CACHE_VAL(cf_cv_sig_atomic_t,[
1889	for cf_type in \
1890		"volatile sig_atomic_t" \
1891		"sig_atomic_t" \
1892		"int"
1893	do
1894	AC_TRY_COMPILE([
1895#include <sys/types.h>
1896#include <signal.h>
1897#include <stdio.h>
1898
1899extern $cf_type x;
1900$cf_type x;
1901static void handler(int sig)
1902{
1903	x = 5;
1904}],
1905		[signal(SIGINT, handler);
1906		 x = 1],
1907		[cf_cv_sig_atomic_t=$cf_type],
1908		[cf_cv_sig_atomic_t=no])
1909		test "$cf_cv_sig_atomic_t" != no && break
1910	done
1911	])
1912AC_MSG_RESULT($cf_cv_sig_atomic_t)
1913test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t)
1914])dnl
1915dnl ---------------------------------------------------------------------------
1916dnl CF_SIZE_T version: 4 updated: 2000/01/22 00:19:54
1917dnl ---------
1918dnl	On both Ultrix and CLIX, I find size_t defined in <stdio.h>
1919AC_DEFUN([CF_SIZE_T],
1920[
1921AC_MSG_CHECKING(for size_t in <sys/types.h> or <stdio.h>)
1922AC_CACHE_VAL(cf_cv_type_size_t,[
1923	AC_TRY_COMPILE([
1924#include <sys/types.h>
1925#ifdef STDC_HEADERS
1926#include <stdlib.h>
1927#include <stddef.h>
1928#endif
1929#include <stdio.h>],
1930		[size_t x],
1931		[cf_cv_type_size_t=yes],
1932		[cf_cv_type_size_t=no])
1933	])
1934AC_MSG_RESULT($cf_cv_type_size_t)
1935test $cf_cv_type_size_t = no && AC_DEFINE(size_t, unsigned)
1936])dnl
1937dnl ---------------------------------------------------------------------------
1938dnl CF_STRUCT_LASTLOG version: 1 updated: 2006/03/12 17:46:43
1939dnl -----------------
1940dnl Check for header defining struct lastlog, ensure that its .ll_time member
1941dnl is compatible with time().
1942AC_DEFUN([CF_STRUCT_LASTLOG],
1943[
1944AC_CHECK_HEADERS(lastlog.h)
1945AC_CACHE_CHECK(for struct lastlog,cf_cv_struct_lastlog,[
1946AC_TRY_RUN([
1947#include <sys/types.h>
1948#include <time.h>
1949#include <lastlog.h>
1950
1951int main()
1952{
1953	struct lastlog data;
1954	return (sizeof(data.ll_time) != sizeof(time_t));
1955}],[
1956cf_cv_struct_lastlog=yes],[
1957cf_cv_struct_lastlog=no],[
1958cf_cv_struct_lastlog=unknown])])
1959
1960test $cf_cv_struct_lastlog != no && AC_DEFINE(USE_STRUCT_LASTLOG)
1961])dnl
1962dnl ---------------------------------------------------------------------------
1963dnl CF_SVR4 version: 3 updated: 2000/05/31 10:16:52
1964dnl -------
1965dnl Check if this is an SVR4 system.  We need the definition for xterm
1966AC_DEFUN([CF_SVR4],
1967[
1968AC_CHECK_LIB(elf, elf_begin,[
1969AC_CACHE_CHECK(if this is an SVR4 system, cf_cv_svr4,[
1970AC_TRY_COMPILE([
1971#include <elf.h>
1972#include <sys/termio.h>
1973],[
1974static struct termio d_tio;
1975	d_tio.c_cc[VINTR] = 0;
1976	d_tio.c_cc[VQUIT] = 0;
1977	d_tio.c_cc[VERASE] = 0;
1978	d_tio.c_cc[VKILL] = 0;
1979	d_tio.c_cc[VEOF] = 0;
1980	d_tio.c_cc[VEOL] = 0;
1981	d_tio.c_cc[VMIN] = 0;
1982	d_tio.c_cc[VTIME] = 0;
1983	d_tio.c_cc[VLNEXT] = 0;
1984],
1985[cf_cv_svr4=yes],
1986[cf_cv_svr4=no])
1987])
1988])
1989test "$cf_cv_svr4" = yes && AC_DEFINE(SVR4)
1990])dnl
1991dnl ---------------------------------------------------------------------------
1992dnl CF_SYSV version: 13 updated: 2006/08/20 14:55:37
1993dnl -------
1994dnl Check if this is a SYSV platform, e.g., as used in <X11/Xos.h>, and whether
1995dnl defining it will be helpful.  The following features are used to check:
1996dnl
1997dnl a) bona-fide SVSV doesn't use const for sys_errlist[].  Since this is a
1998dnl legacy (pre-ANSI) feature, const should not apply.  Modern systems only
1999dnl declare strerror().  Xos.h declares the legacy form of str_errlist[], and
2000dnl a compile-time error will result from trying to assign to a const array.
2001dnl
2002dnl b) compile with headers that exist on SYSV hosts.
2003dnl
2004dnl c) compile with type definitions that differ on SYSV hosts from standard C.
2005AC_DEFUN([CF_SYSV],
2006[
2007AC_CHECK_HEADERS( \
2008termios.h \
2009stdlib.h \
2010X11/Intrinsic.h \
2011)
2012
2013AC_REQUIRE([CF_SYS_ERRLIST])
2014
2015AC_CACHE_CHECK(if we should define SYSV,cf_cv_sysv,[
2016AC_TRY_COMPILE([
2017#undef  SYSV
2018#define SYSV 1			/* get Xos.h to declare sys_errlist[] */
2019#ifdef HAVE_STDLIB_H
2020#include <stdlib.h>		/* look for wchar_t */
2021#endif
2022#ifdef HAVE_X11_INTRINSIC_H
2023#include <X11/Intrinsic.h>	/* Intrinsic.h has other traps... */
2024#endif
2025#ifdef HAVE_TERMIOS_H		/* needed for HPUX 10.20 */ 
2026#include <termios.h> 
2027#define STRUCT_TERMIOS struct termios 
2028#else 
2029#define STRUCT_TERMIOS struct termio 
2030#endif 
2031#include <curses.h>
2032#include <term.h>		/* eliminate most BSD hacks */
2033#include <errno.h>		/* declare sys_errlist on older systems */
2034#include <sys/termio.h>		/* eliminate most of the remaining ones */
2035],[
2036static STRUCT_TERMIOS d_tio;
2037	d_tio.c_cc[VINTR] = 0;
2038	d_tio.c_cc[VQUIT] = 0;
2039	d_tio.c_cc[VERASE] = 0;
2040	d_tio.c_cc[VKILL] = 0;
2041	d_tio.c_cc[VEOF] = 0;
2042	d_tio.c_cc[VEOL] = 0;
2043	d_tio.c_cc[VMIN] = 0;
2044	d_tio.c_cc[VTIME] = 0;
2045#if defined(HAVE_SYS_ERRLIST) && !defined(DECL_SYS_ERRLIST)
2046sys_errlist[0] = "";		/* Cygwin mis-declares this */
2047#endif
2048],
2049[cf_cv_sysv=yes],
2050[cf_cv_sysv=no])
2051])
2052test "$cf_cv_sysv" = yes && AC_DEFINE(SYSV)
2053])dnl
2054dnl ---------------------------------------------------------------------------
2055dnl CF_SYSV_UTMP version: 5 updated: 2001/12/27 12:55:07
2056dnl ------------
2057dnl Check if this is a SYSV flavor of UTMP
2058AC_DEFUN([CF_SYSV_UTMP],
2059[
2060AC_CACHE_CHECK(if $cf_cv_have_utmp is SYSV flavor,cf_cv_sysv_utmp,[
2061test "$cf_cv_have_utmp" = "utmp" && cf_prefix="ut" || cf_prefix="utx"
2062AC_TRY_LINK([
2063#include <sys/types.h>
2064#include <${cf_cv_have_utmp}.h>],[
2065struct $cf_cv_have_utmp x;
2066	set${cf_prefix}ent ();
2067	get${cf_prefix}id(&x);
2068	put${cf_prefix}line(&x);
2069	end${cf_prefix}ent();],
2070	[cf_cv_sysv_utmp=yes],
2071	[cf_cv_sysv_utmp=no])
2072])
2073test $cf_cv_sysv_utmp = yes && AC_DEFINE(USE_SYSV_UTMP)
2074])dnl
2075dnl ---------------------------------------------------------------------------
2076dnl CF_SYS_ERRLIST version: 6 updated: 2001/12/30 13:03:23
2077dnl --------------
2078dnl Check for declaration of sys_nerr and sys_errlist in one of stdio.h and
2079dnl errno.h.  Declaration of sys_errlist on BSD4.4 interferes with our
2080dnl declaration.  Reported by Keith Bostic.
2081AC_DEFUN([CF_SYS_ERRLIST],
2082[
2083    CF_CHECK_ERRNO(sys_nerr)
2084    CF_CHECK_ERRNO(sys_errlist)
2085])dnl
2086dnl ---------------------------------------------------------------------------
2087dnl CF_TERMIO_C_ISPEED version: 2 updated: 2000/05/29 16:16:04
2088dnl ------------------
2089dnl Check for SGI's broken redefinition of baud rates introduced in IRIX 6.5
2090dnl (there doesn't appear to be a useful predefined symbol).
2091AC_DEFUN([CF_TERMIO_C_ISPEED],
2092[
2093AC_CACHE_CHECK(for IRIX 6.5 baud-rate redefinitions,cf_cv_termio_c_ispeed,[
2094AC_TRY_COMPILE([
2095#include <sys/types.h>
2096#include <sys/termio.h>],[
2097struct termio foo;
2098foo.c_ispeed = B38400;
2099foo.c_ospeed = B9600;
2100],[cf_cv_termio_c_ispeed=yes
2101],[cf_cv_termio_c_ispeed=no])
2102])
2103test "$cf_cv_termio_c_ispeed" = yes && AC_DEFINE(HAVE_TERMIO_C_ISPEED)
2104])dnl
2105dnl ---------------------------------------------------------------------------
2106dnl CF_TRY_PKG_CONFIG version: 4 updated: 2010/06/14 17:42:30
2107dnl -----------------
2108dnl This is a simple wrapper to use for pkg-config, for libraries which may be
2109dnl available in that form.
2110dnl
2111dnl $1 = package name
2112dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
2113dnl $3 = logic to use if pkg-config does not have the package
2114AC_DEFUN([CF_TRY_PKG_CONFIG],[
2115AC_REQUIRE([CF_PKG_CONFIG])
2116
2117if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
2118	CF_VERBOSE(found package $1)
2119	cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
2120	cf_pkgconfig_libs="`$PKG_CONFIG --libs   $1 2>/dev/null`"
2121	CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
2122	CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
2123	CF_ADD_CFLAGS($cf_pkgconfig_incs)
2124	CF_ADD_LIBS($cf_pkgconfig_libs)
2125	ifelse([$2],,:,[$2])
2126else
2127	ifelse([$3],,:,[$3])
2128fi
2129])
2130dnl ---------------------------------------------------------------------------
2131dnl CF_TTY_GROUP version: 7 updated: 2007/03/14 16:43:59
2132dnl ------------
2133dnl Check if the system has a tty-group defined.  This is used in xterm when
2134dnl setting pty ownership.
2135AC_DEFUN([CF_TTY_GROUP],
2136[
2137AC_MSG_CHECKING(for explicit tty group name)
2138AC_ARG_WITH(tty-group,
2139	[  --with-tty-group=XXX    use XXX for the tty-group],
2140	[cf_tty_group=$withval],
2141	[cf_tty_group=auto...])
2142test -z "$cf_tty_group"    && cf_tty_group=auto...
2143test "$cf_tty_group" = yes && cf_tty_group=auto...
2144AC_MSG_RESULT($cf_tty_group)
2145
2146if test "$cf_tty_group" = "auto..." ; then
2147AC_CACHE_CHECK(for tty group name,cf_cv_tty_group_name,[
2148
2149# If we are configuring as root, it is hard to get a clue about the tty group.
2150# But we'll guess based on how our connection is set up - assuming it is done
2151# properly.
2152
2153cf_uid=`id | sed -e 's/^[^=]*=//' -e 's/(.*$//'`
2154# )vi
2155if test "$cf_uid" != 0 ; then
2156cf_cv_tty_group_name=
2157cf_tty_name=`tty`
2158test "$cf_tty_name" = "not a tty" && cf_tty_name=/dev/tty
2159test -z "$cf_tty_name" && cf_tty_name=/dev/tty
2160if test -c "$cf_tty_name"
2161then
2162	cf_option="-l -L"
2163
2164	# Expect listing to have fields like this:
2165	#-rwxrwxrwx   1 user      group       34293 Jul 18 16:29 pathname
2166	ls $cf_option $cf_tty_name >conftest.out
2167	read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
2168	if test -z "$cf_rest" ; then
2169		cf_option="$cf_option -g"
2170		ls $cf_option $cf_tty_name >conftest.out
2171		read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
2172	fi
2173	rm -f conftest.out
2174	cf_cv_tty_group_name=$cf_grp
2175fi
2176fi
2177
2178# If we cannot deduce the tty group, fall back on hardcoded cases
2179
2180if test -z "$cf_cv_tty_group_name"
2181then
2182case $host_os in #(vi
2183osf*) #(vi
2184	cf_cv_tty_group_name="terminal"
2185	;;
2186*)
2187	cf_cv_tty_group_name="unknown"
2188	if ( egrep '^tty:' /etc/group 2>/dev/null 1>/dev/null ) then
2189		cf_cv_tty_group_name="tty"
2190	fi
2191	;;
2192esac
2193fi
2194])
2195cf_tty_group="$cf_cv_tty_group_name"
2196else
2197	# if configure option, always do this
2198	AC_DEFINE(USE_TTY_GROUP)
2199fi
2200
2201AC_DEFINE_UNQUOTED(TTY_GROUP_NAME,"$cf_tty_group")
2202
2203# This is only a double-check that the group-name we obtained above really
2204# does apply to the device.  We cannot perform this test if we are in batch
2205# mode, or if we are cross-compiling.
2206
2207AC_CACHE_CHECK(if we may use the $cf_tty_group group,cf_cv_tty_group,[
2208cf_tty_name=`tty`
2209if test "$cf_tty_name" != "not a tty"
2210then
2211AC_TRY_RUN([
2212#include <unistd.h>
2213#include <sys/types.h>
2214#include <sys/stat.h>
2215#include <grp.h>
2216int main()
2217{
2218	struct stat sb;
2219	struct group *ttygrp = getgrnam(TTY_GROUP_NAME);
2220	char *name = ttyname(0);
2221
2222	endgrent();
2223	if (ttygrp != 0
2224	 && name != 0
2225	 && stat(name, &sb) == 0
2226	 && sb.st_gid != getgid()
2227	 && sb.st_gid == ttygrp->gr_gid) {
2228		${cf_cv_main_return:-return} (0);
2229	}
2230	${cf_cv_main_return:-return} (1);
2231}
2232	],
2233	[cf_cv_tty_group=yes],
2234	[cf_cv_tty_group=no],
2235	[cf_cv_tty_group=unknown])
2236elif test "$cross_compiling" = yes; then
2237	cf_cv_tty_group=unknown
2238else
2239	cf_cv_tty_group=yes
2240fi
2241])
2242
2243if test $cf_cv_tty_group = no ; then
2244	AC_MSG_WARN(Cannot use $cf_tty_group group)
2245else
2246	AC_DEFINE(USE_TTY_GROUP)
2247fi
2248])dnl
2249dnl ---------------------------------------------------------------------------
2250dnl CF_TYPE_FD_MASK version: 2 updated: 2008/03/25 20:59:57
2251dnl ---------------
2252dnl Check for the declaration of fd_mask, which is like fd_set, associated
2253dnl with select().  The check for fd_set should have pulled in this as well,
2254dnl but there is a special case for Mac OS X, possibly other BSD-derived
2255dnl platforms.
2256AC_DEFUN([CF_TYPE_FD_MASK],
2257[
2258AC_REQUIRE([CF_TYPE_FD_SET])
2259
2260AC_CACHE_CHECK(for declaration of fd_mask,cf_cv_type_fd_mask,[
2261    if test x$cf_cv_type_fd_set = xX11/Xpoll.h ; then
2262        AC_TRY_COMPILE([
2263#include <X11/Xpoll.h>],[fd_mask x],,
2264        [CF_MSG_LOG(if we must define CSRG_BASED)
2265# Xosdefs.h on Mac OS X may not define this (but it should).
2266            AC_TRY_COMPILE([
2267#define CSRG_BASED
2268#include <X11/Xpoll.h>],[fd_mask x],
2269        cf_cv_type_fd_mask=CSRG_BASED)])
2270    else
2271        cf_cv_type_fd_mask=$cf_cv_type_fd_set
2272    fi
2273])
2274if test x$cf_cv_type_fd_mask = xCSRG_BASED ; then
2275    AC_DEFINE(CSRG_BASED)
2276fi
2277])dnl
2278dnl ---------------------------------------------------------------------------
2279dnl CF_TYPE_FD_SET version: 4 updated: 2008/03/25 20:56:03
2280dnl --------------
2281dnl Check for the declaration of fd_set.  Some platforms declare it in
2282dnl <sys/types.h>, and some in <sys/select.h>, which requires <sys/types.h>.
2283dnl Finally, if we are using this for an X application, Xpoll.h may include
2284dnl <sys/select.h>, so we don't want to do it twice.
2285AC_DEFUN([CF_TYPE_FD_SET],
2286[
2287AC_CHECK_HEADERS(X11/Xpoll.h)
2288
2289AC_CACHE_CHECK(for declaration of fd_set,cf_cv_type_fd_set,
2290	[CF_MSG_LOG(sys/types alone)
2291AC_TRY_COMPILE([
2292#include <sys/types.h>],
2293	[fd_set x],
2294	[cf_cv_type_fd_set=sys/types.h],
2295	[CF_MSG_LOG(X11/Xpoll.h)
2296AC_TRY_COMPILE([
2297#ifdef HAVE_X11_XPOLL_H
2298#include <X11/Xpoll.h>
2299#endif],
2300	[fd_set x],
2301	[cf_cv_type_fd_set=X11/Xpoll.h],
2302	[CF_MSG_LOG(sys/select.h)
2303AC_TRY_COMPILE([
2304#include <sys/types.h>
2305#include <sys/select.h>],
2306	[fd_set x],
2307	[cf_cv_type_fd_set=sys/select.h],
2308	[cf_cv_type_fd_set=unknown])])])])
2309if test $cf_cv_type_fd_set = sys/select.h ; then
2310	AC_DEFINE(USE_SYS_SELECT_H)
2311fi
2312])
2313dnl ---------------------------------------------------------------------------
2314dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
2315dnl --------
2316dnl Make an uppercase version of a variable
2317dnl $1=uppercase($2)
2318AC_DEFUN([CF_UPPER],
2319[
2320$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2321])dnl
2322dnl ---------------------------------------------------------------------------
2323dnl CF_UTEMPTER version: 3 updated: 2010/06/02 05:03:05
2324dnl -----------
2325dnl Try to link with utempter library
2326AC_DEFUN([CF_UTEMPTER],
2327[
2328AC_CACHE_CHECK(if we can link with utempter library,cf_cv_have_utempter,[
2329cf_save_LIBS="$LIBS"
2330CF_ADD_LIB(utempter)
2331AC_TRY_LINK([
2332#include <utempter.h>
2333],[
2334	addToUtmp("/dev/tty", 0, 1);
2335	removeFromUtmp();
2336],[
2337	cf_cv_have_utempter=yes],[
2338	cf_cv_have_utempter=no])
2339LIBS="$cf_save_LIBS"
2340])
2341if test "$cf_cv_have_utempter" = yes ; then
2342	AC_DEFINE(USE_UTEMPTER)
2343	CF_ADD_LIB(utempter)
2344fi
2345])dnl
2346dnl ---------------------------------------------------------------------------
2347dnl CF_UTMP version: 9 updated: 2008/01/25 17:18:00
2348dnl -------
2349dnl Check for UTMP/UTMPX headers
2350AC_DEFUN([CF_UTMP],
2351[
2352AC_REQUIRE([CF_LASTLOG])
2353
2354AC_CACHE_CHECK(for utmp implementation,cf_cv_have_utmp,[
2355	cf_cv_have_utmp=no
2356for cf_header in utmpx utmp ; do
2357cf_utmp_includes="
2358#include <sys/types.h>
2359#include <${cf_header}.h>
2360#define getutent getutxent
2361#ifdef USE_LASTLOG
2362#include <lastlog.h>	/* may conflict with utmpx.h on Linux */
2363#endif
2364"
2365	AC_TRY_COMPILE([$cf_utmp_includes],
2366	[struct $cf_header x;
2367	 char *name = x.ut_name; /* utmp.h and compatible definitions */
2368	],
2369	[cf_cv_have_utmp=$cf_header
2370	 break],
2371	[
2372	AC_TRY_COMPILE([$cf_utmp_includes],
2373	[struct $cf_header x;
2374	 char *name = x.ut_user; /* utmpx.h must declare this */
2375	],
2376	[cf_cv_have_utmp=$cf_header
2377	 break
2378	])])
2379done
2380])
2381
2382if test $cf_cv_have_utmp != no ; then
2383	AC_DEFINE(HAVE_UTMP)
2384	test $cf_cv_have_utmp = utmpx && AC_DEFINE(UTMPX_FOR_UTMP)
2385	CF_UTMP_UT_HOST
2386	CF_UTMP_UT_SYSLEN
2387	CF_UTMP_UT_NAME
2388	CF_UTMP_UT_XSTATUS
2389	CF_UTMP_UT_XTIME
2390	CF_UTMP_UT_SESSION
2391	CF_SYSV_UTMP
2392fi
2393])dnl
2394dnl ---------------------------------------------------------------------------
2395dnl CF_UTMP_GROUP version: 1 updated: 2005/10/06 20:29:29
2396dnl -------------
2397dnl Find the utmp/utmpx file and determine its group to allow setgid programs
2398dnl to manipulate it, e.g., when there is no intermediary.
2399AC_DEFUN([CF_UTMP_GROUP],[
2400AC_REQUIRE([CF_UTMP])
2401if test $cf_cv_have_utmp != no ; then
2402AC_CACHE_CHECK(for utmp/utmpx group,cf_cv_utmp_group,[
2403for cf_utmp_path in /var/adm /var/run
2404do
2405	for cf_utmp_file in utmpx utmp
2406	do
2407		if test -f $cf_utmp_path/$cf_utmp_file
2408		then
2409			cf_cv_utmp_group=root
2410
2411			cf_option="-l -L"
2412
2413			# Expect listing to have fields like this:
2414			#-r--r--r--   1 user      group       34293 Jul 18 16:29 pathname
2415			ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
2416			read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
2417			if test -z "$cf_rest" ; then
2418				cf_option="$cf_option -g"
2419				ls $cf_option $cf_utmp_path/$cf_utmp_file >conftest
2420				read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
2421			fi
2422			rm -f conftest
2423
2424			# If we have a pathname, and the date fields look right, assume we've
2425			# captured the group as well.
2426			if test -n "$cf_rest" ; then
2427				cf_test=`echo "${cf_date2}${cf_date3}" | sed -e 's/[[0-9:]]//g'`
2428				if test -z "$cf_test" ; then
2429					cf_cv_utmp_group=$cf_grp;
2430				fi
2431			fi
2432			break
2433		fi
2434	done
2435	test -n "$cf_cv_utmp_group" && break
2436done
2437])
2438else
2439	AC_MSG_ERROR(cannot find utmp group)
2440fi
2441])dnl
2442dnl ---------------------------------------------------------------------------
2443dnl CF_UTMP_UT_HOST version: 7 updated: 2007/03/13 19:17:11
2444dnl ---------------
2445dnl Check if UTMP/UTMPX struct defines ut_host member
2446AC_DEFUN([CF_UTMP_UT_HOST],
2447[
2448if test $cf_cv_have_utmp != no ; then
2449AC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_host is declared)
2450AC_CACHE_VAL(cf_cv_have_utmp_ut_host,[
2451	AC_TRY_COMPILE([
2452#include <sys/types.h>
2453#include <${cf_cv_have_utmp}.h>],
2454	[struct $cf_cv_have_utmp x; char *y = &x.ut_host[0]],
2455	[cf_cv_have_utmp_ut_host=yes],
2456	[cf_cv_have_utmp_ut_host=no])
2457	])
2458AC_MSG_RESULT($cf_cv_have_utmp_ut_host)
2459test $cf_cv_have_utmp_ut_host != no && AC_DEFINE(HAVE_UTMP_UT_HOST)
2460fi
2461])dnl
2462dnl ---------------------------------------------------------------------------
2463dnl CF_UTMP_UT_NAME version: 4 updated: 2007/03/13 19:17:11
2464dnl ---------------
2465dnl Check if UTMP/UTMPX struct defines ut_name member
2466AC_DEFUN([CF_UTMP_UT_NAME],
2467[
2468if test $cf_cv_have_utmp != no ; then
2469AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_name is declared,cf_cv_have_utmp_ut_name,[
2470	cf_cv_have_utmp_ut_name=no
2471cf_utmp_includes="
2472#include <sys/types.h>
2473#include <${cf_cv_have_utmp}.h>
2474#define getutent getutxent
2475#ifdef USE_LASTLOG
2476#include <lastlog.h>		/* may conflict with utmpx.h on Linux */
2477#endif
2478"
2479for cf_header in ut_name ut_user ; do
2480	AC_TRY_COMPILE([$cf_utmp_includes],
2481	[struct $cf_cv_have_utmp x;
2482	 char *name = x.$cf_header;
2483	],
2484	[cf_cv_have_utmp_ut_name=$cf_header
2485	 break])
2486done
2487])
2488
2489case $cf_cv_have_utmp_ut_name in #(vi
2490no) #(vi
2491	AC_MSG_ERROR(Cannot find declaration for ut.ut_name)
2492	;;
2493ut_user)
2494	AC_DEFINE(ut_name,ut_user)
2495	;;
2496esac
2497fi
2498])dnl
2499dnl ---------------------------------------------------------------------------
2500dnl CF_UTMP_UT_SESSION version: 5 updated: 2007/03/13 19:17:11
2501dnl ------------------
2502dnl Check if UTMP/UTMPX struct defines ut_session member
2503AC_DEFUN([CF_UTMP_UT_SESSION],
2504[
2505if test $cf_cv_have_utmp != no ; then
2506AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_session is declared, cf_cv_have_utmp_ut_session,[
2507	AC_TRY_COMPILE([
2508#include <sys/types.h>
2509#include <${cf_cv_have_utmp}.h>],
2510	[struct $cf_cv_have_utmp x; long y = x.ut_session],
2511	[cf_cv_have_utmp_ut_session=yes],
2512	[cf_cv_have_utmp_ut_session=no])
2513])
2514if test $cf_cv_have_utmp_ut_session != no ; then
2515	AC_DEFINE(HAVE_UTMP_UT_SESSION)
2516fi
2517fi
2518])dnl
2519dnl ---------------------------------------------------------------------------
2520dnl CF_UTMP_UT_SYSLEN version: 1 updated: 2008/01/25 17:18:00
2521dnl -----------------
2522dnl Check if UTMP/UTMPX struct defines ut_syslen member
2523AC_DEFUN([CF_UTMP_UT_SYSLEN],
2524[
2525if test $cf_cv_have_utmp != no ; then
2526AC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_syslen is declared)
2527AC_CACHE_VAL(cf_cv_have_utmp_ut_syslen,[
2528	AC_TRY_COMPILE([
2529#include <sys/types.h>
2530#include <${cf_cv_have_utmp}.h>],
2531	[struct $cf_cv_have_utmp x; int y = x.ut_syslen],
2532	[cf_cv_have_utmp_ut_syslen=yes],
2533	[cf_cv_have_utmp_ut_syslen=no])
2534	])
2535AC_MSG_RESULT($cf_cv_have_utmp_ut_syslen)
2536test $cf_cv_have_utmp_ut_syslen != no && AC_DEFINE(HAVE_UTMP_UT_SYSLEN)
2537fi
2538])dnl
2539dnl ---------------------------------------------------------------------------
2540dnl CF_UTMP_UT_XSTATUS version: 3 updated: 2001/12/27 12:55:07
2541dnl ------------------
2542dnl Check for known variants on the UTMP/UTMPX struct's exit-status as reported
2543dnl by various people:
2544dnl
2545dnl	ut_exit.__e_exit (HPUX 11 - David Ellement, also in glibc2)
2546dnl	ut_exit.e_exit (SVR4)
2547dnl	ut_exit.ut_e_exit (os390 - Greg Smith)
2548dnl	ut_exit.ut_exit (Tru64 4.0f - Jeremie Petit, 4.0e - Tomas Vanhala)
2549dnl
2550dnl Note: utmp_xstatus is not a conventional compatibility definition in the
2551dnl system header files.
2552AC_DEFUN([CF_UTMP_UT_XSTATUS],
2553[
2554if test $cf_cv_have_utmp != no ; then
2555AC_CACHE_CHECK(for exit-status in $cf_cv_have_utmp,cf_cv_have_utmp_ut_xstatus,[
2556for cf_result in \
2557	ut_exit.__e_exit \
2558	ut_exit.e_exit \
2559	ut_exit.ut_e_exit \
2560	ut_exit.ut_exit
2561do
2562AC_TRY_COMPILE([
2563#include <sys/types.h>
2564#include <${cf_cv_have_utmp}.h>],
2565	[struct $cf_cv_have_utmp x; long y = x.$cf_result = 0],
2566	[cf_cv_have_utmp_ut_xstatus=$cf_result
2567	 break],
2568	[cf_cv_have_utmp_ut_xstatus=no])
2569done
2570])
2571if test $cf_cv_have_utmp_ut_xstatus != no ; then
2572	AC_DEFINE(HAVE_UTMP_UT_XSTATUS)
2573	AC_DEFINE_UNQUOTED(ut_xstatus,$cf_cv_have_utmp_ut_xstatus)
2574fi
2575fi
2576])dnl
2577dnl ---------------------------------------------------------------------------
2578dnl CF_UTMP_UT_XTIME version: 7 updated: 2007/03/13 19:17:11
2579dnl ----------------
2580dnl Check if UTMP/UTMPX struct defines ut_xtime member
2581AC_DEFUN([CF_UTMP_UT_XTIME],
2582[
2583if test $cf_cv_have_utmp != no ; then
2584AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_xtime is declared, cf_cv_have_utmp_ut_xtime,[
2585	AC_TRY_COMPILE([
2586#include <sys/types.h>
2587#include <${cf_cv_have_utmp}.h>],
2588	[struct $cf_cv_have_utmp x; long y = x.ut_xtime = 0],
2589	[cf_cv_have_utmp_ut_xtime=yes],
2590	[AC_TRY_COMPILE([
2591#include <sys/types.h>
2592#include <${cf_cv_have_utmp}.h>],
2593	[struct $cf_cv_have_utmp x; long y = x.ut_tv.tv_sec],
2594	[cf_cv_have_utmp_ut_xtime=define],
2595	[cf_cv_have_utmp_ut_xtime=no])
2596	])
2597])
2598if test $cf_cv_have_utmp_ut_xtime != no ; then
2599	AC_DEFINE(HAVE_UTMP_UT_XTIME)
2600	if test $cf_cv_have_utmp_ut_xtime = define ; then
2601		AC_DEFINE(ut_xtime,ut_tv.tv_sec)
2602	fi
2603fi
2604fi
2605])dnl
2606dnl ---------------------------------------------------------------------------
2607dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
2608dnl ----------
2609dnl Use AC_VERBOSE w/o the warnings
2610AC_DEFUN([CF_VERBOSE],
2611[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
2612CF_MSG_LOG([$1])
2613])dnl
2614dnl ---------------------------------------------------------------------------
2615dnl CF_WITH_IMAKE_CFLAGS version: 9 updated: 2010/05/26 05:38:42
2616dnl --------------------
2617dnl xterm and similar programs build more readily when propped up with imake's
2618dnl hand-tuned definitions.  If we do not use imake, provide fallbacks for the
2619dnl most common definitions that we're not likely to do by autoconf tests.
2620AC_DEFUN([CF_WITH_IMAKE_CFLAGS],[
2621AC_REQUIRE([CF_ENABLE_NARROWPROTO])
2622
2623AC_MSG_CHECKING(if we should use imake to help)
2624CF_ARG_DISABLE(imake,
2625	[  --disable-imake         disable use of imake for definitions],
2626	[enable_imake=no],
2627	[enable_imake=yes])
2628AC_MSG_RESULT($enable_imake)
2629
2630if test "$enable_imake" = yes ; then
2631	CF_IMAKE_CFLAGS(ifelse([$1],,,[$1]))
2632fi
2633
2634if test -n "$IMAKE" && test -n "$IMAKE_CFLAGS" ; then
2635	CF_ADD_CFLAGS($IMAKE_CFLAGS)
2636else
2637	IMAKE_CFLAGS=
2638	IMAKE_LOADFLAGS=
2639	CF_VERBOSE(make fallback definitions)
2640
2641	# We prefer config.guess' values when we can get them, to avoid
2642	# inconsistent results with uname (AIX for instance).  However,
2643	# config.guess is not always consistent either.
2644	case $host_os in
2645	*[[0-9]].[[0-9]]*)
2646		UNAME_RELEASE="$host_os"
2647		;;
2648	*)
2649		UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
2650		;;
2651	esac
2652
2653	case .$UNAME_RELEASE in
2654	*[[0-9]].[[0-9]]*)
2655		OSMAJORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/\..*//'`
2656		OSMINORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/^[[^.]]*\.//' -e 's/\..*//' -e 's/[[^0-9]].*//' `
2657		test -z "$OSMAJORVERSION" && OSMAJORVERSION=1
2658		test -z "$OSMINORVERSION" && OSMINORVERSION=0
2659		IMAKE_CFLAGS="-DOSMAJORVERSION=$OSMAJORVERSION -DOSMINORVERSION=$OSMINORVERSION $IMAKE_CFLAGS"
2660		;;
2661	esac
2662
2663	# FUNCPROTO is standard with X11R6, but XFree86 drops it, leaving some
2664	# fallback/fragments for NeedPrototypes, etc.
2665	IMAKE_CFLAGS="-DFUNCPROTO=15 $IMAKE_CFLAGS"
2666
2667	# If this is not set properly, Xaw's scrollbars will not work
2668	if test "$enable_narrowproto" = yes ; then
2669		IMAKE_CFLAGS="-DNARROWPROTO=1 $IMAKE_CFLAGS"
2670	fi
2671
2672	# Other special definitions:
2673	case $host_os in
2674	aix*)
2675		# imake on AIX 5.1 defines AIXV3.  really.
2676		IMAKE_CFLAGS="-DAIXV3 -DAIXV4 $IMAKE_CFLAGS"
2677		;;
2678	irix[[56]].*) #(vi
2679		# these are needed to make SIGWINCH work in xterm
2680		IMAKE_CFLAGS="-DSYSV -DSVR4 $IMAKE_CFLAGS"
2681		;;
2682	esac
2683
2684	CF_ADD_CFLAGS($IMAKE_CFLAGS)
2685
2686	AC_SUBST(IMAKE_CFLAGS)
2687	AC_SUBST(IMAKE_LOADFLAGS)
2688fi
2689])dnl
2690dnl ---------------------------------------------------------------------------
2691dnl CF_WITH_PATH version: 10 updated: 2010/10/23 15:44:18
2692dnl ------------
2693dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
2694dnl defaulting to yes/no.
2695dnl
2696dnl $1 = option name
2697dnl $2 = help-text
2698dnl $3 = environment variable to set
2699dnl $4 = default value, shown in the help-message, must be a constant
2700dnl $5 = default value, if it's an expression & cannot be in the help-message
2701dnl
2702AC_DEFUN([CF_WITH_PATH],
2703[AC_ARG_WITH($1,[$2 ](default: ifelse([$4],,empty,[$4])),,
2704ifelse([$4],,[withval="${$3}"],[withval="${$3:-ifelse([$5],,[$4],[$5])}"]))dnl
2705if ifelse([$5],,true,[test -n "$5"]) ; then
2706CF_PATH_SYNTAX(withval)
2707fi
2708$3="$withval"
2709AC_SUBST($3)dnl
2710])dnl
2711dnl ---------------------------------------------------------------------------
2712dnl CF_WITH_PCRE version: 8 updated: 2010/06/05 11:30:21
2713dnl ------------
2714dnl Add PCRE (Perl-compatible regular expressions) to the build if it is
2715dnl available and the user requests it.  Assume the application will otherwise
2716dnl use the POSIX interface.
2717dnl
2718dnl TODO allow $withval to specify package location
2719AC_DEFUN([CF_WITH_PCRE],
2720[
2721AC_REQUIRE([CF_PKG_CONFIG])
2722
2723AC_MSG_CHECKING(if you want to use PCRE for regular-expressions)
2724AC_ARG_WITH(pcre,
2725	[  --with-pcre             use PCRE for regular-expressions])
2726test -z "$with_pcre" && with_pcre=no
2727AC_MSG_RESULT($with_pcre)
2728
2729if test "$with_pcre" != no ; then
2730	CF_TRY_PKG_CONFIG(libpcre,,[
2731		AC_CHECK_LIB(pcre,pcre_compile,,
2732			AC_MSG_ERROR(Cannot find PCRE library))])
2733
2734		AC_DEFINE(HAVE_LIB_PCRE)
2735
2736		case $LIBS in #(vi
2737		*pcreposix*) #(vi
2738			;;
2739		*)
2740			AC_CHECK_LIB(pcreposix,pcreposix_regcomp,
2741				[AC_DEFINE(HAVE_PCREPOSIX_H)
2742				 CF_ADD_LIB(pcreposix)],
2743				[AC_CHECK_LIB(pcreposix,regcomp,[
2744					AC_DEFINE(HAVE_PCREPOSIX_H)
2745					CF_ADD_LIB(pcreposix)],
2746					AC_MSG_ERROR(Cannot find PCRE POSIX library)]))
2747			;;
2748		esac
2749fi
2750])dnl
2751dnl ---------------------------------------------------------------------------
2752dnl CF_XKB_BELL_EXT version: 3 updated: 2009/02/13 16:00:39
2753dnl ---------------
2754dnl Check for XKB bell extension
2755AC_DEFUN([CF_XKB_BELL_EXT],[
2756AC_CACHE_CHECK(for XKB Bell extension, cf_cv_xkb_bell_ext,[
2757AC_TRY_LINK([
2758#include <X11/Intrinsic.h>
2759#include <X11/XKBlib.h>		/* has the prototype */
2760#include <X11/extensions/XKBbells.h>	/* has the XkbBI_xxx definitions */
2761],[
2762	int x = (XkbBI_Info |XkbBI_MinorError |XkbBI_MajorError |XkbBI_TerminalBell |XkbBI_MarginBell);
2763	Atom y;
2764	XkbBell((Display *)0, (Widget)0, 0, y);
2765],[cf_cv_xkb_bell_ext=yes],[cf_cv_xkb_bell_ext=no])
2766])
2767test "$cf_cv_xkb_bell_ext" = yes && AC_DEFINE(HAVE_XKB_BELL_EXT)
2768])
2769dnl ---------------------------------------------------------------------------
2770dnl CF_XOPEN_SOURCE version: 34 updated: 2010/05/26 05:38:42
2771dnl ---------------
2772dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
2773dnl or adapt to the vendor's definitions to get equivalent functionality,
2774dnl without losing the common non-POSIX features.
2775dnl
2776dnl Parameters:
2777dnl	$1 is the nominal value for _XOPEN_SOURCE
2778dnl	$2 is the nominal value for _POSIX_C_SOURCE
2779AC_DEFUN([CF_XOPEN_SOURCE],[
2780
2781cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
2782cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
2783cf_xopen_source=
2784
2785case $host_os in #(vi
2786aix[[456]]*) #(vi
2787	cf_xopen_source="-D_ALL_SOURCE"
2788	;;
2789darwin[[0-8]].*) #(vi
2790	cf_xopen_source="-D_APPLE_C_SOURCE"
2791	;;
2792darwin*) #(vi
2793	cf_xopen_source="-D_DARWIN_C_SOURCE"
2794	;;
2795freebsd*|dragonfly*) #(vi
2796	# 5.x headers associate
2797	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
2798	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
2799	cf_POSIX_C_SOURCE=200112L
2800	cf_XOPEN_SOURCE=600
2801	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2802	;;
2803hpux11*) #(vi
2804	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
2805	;;
2806hpux*) #(vi
2807	cf_xopen_source="-D_HPUX_SOURCE"
2808	;;
2809irix[[56]].*) #(vi
2810	cf_xopen_source="-D_SGI_SOURCE"
2811	;;
2812linux*|gnu*|mint*|k*bsd*-gnu) #(vi
2813	CF_GNU_SOURCE
2814	;;
2815mirbsd*) #(vi
2816	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
2817	;;
2818netbsd*) #(vi
2819	# setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
2820	;;
2821openbsd*) #(vi
2822	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
2823	;;
2824osf[[45]]*) #(vi
2825	cf_xopen_source="-D_OSF_SOURCE"
2826	;;
2827nto-qnx*) #(vi
2828	cf_xopen_source="-D_QNX_SOURCE"
2829	;;
2830sco*) #(vi
2831	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
2832	;;
2833solaris2.1[[0-9]]) #(vi
2834	cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2835	;;
2836solaris2.[[1-9]]) #(vi
2837	cf_xopen_source="-D__EXTENSIONS__"
2838	;;
2839*)
2840	AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
2841	AC_TRY_COMPILE([#include <sys/types.h>],[
2842#ifndef _XOPEN_SOURCE
2843make an error
2844#endif],
2845	[cf_cv_xopen_source=no],
2846	[cf_save="$CPPFLAGS"
2847	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2848	 AC_TRY_COMPILE([#include <sys/types.h>],[
2849#ifdef _XOPEN_SOURCE
2850make an error
2851#endif],
2852	[cf_cv_xopen_source=no],
2853	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
2854	CPPFLAGS="$cf_save"
2855	])
2856])
2857	if test "$cf_cv_xopen_source" != no ; then
2858		CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
2859		CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
2860		cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
2861		CF_ADD_CFLAGS($cf_temp_xopen_source)
2862	fi
2863	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
2864	;;
2865esac
2866
2867if test -n "$cf_xopen_source" ; then
2868	CF_ADD_CFLAGS($cf_xopen_source)
2869fi
2870])
2871dnl ---------------------------------------------------------------------------
2872dnl CF_X_ATHENA version: 20 updated: 2010/11/09 05:18:02
2873dnl -----------
2874dnl Check for Xaw (Athena) libraries
2875dnl
2876dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
2877AC_DEFUN([CF_X_ATHENA],
2878[
2879cf_x_athena=${cf_x_athena:-Xaw}
2880
2881AC_MSG_CHECKING(if you want to link with Xaw 3d library)
2882withval=
2883AC_ARG_WITH(Xaw3d,
2884	[  --with-Xaw3d            link with Xaw 3d library])
2885if test "$withval" = yes ; then
2886	cf_x_athena=Xaw3d
2887	AC_MSG_RESULT(yes)
2888else
2889	AC_MSG_RESULT(no)
2890fi
2891
2892AC_MSG_CHECKING(if you want to link with neXT Athena library)
2893withval=
2894AC_ARG_WITH(neXtaw,
2895	[  --with-neXtaw           link with neXT Athena library])
2896if test "$withval" = yes ; then
2897	cf_x_athena=neXtaw
2898	AC_MSG_RESULT(yes)
2899else
2900	AC_MSG_RESULT(no)
2901fi
2902
2903AC_MSG_CHECKING(if you want to link with Athena-Plus library)
2904withval=
2905AC_ARG_WITH(XawPlus,
2906	[  --with-XawPlus          link with Athena-Plus library])
2907if test "$withval" = yes ; then
2908	cf_x_athena=XawPlus
2909	AC_MSG_RESULT(yes)
2910else
2911	AC_MSG_RESULT(no)
2912fi
2913
2914cf_x_athena_lib=""
2915
2916if test "$PKG_CONFIG" != none ; then
2917	cf_athena_list=
2918	test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
2919	for cf_athena_pkg in \
2920		$cf_athena_list \
2921		${cf_x_athena} \
2922		${cf_x_athena}-devel \
2923		lib${cf_x_athena} \
2924		lib${cf_x_athena}-devel
2925	do
2926		CF_TRY_PKG_CONFIG($cf_athena_pkg,[
2927			cf_x_athena_lib="$cf_pkgconfig_libs"
2928			CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
2929			AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
2930
2931AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
2932AC_TRY_LINK([
2933#include <X11/Xmu/CharSet.h>
2934],[
2935int check = XmuCompareISOLatin1("big", "small")
2936],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
2937
2938			if test "$cf_cv_xaw_compat" = no
2939			then
2940				# workaround for broken ".pc" files...
2941				case "$cf_x_athena_lib" in #(vi
2942				*-lXmu*) #(vi
2943					;;
2944				*)
2945					CF_VERBOSE(work around broken package)
2946					CF_TRY_PKG_CONFIG(xmu,,[CF_ADD_LIB_AFTER(-lXt,-lXmu)])
2947					;;
2948				esac
2949			fi
2950
2951			break])
2952	done
2953fi
2954
2955if test -z "$cf_x_athena_lib" ; then
2956	CF_X_EXT
2957	CF_X_TOOLKIT
2958	CF_X_ATHENA_CPPFLAGS($cf_x_athena)
2959	CF_X_ATHENA_LIBS($cf_x_athena)
2960fi
2961])dnl
2962dnl ---------------------------------------------------------------------------
2963dnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
2964dnl --------------------
2965dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
2966dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
2967AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
2968[
2969cf_x_athena_root=ifelse([$1],,Xaw,[$1])
2970cf_x_athena_inc=""
2971
2972for cf_path in default \
2973	/usr/contrib/X11R6 \
2974	/usr/contrib/X11R5 \
2975	/usr/lib/X11R5 \
2976	/usr/local
2977do
2978	if test -z "$cf_x_athena_inc" ; then
2979		cf_save="$CPPFLAGS"
2980		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
2981		if test $cf_path != default ; then
2982			CPPFLAGS="$cf_save -I$cf_path/include"
2983			AC_MSG_CHECKING(for $cf_test in $cf_path)
2984		else
2985			AC_MSG_CHECKING(for $cf_test)
2986		fi
2987		AC_TRY_COMPILE([
2988#include <X11/Intrinsic.h>
2989#include <$cf_test>],[],
2990			[cf_result=yes],
2991			[cf_result=no])
2992		AC_MSG_RESULT($cf_result)
2993		if test "$cf_result" = yes ; then
2994			cf_x_athena_inc=$cf_path
2995			break
2996		else
2997			CPPFLAGS="$cf_save"
2998		fi
2999	fi
3000done
3001
3002if test -z "$cf_x_athena_inc" ; then
3003	AC_MSG_WARN(
3004[Unable to successfully find Athena header files with test program])
3005elif test "$cf_x_athena_inc" != default ; then
3006	CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
3007fi
3008])
3009dnl ---------------------------------------------------------------------------
3010dnl CF_X_ATHENA_LIBS version: 10 updated: 2011/02/13 13:31:33
3011dnl ----------------
3012dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
3013dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
3014AC_DEFUN([CF_X_ATHENA_LIBS],
3015[AC_REQUIRE([CF_X_TOOLKIT])
3016cf_x_athena_root=ifelse([$1],,Xaw,[$1])
3017cf_x_athena_lib=""
3018
3019for cf_path in default \
3020	/usr/contrib/X11R6 \
3021	/usr/contrib/X11R5 \
3022	/usr/lib/X11R5 \
3023	/usr/local
3024do
3025	for cf_lib in \
3026		"-l$cf_x_athena_root -lXmu" \
3027		"-l$cf_x_athena_root -lXpm -lXmu" \
3028		"-l${cf_x_athena_root}_s -lXmu_s"
3029	do
3030		if test -z "$cf_x_athena_lib" ; then
3031			cf_save="$LIBS"
3032			cf_test=XawSimpleMenuAddGlobalActions
3033			if test $cf_path != default ; then
3034				CF_ADD_LIBS(-L$cf_path/lib $cf_lib)
3035				AC_MSG_CHECKING(for $cf_lib in $cf_path)
3036			else
3037				CF_ADD_LIBS($cf_lib)
3038				AC_MSG_CHECKING(for $cf_test in $cf_lib)
3039			fi
3040			AC_TRY_LINK([
3041#include <X11/Intrinsic.h>
3042#include <X11/$cf_x_athena_root/SimpleMenu.h>
3043],[
3044$cf_test((XtAppContext) 0)],
3045				[cf_result=yes],
3046				[cf_result=no])
3047			AC_MSG_RESULT($cf_result)
3048			if test "$cf_result" = yes ; then
3049				cf_x_athena_lib="$cf_lib"
3050				break
3051			fi
3052			LIBS="$cf_save"
3053		fi
3054	done
3055done
3056
3057if test -z "$cf_x_athena_lib" ; then
3058	AC_MSG_ERROR(
3059[Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
3060fi
3061
3062CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
3063AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
3064])
3065dnl ---------------------------------------------------------------------------
3066dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
3067dnl --------
3068AC_DEFUN([CF_X_EXT],[
3069CF_TRY_PKG_CONFIG(Xext,,[
3070	AC_CHECK_LIB(Xext,XextCreateExtension,
3071		[CF_ADD_LIB(Xext)])])
3072])dnl
3073dnl ---------------------------------------------------------------------------
3074dnl CF_X_FONTCONFIG version: 3 updated: 2010/11/09 05:18:02
3075dnl ---------------
3076dnl Check for fontconfig library, a dependency of the X FreeType library.
3077AC_DEFUN([CF_X_FONTCONFIG],
3078[
3079AC_REQUIRE([CF_X_FREETYPE])
3080
3081AC_CACHE_CHECK(for usable Xft/fontconfig package,cf_cv_xft_compat,[
3082AC_TRY_LINK([
3083#include <X11/Xft/Xft.h>
3084],[
3085	XftPattern *pat;
3086	XftPatternBuild(pat,
3087					XFT_FAMILY, XftTypeString, "mono",
3088					(void *) 0);
3089],[cf_cv_xft_compat=yes],[cf_cv_xft_compat=no])
3090])
3091
3092if test "$cf_cv_xft_compat" = no
3093then
3094	# workaround for broken ".pc" files used for Xft.
3095	case "$cf_cv_x_freetype_libs" in #(vi
3096	*-lfontconfig*) #(vi
3097		;;
3098	*)
3099		CF_VERBOSE(work around broken package)
3100		CF_TRY_PKG_CONFIG(fontconfig,,[CF_ADD_LIB_AFTER(-lXft,-lfontconfig)])
3101		;;
3102	esac
3103fi
3104])dnl
3105dnl ---------------------------------------------------------------------------
3106dnl CF_X_FREETYPE version: 23 updated: 2010/11/08 20:19:21
3107dnl -------------
3108dnl Check for X FreeType headers and libraries (XFree86 4.x, etc).
3109dnl
3110dnl First check for the appropriate config program, since the developers for
3111dnl these libraries change their configuration (and config program) more or
3112dnl less randomly.  If we cannot find the config program, do not bother trying
3113dnl to guess the latest variation of include/lib directories.
3114dnl
3115dnl If either or both of these configure-script options are not given, rely on
3116dnl the output of the config program to provide the cflags/libs options:
3117dnl	--with-freetype-cflags
3118dnl	--with-freetype-libs
3119AC_DEFUN([CF_X_FREETYPE],
3120[
3121AC_REQUIRE([CF_PKG_CONFIG])
3122
3123cf_extra_freetype_libs=
3124FREETYPE_CONFIG=none
3125FREETYPE_PARAMS=
3126
3127AC_MSG_CHECKING(if you specified -D/-I options for FreeType)
3128AC_ARG_WITH(freetype-cflags,
3129	[  --with-freetype-cflags  -D/-I options for compiling with FreeType],
3130	[cf_cv_x_freetype_incs="$with_freetype_cflags"],
3131	[cf_cv_x_freetype_incs=no])
3132AC_MSG_RESULT($cf_cv_x_freetype_incs)
3133
3134
3135AC_MSG_CHECKING(if you specified -L/-l options for FreeType)
3136AC_ARG_WITH(freetype-libs,
3137	[  --with-freetype-libs    -L/-l options to link FreeType],
3138	[cf_cv_x_freetype_libs="$with_freetype_libs"],
3139	[cf_cv_x_freetype_libs=no])
3140AC_MSG_RESULT($cf_cv_x_freetype_libs)
3141
3142if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
3143	FREETYPE_CONFIG=$PKG_CONFIG
3144	FREETYPE_PARAMS=xft
3145else
3146	AC_PATH_PROG(FREETYPE_XFT_CONFIG, xft-config, none)
3147	if test "$FREETYPE_XFT_CONFIG" != none; then
3148		FREETYPE_CONFIG=$FREETYPE_XFT_CONFIG
3149	else
3150		cf_extra_freetype_libs="-lXft"
3151		AC_PATH_PROG(FREETYPE_OLD_CONFIG, freetype-config, none)
3152		if test "$FREETYPE_OLD_CONFIG" != none; then
3153			FREETYPE_CONFIG=$FREETYPE_OLD_CONFIG
3154		fi
3155	fi
3156fi
3157AC_MSG_CHECKING(for FreeType config)
3158AC_MSG_RESULT($FREETYPE_CONFIG $FREETYPE_PARAMS)
3159
3160if test "$FREETYPE_CONFIG" != none ; then
3161
3162	if test "$cf_cv_x_freetype_incs" = no ; then
3163		AC_MSG_CHECKING(for $FREETYPE_CONFIG cflags)
3164		cf_cv_x_freetype_incs="`$FREETYPE_CONFIG $FREETYPE_PARAMS --cflags 2>/dev/null`"
3165		AC_MSG_RESULT($cf_cv_x_freetype_incs)
3166	fi
3167
3168	if test "$cf_cv_x_freetype_libs" = no ; then
3169		AC_MSG_CHECKING(for $FREETYPE_CONFIG libs)
3170		cf_cv_x_freetype_libs="$cf_extra_freetype_libs `$FREETYPE_CONFIG $FREETYPE_PARAMS --libs 2>/dev/null`"
3171		AC_MSG_RESULT($cf_cv_x_freetype_libs)
3172	fi
3173
3174fi
3175
3176if test "$cf_cv_x_freetype_incs" = no ; then
3177	cf_cv_x_freetype_incs=
3178fi
3179
3180if test "$cf_cv_x_freetype_libs" = no ; then
3181	cf_cv_x_freetype_libs=-lXft
3182fi
3183
3184AC_MSG_CHECKING(if we can link with FreeType libraries)
3185
3186cf_save_LIBS="$LIBS"
3187cf_save_INCS="$CPPFLAGS"
3188
3189CF_ADD_LIBS($cf_cv_x_freetype_libs)
3190CPPFLAGS="$CPPFLAGS $cf_cv_x_freetype_incs"
3191
3192AC_TRY_LINK([
3193#include <X11/Xlib.h>
3194#include <X11/extensions/Xrender.h>
3195#include <X11/Xft/Xft.h>],[
3196	XftPattern  *pat = XftNameParse ("name");],
3197	[cf_cv_found_freetype=yes],
3198	[cf_cv_found_freetype=no])
3199AC_MSG_RESULT($cf_cv_found_freetype)
3200
3201LIBS="$cf_save_LIBS"
3202CPPFLAGS="$cf_save_INCS"
3203
3204if test "$cf_cv_found_freetype" = yes ; then
3205	CF_ADD_LIBS($cf_cv_x_freetype_libs)
3206	CF_ADD_CFLAGS($cf_cv_x_freetype_incs)
3207	AC_DEFINE(XRENDERFONT)
3208
3209AC_CHECK_FUNCS( \
3210	XftDrawCharSpec \
3211	XftDrawSetClip \
3212	XftDrawSetClipRectangles \
3213)
3214
3215else
3216	AC_MSG_WARN(No libraries found for FreeType)
3217	CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
3218fi
3219
3220# FIXME: revisit this if needed
3221AC_SUBST(HAVE_TYPE_FCCHAR32)
3222AC_SUBST(HAVE_TYPE_XFTCHARSPEC)
3223])
3224dnl ---------------------------------------------------------------------------
3225dnl CF_X_TOOLKIT version: 20 updated: 2010/11/19 05:43:04
3226dnl ------------
3227dnl Check for X Toolkit libraries
3228dnl
3229AC_DEFUN([CF_X_TOOLKIT],
3230[
3231AC_REQUIRE([AC_PATH_XTRA])
3232AC_REQUIRE([CF_CHECK_CACHE])
3233
3234cf_have_X_LIBS=no
3235
3236CF_TRY_PKG_CONFIG(xt,[
3237
3238	case "x$LIBS" in #(vi
3239	*-lX11*) #(vi
3240		;;
3241	*)
3242# we have an "xt" package, but it may omit Xt's dependency on X11
3243AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
3244AC_TRY_LINK([
3245#include <X11/Xlib.h>
3246],[
3247	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
3248	int rc2 = XClearWindow((Display*) 0, (Window) 0);
3249	int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
3250	int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
3251],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
3252		if test "$cf_cv_xt_x11_compat" = no
3253		then
3254			CF_VERBOSE(work around broken X11 dependency)
3255			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.
3256			CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
3257		fi
3258		;;
3259	esac
3260
3261AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
3262AC_TRY_LINK([
3263#include <X11/Shell.h>
3264],[int num = IceConnectionNumber(0)
3265],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
3266
3267	if test "$cf_cv_xt_ice_compat" = no
3268	then
3269		# workaround for broken ".pc" files used for X Toolkit.
3270		case "x$X_PRE_LIBS" in #(vi
3271		*-lICE*)
3272			case "x$LIBS" in #(vi
3273			*-lICE*) #(vi
3274				;;
3275			*)
3276				CF_VERBOSE(work around broken ICE dependency)
3277				CF_TRY_PKG_CONFIG(ice,
3278					[CF_TRY_PKG_CONFIG(sm)],
3279					[CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
3280				;;
3281			esac
3282			;;
3283		esac
3284	fi
3285
3286	cf_have_X_LIBS=yes
3287],[
3288
3289	LDFLAGS="$X_LIBS $LDFLAGS"
3290	CF_CHECK_CFLAGS($X_CFLAGS)
3291
3292	AC_CHECK_FUNC(XOpenDisplay,,[
3293	AC_CHECK_LIB(X11,XOpenDisplay,
3294		[CF_ADD_LIB(X11)],,
3295		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3296
3297	AC_CHECK_FUNC(XtAppInitialize,,[
3298	AC_CHECK_LIB(Xt, XtAppInitialize,
3299		[AC_DEFINE(HAVE_LIBXT)
3300		 cf_have_X_LIBS=Xt
3301		 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
3302		[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3303])
3304
3305if test $cf_have_X_LIBS = no ; then
3306	AC_MSG_WARN(
3307[Unable to successfully link X Toolkit library (-lXt) with
3308test program.  You will have to check and add the proper libraries by hand
3309to makefile.])
3310fi
3311])dnl
3312