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