1 dnl Id: aclocal.m4,v 1.30 2013/03/05 01:13:39 tom Exp
2 dnl Macros for byacc configure script (Thomas E. Dickey)
3 dnl ---------------------------------------------------------------------------
4 dnl Copyright 2004-2012,2013 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_ACVERSION_CHECK version: 4 updated: 2013/03/04 19:52:56
32 dnl ------------------
33 dnl Conditionally generate script according to whether we're using a given autoconf.
35 dnl $1 = version to compare against
36 dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
37 dnl $3 = code to use if AC_ACVERSION is older than $1.
38 define([CF_ACVERSION_CHECK],
40 ifdef([AC_ACVERSION], ,[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])dnl
41 ifdef([m4_version_compare],
42 [m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
43 [CF_ACVERSION_COMPARE(
44 AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
45 AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
46 dnl ---------------------------------------------------------------------------
47 dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
48 dnl --------------------
49 dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
50 dnl MAJOR2, MINOR2, TERNARY2,
51 dnl PRINTABLE2, not FOUND, FOUND)
52 define([CF_ACVERSION_COMPARE],
53 [ifelse(builtin([eval], [$2 < $5]), 1,
54 [ifelse([$8], , ,[$8])],
55 [ifelse([$9], , ,[$9])])])dnl
56 dnl ---------------------------------------------------------------------------
57 dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
59 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
60 dnl The second parameter if given makes this macro verbose.
62 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
63 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
64 dnl confused by the quotes (which require backslashes to keep them usable).
65 AC_DEFUN([CF_ADD_CFLAGS],
70 cf_new_extra_cppflags=
72 for cf_add_cflags in $1
74 case $cf_fix_cppflags in
76 case $cf_add_cflags in #(vi
77 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
78 case $cf_add_cflags in
80 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
82 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
83 && test -z "${cf_tst_cflags}" \
84 && cf_fix_cppflags=yes
86 if test $cf_fix_cppflags = yes ; then
87 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
89 elif test "${cf_tst_cflags}" = "\"'" ; then
90 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
99 case $cf_add_cflags in #(vi
101 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
102 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
105 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
110 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
115 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
117 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
119 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
120 && test -z "${cf_tst_cflags}" \
121 && cf_fix_cppflags=no
126 if test -n "$cf_new_cflags" ; then
127 ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
128 CFLAGS="$CFLAGS $cf_new_cflags"
131 if test -n "$cf_new_cppflags" ; then
132 ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
133 CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
136 if test -n "$cf_new_extra_cppflags" ; then
137 ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
138 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
141 AC_SUBST(EXTRA_CPPFLAGS)
144 dnl ---------------------------------------------------------------------------
145 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
147 dnl Allow user to disable a normally-on option.
148 AC_DEFUN([CF_ARG_DISABLE],
149 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
150 dnl ---------------------------------------------------------------------------
151 dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
153 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
159 dnl $3 = action to perform if option is not default
160 dnl $4 = action if perform if option is default
161 dnl $5 = default option value (either 'yes' or 'no')
162 AC_DEFUN([CF_ARG_OPTION],
163 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
164 if test "$enableval" != "$5" ; then
166 ,[ $3]) ifelse([$4],,,[
169 fi],[enableval=$5 ifelse([$4],,,[
173 dnl ---------------------------------------------------------------------------
174 dnl CF_CC_ENV_FLAGS version: 1 updated: 2012/10/03 05:25:49
176 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
177 dnl into CC. This will not help with broken scripts that wrap the compiler with
178 dnl options, but eliminates a more common category of user confusion.
179 AC_DEFUN([CF_CC_ENV_FLAGS],
181 # This should have been defined by AC_PROG_CC
184 AC_MSG_CHECKING(\$CC variable)
187 AC_MSG_RESULT(broken)
188 AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
190 cf_flags=`echo "$CC" | sed -e 's/^[[^ ]]*[[ ]]//'`
191 CC=`echo "$CC" | sed -e 's/[[ ]].*//'`
192 CF_ADD_CFLAGS($cf_flags)
199 dnl ---------------------------------------------------------------------------
200 dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
202 dnl Check if we're accidentally using a cache from a different machine.
203 dnl Derive the system name, as a check for reusing the autoconf cache.
205 dnl If we've packaged config.guess and config.sub, run that (since it does a
206 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
207 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
208 dnl which is useful in cross-compiles.
210 dnl Note: we would use $ac_config_sub, but that is one of the places where
211 dnl autoconf 2.5x broke compatibility with autoconf 2.13
212 AC_DEFUN([CF_CHECK_CACHE],
214 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
215 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
216 system_name="$host_os"
218 system_name="`(uname -s -r) 2>/dev/null`"
219 if test -z "$system_name" ; then
220 system_name="`(hostname) 2>/dev/null`"
223 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
224 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
226 test -z "$system_name" && system_name="$cf_cv_system_name"
227 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
229 if test ".$system_name" != ".$cf_cv_system_name" ; then
230 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
231 AC_MSG_ERROR("Please remove config.cache and try again.")
234 dnl ---------------------------------------------------------------------------
235 dnl CF_CLANG_COMPILER version: 1 updated: 2012/06/16 14:55:39
236 dnl -----------------
237 dnl Check if the given compiler is really clang. clang's C driver defines
238 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
239 dnl not ignore some gcc options.
241 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
242 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
243 dnl the wrappers for gcc and g++ warnings.
245 dnl $1 = GCC (default) or GXX
246 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
247 dnl $3 = CFLAGS (default) or CXXFLAGS
248 AC_DEFUN([CF_CLANG_COMPILER],[
249 ifelse([$2],,CLANG_COMPILER,[$2])=no
251 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
252 AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
253 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
254 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
260 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
261 cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
263 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
264 AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
267 dnl ---------------------------------------------------------------------------
268 dnl CF_DISABLE_ECHO version: 12 updated: 2012/10/06 16:30:28
270 dnl You can always use "make -n" to see the actual options, but it's hard to
271 dnl pick out/analyze warning messages when the compile-line is long.
274 dnl ECHO_LT - symbol to control if libtool is verbose
275 dnl ECHO_LD - symbol to prefix "cc -o" lines
276 dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
277 dnl SHOW_CC - symbol to put before explicit "cc -c" lines
278 dnl ECHO_CC - symbol to put before any "cc" line
280 AC_DEFUN([CF_DISABLE_ECHO],[
281 AC_MSG_CHECKING(if you want to see long compiling messages)
283 [ --disable-echo do not display "compiling" commands],
286 ECHO_LD='@echo linking [$]@;'
287 RULE_CC='@echo compiling [$]<'
288 SHOW_CC='@echo compiling [$]@'
297 AC_MSG_RESULT($enableval)
304 dnl ---------------------------------------------------------------------------
305 dnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
307 dnl Combine no-leak checks with the libraries or tools that are used for the
309 AC_DEFUN([CF_DISABLE_LEAKS],[
311 AC_REQUIRE([CF_WITH_DMALLOC])
312 AC_REQUIRE([CF_WITH_DBMALLOC])
313 AC_REQUIRE([CF_WITH_VALGRIND])
315 AC_MSG_CHECKING(if you want to perform memory-leak testing)
317 [ --disable-leaks test: free permanent memory, analyze leaks],
318 [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
319 : ${with_no_leaks:=no})
320 AC_MSG_RESULT($with_no_leaks)
322 if test "$with_no_leaks" = yes ; then
323 AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
324 AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
327 dnl ---------------------------------------------------------------------------
328 dnl CF_GCC_ATTRIBUTES version: 16 updated: 2012/10/02 20:55:03
329 dnl -----------------
330 dnl Test for availability of useful gcc __attribute__ directives to quiet
331 dnl compiler warnings. Though useful, not all are supported -- and contrary
332 dnl to documentation, unrecognized directives cause older compilers to barf.
333 AC_DEFUN([CF_GCC_ATTRIBUTES],
337 cat > conftest.i <<EOF
345 #define GCC_NORETURN /* nothing */
348 #define GCC_UNUSED /* nothing */
353 AC_CHECKING([for $CC __attribute__ directives])
354 cat > conftest.$ac_ext <<EOF
355 #line __oline__ "${as_me:-configure}"
356 #include "confdefs.h"
357 #include "conftest.h"
358 #include "conftest.i"
360 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
362 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
365 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
367 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
369 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
370 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
371 extern void foo(void) GCC_NORETURN;
372 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
374 cf_printf_attribute=no
375 cf_scanf_attribute=no
376 for cf_attribute in scanf printf unused noreturn
378 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
379 cf_directive="__attribute__(($cf_attribute))"
380 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
382 case $cf_attribute in #(vi
384 cf_printf_attribute=yes
385 cat >conftest.h <<EOF
386 #define GCC_$cf_ATTRIBUTE 1
390 cf_scanf_attribute=yes
391 cat >conftest.h <<EOF
392 #define GCC_$cf_ATTRIBUTE 1
396 cat >conftest.h <<EOF
397 #define GCC_$cf_ATTRIBUTE $cf_directive
402 if AC_TRY_EVAL(ac_compile); then
403 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
404 cat conftest.h >>confdefs.h
405 case $cf_attribute in #(vi
407 AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
410 cf_value='/* nothing */'
411 if test "$cf_printf_attribute" != no ; then
412 cf_value='__attribute__((format(printf,fmt,var)))'
413 AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
415 AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
418 cf_value='/* nothing */'
419 if test "$cf_scanf_attribute" != no ; then
420 cf_value='__attribute__((format(scanf,fmt,var)))'
421 AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
423 AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
426 AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
432 fgrep define conftest.i >>confdefs.h
437 dnl ---------------------------------------------------------------------------
438 dnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
440 dnl Find version of gcc
441 AC_DEFUN([CF_GCC_VERSION],[
442 AC_REQUIRE([AC_PROG_CC])
444 if test "$GCC" = yes ; then
445 AC_MSG_CHECKING(version of $CC)
446 GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
447 test -z "$GCC_VERSION" && GCC_VERSION=unknown
448 AC_MSG_RESULT($GCC_VERSION)
451 dnl ---------------------------------------------------------------------------
452 dnl CF_GCC_WARNINGS version: 29 updated: 2012/06/16 14:55:39
454 dnl Check if the compiler supports useful warning options. There's a few that
455 dnl we don't use, simply because they're too noisy:
457 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
458 dnl -Wredundant-decls (system headers make this too noisy)
459 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
460 dnl -Wwrite-strings (too noisy, but should review occasionally). This
461 dnl is enabled for ncurses using "--enable-const".
465 dnl $1 is an optional list of gcc warning flags that a particular
466 dnl application might want to use, e.g., "no-unused" for
469 dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
471 AC_DEFUN([CF_GCC_WARNINGS],
473 AC_REQUIRE([CF_GCC_VERSION])
474 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
475 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
477 cat > conftest.$ac_ext <<EOF
478 #line __oline__ "${as_me:-configure}"
479 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
482 if test "$INTEL_COMPILER" = yes
484 # The "-wdXXX" options suppress warnings:
485 # remark #1419: external declaration in primary source file
486 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
487 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
488 # remark #193: zero used for undefined preprocessing identifier
489 # remark #593: variable "curs_sb_left_arrow" was set but never used
490 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
491 # remark #869: parameter "tw" was never referenced
492 # remark #981: operands are evaluated in unspecified order
493 # warning #279: controlling expression is constant
495 AC_CHECKING([for $CC warning options])
496 cf_save_CFLAGS="$CFLAGS"
509 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
510 if AC_TRY_EVAL(ac_compile); then
511 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
512 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
515 CFLAGS="$cf_save_CFLAGS"
517 elif test "$GCC" = yes
519 AC_CHECKING([for $CC warning options])
520 cf_save_CFLAGS="$CFLAGS"
523 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
524 for cf_opt in W Wall \
529 Wmissing-declarations \
530 Wmissing-prototypes \
535 Wundef $cf_warn_CONST $1
537 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
538 if AC_TRY_EVAL(ac_compile); then
539 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
542 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
547 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
554 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
559 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
562 CFLAGS="$cf_save_CFLAGS"
566 AC_SUBST(EXTRA_CFLAGS)
568 dnl ---------------------------------------------------------------------------
569 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
571 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
572 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
573 dnl (or misfeature) of glibc2, which breaks portability of many applications,
574 dnl since it is interwoven with GNU extensions.
576 dnl Well, yes we could work around it...
577 AC_DEFUN([CF_GNU_SOURCE],
579 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
580 AC_TRY_COMPILE([#include <sys/types.h>],[
581 #ifndef _XOPEN_SOURCE
584 [cf_cv_gnu_source=no],
586 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
587 AC_TRY_COMPILE([#include <sys/types.h>],[
591 [cf_cv_gnu_source=no],
592 [cf_cv_gnu_source=yes])
596 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
598 dnl ---------------------------------------------------------------------------
599 dnl CF_INTEL_COMPILER version: 5 updated: 2013/02/10 10:41:05
600 dnl -----------------
601 dnl Check if the given compiler is really the Intel compiler for Linux. It
602 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
603 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
605 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
606 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
607 dnl the wrappers for gcc and g++ warnings.
609 dnl $1 = GCC (default) or GXX
610 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
611 dnl $3 = CFLAGS (default) or CXXFLAGS
612 AC_DEFUN([CF_INTEL_COMPILER],[
613 AC_REQUIRE([AC_CANONICAL_HOST])
614 ifelse([$2],,INTEL_COMPILER,[$2])=no
616 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
619 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
620 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
621 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
623 #ifdef __INTEL_COMPILER
627 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
628 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
630 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
631 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
636 dnl ---------------------------------------------------------------------------
637 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
639 dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have
640 dnl a monocase filesystem.
641 AC_DEFUN([CF_MAKE_TAGS],[
642 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
644 AC_CHECK_PROGS(CTAGS, exctags ctags)
645 AC_CHECK_PROGS(ETAGS, exetags etags)
647 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
649 if test "$cf_cv_mixedcase" = yes ; then
650 AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
655 if test "$MAKE_UPPER_TAGS" = yes ; then
661 if test "$MAKE_LOWER_TAGS" = yes ; then
670 AC_SUBST(MAKE_UPPER_TAGS)
671 AC_SUBST(MAKE_LOWER_TAGS)
673 dnl ---------------------------------------------------------------------------
674 dnl CF_MIXEDCASE_FILENAMES version: 4 updated: 2012/10/02 20:55:03
675 dnl ----------------------
676 dnl Check if the file-system supports mixed-case filenames. If we're able to
677 dnl create a lowercase name and see it as uppercase, it doesn't support that.
678 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
680 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
681 if test "$cross_compiling" = yes ; then
682 case $target_alias in #(vi
683 *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
691 rm -f conftest CONFTEST
693 if test -f CONFTEST ; then
698 rm -f conftest CONFTEST
701 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
703 dnl ---------------------------------------------------------------------------
704 dnl CF_MKSTEMP version: 9 updated: 2012/10/03 04:34:49
706 dnl Check for a working mkstemp. This creates two files, checks that they are
707 dnl successfully created and distinct (AmigaOS apparently fails on the last).
708 AC_DEFUN([CF_MKSTEMP],[
709 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
712 #include <sys/types.h>
716 #include <sys/stat.h>
719 char *tmpl = "conftestXXXXXX";
727 for (n = 0; n < 2; ++n) {
728 strcpy(name[n], tmpl);
729 if ((fd = mkstemp(name[n])) >= 0) {
730 if (!strcmp(name[n], tmpl)
731 || stat(name[n], &sb) != 0
732 || (sb.st_mode & S_IFMT) != S_IFREG
733 || (sb.st_mode & 077) != 0) {
740 && !strcmp(name[0], name[1]))
742 ${cf_cv_main_return:-return}(result);
744 ],[cf_cv_func_mkstemp=yes
745 ],[cf_cv_func_mkstemp=no
746 ],[cf_cv_func_mkstemp=maybe])
748 if test "x$cf_cv_func_mkstemp" = xmaybe ; then
749 AC_CHECK_FUNC(mkstemp)
751 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
752 AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
755 dnl ---------------------------------------------------------------------------
756 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
758 dnl Write a debug message to config.log, along with the line number in the
759 dnl configure script.
760 AC_DEFUN([CF_MSG_LOG],[
761 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
763 dnl ---------------------------------------------------------------------------
764 dnl CF_NO_LEAKS_OPTION version: 5 updated: 2012/10/02 20:55:03
765 dnl ------------------
766 dnl see CF_WITH_NO_LEAKS
767 AC_DEFUN([CF_NO_LEAKS_OPTION],[
768 AC_MSG_CHECKING(if you want to use $1 for testing)
771 [AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
775 : ${with_no_leaks:=yes}
778 AC_MSG_RESULT(${with_$1:-no})
780 case .$with_cflags in #(vi
782 case .$CFLAGS in #(vi
792 dnl ---------------------------------------------------------------------------
793 dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
794 dnl -----------------
795 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
797 dnl POSIX.1-1990 _POSIX_SOURCE
798 dnl POSIX.1-1990 and _POSIX_SOURCE and
799 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
801 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
802 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
803 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
806 dnl $1 is the nominal value for _POSIX_C_SOURCE
807 AC_DEFUN([CF_POSIX_C_SOURCE],
809 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
811 cf_save_CFLAGS="$CFLAGS"
812 cf_save_CPPFLAGS="$CPPFLAGS"
814 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
815 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
817 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
818 CF_MSG_LOG(if the symbol is already defined go no further)
819 AC_TRY_COMPILE([#include <sys/types.h>],[
820 #ifndef _POSIX_C_SOURCE
823 [cf_cv_posix_c_source=no],
824 [cf_want_posix_source=no
825 case .$cf_POSIX_C_SOURCE in #(vi
827 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
830 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
831 cf_want_posix_source=yes
834 cf_want_posix_source=yes
837 if test "$cf_want_posix_source" = yes ; then
838 AC_TRY_COMPILE([#include <sys/types.h>],[
842 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
844 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
845 CFLAGS="$cf_trim_CFLAGS"
846 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
847 CF_MSG_LOG(if the second compile does not leave our definition intact error)
848 AC_TRY_COMPILE([#include <sys/types.h>],[
849 #ifndef _POSIX_C_SOURCE
852 [cf_cv_posix_c_source=no])
853 CFLAGS="$cf_save_CFLAGS"
854 CPPFLAGS="$cf_save_CPPFLAGS"
858 if test "$cf_cv_posix_c_source" != no ; then
859 CFLAGS="$cf_trim_CFLAGS"
860 CPPFLAGS="$cf_trim_CPPFLAGS"
861 CF_ADD_CFLAGS($cf_cv_posix_c_source)
865 dnl ---------------------------------------------------------------------------
866 dnl CF_PROG_CC version: 3 updated: 2012/10/06 15:31:55
868 dnl standard check for CC, plus followup sanity checks
869 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
870 AC_DEFUN([CF_PROG_CC],[
871 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
873 CF_ACVERSION_CHECK(2.52,
878 dnl ---------------------------------------------------------------------------
879 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
881 AC_DEFUN([CF_PROG_LINT],
883 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
886 dnl ---------------------------------------------------------------------------
887 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
889 dnl Remove all -U and -D options that refer to the given symbol from a list
890 dnl of C compiler options. This works around the problem that not all
891 dnl compilers process -U and -D options from left-to-right, so a -U option
892 dnl cannot be used to cancel the effect of a preceding -D option.
894 dnl $1 = target (which could be the same as the source variable)
895 dnl $2 = source (including '$')
896 dnl $3 = symbol to remove
897 define([CF_REMOVE_DEFINE],
900 sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \
901 -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'`
903 dnl ---------------------------------------------------------------------------
904 dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
905 dnl -------------------
906 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
907 dnl can define it successfully.
908 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
909 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
913 #include <sys/types.h>
915 #ifndef _XOPEN_SOURCE
918 [cf_cv_xopen_source=no],
920 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
924 #include <sys/types.h>
929 [cf_cv_xopen_source=no],
930 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
935 if test "$cf_cv_xopen_source" != no ; then
936 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
937 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
938 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
939 CF_ADD_CFLAGS($cf_temp_xopen_source)
942 dnl ---------------------------------------------------------------------------
943 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
945 dnl Make an uppercase version of a variable
949 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
951 dnl ---------------------------------------------------------------------------
952 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
954 dnl Use AC_VERBOSE w/o the warnings
955 AC_DEFUN([CF_VERBOSE],
956 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
959 dnl ---------------------------------------------------------------------------
960 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
962 dnl Configure-option for dbmalloc. The optional parameter is used to override
963 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
964 AC_DEFUN([CF_WITH_DBMALLOC],[
965 CF_NO_LEAKS_OPTION(dbmalloc,
966 [ --with-dbmalloc test: use Conor Cahill's dbmalloc library],
969 if test "$with_dbmalloc" = yes ; then
970 AC_CHECK_HEADER(dbmalloc.h,
971 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
974 dnl ---------------------------------------------------------------------------
975 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
977 dnl Configure-option for dmalloc. The optional parameter is used to override
978 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
979 AC_DEFUN([CF_WITH_DMALLOC],[
980 CF_NO_LEAKS_OPTION(dmalloc,
981 [ --with-dmalloc test: use Gray Watson's dmalloc library],
984 if test "$with_dmalloc" = yes ; then
985 AC_CHECK_HEADER(dmalloc.h,
986 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
989 dnl ---------------------------------------------------------------------------
990 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
992 AC_DEFUN([CF_WITH_VALGRIND],[
993 CF_NO_LEAKS_OPTION(valgrind,
994 [ --with-valgrind test: use valgrind],
997 dnl ---------------------------------------------------------------------------
998 dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
1000 dnl Combine the checks for gcc features into a configure-script option
1003 dnl $1 - see CF_GCC_WARNINGS
1004 AC_DEFUN([CF_WITH_WARNINGS],
1006 if ( test "$GCC" = yes || test "$GXX" = yes )
1008 AC_MSG_CHECKING(if you want to check for gcc warnings)
1009 AC_ARG_WITH(warnings,
1010 [ --with-warnings test: turn on gcc warnings],
1011 [cf_opt_with_warnings=$withval],
1012 [cf_opt_with_warnings=no])
1013 AC_MSG_RESULT($cf_opt_with_warnings)
1014 if test "$cf_opt_with_warnings" != no ; then
1016 CF_GCC_WARNINGS([$1])
1020 dnl ---------------------------------------------------------------------------
1021 dnl CF_XOPEN_SOURCE version: 43 updated: 2013/02/10 10:41:05
1023 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1024 dnl or adapt to the vendor's definitions to get equivalent functionality,
1025 dnl without losing the common non-POSIX features.
1028 dnl $1 is the nominal value for _XOPEN_SOURCE
1029 dnl $2 is the nominal value for _POSIX_C_SOURCE
1030 AC_DEFUN([CF_XOPEN_SOURCE],[
1031 AC_REQUIRE([AC_CANONICAL_HOST])
1033 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
1034 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
1037 case $host_os in #(vi
1039 cf_xopen_source="-D_ALL_SOURCE"
1044 darwin[[0-8]].*) #(vi
1045 cf_xopen_source="-D_APPLE_C_SOURCE"
1048 cf_xopen_source="-D_DARWIN_C_SOURCE"
1051 freebsd*|dragonfly*) #(vi
1052 # 5.x headers associate
1053 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1054 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1055 cf_POSIX_C_SOURCE=200112L
1057 cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1060 cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
1063 cf_xopen_source="-D_HPUX_SOURCE"
1066 cf_xopen_source="-D_SGI_SOURCE"
1069 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
1073 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
1075 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1078 cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1080 openbsd[[4-9]]*) #(vi
1081 # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
1082 cf_xopen_source="-D_BSD_SOURCE"
1086 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1089 cf_xopen_source="-D_OSF_SOURCE"
1092 cf_xopen_source="-D_QNX_SOURCE"
1095 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1098 cf_xopen_source="-D__EXTENSIONS__"
1102 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1106 if test -n "$cf_xopen_source" ; then
1107 CF_ADD_CFLAGS($cf_xopen_source)
1110 dnl In anything but the default case, we may have system-specific setting
1111 dnl which is still not guaranteed to provide all of the entrypoints that
1112 dnl _XOPEN_SOURCE would yield.
1113 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
1114 AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
1115 AC_TRY_COMPILE([#include <stdlib.h>],[
1116 #ifndef _XOPEN_SOURCE
1119 [cf_XOPEN_SOURCE_set=yes],
1120 [cf_XOPEN_SOURCE_set=no])
1121 AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
1122 if test $cf_XOPEN_SOURCE_set = yes
1124 AC_TRY_COMPILE([#include <stdlib.h>],[
1125 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
1128 [cf_XOPEN_SOURCE_set_ok=yes],
1129 [cf_XOPEN_SOURCE_set_ok=no])
1130 if test $cf_XOPEN_SOURCE_set_ok = no
1132 AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)