1 dnl $Id: aclocal.m4,v 1.21 2012/01/03 09:37:14 tom Exp $
2 dnl autoconf macros for 'diffstat'
4 dnl Copyright 2003-2010,2012 Thomas E. Dickey
7 dnl http://invisible-island.net/autoconf/
9 dnl ---------------------------------------------------------------------------
10 dnl ---------------------------------------------------------------------------
11 dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
13 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
14 dnl The second parameter if given makes this macro verbose.
16 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
17 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
18 dnl confused by the quotes (which require backslashes to keep them usable).
19 AC_DEFUN([CF_ADD_CFLAGS],
24 cf_new_extra_cppflags=
26 for cf_add_cflags in $1
28 case $cf_fix_cppflags in
30 case $cf_add_cflags in #(vi
31 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
32 case $cf_add_cflags in
34 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
36 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
37 && test -z "${cf_tst_cflags}" \
38 && cf_fix_cppflags=yes
40 if test $cf_fix_cppflags = yes ; then
41 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
43 elif test "${cf_tst_cflags}" = "\"'" ; then
44 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
53 case $cf_add_cflags in #(vi
55 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
56 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
59 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
64 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
69 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
71 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
73 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
74 && test -z "${cf_tst_cflags}" \
80 if test -n "$cf_new_cflags" ; then
81 ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
82 CFLAGS="$CFLAGS $cf_new_cflags"
85 if test -n "$cf_new_cppflags" ; then
86 ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
87 CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
90 if test -n "$cf_new_extra_cppflags" ; then
91 ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
92 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
95 AC_SUBST(EXTRA_CPPFLAGS)
98 dnl ---------------------------------------------------------------------------
99 dnl CF_ANSI_CC_CHECK version: 11 updated: 2011/07/01 19:47:45
101 dnl This was originally adapted from the macros 'fp_PROG_CC_STDC' and
102 dnl 'fp_C_PROTOTYPES' in the sharutils 4.2 distribution.
103 AC_DEFUN([CF_ANSI_CC_CHECK],
105 # This should have been defined by AC_PROG_CC
108 # Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
109 # into CC. This will not help with broken scripts that wrap the compiler with
110 # options, but eliminates a more common category of user confusion.
111 AC_MSG_CHECKING(\$CC variable)
114 AC_MSG_RESULT(broken)
115 AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
117 cf_flags=`echo "$CC" | sed -e 's/^[[^ ]]*[[ ]]//'`
118 CC=`echo "$CC" | sed -e 's/[[ ]].*//'`
119 CF_ADD_CFLAGS($cf_flags)
126 AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
128 cf_save_CFLAGS="$CFLAGS"
129 cf_save_CPPFLAGS="$CPPFLAGS"
130 # Don't try gcc -ansi; that turns off useful extensions and
131 # breaks some systems' header files.
133 # Ultrix and OSF/1 -std1
134 # HP-UX -Aa -D_HPUX_SOURCE
136 # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
137 for cf_arg in "-DCC_HAS_PROTOS" \
142 "-Aa -D_HPUX_SOURCE" \
145 CF_ADD_CFLAGS($cf_arg)
148 #ifndef CC_HAS_PROTOS
149 #if !defined(__STDC__) || (__STDC__ != 1)
154 int test (int i, double x);
155 struct s1 {int (*f) (int a);};
156 struct s2 {int (*f) (double a);};],
157 [cf_cv_ansi_cc="$cf_arg"; break])
159 CFLAGS="$cf_save_CFLAGS"
160 CPPFLAGS="$cf_save_CPPFLAGS"
163 if test "$cf_cv_ansi_cc" != "no"; then
164 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
165 CF_ADD_CFLAGS($cf_cv_ansi_cc)
167 AC_DEFINE(CC_HAS_PROTOS)
171 dnl ---------------------------------------------------------------------------
172 dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
174 dnl For programs that must use an ANSI compiler, obtain compiler options that
175 dnl will make it recognize prototypes. We'll do preprocessor checks in other
176 dnl macros, since tools such as unproto can fake prototypes, but only part of
177 dnl the preprocessor.
178 AC_DEFUN([CF_ANSI_CC_REQD],
179 [AC_REQUIRE([CF_ANSI_CC_CHECK])
180 if test "$cf_cv_ansi_cc" = "no"; then
182 [Your compiler does not appear to recognize prototypes.
183 You have the following choices:
184 a. adjust your compiler options
185 b. get an up-to-date compiler
186 c. use a wrapper such as unproto])
189 dnl ---------------------------------------------------------------------------
190 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
192 dnl Allow user to disable a normally-on option.
193 AC_DEFUN([CF_ARG_DISABLE],
194 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
195 dnl ---------------------------------------------------------------------------
196 dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
198 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
204 dnl $3 = action to perform if option is not default
205 dnl $4 = action if perform if option is default
206 dnl $5 = default option value (either 'yes' or 'no')
207 AC_DEFUN([CF_ARG_OPTION],
208 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
209 if test "$enableval" != "$5" ; then
211 ,[ $3]) ifelse([$4],,,[
214 fi],[enableval=$5 ifelse([$4],,,[
218 dnl ---------------------------------------------------------------------------
219 dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
221 dnl Check if we're accidentally using a cache from a different machine.
222 dnl Derive the system name, as a check for reusing the autoconf cache.
224 dnl If we've packaged config.guess and config.sub, run that (since it does a
225 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
226 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
227 dnl which is useful in cross-compiles.
229 dnl Note: we would use $ac_config_sub, but that is one of the places where
230 dnl autoconf 2.5x broke compatibility with autoconf 2.13
231 AC_DEFUN([CF_CHECK_CACHE],
233 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
234 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
235 system_name="$host_os"
237 system_name="`(uname -s -r) 2>/dev/null`"
238 if test -z "$system_name" ; then
239 system_name="`(hostname) 2>/dev/null`"
242 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
243 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
245 test -z "$system_name" && system_name="$cf_cv_system_name"
246 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
248 if test ".$system_name" != ".$cf_cv_system_name" ; then
249 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
250 AC_MSG_ERROR("Please remove config.cache and try again.")
253 dnl ---------------------------------------------------------------------------
254 dnl CF_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57
256 dnl You can always use "make -n" to see the actual options, but it's hard to
257 dnl pick out/analyze warning messages when the compile-line is long.
260 dnl ECHO_LT - symbol to control if libtool is verbose
261 dnl ECHO_LD - symbol to prefix "cc -o" lines
262 dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
263 dnl SHOW_CC - symbol to put before explicit "cc -c" lines
264 dnl ECHO_CC - symbol to put before any "cc" line
266 AC_DEFUN([CF_DISABLE_ECHO],[
267 AC_MSG_CHECKING(if you want to see long compiling messages)
269 [ --disable-echo display "compiling" commands],
272 ECHO_LD='@echo linking [$]@;'
273 RULE_CC='@echo compiling [$]<'
274 SHOW_CC='@echo compiling [$]@'
283 AC_MSG_RESULT($enableval)
290 dnl ---------------------------------------------------------------------------
291 dnl CF_DISABLE_LEAKS version: 6 updated: 2010/07/23 04:14:32
293 dnl Combine no-leak checks with the libraries or tools that are used for the
295 AC_DEFUN([CF_DISABLE_LEAKS],[
297 AC_REQUIRE([CF_WITH_DMALLOC])
298 AC_REQUIRE([CF_WITH_DBMALLOC])
299 AC_REQUIRE([CF_WITH_VALGRIND])
301 AC_MSG_CHECKING(if you want to perform memory-leak testing)
303 [ --disable-leaks test: free permanent memory, analyze leaks],
304 [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
305 : ${with_no_leaks:=no})
306 AC_MSG_RESULT($with_no_leaks)
308 if test "$with_no_leaks" = yes ; then
310 AC_DEFINE(YY_NO_LEAKS)
313 dnl ---------------------------------------------------------------------------
314 dnl CF_GCC_ATTRIBUTES version: 14 updated: 2010/10/23 15:52:32
315 dnl -----------------
316 dnl Test for availability of useful gcc __attribute__ directives to quiet
317 dnl compiler warnings. Though useful, not all are supported -- and contrary
318 dnl to documentation, unrecognized directives cause older compilers to barf.
319 AC_DEFUN([CF_GCC_ATTRIBUTES],
323 cat > conftest.i <<EOF
331 #define GCC_NORETURN /* nothing */
334 #define GCC_UNUSED /* nothing */
339 AC_CHECKING([for $CC __attribute__ directives])
340 cat > conftest.$ac_ext <<EOF
341 #line __oline__ "${as_me:-configure}"
342 #include "confdefs.h"
343 #include "conftest.h"
344 #include "conftest.i"
346 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
348 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
351 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
353 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
355 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
356 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
357 extern void foo(void) GCC_NORETURN;
358 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
360 cf_printf_attribute=no
361 cf_scanf_attribute=no
362 for cf_attribute in scanf printf unused noreturn
364 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
365 cf_directive="__attribute__(($cf_attribute))"
366 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
368 case $cf_attribute in #(vi
370 cf_printf_attribute=yes
371 cat >conftest.h <<EOF
372 #define GCC_$cf_ATTRIBUTE 1
376 cf_scanf_attribute=yes
377 cat >conftest.h <<EOF
378 #define GCC_$cf_ATTRIBUTE 1
382 cat >conftest.h <<EOF
383 #define GCC_$cf_ATTRIBUTE $cf_directive
388 if AC_TRY_EVAL(ac_compile); then
389 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
390 cat conftest.h >>confdefs.h
391 case $cf_attribute in #(vi
393 if test "$cf_printf_attribute" = no ; then
394 cat >>confdefs.h <<EOF
395 #define GCC_PRINTFLIKE(fmt,var) /* nothing */
398 cat >>confdefs.h <<EOF
399 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
404 if test "$cf_scanf_attribute" = no ; then
405 cat >>confdefs.h <<EOF
406 #define GCC_SCANFLIKE(fmt,var) /* nothing */
409 cat >>confdefs.h <<EOF
410 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
418 fgrep define conftest.i >>confdefs.h
423 dnl ---------------------------------------------------------------------------
424 dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
426 dnl Find version of gcc
427 AC_DEFUN([CF_GCC_VERSION],[
428 AC_REQUIRE([AC_PROG_CC])
430 if test "$GCC" = yes ; then
431 AC_MSG_CHECKING(version of $CC)
432 GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
433 test -z "$GCC_VERSION" && GCC_VERSION=unknown
434 AC_MSG_RESULT($GCC_VERSION)
437 dnl ---------------------------------------------------------------------------
438 dnl CF_GCC_WARNINGS version: 27 updated: 2010/10/23 15:52:32
440 dnl Check if the compiler supports useful warning options. There's a few that
441 dnl we don't use, simply because they're too noisy:
443 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
444 dnl -Wredundant-decls (system headers make this too noisy)
445 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
446 dnl -Wwrite-strings (too noisy, but should review occasionally). This
447 dnl is enabled for ncurses using "--enable-const".
451 dnl $1 is an optional list of gcc warning flags that a particular
452 dnl application might want to use, e.g., "no-unused" for
455 dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
457 AC_DEFUN([CF_GCC_WARNINGS],
459 AC_REQUIRE([CF_GCC_VERSION])
460 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
462 cat > conftest.$ac_ext <<EOF
463 #line __oline__ "${as_me:-configure}"
464 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
467 if test "$INTEL_COMPILER" = yes
469 # The "-wdXXX" options suppress warnings:
470 # remark #1419: external declaration in primary source file
471 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
472 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
473 # remark #193: zero used for undefined preprocessing identifier
474 # remark #593: variable "curs_sb_left_arrow" was set but never used
475 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
476 # remark #869: parameter "tw" was never referenced
477 # remark #981: operands are evaluated in unspecified order
478 # warning #279: controlling expression is constant
480 AC_CHECKING([for $CC warning options])
481 cf_save_CFLAGS="$CFLAGS"
494 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
495 if AC_TRY_EVAL(ac_compile); then
496 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
497 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
500 CFLAGS="$cf_save_CFLAGS"
502 elif test "$GCC" = yes
504 AC_CHECKING([for $CC warning options])
505 cf_save_CFLAGS="$CFLAGS"
508 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
509 for cf_opt in W Wall \
514 Wmissing-declarations \
515 Wmissing-prototypes \
520 Wundef $cf_warn_CONST $1
522 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
523 if AC_TRY_EVAL(ac_compile); then
524 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
527 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
532 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
537 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
540 CFLAGS="$cf_save_CFLAGS"
544 AC_SUBST(EXTRA_CFLAGS)
546 dnl ---------------------------------------------------------------------------
547 dnl CF_GETOPT_HEADER version: 4 updated: 2009/08/31 20:07:52
549 dnl Check for getopt's variables which are commonly defined in stdlib.h,
550 dnl unistd.h or (nonstandard) in getopt.h
551 AC_DEFUN([CF_GETOPT_HEADER],
553 AC_HAVE_HEADERS(unistd.h getopt.h)
554 AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
555 cf_cv_getopt_header=none
556 for cf_header in stdio.h stdlib.h unistd.h getopt.h
559 #include <$cf_header>],
560 [int x = optind; char *y = optarg],
561 [cf_cv_getopt_header=$cf_header
565 if test $cf_cv_getopt_header != none ; then
566 AC_DEFINE(HAVE_GETOPT_HEADER)
569 dnl ---------------------------------------------------------------------------
570 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
572 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
573 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
574 dnl (or misfeature) of glibc2, which breaks portability of many applications,
575 dnl since it is interwoven with GNU extensions.
577 dnl Well, yes we could work around it...
578 AC_DEFUN([CF_GNU_SOURCE],
580 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
581 AC_TRY_COMPILE([#include <sys/types.h>],[
582 #ifndef _XOPEN_SOURCE
585 [cf_cv_gnu_source=no],
587 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
588 AC_TRY_COMPILE([#include <sys/types.h>],[
592 [cf_cv_gnu_source=no],
593 [cf_cv_gnu_source=yes])
597 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
599 dnl ---------------------------------------------------------------------------
600 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
602 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
603 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
604 dnl (or misfeature) of glibc2, which breaks portability of many applications,
605 dnl since it is interwoven with GNU extensions.
607 dnl Well, yes we could work around it...
608 AC_DEFUN([CF_GNU_SOURCE],
610 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
611 AC_TRY_COMPILE([#include <sys/types.h>],[
612 #ifndef _XOPEN_SOURCE
615 [cf_cv_gnu_source=no],
617 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
618 AC_TRY_COMPILE([#include <sys/types.h>],[
622 [cf_cv_gnu_source=no],
623 [cf_cv_gnu_source=yes])
627 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
629 dnl ---------------------------------------------------------------------------
630 dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
631 dnl -----------------
632 dnl Check if the given compiler is really the Intel compiler for Linux. It
633 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
634 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
636 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
637 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
638 dnl the wrappers for gcc and g++ warnings.
640 dnl $1 = GCC (default) or GXX
641 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
642 dnl $3 = CFLAGS (default) or CXXFLAGS
643 AC_DEFUN([CF_INTEL_COMPILER],[
644 ifelse([$2],,INTEL_COMPILER,[$2])=no
646 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
649 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
650 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
651 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
653 #ifdef __INTEL_COMPILER
657 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
658 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
660 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
661 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
666 dnl ---------------------------------------------------------------------------
667 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
669 dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have
670 dnl a monocase filesystem.
671 AC_DEFUN([CF_MAKE_TAGS],[
672 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
674 AC_CHECK_PROGS(CTAGS, exctags ctags)
675 AC_CHECK_PROGS(ETAGS, exetags etags)
677 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
679 if test "$cf_cv_mixedcase" = yes ; then
680 AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
685 if test "$MAKE_UPPER_TAGS" = yes ; then
691 if test "$MAKE_LOWER_TAGS" = yes ; then
700 AC_SUBST(MAKE_UPPER_TAGS)
701 AC_SUBST(MAKE_LOWER_TAGS)
703 dnl ---------------------------------------------------------------------------
704 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
705 dnl ----------------------
706 dnl Check if the file-system supports mixed-case filenames. If we're able to
707 dnl create a lowercase name and see it as uppercase, it doesn't support that.
708 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
710 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
711 if test "$cross_compiling" = yes ; then
712 case $target_alias in #(vi
713 *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
721 rm -f conftest CONFTEST
723 if test -f CONFTEST ; then
728 rm -f conftest CONFTEST
731 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
733 dnl ---------------------------------------------------------------------------
734 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
736 dnl Write a debug message to config.log, along with the line number in the
737 dnl configure script.
738 AC_DEFUN([CF_MSG_LOG],[
739 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
741 dnl ---------------------------------------------------------------------------
742 dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
743 dnl ------------------
744 dnl see CF_WITH_NO_LEAKS
745 AC_DEFUN([CF_NO_LEAKS_OPTION],[
746 AC_MSG_CHECKING(if you want to use $1 for testing)
749 [AC_DEFINE($3)ifelse([$4],,[
753 : ${with_no_leaks:=yes}
756 AC_MSG_RESULT(${with_$1:-no})
758 case .$with_cflags in #(vi
760 case .$CFLAGS in #(vi
770 dnl ---------------------------------------------------------------------------
771 dnl CF_PATHSEP version: 5 updated: 2010/05/26 05:38:42
773 dnl Provide a value for the $PATH and similar separator
774 AC_DEFUN([CF_PATHSEP],
776 case $cf_cv_system_name in
777 os2*) PATH_SEPARATOR=';' ;;
778 *) PATH_SEPARATOR=':' ;;
780 ifelse([$1],,,[$1=$PATH_SEPARATOR])
781 AC_SUBST(PATH_SEPARATOR)
783 dnl ---------------------------------------------------------------------------
784 dnl CF_PATH_PROG version: 8 updated: 2010/10/23 16:12:25
786 dnl Check for a given program, defining corresponding symbol.
787 dnl $1 = environment variable, which is suffixed by "_PATH" in the #define.
788 dnl $2 = program name to find.
789 dnl $3 = optional list of additional program names to test.
791 dnl If there is more than one token in the result, #define the remaining tokens
792 dnl to $1_ARGS. We need this for 'install' in particular.
794 dnl FIXME: we should allow this to be overridden by environment variables
796 AC_DEFUN([CF_PATH_PROG],[
797 AC_REQUIRE([CF_PATHSEP])
798 test -z "[$]$1" && $1=$2
799 AC_PATH_PROGS($1,[$]$1 $2 $3,[$]$1)
803 IFS="${IFS:- }"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
804 for cf_temp in $ac_cv_path_$1
806 if test -z "$cf_path_prog" ; then
807 if test "$with_full_paths" = yes ; then
808 CF_PATH_SYNTAX(cf_temp,break)
809 cf_path_prog="$cf_temp"
811 cf_path_prog="`basename $cf_temp`"
813 elif test -z "$cf_path_args" ; then
814 cf_path_args="$cf_temp"
816 cf_path_args="$cf_path_args $cf_temp"
821 if test -n "$cf_path_prog" ; then
822 CF_MSG_LOG(defining path for ${cf_path_prog})
823 AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog")
824 test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args")
827 dnl ---------------------------------------------------------------------------
828 dnl CF_PATH_SYNTAX version: 13 updated: 2010/05/26 05:38:42
830 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
831 dnl begins with one of the prefix/exec_prefix variables, and then again if the
832 dnl result begins with 'NONE'. This is necessary to work around autoconf's
833 dnl delayed evaluation of those symbols.
834 AC_DEFUN([CF_PATH_SYNTAX],[
835 if test "x$prefix" != xNONE; then
836 cf_path_syntax="$prefix"
838 cf_path_syntax="$ac_default_prefix"
841 case ".[$]$1" in #(vi
842 .\[$]\(*\)*|.\'*\'*) #(vi
846 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
848 .\[$]{*prefix}*) #(vi
850 case ".[$]$1" in #(vi
852 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
857 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
860 ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
864 dnl ---------------------------------------------------------------------------
865 dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
866 dnl -----------------
867 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
869 dnl POSIX.1-1990 _POSIX_SOURCE
870 dnl POSIX.1-1990 and _POSIX_SOURCE and
871 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
873 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
874 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
875 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
878 dnl $1 is the nominal value for _POSIX_C_SOURCE
879 AC_DEFUN([CF_POSIX_C_SOURCE],
881 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
883 cf_save_CFLAGS="$CFLAGS"
884 cf_save_CPPFLAGS="$CPPFLAGS"
886 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
887 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
889 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
890 CF_MSG_LOG(if the symbol is already defined go no further)
891 AC_TRY_COMPILE([#include <sys/types.h>],[
892 #ifndef _POSIX_C_SOURCE
895 [cf_cv_posix_c_source=no],
896 [cf_want_posix_source=no
897 case .$cf_POSIX_C_SOURCE in #(vi
899 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
902 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
903 cf_want_posix_source=yes
906 cf_want_posix_source=yes
909 if test "$cf_want_posix_source" = yes ; then
910 AC_TRY_COMPILE([#include <sys/types.h>],[
914 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
916 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
917 CFLAGS="$cf_trim_CFLAGS"
918 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
919 CF_MSG_LOG(if the second compile does not leave our definition intact error)
920 AC_TRY_COMPILE([#include <sys/types.h>],[
921 #ifndef _POSIX_C_SOURCE
924 [cf_cv_posix_c_source=no])
925 CFLAGS="$cf_save_CFLAGS"
926 CPPFLAGS="$cf_save_CPPFLAGS"
930 if test "$cf_cv_posix_c_source" != no ; then
931 CFLAGS="$cf_trim_CFLAGS"
932 CPPFLAGS="$cf_trim_CPPFLAGS"
933 CF_ADD_CFLAGS($cf_cv_posix_c_source)
937 dnl ---------------------------------------------------------------------------
938 dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
940 dnl Check if C (preprocessor) -U and -D options are processed in the order
941 dnl given rather than by type of option. Some compilers insist on apply all
942 dnl of the -U options after all of the -D options. Others allow mixing them,
943 dnl and may predefine symbols that conflict with those we define.
944 AC_DEFUN([CF_PROG_CC_U_D],
946 AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
947 cf_save_CPPFLAGS="$CPPFLAGS"
948 CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
951 make an undefined-error
957 cf_cv_cc_u_d_options=yes],[
958 cf_cv_cc_u_d_options=no])
959 CPPFLAGS="$cf_save_CPPFLAGS"
962 dnl ---------------------------------------------------------------------------
963 dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
965 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
966 AC_DEFUN([CF_PROG_EXT],
968 AC_REQUIRE([CF_CHECK_CACHE])
969 case $cf_cv_system_name in
971 CFLAGS="$CFLAGS -Zmt"
972 CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
973 CXXFLAGS="$CXXFLAGS -Zmt"
974 # autoconf's macro sets -Zexe and suffix both, which conflict:w
975 LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
985 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
987 dnl ---------------------------------------------------------------------------
988 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
990 AC_DEFUN([CF_PROG_LINT],
992 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
995 dnl ---------------------------------------------------------------------------
996 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
998 dnl Remove all -U and -D options that refer to the given symbol from a list
999 dnl of C compiler options. This works around the problem that not all
1000 dnl compilers process -U and -D options from left-to-right, so a -U option
1001 dnl cannot be used to cancel the effect of a preceding -D option.
1003 dnl $1 = target (which could be the same as the source variable)
1004 dnl $2 = source (including '$')
1005 dnl $3 = symbol to remove
1006 define([CF_REMOVE_DEFINE],
1009 sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \
1010 -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'`
1012 dnl ---------------------------------------------------------------------------
1013 dnl CF_STDIO_UNLOCKED version: 3 updated: 2009/10/06 19:54:39
1014 dnl -----------------
1015 dnl The four functions getc_unlocked(), getchar_unlocked(), putc_unlocked(),
1016 dnl putchar_unlocked() are in POSIX.1-2001.
1018 dnl Test for one or more of the "unlocked" stdio getc/putc functions, and (if
1019 dnl the system requires it to declare the prototype) define _REENTRANT
1021 dnl $1 = one or more stdio functions to check for existence and prototype.
1022 AC_DEFUN([CF_STDIO_UNLOCKED],
1024 cf_stdio_unlocked=no
1025 AC_CHECK_FUNCS(ifelse([$1],,[getc_unlocked putc_unlocked],[$1]),
1026 [cf_stdio_unlocked=$ac_func])
1027 if test "$cf_stdio_unlocked" != no ; then
1028 case "$CPPFLAGS" in #(vi
1029 *-D_REENTRANT*) #(vi
1032 AC_CACHE_CHECK(if we should define _REENTRANT,cf_cv_stdio_unlocked,[
1033 AC_TRY_COMPILE([#include <stdio.h>],[
1034 extern void *$cf_stdio_unlocked(void *);
1035 void *dummy = $cf_stdio_unlocked(0)],
1036 [cf_cv_stdio_unlocked=yes],
1037 [cf_cv_stdio_unlocked=no])])
1038 if test "$cf_cv_stdio_unlocked" = yes ; then
1039 AC_DEFINE(_REENTRANT)
1045 dnl ---------------------------------------------------------------------------
1046 dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
1047 dnl -------------------
1048 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
1049 dnl can define it successfully.
1050 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
1051 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1055 #include <sys/types.h>
1057 #ifndef _XOPEN_SOURCE
1060 [cf_cv_xopen_source=no],
1061 [cf_save="$CPPFLAGS"
1062 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1066 #include <sys/types.h>
1068 #ifdef _XOPEN_SOURCE
1071 [cf_cv_xopen_source=no],
1072 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1077 if test "$cf_cv_xopen_source" != no ; then
1078 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1079 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1080 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
1081 CF_ADD_CFLAGS($cf_temp_xopen_source)
1084 dnl ---------------------------------------------------------------------------
1085 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1087 dnl Make an uppercase version of a variable
1088 dnl $1=uppercase($2)
1089 AC_DEFUN([CF_UPPER],
1091 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1093 dnl ---------------------------------------------------------------------------
1094 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
1096 dnl Use AC_VERBOSE w/o the warnings
1097 AC_DEFUN([CF_VERBOSE],
1098 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
1101 dnl ---------------------------------------------------------------------------
1102 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
1103 dnl ----------------
1104 dnl Configure-option for dbmalloc. The optional parameter is used to override
1105 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1106 AC_DEFUN([CF_WITH_DBMALLOC],[
1107 CF_NO_LEAKS_OPTION(dbmalloc,
1108 [ --with-dbmalloc test: use Conor Cahill's dbmalloc library],
1111 if test "$with_dbmalloc" = yes ; then
1112 AC_CHECK_HEADER(dbmalloc.h,
1113 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
1116 dnl ---------------------------------------------------------------------------
1117 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
1119 dnl Configure-option for dmalloc. The optional parameter is used to override
1120 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1121 AC_DEFUN([CF_WITH_DMALLOC],[
1122 CF_NO_LEAKS_OPTION(dmalloc,
1123 [ --with-dmalloc test: use Gray Watson's dmalloc library],
1126 if test "$with_dmalloc" = yes ; then
1127 AC_CHECK_HEADER(dmalloc.h,
1128 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
1131 dnl ---------------------------------------------------------------------------
1132 dnl CF_WITH_INSTALL_PREFIX version: 4 updated: 2010/10/23 15:52:32
1133 dnl ----------------------
1134 dnl Configure-script option to give a default value for the poorly-chosen name
1136 AC_DEFUN([CF_WITH_INSTALL_PREFIX],
1138 AC_MSG_CHECKING(for install-prefix)
1139 AC_ARG_WITH(install-prefix,
1140 [ --with-install-prefix=XXX sets DESTDIR, useful for packaging],
1141 [cf_opt_with_install_prefix=$withval],
1142 [cf_opt_with_install_prefix=${DESTDIR:-no}])
1143 AC_MSG_RESULT($cf_opt_with_install_prefix)
1144 if test "$cf_opt_with_install_prefix" != no ; then
1145 CF_PATH_SYNTAX(cf_opt_with_install_prefix)
1146 DESTDIR=$cf_opt_with_install_prefix
1150 dnl ---------------------------------------------------------------------------
1151 dnl CF_WITH_PURIFY version: 2 updated: 2006/12/14 18:43:43
1153 AC_DEFUN([CF_WITH_PURIFY],[
1154 CF_NO_LEAKS_OPTION(purify,
1155 [ --with-purify test: use Purify],
1157 [LINK_PREFIX="$LINK_PREFIX purify"])
1158 AC_SUBST(LINK_PREFIX)
1160 dnl ---------------------------------------------------------------------------
1161 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
1162 dnl ----------------
1163 AC_DEFUN([CF_WITH_VALGRIND],[
1164 CF_NO_LEAKS_OPTION(valgrind,
1165 [ --with-valgrind test: use valgrind],
1168 dnl ---------------------------------------------------------------------------
1169 dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
1170 dnl ----------------
1171 dnl Combine the checks for gcc features into a configure-script option
1174 dnl $1 - see CF_GCC_WARNINGS
1175 AC_DEFUN([CF_WITH_WARNINGS],
1177 if ( test "$GCC" = yes || test "$GXX" = yes )
1179 AC_MSG_CHECKING(if you want to check for gcc warnings)
1180 AC_ARG_WITH(warnings,
1181 [ --with-warnings test: turn on gcc warnings],
1182 [cf_opt_with_warnings=$withval],
1183 [cf_opt_with_warnings=no])
1184 AC_MSG_RESULT($cf_opt_with_warnings)
1185 if test "$cf_opt_with_warnings" != no ; then
1187 CF_GCC_WARNINGS([$1])
1191 dnl ---------------------------------------------------------------------------
1192 dnl CF_XOPEN_SOURCE version: 41 updated: 2011/12/10 18:58:47
1194 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1195 dnl or adapt to the vendor's definitions to get equivalent functionality,
1196 dnl without losing the common non-POSIX features.
1199 dnl $1 is the nominal value for _XOPEN_SOURCE
1200 dnl $2 is the nominal value for _POSIX_C_SOURCE
1201 AC_DEFUN([CF_XOPEN_SOURCE],[
1203 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
1204 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
1207 case $host_os in #(vi
1209 cf_xopen_source="-D_ALL_SOURCE"
1214 darwin[[0-8]].*) #(vi
1215 cf_xopen_source="-D_APPLE_C_SOURCE"
1218 cf_xopen_source="-D_DARWIN_C_SOURCE"
1220 freebsd*|dragonfly*) #(vi
1221 # 5.x headers associate
1222 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1223 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1224 cf_POSIX_C_SOURCE=200112L
1226 cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1229 cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
1232 cf_xopen_source="-D_HPUX_SOURCE"
1235 cf_xopen_source="-D_SGI_SOURCE"
1238 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
1242 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
1244 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1247 cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1249 openbsd[[4-9]]*) #(vi
1250 # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
1254 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1257 cf_xopen_source="-D_OSF_SOURCE"
1260 cf_xopen_source="-D_QNX_SOURCE"
1263 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1266 cf_xopen_source="-D__EXTENSIONS__"
1270 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1274 if test -n "$cf_xopen_source" ; then
1275 CF_ADD_CFLAGS($cf_xopen_source)
1278 dnl In anything but the default case, we may have system-specific setting
1279 dnl which is still not guaranteed to provide all of the entrypoints that
1280 dnl _XOPEN_SOURCE would yield.
1281 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
1282 AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
1283 AC_TRY_COMPILE([#include <stdlib.h>],[
1284 #ifndef _XOPEN_SOURCE
1287 [cf_XOPEN_SOURCE_set=yes],
1288 [cf_XOPEN_SOURCE_set=no])
1289 AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
1290 if test $cf_XOPEN_SOURCE_set = yes
1292 AC_TRY_COMPILE([#include <stdlib.h>],[
1293 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
1296 [cf_XOPEN_SOURCE_set_ok=yes],
1297 [cf_XOPEN_SOURCE_set_ok=no])
1298 if test $cf_XOPEN_SOURCE_set_ok = no
1300 AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)