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