1dnl Id: aclocal.m4,v 1.15 2010/06/09 09:30:08 tom Exp 2dnl Macros for byacc configure script (Thomas E. Dickey) 3dnl --------------------------------------------------------------------------- 4dnl Copyright 2004-2009,2010 Thomas E. Dickey 5dnl 6dnl Permission is hereby granted, free of charge, to any person obtaining a 7dnl copy of this software and associated documentation files (the 8dnl "Software"), to deal in the Software without restriction, including 9dnl without limitation the rights to use, copy, modify, merge, publish, 10dnl distribute, distribute with modifications, sublicense, and/or sell 11dnl copies of the Software, and to permit persons to whom the Software is 12dnl furnished to do so, subject to the following conditions: 13dnl 14dnl The above copyright notice and this permission notice shall be included 15dnl in all copies or portions of the Software. 16dnl 17dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 21dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 22dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 23dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24dnl 25dnl Except as contained in this notice, the name(s) of the above copyright 26dnl holders shall not be used in advertising or otherwise to promote the 27dnl sale, use or other dealings in this Software without prior written 28dnl authorization. 29dnl --------------------------------------------------------------------------- 30dnl --------------------------------------------------------------------------- 31dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42 32dnl ------------- 33dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS 34dnl The second parameter if given makes this macro verbose. 35dnl 36dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS, 37dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily 38dnl confused by the quotes (which require backslashes to keep them usable). 39AC_DEFUN([CF_ADD_CFLAGS], 40[ 41cf_fix_cppflags=no 42cf_new_cflags= 43cf_new_cppflags= 44cf_new_extra_cppflags= 45 46for cf_add_cflags in $1 47do 48case $cf_fix_cppflags in 49no) 50 case $cf_add_cflags in #(vi 51 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi 52 case $cf_add_cflags in 53 -D*) 54 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'` 55 56 test "${cf_add_cflags}" != "${cf_tst_cflags}" \ 57 && test -z "${cf_tst_cflags}" \ 58 && cf_fix_cppflags=yes 59 60 if test $cf_fix_cppflags = yes ; then 61 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" 62 continue 63 elif test "${cf_tst_cflags}" = "\"'" ; then 64 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" 65 continue 66 fi 67 ;; 68 esac 69 case "$CPPFLAGS" in 70 *$cf_add_cflags) #(vi 71 ;; 72 *) #(vi 73 case $cf_add_cflags in #(vi 74 -D*) 75 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'` 76 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags) 77 ;; 78 esac 79 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags" 80 ;; 81 esac 82 ;; 83 *) 84 cf_new_cflags="$cf_new_cflags $cf_add_cflags" 85 ;; 86 esac 87 ;; 88yes) 89 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags" 90 91 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'` 92 93 test "${cf_add_cflags}" != "${cf_tst_cflags}" \ 94 && test -z "${cf_tst_cflags}" \ 95 && cf_fix_cppflags=no 96 ;; 97esac 98done 99 100if test -n "$cf_new_cflags" ; then 101 ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)]) 102 CFLAGS="$CFLAGS $cf_new_cflags" 103fi 104 105if test -n "$cf_new_cppflags" ; then 106 ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)]) 107 CPPFLAGS="$CPPFLAGS $cf_new_cppflags" 108fi 109 110if 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" 113fi 114 115AC_SUBST(EXTRA_CPPFLAGS) 116 117])dnl 118dnl --------------------------------------------------------------------------- 119dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34 120dnl ---------------- 121dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES' 122dnl in the sharutils 4.2 distribution. 123AC_DEFUN([CF_ANSI_CC_CHECK], 124[ 125AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[ 126cf_cv_ansi_cc=no 127cf_save_CFLAGS="$CFLAGS" 128cf_save_CPPFLAGS="$CPPFLAGS" 129# Don't try gcc -ansi; that turns off useful extensions and 130# breaks some systems' header files. 131# AIX -qlanglvl=ansi 132# Ultrix and OSF/1 -std1 133# HP-UX -Aa -D_HPUX_SOURCE 134# SVR4 -Xc 135# UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes) 136for cf_arg in "-DCC_HAS_PROTOS" \ 137 "" \ 138 -qlanglvl=ansi \ 139 -std1 \ 140 -Ae \ 141 "-Aa -D_HPUX_SOURCE" \ 142 -Xc 143do 144 CF_ADD_CFLAGS($cf_arg) 145 AC_TRY_COMPILE( 146[ 147#ifndef CC_HAS_PROTOS 148#if !defined(__STDC__) || (__STDC__ != 1) 149choke me 150#endif 151#endif 152],[ 153 int test (int i, double x); 154 struct s1 {int (*f) (int a);}; 155 struct s2 {int (*f) (double a);};], 156 [cf_cv_ansi_cc="$cf_arg"; break]) 157done 158CFLAGS="$cf_save_CFLAGS" 159CPPFLAGS="$cf_save_CPPFLAGS" 160]) 161 162if test "$cf_cv_ansi_cc" != "no"; then 163if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then 164 CF_ADD_CFLAGS($cf_cv_ansi_cc) 165else 166 AC_DEFINE(CC_HAS_PROTOS) 167fi 168fi 169])dnl 170dnl --------------------------------------------------------------------------- 171dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54 172dnl --------------- 173dnl For programs that must use an ANSI compiler, obtain compiler options that 174dnl will make it recognize prototypes. We'll do preprocessor checks in other 175dnl macros, since tools such as unproto can fake prototypes, but only part of 176dnl the preprocessor. 177AC_DEFUN([CF_ANSI_CC_REQD], 178[AC_REQUIRE([CF_ANSI_CC_CHECK]) 179if test "$cf_cv_ansi_cc" = "no"; then 180 AC_MSG_ERROR( 181[Your compiler does not appear to recognize prototypes. 182You have the following choices: 183 a. adjust your compiler options 184 b. get an up-to-date compiler 185 c. use a wrapper such as unproto]) 186fi 187])dnl 188dnl --------------------------------------------------------------------------- 189dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31 190dnl -------------- 191dnl Allow user to disable a normally-on option. 192AC_DEFUN([CF_ARG_DISABLE], 193[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl 194dnl --------------------------------------------------------------------------- 195dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42 196dnl ------------- 197dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus 198dnl values. 199dnl 200dnl Parameters: 201dnl $1 = option name 202dnl $2 = help-string 203dnl $3 = action to perform if option is not default 204dnl $4 = action if perform if option is default 205dnl $5 = default option value (either 'yes' or 'no') 206AC_DEFUN([CF_ARG_OPTION], 207[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes) 208 if test "$enableval" != "$5" ; then 209ifelse([$3],,[ :]dnl 210,[ $3]) ifelse([$4],,,[ 211 else 212 $4]) 213 fi],[enableval=$5 ifelse([$4],,,[ 214 $4 215])dnl 216 ])])dnl 217dnl --------------------------------------------------------------------------- 218dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59 219dnl -------------- 220dnl Check if we're accidentally using a cache from a different machine. 221dnl Derive the system name, as a check for reusing the autoconf cache. 222dnl 223dnl If we've packaged config.guess and config.sub, run that (since it does a 224dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow 225dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM 226dnl which is useful in cross-compiles. 227dnl 228dnl Note: we would use $ac_config_sub, but that is one of the places where 229dnl autoconf 2.5x broke compatibility with autoconf 2.13 230AC_DEFUN([CF_CHECK_CACHE], 231[ 232if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then 233 ifelse([$1],,[AC_CANONICAL_HOST],[$1]) 234 system_name="$host_os" 235else 236 system_name="`(uname -s -r) 2>/dev/null`" 237 if test -z "$system_name" ; then 238 system_name="`(hostname) 2>/dev/null`" 239 fi 240fi 241test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name") 242AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"]) 243 244test -z "$system_name" && system_name="$cf_cv_system_name" 245test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name) 246 247if test ".$system_name" != ".$cf_cv_system_name" ; then 248 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)) 249 AC_MSG_ERROR("Please remove config.cache and try again.") 250fi 251])dnl 252dnl --------------------------------------------------------------------------- 253dnl CF_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57 254dnl --------------- 255dnl You can always use "make -n" to see the actual options, but it's hard to 256dnl pick out/analyze warning messages when the compile-line is long. 257dnl 258dnl Sets: 259dnl ECHO_LT - symbol to control if libtool is verbose 260dnl ECHO_LD - symbol to prefix "cc -o" lines 261dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o) 262dnl SHOW_CC - symbol to put before explicit "cc -c" lines 263dnl ECHO_CC - symbol to put before any "cc" line 264dnl 265AC_DEFUN([CF_DISABLE_ECHO],[ 266AC_MSG_CHECKING(if you want to see long compiling messages) 267CF_ARG_DISABLE(echo, 268 [ --disable-echo display "compiling" commands], 269 [ 270 ECHO_LT='--silent' 271 ECHO_LD='@echo linking [$]@;' 272 RULE_CC='@echo compiling [$]<' 273 SHOW_CC='@echo compiling [$]@' 274 ECHO_CC='@' 275],[ 276 ECHO_LT='' 277 ECHO_LD='' 278 RULE_CC='' 279 SHOW_CC='' 280 ECHO_CC='' 281]) 282AC_MSG_RESULT($enableval) 283AC_SUBST(ECHO_LT) 284AC_SUBST(ECHO_LD) 285AC_SUBST(RULE_CC) 286AC_SUBST(SHOW_CC) 287AC_SUBST(ECHO_CC) 288])dnl 289dnl --------------------------------------------------------------------------- 290dnl CF_DISABLE_LEAKS version: 5 updated: 2010/03/13 15:14:55 291dnl ---------------- 292dnl Combine no-leak checks with the libraries or tools that are used for the 293dnl checks. 294AC_DEFUN([CF_DISABLE_LEAKS],[ 295 296AC_REQUIRE([CF_WITH_DMALLOC]) 297AC_REQUIRE([CF_WITH_DBMALLOC]) 298AC_REQUIRE([CF_WITH_VALGRIND]) 299 300AC_MSG_CHECKING(if you want to perform memory-leak testing) 301AC_ARG_ENABLE(leaks, 302 [ --disable-leaks test: free permanent memory, analyze leaks], 303 [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi], 304 : ${with_no_leaks:=no}) 305AC_MSG_RESULT($with_no_leaks) 306 307if test "$with_no_leaks" = yes ; then 308 AC_DEFINE(NO_LEAKS) 309fi 310])dnl 311dnl --------------------------------------------------------------------------- 312dnl CF_GCC_ATTRIBUTES version: 13 updated: 2009/08/11 20:19:56 313dnl ----------------- 314dnl Test for availability of useful gcc __attribute__ directives to quiet 315dnl compiler warnings. Though useful, not all are supported -- and contrary 316dnl to documentation, unrecognized directives cause older compilers to barf. 317AC_DEFUN([CF_GCC_ATTRIBUTES], 318[ 319if test "$GCC" = yes 320then 321cat > conftest.i <<EOF 322#ifndef GCC_PRINTF 323#define GCC_PRINTF 0 324#endif 325#ifndef GCC_SCANF 326#define GCC_SCANF 0 327#endif 328#ifndef GCC_NORETURN 329#define GCC_NORETURN /* nothing */ 330#endif 331#ifndef GCC_UNUSED 332#define GCC_UNUSED /* nothing */ 333#endif 334EOF 335if test "$GCC" = yes 336then 337 AC_CHECKING([for $CC __attribute__ directives]) 338cat > conftest.$ac_ext <<EOF 339#line __oline__ "${as_me-configure}" 340#include "confdefs.h" 341#include "conftest.h" 342#include "conftest.i" 343#if GCC_PRINTF 344#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) 345#else 346#define GCC_PRINTFLIKE(fmt,var) /*nothing*/ 347#endif 348#if GCC_SCANF 349#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) 350#else 351#define GCC_SCANFLIKE(fmt,var) /*nothing*/ 352#endif 353extern void wow(char *,...) GCC_SCANFLIKE(1,2); 354extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN; 355extern void foo(void) GCC_NORETURN; 356int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; } 357EOF 358 cf_printf_attribute=no 359 cf_scanf_attribute=no 360 for cf_attribute in scanf printf unused noreturn 361 do 362 CF_UPPER(cf_ATTRIBUTE,$cf_attribute) 363 cf_directive="__attribute__(($cf_attribute))" 364 echo "checking for $CC $cf_directive" 1>&AC_FD_CC 365 366 case $cf_attribute in #(vi 367 printf) #(vi 368 cf_printf_attribute=yes 369 cat >conftest.h <<EOF 370#define GCC_$cf_ATTRIBUTE 1 371EOF 372 ;; 373 scanf) #(vi 374 cf_scanf_attribute=yes 375 cat >conftest.h <<EOF 376#define GCC_$cf_ATTRIBUTE 1 377EOF 378 ;; 379 *) #(vi 380 cat >conftest.h <<EOF 381#define GCC_$cf_ATTRIBUTE $cf_directive 382EOF 383 ;; 384 esac 385 386 if AC_TRY_EVAL(ac_compile); then 387 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute) 388 cat conftest.h >>confdefs.h 389 case $cf_attribute in #(vi 390 printf) #(vi 391 if test "$cf_printf_attribute" = no ; then 392 cat >>confdefs.h <<EOF 393#define GCC_PRINTFLIKE(fmt,var) /* nothing */ 394EOF 395 else 396 cat >>confdefs.h <<EOF 397#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) 398EOF 399 fi 400 ;; 401 scanf) #(vi 402 if test "$cf_scanf_attribute" = no ; then 403 cat >>confdefs.h <<EOF 404#define GCC_SCANFLIKE(fmt,var) /* nothing */ 405EOF 406 else 407 cat >>confdefs.h <<EOF 408#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) 409EOF 410 fi 411 ;; 412 esac 413 fi 414 done 415else 416 fgrep define conftest.i >>confdefs.h 417fi 418rm -rf conftest* 419fi 420])dnl 421dnl --------------------------------------------------------------------------- 422dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31 423dnl -------------- 424dnl Find version of gcc 425AC_DEFUN([CF_GCC_VERSION],[ 426AC_REQUIRE([AC_PROG_CC]) 427GCC_VERSION=none 428if test "$GCC" = yes ; then 429 AC_MSG_CHECKING(version of $CC) 430 GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`" 431 test -z "$GCC_VERSION" && GCC_VERSION=unknown 432 AC_MSG_RESULT($GCC_VERSION) 433fi 434])dnl 435dnl --------------------------------------------------------------------------- 436dnl CF_GCC_WARNINGS version: 25 updated: 2010/04/24 11:03:31 437dnl --------------- 438dnl Check if the compiler supports useful warning options. There's a few that 439dnl we don't use, simply because they're too noisy: 440dnl 441dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x) 442dnl -Wredundant-decls (system headers make this too noisy) 443dnl -Wtraditional (combines too many unrelated messages, only a few useful) 444dnl -Wwrite-strings (too noisy, but should review occasionally). This 445dnl is enabled for ncurses using "--enable-const". 446dnl -pedantic 447dnl 448dnl Parameter: 449dnl $1 is an optional list of gcc warning flags that a particular 450dnl application might want to use, e.g., "no-unused" for 451dnl -Wno-unused 452dnl Special: 453dnl If $with_ext_const is "yes", add a check for -Wwrite-strings 454dnl 455AC_DEFUN([CF_GCC_WARNINGS], 456[ 457AC_REQUIRE([CF_GCC_VERSION]) 458CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS) 459 460cat > conftest.$ac_ext <<EOF 461#line __oline__ "${as_me-configure}" 462int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; } 463EOF 464 465if test "$INTEL_COMPILER" = yes 466then 467# The "-wdXXX" options suppress warnings: 468# remark #1419: external declaration in primary source file 469# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem) 470# remark #1684: conversion from pointer to same-sized integral type (potential portability problem) 471# remark #193: zero used for undefined preprocessing identifier 472# remark #593: variable "curs_sb_left_arrow" was set but never used 473# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits 474# remark #869: parameter "tw" was never referenced 475# remark #981: operands are evaluated in unspecified order 476# warning #279: controlling expression is constant 477 478 AC_CHECKING([for $CC warning options]) 479 cf_save_CFLAGS="$CFLAGS" 480 EXTRA_CFLAGS="-Wall" 481 for cf_opt in \ 482 wd1419 \ 483 wd1683 \ 484 wd1684 \ 485 wd193 \ 486 wd593 \ 487 wd279 \ 488 wd810 \ 489 wd869 \ 490 wd981 491 do 492 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" 493 if AC_TRY_EVAL(ac_compile); then 494 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt) 495 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt" 496 fi 497 done 498 CFLAGS="$cf_save_CFLAGS" 499 500elif test "$GCC" = yes 501then 502 AC_CHECKING([for $CC warning options]) 503 cf_save_CFLAGS="$CFLAGS" 504 EXTRA_CFLAGS= 505 cf_warn_CONST="" 506 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings" 507 for cf_opt in W Wall \ 508 Wbad-function-cast \ 509 Wcast-align \ 510 Wcast-qual \ 511 Winline \ 512 Wmissing-declarations \ 513 Wmissing-prototypes \ 514 Wnested-externs \ 515 Wpointer-arith \ 516 Wshadow \ 517 Wstrict-prototypes \ 518 Wundef $cf_warn_CONST $1 519 do 520 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt" 521 if AC_TRY_EVAL(ac_compile); then 522 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt) 523 case $cf_opt in #(vi 524 Wcast-qual) #(vi 525 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES" 526 ;; 527 Winline) #(vi 528 case $GCC_VERSION in 529 [[34]].*) 530 CF_VERBOSE(feature is broken in gcc $GCC_VERSION) 531 continue;; 532 esac 533 ;; 534 esac 535 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt" 536 fi 537 done 538 CFLAGS="$cf_save_CFLAGS" 539fi 540rm -f conftest* 541 542AC_SUBST(EXTRA_CFLAGS) 543])dnl 544dnl --------------------------------------------------------------------------- 545dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07 546dnl ------------- 547dnl Check if we must define _GNU_SOURCE to get a reasonable value for 548dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect 549dnl (or misfeature) of glibc2, which breaks portability of many applications, 550dnl since it is interwoven with GNU extensions. 551dnl 552dnl Well, yes we could work around it... 553AC_DEFUN([CF_GNU_SOURCE], 554[ 555AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[ 556AC_TRY_COMPILE([#include <sys/types.h>],[ 557#ifndef _XOPEN_SOURCE 558make an error 559#endif], 560 [cf_cv_gnu_source=no], 561 [cf_save="$CPPFLAGS" 562 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" 563 AC_TRY_COMPILE([#include <sys/types.h>],[ 564#ifdef _XOPEN_SOURCE 565make an error 566#endif], 567 [cf_cv_gnu_source=no], 568 [cf_cv_gnu_source=yes]) 569 CPPFLAGS="$cf_save" 570 ]) 571]) 572test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" 573])dnl 574dnl --------------------------------------------------------------------------- 575dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42 576dnl ----------------- 577dnl Check if the given compiler is really the Intel compiler for Linux. It 578dnl tries to imitate gcc, but does not return an error when it finds a mismatch 579dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK. 580dnl 581dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to 582dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from 583dnl the wrappers for gcc and g++ warnings. 584dnl 585dnl $1 = GCC (default) or GXX 586dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS 587dnl $3 = CFLAGS (default) or CXXFLAGS 588AC_DEFUN([CF_INTEL_COMPILER],[ 589ifelse([$2],,INTEL_COMPILER,[$2])=no 590 591if test "$ifelse([$1],,[$1],GCC)" = yes ; then 592 case $host_os in 593 linux*|gnu*) 594 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler) 595 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])" 596 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc" 597 AC_TRY_COMPILE([],[ 598#ifdef __INTEL_COMPILER 599#else 600make an error 601#endif 602],[ifelse([$2],,INTEL_COMPILER,[$2])=yes 603cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc" 604],[]) 605 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS" 606 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2])) 607 ;; 608 esac 609fi 610])dnl 611dnl --------------------------------------------------------------------------- 612dnl CF_MAKE_TAGS version: 5 updated: 2010/04/03 20:07:32 613dnl ------------ 614dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have 615dnl a monocase filesystem. 616AC_DEFUN([CF_MAKE_TAGS],[ 617AC_REQUIRE([CF_MIXEDCASE_FILENAMES]) 618 619AC_CHECK_PROGS(CTAGS, exctags ctags) 620AC_CHECK_PROGS(ETAGS, exetags etags) 621 622AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS-ctags}, yes, no) 623 624if test "$cf_cv_mixedcase" = yes ; then 625 AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS-etags}, yes, no) 626else 627 MAKE_UPPER_TAGS=no 628fi 629 630if test "$MAKE_UPPER_TAGS" = yes ; then 631 MAKE_UPPER_TAGS= 632else 633 MAKE_UPPER_TAGS="#" 634fi 635 636if test "$MAKE_LOWER_TAGS" = yes ; then 637 MAKE_LOWER_TAGS= 638else 639 MAKE_LOWER_TAGS="#" 640fi 641 642AC_SUBST(CTAGS) 643AC_SUBST(ETAGS) 644 645AC_SUBST(MAKE_UPPER_TAGS) 646AC_SUBST(MAKE_LOWER_TAGS) 647])dnl 648dnl --------------------------------------------------------------------------- 649dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55 650dnl ---------------------- 651dnl Check if the file-system supports mixed-case filenames. If we're able to 652dnl create a lowercase name and see it as uppercase, it doesn't support that. 653AC_DEFUN([CF_MIXEDCASE_FILENAMES], 654[ 655AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[ 656if test "$cross_compiling" = yes ; then 657 case $target_alias in #(vi 658 *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi 659 cf_cv_mixedcase=no 660 ;; 661 *) 662 cf_cv_mixedcase=yes 663 ;; 664 esac 665else 666 rm -f conftest CONFTEST 667 echo test >conftest 668 if test -f CONFTEST ; then 669 cf_cv_mixedcase=no 670 else 671 cf_cv_mixedcase=yes 672 fi 673 rm -f conftest CONFTEST 674fi 675]) 676test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES) 677])dnl 678dnl --------------------------------------------------------------------------- 679dnl CF_MSG_LOG version: 4 updated: 2007/07/29 09:55:12 680dnl ---------- 681dnl Write a debug message to config.log, along with the line number in the 682dnl configure script. 683AC_DEFUN([CF_MSG_LOG],[ 684echo "${as_me-configure}:__oline__: testing $* ..." 1>&AC_FD_CC 685])dnl 686dnl --------------------------------------------------------------------------- 687dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05 688dnl ------------------ 689dnl see CF_WITH_NO_LEAKS 690AC_DEFUN([CF_NO_LEAKS_OPTION],[ 691AC_MSG_CHECKING(if you want to use $1 for testing) 692AC_ARG_WITH($1, 693 [$2], 694 [AC_DEFINE($3)ifelse([$4],,[ 695 $4 696]) 697 : ${with_cflags:=-g} 698 : ${with_no_leaks:=yes} 699 with_$1=yes], 700 [with_$1=]) 701AC_MSG_RESULT(${with_$1:-no}) 702 703case .$with_cflags in #(vi 704.*-g*) 705 case .$CFLAGS in #(vi 706 .*-g*) #(vi 707 ;; 708 *) 709 CF_ADD_CFLAGS([-g]) 710 ;; 711 esac 712 ;; 713esac 714])dnl 715dnl --------------------------------------------------------------------------- 716dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42 717dnl ----------------- 718dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed. 719dnl 720dnl POSIX.1-1990 _POSIX_SOURCE 721dnl POSIX.1-1990 and _POSIX_SOURCE and 722dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2 723dnl Bindings Option 724dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L 725dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L 726dnl X/Open 2000 _POSIX_C_SOURCE=200112L 727dnl 728dnl Parameters: 729dnl $1 is the nominal value for _POSIX_C_SOURCE 730AC_DEFUN([CF_POSIX_C_SOURCE], 731[ 732cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1]) 733 734cf_save_CFLAGS="$CFLAGS" 735cf_save_CPPFLAGS="$CPPFLAGS" 736 737CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE) 738CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE) 739 740AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[ 741 CF_MSG_LOG(if the symbol is already defined go no further) 742 AC_TRY_COMPILE([#include <sys/types.h>],[ 743#ifndef _POSIX_C_SOURCE 744make an error 745#endif], 746 [cf_cv_posix_c_source=no], 747 [cf_want_posix_source=no 748 case .$cf_POSIX_C_SOURCE in #(vi 749 .[[12]]??*) #(vi 750 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE" 751 ;; 752 .2) #(vi 753 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE" 754 cf_want_posix_source=yes 755 ;; 756 .*) 757 cf_want_posix_source=yes 758 ;; 759 esac 760 if test "$cf_want_posix_source" = yes ; then 761 AC_TRY_COMPILE([#include <sys/types.h>],[ 762#ifdef _POSIX_SOURCE 763make an error 764#endif],[], 765 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE") 766 fi 767 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE) 768 CFLAGS="$cf_trim_CFLAGS" 769 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source" 770 CF_MSG_LOG(if the second compile does not leave our definition intact error) 771 AC_TRY_COMPILE([#include <sys/types.h>],[ 772#ifndef _POSIX_C_SOURCE 773make an error 774#endif],, 775 [cf_cv_posix_c_source=no]) 776 CFLAGS="$cf_save_CFLAGS" 777 CPPFLAGS="$cf_save_CPPFLAGS" 778 ]) 779]) 780 781if test "$cf_cv_posix_c_source" != no ; then 782 CFLAGS="$cf_trim_CFLAGS" 783 CPPFLAGS="$cf_trim_CPPFLAGS" 784 CF_ADD_CFLAGS($cf_cv_posix_c_source) 785fi 786 787])dnl 788dnl --------------------------------------------------------------------------- 789dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18 790dnl ----------- 791dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX. 792AC_DEFUN([CF_PROG_EXT], 793[ 794AC_REQUIRE([CF_CHECK_CACHE]) 795case $cf_cv_system_name in 796os2*) 797 CFLAGS="$CFLAGS -Zmt" 798 CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__" 799 CXXFLAGS="$CXXFLAGS -Zmt" 800 # autoconf's macro sets -Zexe and suffix both, which conflict:w 801 LDFLAGS="$LDFLAGS -Zmt -Zcrtdll" 802 ac_cv_exeext=.exe 803 ;; 804esac 805 806AC_EXEEXT 807AC_OBJEXT 808 809PROG_EXT="$EXEEXT" 810AC_SUBST(PROG_EXT) 811test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT") 812])dnl 813dnl --------------------------------------------------------------------------- 814dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14 815dnl ------------ 816AC_DEFUN([CF_PROG_LINT], 817[ 818AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint) 819AC_SUBST(LINT_OPTS) 820])dnl 821dnl --------------------------------------------------------------------------- 822dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50 823dnl ---------------- 824dnl Remove all -U and -D options that refer to the given symbol from a list 825dnl of C compiler options. This works around the problem that not all 826dnl compilers process -U and -D options from left-to-right, so a -U option 827dnl cannot be used to cancel the effect of a preceding -D option. 828dnl 829dnl $1 = target (which could be the same as the source variable) 830dnl $2 = source (including '$') 831dnl $3 = symbol to remove 832define([CF_REMOVE_DEFINE], 833[ 834$1=`echo "$2" | \ 835 sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \ 836 -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'` 837])dnl 838dnl --------------------------------------------------------------------------- 839dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59 840dnl -------- 841dnl Make an uppercase version of a variable 842dnl $1=uppercase($2) 843AC_DEFUN([CF_UPPER], 844[ 845$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%` 846])dnl 847dnl --------------------------------------------------------------------------- 848dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12 849dnl ---------- 850dnl Use AC_VERBOSE w/o the warnings 851AC_DEFUN([CF_VERBOSE], 852[test -n "$verbose" && echo " $1" 1>&AC_FD_MSG 853CF_MSG_LOG([$1]) 854])dnl 855dnl --------------------------------------------------------------------------- 856dnl CF_WITH_DBMALLOC version: 6 updated: 2006/12/16 14:24:05 857dnl ---------------- 858dnl Configure-option for dbmalloc. The optional parameter is used to override 859dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests. 860AC_DEFUN([CF_WITH_DBMALLOC],[ 861CF_NO_LEAKS_OPTION(dbmalloc, 862 [ --with-dbmalloc test: use Conor Cahill's dbmalloc library], 863 [USE_DBMALLOC]) 864 865if test "$with_dbmalloc" = yes ; then 866 AC_CHECK_HEADER(dbmalloc.h, 867 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse($1,,[],[,$1]))]) 868fi 869])dnl 870dnl --------------------------------------------------------------------------- 871dnl CF_WITH_DMALLOC version: 6 updated: 2006/12/16 14:24:05 872dnl --------------- 873dnl Configure-option for dmalloc. The optional parameter is used to override 874dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests. 875AC_DEFUN([CF_WITH_DMALLOC],[ 876CF_NO_LEAKS_OPTION(dmalloc, 877 [ --with-dmalloc test: use Gray Watson's dmalloc library], 878 [USE_DMALLOC]) 879 880if test "$with_dmalloc" = yes ; then 881 AC_CHECK_HEADER(dmalloc.h, 882 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse($1,,[],[,$1]))]) 883fi 884])dnl 885dnl --------------------------------------------------------------------------- 886dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21 887dnl ---------------- 888AC_DEFUN([CF_WITH_VALGRIND],[ 889CF_NO_LEAKS_OPTION(valgrind, 890 [ --with-valgrind test: use valgrind], 891 [USE_VALGRIND]) 892])dnl 893dnl --------------------------------------------------------------------------- 894dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34 895dnl ---------------- 896dnl Combine the checks for gcc features into a configure-script option 897dnl 898dnl Parameters: 899dnl $1 - see CF_GCC_WARNINGS 900AC_DEFUN([CF_WITH_WARNINGS], 901[ 902if ( test "$GCC" = yes || test "$GXX" = yes ) 903then 904AC_MSG_CHECKING(if you want to check for gcc warnings) 905AC_ARG_WITH(warnings, 906 [ --with-warnings test: turn on gcc warnings], 907 [cf_opt_with_warnings=$withval], 908 [cf_opt_with_warnings=no]) 909AC_MSG_RESULT($cf_opt_with_warnings) 910if test "$cf_opt_with_warnings" != no ; then 911 CF_GCC_ATTRIBUTES 912 CF_GCC_WARNINGS([$1]) 913fi 914fi 915])dnl 916dnl --------------------------------------------------------------------------- 917dnl CF_XOPEN_SOURCE version: 34 updated: 2010/05/26 05:38:42 918dnl --------------- 919dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions, 920dnl or adapt to the vendor's definitions to get equivalent functionality, 921dnl without losing the common non-POSIX features. 922dnl 923dnl Parameters: 924dnl $1 is the nominal value for _XOPEN_SOURCE 925dnl $2 is the nominal value for _POSIX_C_SOURCE 926AC_DEFUN([CF_XOPEN_SOURCE],[ 927 928cf_XOPEN_SOURCE=ifelse([$1],,500,[$1]) 929cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2]) 930cf_xopen_source= 931 932case $host_os in #(vi 933aix[[456]]*) #(vi 934 cf_xopen_source="-D_ALL_SOURCE" 935 ;; 936darwin[[0-8]].*) #(vi 937 cf_xopen_source="-D_APPLE_C_SOURCE" 938 ;; 939darwin*) #(vi 940 cf_xopen_source="-D_DARWIN_C_SOURCE" 941 ;; 942freebsd*|dragonfly*) #(vi 943 # 5.x headers associate 944 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L 945 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L 946 cf_POSIX_C_SOURCE=200112L 947 cf_XOPEN_SOURCE=600 948 cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" 949 ;; 950hpux11*) #(vi 951 cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500" 952 ;; 953hpux*) #(vi 954 cf_xopen_source="-D_HPUX_SOURCE" 955 ;; 956irix[[56]].*) #(vi 957 cf_xopen_source="-D_SGI_SOURCE" 958 ;; 959linux*|gnu*|mint*|k*bsd*-gnu) #(vi 960 CF_GNU_SOURCE 961 ;; 962mirbsd*) #(vi 963 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h> 964 ;; 965netbsd*) #(vi 966 # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw 967 ;; 968openbsd*) #(vi 969 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw 970 ;; 971osf[[45]]*) #(vi 972 cf_xopen_source="-D_OSF_SOURCE" 973 ;; 974nto-qnx*) #(vi 975 cf_xopen_source="-D_QNX_SOURCE" 976 ;; 977sco*) #(vi 978 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer 979 ;; 980solaris2.1[[0-9]]) #(vi 981 cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" 982 ;; 983solaris2.[[1-9]]) #(vi 984 cf_xopen_source="-D__EXTENSIONS__" 985 ;; 986*) 987 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[ 988 AC_TRY_COMPILE([#include <sys/types.h>],[ 989#ifndef _XOPEN_SOURCE 990make an error 991#endif], 992 [cf_cv_xopen_source=no], 993 [cf_save="$CPPFLAGS" 994 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE" 995 AC_TRY_COMPILE([#include <sys/types.h>],[ 996#ifdef _XOPEN_SOURCE 997make an error 998#endif], 999 [cf_cv_xopen_source=no], 1000 [cf_cv_xopen_source=$cf_XOPEN_SOURCE]) 1001 CPPFLAGS="$cf_save" 1002 ]) 1003]) 1004 if test "$cf_cv_xopen_source" != no ; then 1005 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE) 1006 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE) 1007 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source" 1008 CF_ADD_CFLAGS($cf_temp_xopen_source) 1009 fi 1010 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE) 1011 ;; 1012esac 1013 1014if test -n "$cf_xopen_source" ; then 1015 CF_ADD_CFLAGS($cf_xopen_source) 1016fi 1017]) 1018