1 dnl Id: aclocal.m4,v 1.18 2011/09/05 23:45:06 tom Exp
2 dnl Macros for byacc configure script (Thomas E. Dickey)
3 dnl ---------------------------------------------------------------------------
4 dnl Copyright 2004-2009,2010 Thomas E. Dickey
6 dnl Permission is hereby granted, free of charge, to any person obtaining a
7 dnl copy of this software and associated documentation files (the
8 dnl "Software"), to deal in the Software without restriction, including
9 dnl without limitation the rights to use, copy, modify, merge, publish,
10 dnl distribute, distribute with modifications, sublicense, and/or sell
11 dnl copies of the Software, and to permit persons to whom the Software is
12 dnl furnished to do so, subject to the following conditions:
14 dnl The above copyright notice and this permission notice shall be included
15 dnl in all copies or portions of the Software.
17 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
23 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 dnl Except as contained in this notice, the name(s) of the above copyright
26 dnl holders shall not be used in advertising or otherwise to promote the
27 dnl sale, use or other dealings in this Software without prior written
29 dnl ---------------------------------------------------------------------------
30 dnl ---------------------------------------------------------------------------
31 dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
33 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
34 dnl The second parameter if given makes this macro verbose.
36 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
37 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
38 dnl confused by the quotes (which require backslashes to keep them usable).
39 AC_DEFUN([CF_ADD_CFLAGS],
44 cf_new_extra_cppflags=
46 for cf_add_cflags in $1
48 case $cf_fix_cppflags in
50 case $cf_add_cflags in #(vi
51 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
52 case $cf_add_cflags in
54 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
56 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
57 && test -z "${cf_tst_cflags}" \
58 && cf_fix_cppflags=yes
60 if test $cf_fix_cppflags = yes ; then
61 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
63 elif test "${cf_tst_cflags}" = "\"'" ; then
64 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
73 case $cf_add_cflags in #(vi
75 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
76 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
79 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
84 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
89 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
91 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
93 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
94 && test -z "${cf_tst_cflags}" \
100 if test -n "$cf_new_cflags" ; then
101 ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
102 CFLAGS="$CFLAGS $cf_new_cflags"
105 if test -n "$cf_new_cppflags" ; then
106 ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
107 CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
110 if test -n "$cf_new_extra_cppflags" ; then
111 ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
112 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
115 AC_SUBST(EXTRA_CPPFLAGS)
118 dnl ---------------------------------------------------------------------------
119 dnl CF_ANSI_CC_CHECK version: 11 updated: 2011/07/01 19:47:45
121 dnl This was originally adapted from the macros 'fp_PROG_CC_STDC' and
122 dnl 'fp_C_PROTOTYPES' in the sharutils 4.2 distribution.
123 AC_DEFUN([CF_ANSI_CC_CHECK],
125 # This should have been defined by AC_PROG_CC
128 # Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
129 # into CC. This will not help with broken scripts that wrap the compiler with
130 # options, but eliminates a more common category of user confusion.
131 AC_MSG_CHECKING(\$CC variable)
134 AC_MSG_RESULT(broken)
135 AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
137 cf_flags=`echo "$CC" | sed -e 's/^[[^ ]]*[[ ]]//'`
138 CC=`echo "$CC" | sed -e 's/[[ ]].*//'`
139 CF_ADD_CFLAGS($cf_flags)
146 AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
148 cf_save_CFLAGS="$CFLAGS"
149 cf_save_CPPFLAGS="$CPPFLAGS"
150 # Don't try gcc -ansi; that turns off useful extensions and
151 # breaks some systems' header files.
153 # Ultrix and OSF/1 -std1
154 # HP-UX -Aa -D_HPUX_SOURCE
156 # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
157 for cf_arg in "-DCC_HAS_PROTOS" \
162 "-Aa -D_HPUX_SOURCE" \
165 CF_ADD_CFLAGS($cf_arg)
168 #ifndef CC_HAS_PROTOS
169 #if !defined(__STDC__) || (__STDC__ != 1)
174 int test (int i, double x);
175 struct s1 {int (*f) (int a);};
176 struct s2 {int (*f) (double a);};],
177 [cf_cv_ansi_cc="$cf_arg"; break])
179 CFLAGS="$cf_save_CFLAGS"
180 CPPFLAGS="$cf_save_CPPFLAGS"
183 if test "$cf_cv_ansi_cc" != "no"; then
184 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
185 CF_ADD_CFLAGS($cf_cv_ansi_cc)
187 AC_DEFINE(CC_HAS_PROTOS)
191 dnl ---------------------------------------------------------------------------
192 dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
194 dnl For programs that must use an ANSI compiler, obtain compiler options that
195 dnl will make it recognize prototypes. We'll do preprocessor checks in other
196 dnl macros, since tools such as unproto can fake prototypes, but only part of
197 dnl the preprocessor.
198 AC_DEFUN([CF_ANSI_CC_REQD],
199 [AC_REQUIRE([CF_ANSI_CC_CHECK])
200 if test "$cf_cv_ansi_cc" = "no"; then
202 [Your compiler does not appear to recognize prototypes.
203 You have the following choices:
204 a. adjust your compiler options
205 b. get an up-to-date compiler
206 c. use a wrapper such as unproto])
209 dnl ---------------------------------------------------------------------------
210 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
212 dnl Allow user to disable a normally-on option.
213 AC_DEFUN([CF_ARG_DISABLE],
214 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
215 dnl ---------------------------------------------------------------------------
216 dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
218 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
224 dnl $3 = action to perform if option is not default
225 dnl $4 = action if perform if option is default
226 dnl $5 = default option value (either 'yes' or 'no')
227 AC_DEFUN([CF_ARG_OPTION],
228 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
229 if test "$enableval" != "$5" ; then
231 ,[ $3]) ifelse([$4],,,[
234 fi],[enableval=$5 ifelse([$4],,,[
238 dnl ---------------------------------------------------------------------------
239 dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
241 dnl Check if we're accidentally using a cache from a different machine.
242 dnl Derive the system name, as a check for reusing the autoconf cache.
244 dnl If we've packaged config.guess and config.sub, run that (since it does a
245 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
246 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
247 dnl which is useful in cross-compiles.
249 dnl Note: we would use $ac_config_sub, but that is one of the places where
250 dnl autoconf 2.5x broke compatibility with autoconf 2.13
251 AC_DEFUN([CF_CHECK_CACHE],
253 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
254 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
255 system_name="$host_os"
257 system_name="`(uname -s -r) 2>/dev/null`"
258 if test -z "$system_name" ; then
259 system_name="`(hostname) 2>/dev/null`"
262 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
263 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
265 test -z "$system_name" && system_name="$cf_cv_system_name"
266 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
268 if test ".$system_name" != ".$cf_cv_system_name" ; then
269 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
270 AC_MSG_ERROR("Please remove config.cache and try again.")
273 dnl ---------------------------------------------------------------------------
274 dnl CF_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57
276 dnl You can always use "make -n" to see the actual options, but it's hard to
277 dnl pick out/analyze warning messages when the compile-line is long.
280 dnl ECHO_LT - symbol to control if libtool is verbose
281 dnl ECHO_LD - symbol to prefix "cc -o" lines
282 dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
283 dnl SHOW_CC - symbol to put before explicit "cc -c" lines
284 dnl ECHO_CC - symbol to put before any "cc" line
286 AC_DEFUN([CF_DISABLE_ECHO],[
287 AC_MSG_CHECKING(if you want to see long compiling messages)
289 [ --disable-echo display "compiling" commands],
292 ECHO_LD='@echo linking [$]@;'
293 RULE_CC='@echo compiling [$]<'
294 SHOW_CC='@echo compiling [$]@'
303 AC_MSG_RESULT($enableval)
310 dnl ---------------------------------------------------------------------------
311 dnl CF_DISABLE_LEAKS version: 6 updated: 2010/07/23 04:14:32
313 dnl Combine no-leak checks with the libraries or tools that are used for the
315 AC_DEFUN([CF_DISABLE_LEAKS],[
317 AC_REQUIRE([CF_WITH_DMALLOC])
318 AC_REQUIRE([CF_WITH_DBMALLOC])
319 AC_REQUIRE([CF_WITH_VALGRIND])
321 AC_MSG_CHECKING(if you want to perform memory-leak testing)
323 [ --disable-leaks test: free permanent memory, analyze leaks],
324 [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
325 : ${with_no_leaks:=no})
326 AC_MSG_RESULT($with_no_leaks)
328 if test "$with_no_leaks" = yes ; then
330 AC_DEFINE(YY_NO_LEAKS)
333 dnl ---------------------------------------------------------------------------
334 dnl CF_GCC_ATTRIBUTES version: 14 updated: 2010/10/23 15:52:32
335 dnl -----------------
336 dnl Test for availability of useful gcc __attribute__ directives to quiet
337 dnl compiler warnings. Though useful, not all are supported -- and contrary
338 dnl to documentation, unrecognized directives cause older compilers to barf.
339 AC_DEFUN([CF_GCC_ATTRIBUTES],
343 cat > conftest.i <<EOF
351 #define GCC_NORETURN /* nothing */
354 #define GCC_UNUSED /* nothing */
359 AC_CHECKING([for $CC __attribute__ directives])
360 cat > conftest.$ac_ext <<EOF
361 #line __oline__ "${as_me:-configure}"
362 #include "confdefs.h"
363 #include "conftest.h"
364 #include "conftest.i"
366 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
368 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
371 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
373 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
375 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
376 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
377 extern void foo(void) GCC_NORETURN;
378 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
380 cf_printf_attribute=no
381 cf_scanf_attribute=no
382 for cf_attribute in scanf printf unused noreturn
384 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
385 cf_directive="__attribute__(($cf_attribute))"
386 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
388 case $cf_attribute in #(vi
390 cf_printf_attribute=yes
391 cat >conftest.h <<EOF
392 #define GCC_$cf_ATTRIBUTE 1
396 cf_scanf_attribute=yes
397 cat >conftest.h <<EOF
398 #define GCC_$cf_ATTRIBUTE 1
402 cat >conftest.h <<EOF
403 #define GCC_$cf_ATTRIBUTE $cf_directive
408 if AC_TRY_EVAL(ac_compile); then
409 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
410 cat conftest.h >>confdefs.h
411 case $cf_attribute in #(vi
413 if test "$cf_printf_attribute" = no ; then
414 cat >>confdefs.h <<EOF
415 #define GCC_PRINTFLIKE(fmt,var) /* nothing */
418 cat >>confdefs.h <<EOF
419 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
424 if test "$cf_scanf_attribute" = no ; then
425 cat >>confdefs.h <<EOF
426 #define GCC_SCANFLIKE(fmt,var) /* nothing */
429 cat >>confdefs.h <<EOF
430 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
438 fgrep define conftest.i >>confdefs.h
443 dnl ---------------------------------------------------------------------------
444 dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
446 dnl Find version of gcc
447 AC_DEFUN([CF_GCC_VERSION],[
448 AC_REQUIRE([AC_PROG_CC])
450 if test "$GCC" = yes ; then
451 AC_MSG_CHECKING(version of $CC)
452 GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
453 test -z "$GCC_VERSION" && GCC_VERSION=unknown
454 AC_MSG_RESULT($GCC_VERSION)
457 dnl ---------------------------------------------------------------------------
458 dnl CF_GCC_WARNINGS version: 27 updated: 2010/10/23 15:52:32
460 dnl Check if the compiler supports useful warning options. There's a few that
461 dnl we don't use, simply because they're too noisy:
463 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
464 dnl -Wredundant-decls (system headers make this too noisy)
465 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
466 dnl -Wwrite-strings (too noisy, but should review occasionally). This
467 dnl is enabled for ncurses using "--enable-const".
471 dnl $1 is an optional list of gcc warning flags that a particular
472 dnl application might want to use, e.g., "no-unused" for
475 dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
477 AC_DEFUN([CF_GCC_WARNINGS],
479 AC_REQUIRE([CF_GCC_VERSION])
480 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
482 cat > conftest.$ac_ext <<EOF
483 #line __oline__ "${as_me:-configure}"
484 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
487 if test "$INTEL_COMPILER" = yes
489 # The "-wdXXX" options suppress warnings:
490 # remark #1419: external declaration in primary source file
491 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
492 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
493 # remark #193: zero used for undefined preprocessing identifier
494 # remark #593: variable "curs_sb_left_arrow" was set but never used
495 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
496 # remark #869: parameter "tw" was never referenced
497 # remark #981: operands are evaluated in unspecified order
498 # warning #279: controlling expression is constant
500 AC_CHECKING([for $CC warning options])
501 cf_save_CFLAGS="$CFLAGS"
514 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
515 if AC_TRY_EVAL(ac_compile); then
516 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
517 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
520 CFLAGS="$cf_save_CFLAGS"
522 elif test "$GCC" = yes
524 AC_CHECKING([for $CC warning options])
525 cf_save_CFLAGS="$CFLAGS"
528 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
529 for cf_opt in W Wall \
534 Wmissing-declarations \
535 Wmissing-prototypes \
540 Wundef $cf_warn_CONST $1
542 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
543 if AC_TRY_EVAL(ac_compile); then
544 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
547 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
552 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
557 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
560 CFLAGS="$cf_save_CFLAGS"
564 AC_SUBST(EXTRA_CFLAGS)
566 dnl ---------------------------------------------------------------------------
567 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
569 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
570 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
571 dnl (or misfeature) of glibc2, which breaks portability of many applications,
572 dnl since it is interwoven with GNU extensions.
574 dnl Well, yes we could work around it...
575 AC_DEFUN([CF_GNU_SOURCE],
577 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
578 AC_TRY_COMPILE([#include <sys/types.h>],[
579 #ifndef _XOPEN_SOURCE
582 [cf_cv_gnu_source=no],
584 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
585 AC_TRY_COMPILE([#include <sys/types.h>],[
589 [cf_cv_gnu_source=no],
590 [cf_cv_gnu_source=yes])
594 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
596 dnl ---------------------------------------------------------------------------
597 dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
598 dnl -----------------
599 dnl Check if the given compiler is really the Intel compiler for Linux. It
600 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
601 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
603 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
604 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
605 dnl the wrappers for gcc and g++ warnings.
607 dnl $1 = GCC (default) or GXX
608 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
609 dnl $3 = CFLAGS (default) or CXXFLAGS
610 AC_DEFUN([CF_INTEL_COMPILER],[
611 ifelse([$2],,INTEL_COMPILER,[$2])=no
613 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
616 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
617 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
618 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
620 #ifdef __INTEL_COMPILER
624 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
625 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
627 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
628 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
633 dnl ---------------------------------------------------------------------------
634 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
636 dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have
637 dnl a monocase filesystem.
638 AC_DEFUN([CF_MAKE_TAGS],[
639 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
641 AC_CHECK_PROGS(CTAGS, exctags ctags)
642 AC_CHECK_PROGS(ETAGS, exetags etags)
644 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
646 if test "$cf_cv_mixedcase" = yes ; then
647 AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
652 if test "$MAKE_UPPER_TAGS" = yes ; then
658 if test "$MAKE_LOWER_TAGS" = yes ; then
667 AC_SUBST(MAKE_UPPER_TAGS)
668 AC_SUBST(MAKE_LOWER_TAGS)
670 dnl ---------------------------------------------------------------------------
671 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
672 dnl ----------------------
673 dnl Check if the file-system supports mixed-case filenames. If we're able to
674 dnl create a lowercase name and see it as uppercase, it doesn't support that.
675 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
677 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
678 if test "$cross_compiling" = yes ; then
679 case $target_alias in #(vi
680 *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
688 rm -f conftest CONFTEST
690 if test -f CONFTEST ; then
695 rm -f conftest CONFTEST
698 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
700 dnl ---------------------------------------------------------------------------
701 dnl CF_MKSTEMP version: 7 updated: 2010/08/14 18:25:37
703 dnl Check for a working mkstemp. This creates two files, checks that they are
704 dnl successfully created and distinct (AmigaOS apparently fails on the last).
705 AC_DEFUN([CF_MKSTEMP],[
706 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
709 #include <sys/types.h>
713 #include <sys/stat.h>
716 char *tmpl = "conftestXXXXXX";
724 for (n = 0; n < 2; ++n) {
725 strcpy(name[n], tmpl);
726 if ((fd = mkstemp(name[n])) >= 0) {
727 if (!strcmp(name[n], tmpl)
728 || stat(name[n], &sb) != 0
729 || (sb.st_mode & S_IFMT) != S_IFREG
730 || (sb.st_mode & 077) != 0) {
737 && !strcmp(name[0], name[1]))
739 ${cf_cv_main_return:-return}(result);
741 ],[cf_cv_func_mkstemp=yes
742 ],[cf_cv_func_mkstemp=no
743 ],[AC_CHECK_FUNC(mkstemp)
746 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
747 AC_DEFINE(HAVE_MKSTEMP)
750 dnl ---------------------------------------------------------------------------
751 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
753 dnl Write a debug message to config.log, along with the line number in the
754 dnl configure script.
755 AC_DEFUN([CF_MSG_LOG],[
756 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
758 dnl ---------------------------------------------------------------------------
759 dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
760 dnl ------------------
761 dnl see CF_WITH_NO_LEAKS
762 AC_DEFUN([CF_NO_LEAKS_OPTION],[
763 AC_MSG_CHECKING(if you want to use $1 for testing)
766 [AC_DEFINE($3)ifelse([$4],,[
770 : ${with_no_leaks:=yes}
773 AC_MSG_RESULT(${with_$1:-no})
775 case .$with_cflags in #(vi
777 case .$CFLAGS in #(vi
787 dnl ---------------------------------------------------------------------------
788 dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
789 dnl -----------------
790 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
792 dnl POSIX.1-1990 _POSIX_SOURCE
793 dnl POSIX.1-1990 and _POSIX_SOURCE and
794 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
796 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
797 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
798 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
801 dnl $1 is the nominal value for _POSIX_C_SOURCE
802 AC_DEFUN([CF_POSIX_C_SOURCE],
804 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
806 cf_save_CFLAGS="$CFLAGS"
807 cf_save_CPPFLAGS="$CPPFLAGS"
809 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
810 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
812 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
813 CF_MSG_LOG(if the symbol is already defined go no further)
814 AC_TRY_COMPILE([#include <sys/types.h>],[
815 #ifndef _POSIX_C_SOURCE
818 [cf_cv_posix_c_source=no],
819 [cf_want_posix_source=no
820 case .$cf_POSIX_C_SOURCE in #(vi
822 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
825 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
826 cf_want_posix_source=yes
829 cf_want_posix_source=yes
832 if test "$cf_want_posix_source" = yes ; then
833 AC_TRY_COMPILE([#include <sys/types.h>],[
837 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
839 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
840 CFLAGS="$cf_trim_CFLAGS"
841 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
842 CF_MSG_LOG(if the second compile does not leave our definition intact error)
843 AC_TRY_COMPILE([#include <sys/types.h>],[
844 #ifndef _POSIX_C_SOURCE
847 [cf_cv_posix_c_source=no])
848 CFLAGS="$cf_save_CFLAGS"
849 CPPFLAGS="$cf_save_CPPFLAGS"
853 if test "$cf_cv_posix_c_source" != no ; then
854 CFLAGS="$cf_trim_CFLAGS"
855 CPPFLAGS="$cf_trim_CPPFLAGS"
856 CF_ADD_CFLAGS($cf_cv_posix_c_source)
860 dnl ---------------------------------------------------------------------------
861 dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
863 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
864 AC_DEFUN([CF_PROG_EXT],
866 AC_REQUIRE([CF_CHECK_CACHE])
867 case $cf_cv_system_name in
869 CFLAGS="$CFLAGS -Zmt"
870 CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
871 CXXFLAGS="$CXXFLAGS -Zmt"
872 # autoconf's macro sets -Zexe and suffix both, which conflict:w
873 LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
883 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
885 dnl ---------------------------------------------------------------------------
886 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
888 AC_DEFUN([CF_PROG_LINT],
890 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
893 dnl ---------------------------------------------------------------------------
894 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
896 dnl Remove all -U and -D options that refer to the given symbol from a list
897 dnl of C compiler options. This works around the problem that not all
898 dnl compilers process -U and -D options from left-to-right, so a -U option
899 dnl cannot be used to cancel the effect of a preceding -D option.
901 dnl $1 = target (which could be the same as the source variable)
902 dnl $2 = source (including '$')
903 dnl $3 = symbol to remove
904 define([CF_REMOVE_DEFINE],
907 sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \
908 -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'`
910 dnl ---------------------------------------------------------------------------
911 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
913 dnl Make an uppercase version of a variable
917 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
919 dnl ---------------------------------------------------------------------------
920 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
922 dnl Use AC_VERBOSE w/o the warnings
923 AC_DEFUN([CF_VERBOSE],
924 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
927 dnl ---------------------------------------------------------------------------
928 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
930 dnl Configure-option for dbmalloc. The optional parameter is used to override
931 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
932 AC_DEFUN([CF_WITH_DBMALLOC],[
933 CF_NO_LEAKS_OPTION(dbmalloc,
934 [ --with-dbmalloc test: use Conor Cahill's dbmalloc library],
937 if test "$with_dbmalloc" = yes ; then
938 AC_CHECK_HEADER(dbmalloc.h,
939 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
942 dnl ---------------------------------------------------------------------------
943 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
945 dnl Configure-option for dmalloc. The optional parameter is used to override
946 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
947 AC_DEFUN([CF_WITH_DMALLOC],[
948 CF_NO_LEAKS_OPTION(dmalloc,
949 [ --with-dmalloc test: use Gray Watson's dmalloc library],
952 if test "$with_dmalloc" = yes ; then
953 AC_CHECK_HEADER(dmalloc.h,
954 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
957 dnl ---------------------------------------------------------------------------
958 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
960 AC_DEFUN([CF_WITH_VALGRIND],[
961 CF_NO_LEAKS_OPTION(valgrind,
962 [ --with-valgrind test: use valgrind],
965 dnl ---------------------------------------------------------------------------
966 dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
968 dnl Combine the checks for gcc features into a configure-script option
971 dnl $1 - see CF_GCC_WARNINGS
972 AC_DEFUN([CF_WITH_WARNINGS],
974 if ( test "$GCC" = yes || test "$GXX" = yes )
976 AC_MSG_CHECKING(if you want to check for gcc warnings)
977 AC_ARG_WITH(warnings,
978 [ --with-warnings test: turn on gcc warnings],
979 [cf_opt_with_warnings=$withval],
980 [cf_opt_with_warnings=no])
981 AC_MSG_RESULT($cf_opt_with_warnings)
982 if test "$cf_opt_with_warnings" != no ; then
984 CF_GCC_WARNINGS([$1])
988 dnl ---------------------------------------------------------------------------
989 dnl CF_XOPEN_SOURCE version: 37 updated: 2011/08/06 20:32:05
991 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
992 dnl or adapt to the vendor's definitions to get equivalent functionality,
993 dnl without losing the common non-POSIX features.
996 dnl $1 is the nominal value for _XOPEN_SOURCE
997 dnl $2 is the nominal value for _POSIX_C_SOURCE
998 AC_DEFUN([CF_XOPEN_SOURCE],[
1000 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
1001 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
1004 case $host_os in #(vi
1006 cf_xopen_source="-D_ALL_SOURCE"
1011 darwin[[0-8]].*) #(vi
1012 cf_xopen_source="-D_APPLE_C_SOURCE"
1015 cf_xopen_source="-D_DARWIN_C_SOURCE"
1017 freebsd*|dragonfly*) #(vi
1018 # 5.x headers associate
1019 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1020 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1021 cf_POSIX_C_SOURCE=200112L
1023 cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1026 cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
1029 cf_xopen_source="-D_HPUX_SOURCE"
1032 cf_xopen_source="-D_SGI_SOURCE"
1034 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
1038 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
1041 cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1044 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1047 cf_xopen_source="-D_OSF_SOURCE"
1050 cf_xopen_source="-D_QNX_SOURCE"
1053 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1055 solaris2.1[[0-9]]) #(vi
1056 cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1058 solaris2.[[1-9]]) #(vi
1059 cf_xopen_source="-D__EXTENSIONS__"
1062 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1063 AC_TRY_COMPILE([#include <sys/types.h>],[
1064 #ifndef _XOPEN_SOURCE
1067 [cf_cv_xopen_source=no],
1068 [cf_save="$CPPFLAGS"
1069 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1070 AC_TRY_COMPILE([#include <sys/types.h>],[
1071 #ifdef _XOPEN_SOURCE
1074 [cf_cv_xopen_source=no],
1075 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1079 if test "$cf_cv_xopen_source" != no ; then
1080 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1081 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1082 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
1083 CF_ADD_CFLAGS($cf_temp_xopen_source)
1085 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1089 if test -n "$cf_xopen_source" ; then
1090 CF_ADD_CFLAGS($cf_xopen_source)