1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156
|
# ESO_PROG_CC_FLAG(FLAG, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#-----------------------------------------------------------------
AC_DEFUN([ESO_PROG_CC_FLAG],
[
AC_REQUIRE([AC_PROG_CC])
flag=`echo $1 | sed 'y%.=/+-%___p_%'`
AC_CACHE_CHECK([whether $CC supports -$1],
[eso_cv_prog_cc_$flag],
[
eval "eso_cv_prog_cc_$flag=no"
AC_LANG_PUSH(C)
echo 'int main() { return 0; }' >conftest.$ac_ext
try_compile="`$CC -$1 -c conftest.$ac_ext 2>&1`"
if test -z "$try_compile"; then
try_link="`$CC -$1 -o conftest$ac_exeext \
conftest.$ac_ext 2>&1`"
if test -z "$try_link"; then
eval "eso_cv_prog_cc_$flag=yes"
fi
fi
rm -f conftest*
AC_LANG_POP(C)
])
if eval "test \"`echo '$eso_cv_prog_cc_'$flag`\" = yes"; then
:
$2
else
:
$3
fi
])
# ESO_PROG_CC_ATTRIBUTE(VARIANT1, [VARIANT2], [CODE], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#----------------------------------------------------------------------------------------------
AC_DEFUN([ESO_PROG_CC_ATTRIBUTE],
[
AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))],
AS_TR_SH([eso_cv_prog_cc_attribute_$1]),
[
eso_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])],
[eval "AS_TR_SH([eso_cv_prog_cc_attribute_$1])='yes'"],
[eval "AS_TR_SH([eso_cv_prog_cc_attribute_$1])='no'"])
CFLAGS="$eso_save_CFLAGS"
])
if eval "test x\$AS_TR_SH([eso_cv_prog_cc_attribute_$1]) = xyes"; then
:
$4
else
:
$5
fi
])
# ESO_PROG_CC_ATTRIBUTE_VISIBILITY(ARG, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#--------------------------------------------------------------------------------
AC_DEFUN([ESO_PROG_CC_ATTRIBUTE_VISIBILITY],
[
ESO_PROG_CC_ATTRIBUTE([visibility_$1], [visibility("$1")],
[void __attribute__((visibility("$1"))) $1_function() { }],
[$2], [$3])
])
# ESO_ENABLE_DEBUG(debug=no)
#---------------------------
AC_DEFUN([ESO_ENABLE_DEBUG],
[
AC_REQUIRE([AC_PROG_CC])
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],
[creates debugging code [default=$1]]),
eso_enable_debug=$enableval, eso_enable_debug=$1)
AC_CACHE_CHECK([whether debugging code should be created],
eso_cv_enable_debug,
eso_cv_enable_debug=$eso_enable_debug)
if test x"$eso_cv_enable_debug" = xyes; then
eso_clean_CFLAGS="`echo $CFLAGS | sed -e 's/-O[[0-9]]//g' \
-e 's/-g[[0-9]]//g' \
-e 's/-g[[a-z,A-Z]]* / /g' \
-e 's/-[[Og]]//g'`"
ESO_PROG_CC_FLAG([g3], [CFLAGS="$CFLAGS -g3"])
if test x"$eso_cv_prog_cc_g3" = xyes; then
CFLAGS="-g3"
else
if test x"$ac_cv_prog_cc_g" = xyes; then
CFLAGS="-g"
else
CFLAGS=""
fi
fi
ESO_PROG_CC_FLAG([ggdb], [CFLAGS="$CFLAGS -ggdb"])
ESO_PROG_CC_FLAG([O0], [CFLAGS="$CFLAGS -O0"])
ESO_PROG_CC_FLAG([rdynamic], [CFLAGS="$CFLAGS -rdynamic"])
ESO_PROG_CC_FLAG([Wall], [CFLAGS="$CFLAGS -Wall"])
ESO_PROG_CC_FLAG([W], [CFLAGS="$CFLAGS -W"])
CFLAGS="$CFLAGS $eso_clean_CFLAGS"
ESO_DEBUG_FLAGS="-DESO_ENABLE_DEBUG"
else
ESO_DEBUG_FLAGS="-DNDEBUG"
fi
AC_SUBST(ESO_DEBUG_FLAGS)
])
# ESO_ENABLE_TSAN(tsan=no)
# add option to enable gcc and clangs thread sanitizer, needs sanitized
# libgomp, cpl and esorex to be effective. These can be retrieved from jenkins.
#---------------------------
AC_DEFUN([ESO_ENABLE_TSAN],
[
AC_ARG_ENABLE(tsan,
AS_HELP_STRING([--enable-tsan],
[compiles with thread sanitizer, may need
sanitized libgomp, cpl and esorex to be effective.
[[default=$1]]]),
eso_enable_tsan=$enableval, eso_enable_tsan=$1)
if test x"$eso_enable_tsan" = xyes; then
ESO_PROG_CC_FLAG([fsanitize=thread], [CFLAGS="$CFLAGS -fsanitize=thread"
LDFLAGS="$LDFLAGS -fsanitize=thread"])
fi
])
# ESO_ENABLE_ASAN(asan=no)
# add option to enable gcc and clangs address sanitizer, needs sanitized
# cpl to be effective. This can be retrieved from jenkins.
# Note that valgrind does more than asan, but slower
#---------------------------
AC_DEFUN([ESO_ENABLE_ASAN],
[
AC_ARG_ENABLE(asan,
AS_HELP_STRING([--enable-asan],
[compiles with address sanitizer, may need
sanitized cpl to be effective.
[[default=$1]]]),
eso_enable_asan=$enableval, eso_enable_asan=$1)
if test x"$eso_enable_asan" = xyes; then
ESO_PROG_CC_FLAG([fsanitize=address], [CFLAGS="$CFLAGS -fsanitize=address"
LDFLAGS="$LDFLAGS -fsanitize=address"])
fi
])
# ESO_ENABLE_STRICT(strict=no)
#-----------------------------
AC_DEFUN([ESO_ENABLE_STRICT],
[
AC_REQUIRE([AC_PROG_EGREP])
AC_REQUIRE([AC_PROG_CC])
AC_ARG_ENABLE(strict,
AS_HELP_STRING([--enable-strict],
[compiles with strict compiler options (may not work!) [default=$1]]),
eso_enable_strict=$enableval, eso_enable_strict=$1)
AC_CACHE_CHECK([whether strict compiler options should be used],
eso_cv_enable_strict,
eso_cv_enable_strict=$eso_enable_strict)
if test x"$eso_cv_enable_strict" = xyes; then
eso_enable_strict_std_set=no
if test -n "$CFLAGS"; then
echo $CFLAGS | $EGREP '(\-std=|-ansi)' >/dev/null 2>&1
if test x"$?" = x0; then
eso_enable_strict_std_set=yes
fi
fi
if test x"$eso_enable_strict_std_set" = xno; then
ESO_PROG_CC_FLAG([std=c99], [CFLAGS="$CFLAGS -std=c99"])
fi
ESO_PROG_CC_FLAG([pedantic], [CFLAGS="$CFLAGS -pedantic"])
fi
])
# ESO_ENABLE_PROFILE(profile=no)
#-----------------------------
AC_DEFUN([ESO_ENABLE_PROFILE],
[
AC_REQUIRE([AC_PROG_CC])
AC_ARG_ENABLE(profile,
AS_HELP_STRING([--enable-profile],
[compiles with compiler options necessary for profiling (may not work!) [default=$1]]),
eso_enable_profile=$enableval, eso_enable_profile=$1)
AC_CACHE_CHECK([whether profiling compiler options should be used],
eso_cv_enable_profile,
eso_cv_enable_profile=$eso_enable_profile)
if test x"$eso_cv_enable_profile" = xyes; then
ESO_PROG_CC_FLAG([pg], [CFLAGS="$CFLAGS -pg"])
ESO_PROG_CC_FLAG([g], [CFLAGS="$CFLAGS -g"])
ESO_PROG_CC_FLAG([static-libgcc], [CFLAGS="$CFLAGS -static-libgcc"])
AC_ENABLE_SHARED(no)
AC_ENABLE_STATIC(yes)
fi
])
# ESO_CHECK_DOCTOOLS
#-------------------
AC_DEFUN([ESO_CHECK_DOCTOOLS],
[
AC_ARG_VAR([DOXYGEN], [doxygen command])
AC_PATH_PROG([DOXYGEN], [doxygen])
AC_ARG_VAR([LATEX], [latex command])
AC_PATH_PROG([LATEX], [latex])
if test -z "${DOXYGEN}"; then
DOXYGEN=":"
fi
if test -z "${LATEX}"; then
LATEX=":"
fi
])
# ESO_PROG_AR
#------------
# Checks if ar is in the path
AC_DEFUN([ESO_PROG_AR],
[
AC_CHECK_PROG(AR, ar, ar, NONE)
if test x"$AR" = xNONE; then
AC_MSG_ERROR([Cannot find \'ar\'])
fi
])
# ESO_PROG_PKGCONFIG
#-------------------
# Checks if pkg-config is in the path
AC_DEFUN([ESO_PROG_PKGCONFIG],
[
AC_ARG_VAR([PKGCONFIG], [pkg-config command])
AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config])
])
# ESO_CHECK_EXTRA_LIBS
#---------------------
# Check for non-standard headers and libraries
AC_DEFUN([ESO_CHECK_EXTRA_LIBS],
[
AC_ARG_WITH(extra-includes,
AS_HELP_STRING([--with-extra-includes=DIR],
[adds non standard include paths]),
eso_with_extra_includes=$withval, eso_with_extra_includes=NONE)
AC_ARG_WITH(extra-libs,
AS_HELP_STRING([--with-extra-libs=DIR],
[adds non standard library paths]),
eso_with_extra_libs=$withval, eso_with_extra_libs=NONE)
AC_MSG_CHECKING([for extra includes])
AC_CACHE_VAL([eso_cv_with_extra_includes],
[
eso_cv_with_extra_includes=$eso_with_extra_includes
])
if test x"$eso_cv_with_extra_includes" != xNONE; then
eso_save_IFS=$IFS
IFS=':'
for dir in $eso_cv_with_extra_includes; do
EXTRA_INCLUDES="$EXTRA_INCLUDES -I$dir"
done
IFS=$eso_save_IFS
AC_MSG_RESULT(added)
else
AC_MSG_RESULT(no)
fi
AC_MSG_CHECKING([for extra libs])
AC_CACHE_VAL([eso_cv_with_extra_libs],
[
eso_cv_with_extra_libs=$eso_with_extra_libs
])
if test x"$eso_cv_with_extra_libs" != xNONE; then
eso_save_IFS=$IFS
IFS=':'
for dir in $eso_cv_with_extra_libs; do
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$dir"
done
IFS=$eso_save_IFS
AC_MSG_RESULT(added)
else
AC_MSG_RESULT(no)
fi
])
# ESO_CHECK_THREADS_POSIX
#------------------------
# Check whether the POSIX threads are available. The cached result is
# set to 'yes' if either the compiler supports the '-pthread' flag, or linking
# with the POSIX thread library works, and the header file defining the POSIX
# threads symbols is present. If POSIX threads are not supported, the
# result is set to 'no'. Whether the compiler supports POSIX threads,
# or whether the library, and the header are available is stored in cache
# variables.
AC_DEFUN([ESO_CHECK_THREADS_POSIX],
[
AC_REQUIRE([AC_PROG_CC])
ESO_PROG_CC_FLAG([pthread], [], [])
AC_CHECK_LIB([pthread], [pthread_create],
[eso_threads_have_libpthread=yes],
[eso_threads_have_libpthread=no])
AC_CHECK_HEADER([pthread.h],
[eso_threads_have_pthread_h=yes],
[eso_threads_have_pthread_h=no])
if test x"$eso_threads_have_pthread_h" != xyes; then
eso_threads_posix=no
else
if test x"$eso_threads_have_libpthread" != xyes && \
test x"$eso_cv_prog_cc_pthread" != xyes; then
eso_threads_posix=no
else
eso_threads_posix=yes
fi
fi
# Setup the POSIX thread symbols
if test x"$eso_threads_have_pthread_h" = xyes; then
AC_DEFINE([HAVE_PTHREAD_H], [1],
[Define to 1 if you have <pthread.h>.])
fi
if test x"$eso_threads_posix" = xyes; then
if test x"$eso_cv_prog_cc_pthread" = xyes; then
PTHREAD_CFLAGS="-pthread"
else
PTHREAD_CFLAGS=""
fi
if test x"$eso_threads_have_libpthread" = xyes; then
LIBPTHREAD="-lpthread"
else
LIBPTHREAD=""
fi
fi
AC_CACHE_VAL(eso_cv_threads_posix_header,
eso_cv_threads_posix_header=$eso_threads_have_pthread_h)
AC_CACHE_VAL(eso_cv_threads_posix_lib,
eso_cv_threads_posix_lib=$eso_threads_have_libpthread)
AC_CACHE_VAL(eso_cv_threads_posix_flags,
eso_cv_threads_posix_flags=$eso_cv_prog_cc_pthread)
AC_CACHE_VAL(eso_cv_threads_posix,
eso_cv_threads_posix=$eso_threads_posix)
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(LIBPTHREAD)
])
# ESO_CHECK_FUNC(FUNCTION, INCLUDES, SYMBOL)
#-------------------------------------------
# Checks whether a function is available and declared.
AC_DEFUN([ESO_CHECK_FUNC],
[
AC_LANG_PUSH(C)
AC_CHECK_DECL($1, [], [], [$2])
eso_save_CFLAGS="$CFLAGS"
if test x"$GCC" = xyes; then
CFLAGS="$CFLAGS -pedantic-errors"
fi
AC_CHECK_FUNC($1)
CFLAGS="$eso_save_CFLAGS"
AC_LANG_POP(C)
if test x"$ac_cv_have_decl_$1" = xyes &&
test x"$ac_cv_func_$1" = xyes; then
AC_DEFINE($3)
fi
])
# ESO_FUNC_VSNPRINTF_C99
#-----------------------
# Check whether vsnprintf() has C99 semantics.
AC_DEFUN([ESO_FUNC_VSNPRINTF_C99],
[
AH_TEMPLATE([HAVE_VSNPRINTF_C99],
[Define if you have the C99 `vsnprintf' function.])
AC_CACHE_CHECK([whether vsnprintf has C99 semantics],
[eso_cv_func_vsnprintf_c99],
[
AC_LANG_PUSH(C)
eso_cppflags_save="$CPPFLAGS"
eso_cflags_save="$CFLAGS"
eso_ldflags_save="$LDFLAGS"
eso_libs_save="$LIBS"
if test x$GCC = xyes; then
CFLAGS="$CFLAGS -pedantic-errors"
CPPFLAGS="$CPPFLAGS $CFLAGS"
fi
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
int
doit(char * s, ...)
{
char buffer[32];
va_list args;
int q, r;
va_start(args, s);
q = vsnprintf(NULL, 0, s, args);
r = vsnprintf(buffer, 5, s, args);
va_end(args);
if (q != 7 || r != 7)
exit(1);
exit(0);
}
]],
[[
doit((char*)"1234567");
exit(1);
]])
],
[eso_cv_func_vsnprintf_c99=yes],
[eso_cv_func_vsnprintf_c99=no],
[eso_cv_func_vsnprintf_c99=no])
CPPFLAGS="$eso_cppflags_save"
CFLAGS="$eso_cflags_save"
LDFLAGS="$eso_ldflags_save"
LIBS="$eso_libs_save"
AC_LANG_POP(C)
])
# Note that the default is to be pessimistic in the case of cross compilation.
# If you know that the target has a C99 vsnprintf(), you can get around this
# by setting eso_func_vsnprintf_c99 to yes, as described in the Autoconf
# manual.
if test x$eso_cv_func_vsnprintf_c99 = xyes; then
AC_DEFINE(HAVE_VSNPRINTF_C99)
fi
])
# ESO_CHECK_PRINTF_FORMATS
#-------------------------
# Checks for printf() format peculiarities.
AC_DEFUN([ESO_CHECK_PRINTF_FORMATS],
[
# Check if string format for NULL is `(null)'
AH_TEMPLATE([HAVE_PRINTF_STR_FMT_NULL],
[Define if printf outputs `(null)' when printing NULL using
`%s'])
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <string.h>
]],
[[
char s[128];
sprintf(s, "%s", NULL);
return strncmp(s, "(null)", 6) ? 1 : 0;
]])
],
[eso_have_printf_str_format_null=yes],
[eso_have_printf_str_format_null=no],
[eso_have_printf_str_format_null=no])
if test x$eso_have_printf_str_format_null = xyes; then
AC_DEFINE(HAVE_PRINTF_STR_FMT_NULL)
fi
# Check if pointer format for NULL is `(nil)'
AH_TEMPLATE([HAVE_PRINTF_PTR_FMT_NIL],
[Define if printf outputs `(nil)' when printing NULL using
`%p'])
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <string.h>
]],
[[
char s[128];
sprintf(s, "%p", NULL);
return strncmp(s, "(nil)", 5) ? 1 : 0;
]])
],
[eso_have_printf_ptr_format_nil=yes],
[eso_have_printf_ptr_format_nil=no],
[eso_have_printf_ptr_format_nil=no])
if test x$eso_have_printf_ptr_format_nil = xyes; then
AC_DEFINE(HAVE_PRINTF_PTR_FMT_NIL)
fi
# Check if output for `%p' is the same as `%#x'
AH_TEMPLATE([HAVE_PRINTF_PTR_FMT_ALTERNATE],
[Define if printf format `%p' produces the same output as
`%#x' or `%#lx'])
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <string.h>
]],
[[
char s1[128], s2[128];
sprintf(s1, "%p", s1);
sprintf(s2, "%#x", s1);
return strncmp(s1, s2, 3) ? 1 : 0;
]])
],
[eso_have_printf_ptr_format_alternate=yes],
[eso_have_printf_ptr_format_alternate=no],
[eso_have_printf_ptr_format_alternate=no])
if test x$eso_have_printf_ptr_format_alternate = xyes; then
AC_DEFINE(HAVE_PRINTF_PTR_FMT_ALTERNATE)
fi
# Check if pointers are treated as signed
AH_TEMPLATE([HAVE_PRINTF_PTR_FMT_SIGNED],
[Define if printf treats pointers as signed when using a sign
flag])
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[[
#include <stdio.h>
]],
[[
char s[128];
sprintf(s, "%+p", s);
return s[0] == '+' ? 0 : 1;
]])
],
[eso_have_printf_ptr_format_signed=yes],
[eso_have_printf_ptr_format_signed=no],
[eso_have_printf_ptr_format_signed=no])
if test x$eso_have_printf_ptr_format_signed = xyes; then
AC_DEFINE(HAVE_PRINTF_PTR_FMT_SIGNED)
fi
# Check if default precision for conversion specifier `g' is 1 (as
# required by ISO C) or 6.
AH_TEMPLATE([HAVE_PRINTF_FLT_FMT_G_STD],
[Define if printf default precision for format `g' is 1
(ISO C standard) or 6])
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[[
#include <stdio.h>
]],
[[
char s1[128], s2[128];
int n1, n2;
sprintf(s1, "%g%n", 1.123456, &n1);
sprintf(s2, "%.1g%n", 1.123456, &n2);
return n1 > n2 ? 1 : 0;
]])
],
[eso_have_printf_flt_format_g_std=yes],
[eso_have_printf_flt_format_g_std=no],
[eso_have_printf_flt_format_g_std=no])
if test x$eso_have_printf_flt_format_g_std = xyes; then
AC_DEFINE(HAVE_PRINTF_FLT_FMT_G_STD)
fi
])
# ESO_FUNC_VSNPRINTF
#-------------------
# Checks for vsnprintf and snprintf declaration and function.
AC_DEFUN([ESO_FUNC_VSNPRINTF],
[
eso_compile_snprintf=no
AH_TEMPLATE([HAVE_VSNPRINTF],
[Define if you have the `vsnprintf' function])
ESO_CHECK_FUNC(vsnprintf, [
#include <stdio.h>
#include <stdarg.h>
], HAVE_VSNPRINTF)
if test x$ac_cv_func_vsnprintf = xyes &&
test x$ac_cv_have_decl_vsnprintf = xyes; then
ESO_FUNC_VSNPRINTF_C99
if test x$eso_cv_func_vsnprintf_c99 != xyes; then
eso_compile_snprintf=yes
fi
else
eso_compile_snprintf=yes
fi
if test x$eso_compile_snprintf = xyes; then
if test -n "$LIBTOOL"; then
SNPRINTF=snprintf.lo
else
SNPRINTF=snprintf.$ac_objext
fi
fi
AC_SUBST(SNPRINTF)
# The symbols defined by the following macro are only needed to setup the
# vsnprintf() replacement. May be useless if the vsnprintf implementation
# changes.
ESO_CHECK_PRINTF_FORMATS
AH_TEMPLATE([HAVE_SNPRINTF],
[Define if you have the `snprintf' function])
ESO_CHECK_FUNC(snprintf, [#include <stdio.h>], HAVE_SNPRINTF)
])
# ESO_FUNC_VASPRINTF
#-------------------
# Checks for vasprintf and asprintf declaration and function.
AC_DEFUN([ESO_FUNC_VASPRINTF],
[
AH_TEMPLATE([HAVE_VASPRINTF],
[Define if you have the `vasprintf' function])
ESO_CHECK_FUNC(vasprintf, [
#include <stdio.h>
#include <stdarg.h>
], HAVE_VASPRINTF)
AH_TEMPLATE([HAVE_ASPRINTF],
[Define if you have the `asprintf' function])
ESO_CHECK_FUNC(asprintf, [
#include <stdio.h>
], HAVE_ASPRINTF)
])
# ESO_FUNC_FPATHCONF
#-------------------
# Checks for fpathconf declaration and function.
AC_DEFUN([ESO_FUNC_FPATHCONF],
[
AH_TEMPLATE([HAVE_FPATHCONF],
[Define if you have the `fpathconf' function])
ESO_CHECK_FUNC(fpathconf, [#include <unistd.h>], HAVE_FPATHCONF)
# If we have fpathconf we should also have pathconf, but who knows.
AH_TEMPLATE([HAVE_PATHCONF],
[Define if you have the `pathconf' function])
ESO_CHECK_FUNC(pathconf, [#include <unistd.h>], HAVE_PATHCONF)
])
# ESO_FUNC_SYSCONF
#-----------------
# Checks for sysconf declaration and function.
AC_DEFUN([ESO_FUNC_SYSCONF],
[
AH_TEMPLATE([HAVE_SYSCONF],
[Define if you have the `sysconf' function])
ESO_CHECK_FUNC(sysconf, [#include <unistd.h>], HAVE_SYSCONF)
])
# ESO_FUNC_GETOPT
#----------------
# Checks for GNU getopt_long declaration and function.
AC_DEFUN([ESO_FUNC_GETOPT],
[
AH_TEMPLATE([HAVE_GETOPT_LONG],
[Define if you have the `getopt_long' function])
ESO_CHECK_FUNC(getopt_long, [#include <getopt.h>], HAVE_GETOPT_LONG)
if test x"$ac_cv_func_getopt_long" = xno ||
test x"$eso_cv_have_decl_getopt_long" = xno; then
if test -n "$LIBTOOL"; then
GETOPT="getopt.lo getopt1.lo"
else
GETOPT="getopt.$ac_objext getopt1.$ac_objext"
fi
fi
AC_SUBST(GETOPT)
])
# ESO_FUNC_GETPWUID
#------------------
# Checks for getpwuid declaration and function.
AC_DEFUN([ESO_FUNC_GETPWUID],
[
AH_TEMPLATE([HAVE_GETPWUID],
[Define if you have the `getpwuid' function])
ESO_CHECK_FUNC(getpwuid, [#include <pwd.h>], HAVE_GETPWUID)
])
# ESO_FUNC_GETUID
#----------------
AC_DEFUN([ESO_FUNC_GETUID],
[
AH_TEMPLATE([HAVE_GETUID],
[Define if you have the `getuid' function])
ESO_CHECK_FUNC(getuid, [#include <unistd.h>], HAVE_GETUID)
])
# ESO_FUNC_LSTAT
#---------------
AC_DEFUN([ESO_FUNC_LSTAT],
[
AH_TEMPLATE([HAVE_LSTAT],
[Define if you have the `lstat' function])
ESO_CHECK_FUNC(lstat, [#include <sys/stat.h>], HAVE_LSTAT)
])
# ESO_FUNC_STRDUP
#----------------
AC_DEFUN([ESO_FUNC_STRDUP],
[
AH_TEMPLATE([HAVE_STRDUP],
[Define if you have the `strdup' function])
ESO_CHECK_FUNC(strdup, [#include <string.h>], HAVE_STRDUP)
AH_BOTTOM([
#ifndef HAVE_STRDUP
# define strdup cx_strdup
#endif
])
])
# ESO_FUNC_STPCPY
#----------------
AC_DEFUN([ESO_FUNC_STPCPY],
[
AH_TEMPLATE([HAVE_STPCPY],
[Define if you have the `stpcpy' function])
ESO_CHECK_FUNC(stpcpy, [#include <stpcpy.h>], HAVE_STPCPY)
])
# ESO_FUNC_SYMLINK
#-----------------
AC_DEFUN([ESO_FUNC_SYMLINK],
[
AH_TEMPLATE([HAVE_SYMLINK],
[Define if you have the `symlink' function])
ESO_CHECK_FUNC(symlink, [#include <unistd.h>], HAVE_SYMLINK)
])
# ESO_FUNC_WORDEXP
#-----------------
AC_DEFUN([ESO_FUNC_WORDEXP],
[
AH_TEMPLATE([HAVE_WORDEXP],
[Define if you have the `wordexp' function])
ESO_CHECK_FUNC(wordexp, [#include <wordexp.h>], HAVE_WORDEXP)
])
# ESO_FUNC_GETTIMEOFDAY
#----------------------
AC_DEFUN([ESO_FUNC_GETTIMEOFDAY],
[
AH_TEMPLATE([HAVE_GETTIMEOFDAY],
[Define if you have the `gettimeofday' function])
ESO_CHECK_FUNC(gettimeofday,
[
#include <unistd.h>
#include <sys/time.h>
],
HAVE_GETTIMEOFDAY)
])
# ESO_FUNC_VA_COPY(symbol)
#-------------------------
# Check for an implementation of va_copy(). The argument which must be
# given is the preprocessor symbol that is defined to be either va_copy
# or __va_copy depending on the available function, provided that an
# implementation of va_copy is available at all.
AC_DEFUN([ESO_FUNC_VA_COPY],
[
# Check for all three va_copy possibilities, so we get
# all results in config.log for bug reports.
# Check for availability of va_copy(). This is ISO C. Available with
# gcc since version 3.0.
AC_CACHE_CHECK([for an implementation of va_copy()],
[eso_cv_have_va_copy],
[
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[[
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
void f(int i, ...)
{
va_list args1, args2;
va_start (args1, i);
va_copy (args2, args1);
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
exit (1);
va_end (args1);
va_end (args2);
}
]],
[[
f(0, 42);
]])
],
[eso_cv_have_va_copy=yes],
[eso_cv_have_va_copy=no],
[eso_cv_have_va_copy=no])
])
# Check for availability of __va_copy(). Some compilers provide
# this. Available with gcc since version 2.8.1.
AC_CACHE_CHECK([for an implementation of __va_copy()],
[eso_cv_have__va_copy],
[
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[[
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
void f(int i, ...)
{
va_list args1, args2;
va_start (args1, i);
__va_copy (args2, args1);
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
exit (1);
va_end (args1);
va_end (args2);
}
]],
[[
f(0, 42);
]])
],
[eso_cv_have__va_copy=yes],
[eso_cv_have__va_copy=no],
[eso_cv_have__va_copy=no])
])
AH_TEMPLATE([HAVE_VA_COPY],
[Define if you have an implementation of `va_copy()'.])
AH_TEMPLATE([HAVE___VA_COPY],
[Define if you have an implementation of `__va_copy()'.])
if test "x$eso_cv_have_va_copy" = "xyes"; then
eso_func_va_copy=va_copy
AC_DEFINE(HAVE_VA_COPY)
else
if test "x$eso_cv_have__va_copy" = "xyes"; then
eso_func_va_copy=__va_copy
AC_DEFINE(HAVE___VA_COPY)
fi
fi
AH_TEMPLATE([HAVE_VA_COPY_STYLE_FUNCTION],
[Define if you have an implementation of a `va_copy()' style
function.])
AH_TEMPLATE([$1], [A `va_copy()' style function])
if test -n "$eso_func_va_copy"; then
AC_DEFINE_UNQUOTED([$1], $eso_func_va_copy)
AC_DEFINE(HAVE_VA_COPY_STYLE_FUNCTION)
fi
# Check whether va_lists can be copied by value
AC_CACHE_CHECK([whether va_lists can be copied by value],
[eso_cv_have_va_value_copy],
[
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[[
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
void f(int i, ...)
{
va_list args1, args2;
va_start (args1, i);
args2 = args1;
if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
exit (1);
va_end (args1);
va_end (args2);
}
]],
[[
f(0, 42);
]])
],
[eso_cv_have_va_value_copy=yes],
[eso_cv_have_va_value_copy=no],
[eso_cv_have_va_value_copy=no])
])
AH_TEMPLATE([HAVE_VA_LIST_COPY_BY_VALUE],
[Define if `va_lists' can be copied by value])
if test "x$eso_cv_have_va_value_copy" = "xyes"; then
AC_DEFINE(HAVE_VA_LIST_COPY_BY_VALUE)
fi
])
# ESO_FUNC_REALLOC_SANITY
#-------------------------
# Check whether realloc(NULL,) works.
AC_DEFUN([ESO_FUNC_REALLOC_SANITY],
[
AC_CACHE_CHECK([whether realloc(NULL,) works],
[eso_cv_have_sane_realloc],
[
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[[
#include <stdlib.h>
]],
[[
return realloc (0, sizeof (int)) == 0;
]])
],
[eso_cv_have_sane_realloc=yes],
[eso_cv_have_sane_realloc=no],
[eso_cv_have_sane_realloc=no])
])
AH_TEMPLATE([HAVE_WORKING_REALLOC],
[Define if realloc(NULL,) works])
if test x$eso_cv_have_sane_realloc = xyes; then
AC_DEFINE(HAVE_WORKING_REALLOC)
fi
])
# ESO_FIND_FILE(file, directories, variable)
#------------------------------------------
# Search for file in directories. Set variable to the first location
# where file was found, if file is not found at all variable is set to NO.
AC_DEFUN([ESO_FIND_FILE],
[
$3=no
for i in $2; do
for j in $1; do
echo "configure: __oline__: $i/$j" >&AC_FD_CC
if test -r "$i/$j"; then
echo "taking that" >&AC_FD_CC
$3=$i
break 2
fi
done
done
])
# ESO_SET_LIBRARY_VERSION([CURRENT], [REVISION], [AGE])
#------------------------------------------------------
# Sets the libtool versioning symbols LT_CURRENT, LT_REVISION, LT_AGE.
AC_DEFUN([ESO_SET_LIBRARY_VERSION],
[
if test -z "$1"; then
LT_CURRENT=0
else
LT_CURRENT="$1"
fi
if test -z "$2"; then
LT_REVISION=0
else
LT_REVISION="$2"
fi
if test -z "$3"; then
LT_AGE=0
else
LT_AGE="$3"
fi
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)
])
|