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