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