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