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