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 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234
|
# configure.ac - Process with autoconf to produce a configure script
#
# 2012, Jonathan Toppins <jtoppins@users.sourceforge.net>
# 2017-2024 Reini Urban <rurban@cpan.org>
#
# Copyright (c) 2012, 2013 Cisco Systems
# Copyright (c) 2017-2024 Reini Urban
# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# -*- Autoconf -*-
# Autoconf requirements
AC_PREREQ([2.69])
# information on the package
AC_INIT([Safe C Library],
[m4_esyscmd(build-aux/version-gen.sh .tarball-version)],
[https://github.com/rurban/safeclib/issues],
[safeclib],
[http://github.com/rurban/safeclib/])
# Configure the configure script
# ===============================================
# unique source file --- primitive safety check
AC_CONFIG_SRCDIR([src/abort_handler_s.c])
# extra autoconf macros are kept here
AC_CONFIG_MACRO_DIR([m4])
# place to put some extra build scripts
AC_CONFIG_AUX_DIR([build-aux])
# Other tool initializations
# ===============================================
# really severe build strictness also place generated object files (.o)
# into the same directory as their source files, in order to avoid
# collisions when non-recursive make is used.
AM_INIT_AUTOMAKE([1.10 no-define foreign subdir-objects dist-bzip2 dist-xz])
# Check if automake supports 'pretty' builds, if so enable them by default
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# this is missing with mingw 1.0
# m4_pattern_allow([AM_PROG_AR])
# AM_PROG_AR
AC_CHECK_TOOLS([AR], [gcc-ar ar])
AC_CHECK_TOOLS([RANLIB], [gcc-ranlib ranlib])
AC_CHECK_TOOLS([NM], [gcc-nm nm])
# Enable LibTool as we are building a library
#LT_PREREQ([2.2.6]) # TODO: don't really know what to put here so leave
# it out for now
LT_INIT
# Initialize pkg-config since we are installing a .pc file
PKG_INSTALLDIR
# Global Variable & Defaults
# ===============================================
# Keep this in sync with what is passed in AC_INIT
TARBALL_VERSION_FILE=".tarball-version"
# Initial values for automake variables AM_*
AM_CPPFLAGS="-I\$(top_srcdir)/include"
dnl we manually export the symbols via dllexport, we only use shared
dnl no libtool -DDLL_EXPORT support yet
dnl case $host_os in
dnl mingw*|msys*)
dnl AC_MSG_NOTICE([--disable-static on mingw])
dnl lt_prog_compiler_static=
dnl enable_static=no
dnl ;;
dnl esac
ISODATE=`date +%Y-%m-%d`
AC_SUBST(ISODATE)
AC_CANONICAL_HOST
# Configure options
# ===============================================
# User switches
AC_ARG_ENABLE(gcov,
AS_HELP_STRING([--enable-gcov],
[turn on test coverage @<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_gcov=true ; gcov=gcov ;;
no) enable_gcov=false ;;
*) enable_gcov=true ; gcov="${enableval}" ;;
esac], [enable_gcov=false ])
AC_MSG_CHECKING([for --enable-gcov])
if test "$enable_gcov" = "true" ; then
dnl if test "$GCC" = yes; then
dnl AC_MSG_ERROR([gcov only works if gcc is used])
dnl fi
dnl You might need the compiler-specific gcov: e.g. gcov-mp-6
GCOV="$gcov"
AC_MSG_RESULT([gcov=$gcov])
AC_SUBST(GCOV)
GCOV_CFLAGS="-fprofile-arcs -ftest-coverage"
AC_SUBST(GCOV_CFLAGS)
dnl libtool 1.5.22 and lower strip -fprofile-arcs from the flags
dnl passed to the linker, which is a bug; -fprofile-arcs implicitly
dnl links in -lgcov, so we do it explicitly here for the same effect
GCOV_LIBS=-lgcov
AC_SUBST(GCOV_LIBS)
else
AC_MSG_RESULT([no (default)])
fi
AM_CONDITIONAL(ENABLE_GCOV, test "$enable_gcov" = "true")
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug],
[compile library w/ debugging symbols (-g)
@<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_debug=true ;;
no) enable_debug=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac], [enable_debug=false ])
AC_MSG_CHECKING([for --enable-debug])
if test "$enable_debug" = "true" ; then
if test "$enable_gcov" = "true" ; then
DEBUG_CFLAGS="-g"
else
DEBUG_CFLAGS="-g -O2"
fi
if test "$(uname -o)" = "Darwin" -a "$cross_compiling" = "no"; then
enable_shared=no
enable_shared_with_static_runtimes=no
fi
AC_MSG_RESULT([yes CFLAGS = $DEBUG_CFLAGS])
AM_CPPFLAGS="${AM_CPPFLAGS} -DDEBUG"
else
if test "$enable_gcov" = "true"; then
DEBUG_CFLAGS="-g"
else
# default release optimization
DEBUG_CFLAGS="-O2"
if test "$GCC" = "yes"; then
DEBUG_CFLAGS="-O2 -D_FORTIFY_SOURCE=2"
fi
fi
AC_MSG_RESULT([no CFLAGS = $DEBUG_CFLAGS])
fi
if test "$CFLAGS" = "-g -O2" -o "$CFLAGS" = "-g"; then
# by doing it this way we suppress automake's assumption that if
# CFLAGS is empty lets compile the code with '-g -O2'.
CFLAGS="${DEBUG_CFLAGS}"
else
AC_MSG_WARN([CFLAGS is not empty, will attempt to apply optimization
flags to 'AM_CFLAGS' but depending on the contents of
CFLAGS these may be overridden.
CFLAGS = '$CFLAGS'])
fi
AM_CONDITIONAL(ENABLE_DEBUG, test "$enable_debug" = "true")
AC_ARG_ENABLE(extensions,
AS_HELP_STRING([--disable-extensions],
[This library contains additional functions not defined
in the C11 specification. Disable to omit these.
@<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_extensions=true ;;
no) enable_extensions=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --disable-extensions]) ;;
esac], [enable_extensions=true])
AC_MSG_CHECKING([for --disable-extensions])
if test "$enable_extensions" = "false" ; then
AC_MSG_RESULT([yes])
INSERT_EXTS="#define SAFECLIB_DISABLE_EXTENSIONS 1"
else
AC_MSG_RESULT([no (default)])
INSERT_EXTS="#undef SAFECLIB_DISABLE_EXTENSIONS"
fi
# AC_DEFINE([SAFECLIB_DISABLE_EXTENSIONS], 1,
# [Define to 1 to disable additional functions not defined
# in the C11 appendix K specification])
AC_SUBST(INSERT_EXTS)
AM_CONDITIONAL(ENABLE_EXTS, test "$enable_extensions" = "true")
AC_ARG_ENABLE(float,
AS_HELP_STRING([--disable-float],
[Disable float support in the printf funcstions.
@<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_float=true ;;
no) enable_float=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --disable-float]) ;;
esac], [enable_float=true])
AC_MSG_CHECKING([for --disable-float])
if test "$enable_float" = "false" ; then
AC_MSG_RESULT([yes])
AC_DEFINE([PRINTF_DISABLE_SUPPORT_FLOAT], 1,
[Defined to 1 to disable float support in the printf functions])
else
AC_MSG_RESULT([no (default)])
fi
AC_ARG_ENABLE(float-exp,
AS_HELP_STRING([--disable-float-exp],
[Disable exponential floating point notation (%e/%g) in the printf funcstions.
@<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_float_exp=true ;;
no) enable_float_exp=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --disable-float-exp]) ;;
esac], [enable_float_exp=true])
AC_MSG_CHECKING([for --disable-float_exp])
if test "$enable_float_exp" = "false" ; then
AC_MSG_RESULT([yes])
AC_DEFINE([PRINTF_DISABLE_SUPPORT_EXPONENTIAL], 1,
[Defined to 1 to disable exponential floating point notation (%e/%g) in the printf functions])
else
AC_MSG_RESULT([no (default)])
fi
AC_ARG_ENABLE(long-long,
AS_HELP_STRING([--disable-long-long],
[Disable exponential floating point notation (%e/%g) in the printf funcstions.
@<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_long_long=true ;;
no) enable_long_long=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --disable-long-long]) ;;
esac], [enable_long_long=true])
AC_MSG_CHECKING([for --disable-long-long])
if test "$enable_long_long" = "false" ; then
AC_MSG_RESULT([yes])
AC_DEFINE([PRINTF_DISABLE_SUPPORT_LONG_LONG], 1,
[Defined to 1 to disable long long types (%llu/%p) in the printf functions])
else
AC_MSG_RESULT([no (default)])
fi
AC_ARG_ENABLE(long-double,
AS_HELP_STRING([--disable-long-double],
[Disable exponential floating point notation (%e/%g) in the printf funcstions.
@<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_long_double=true ;;
no) enable_long_double=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --disable-long-double]) ;;
esac], [enable_long_double=true])
AC_MSG_CHECKING([for --disable-long-double])
if test "$enable_long_double" = "false" ; then
AC_MSG_RESULT([yes])
AC_DEFINE([PRINTF_DISABLE_SUPPORT_LONG_DOUBLE], 1,
[Defined to 1 to disable long double types (%Lf/%Le/%Lg/%La) in the printf functions])
else
AC_MSG_RESULT([no (default)])
fi
AC_ARG_ENABLE(printf-ptrdiff,
AS_HELP_STRING([--disable-printf-ptrdiff],
[Disable exponential floating point notation (%e/%g) in the printf funcstions.
@<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_printf_ptrdiff=true ;;
no) enable_printf_ptrdiff=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --disable-printf-ptrdiff]) ;;
esac], [enable_printf_ptrdiff=true])
AC_MSG_CHECKING([for --disable-printf-ptrdiff])
if test "$enable_printf_ptrdiff" = "false" ; then
AC_MSG_RESULT([yes])
AC_DEFINE([PRINTF_DISABLE_SUPPORT_PTRDIFF_T], 1,
[Defined to 1 to disable ptrdiff_t type (%t) in the printf functions])
else
AC_MSG_RESULT([no (default)])
fi
AC_ARG_ENABLE(memmax,
AS_HELP_STRING([--enable-memmax],
[specify the largest object size allowed for the
mem* functions @<:@default=256MB@:>@]),
[case "${enableval}" in
@<:@0-9@:>@*) enable_memmax=${enableval} ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-memmax]) ;;
esac], [enable_memmax="(256UL << 20) /* 256MB */" ])
AC_MSG_CHECKING([for --enable-memmax])
AC_MSG_RESULT([$enable_memmax])
# AC_DEFINE([RSIZE_MAX_MEM], [ $enable_memmax ],
# [Maximum object size the mem* functions will allow,
# default is 256MB])
RSIZE_MAX_MEM=$enable_memmax
AC_SUBST(RSIZE_MAX_MEM)
AC_ARG_ENABLE(strmax,
AS_HELP_STRING([--enable-strmax],
[specify the largest object size allowed for the
str* functions @<:@default=4KB@:>@]),
[case "${enableval}" in
@<:@0-9@:>@*) enable_strmax=${enableval} ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-strmax]) ;;
esac], [enable_strmax="(4UL << 10) /* 4KB */" ])
AC_MSG_CHECKING([for --enable-strmax])
AC_MSG_RESULT([$enable_strmax])
RSIZE_MAX_STR=$enable_strmax
AC_SUBST(RSIZE_MAX_STR)
AC_ARG_ENABLE(nullslack,
AS_HELP_STRING([--disable-nullslack],
[Do not null out the remaining part of a string if it is
not completely used @<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_nullslack=true ;;
no) enable_nullslack=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --disable-nullslack]) ;;
esac], [enable_nullslack=true ])
AC_MSG_CHECKING([for --disable-nullslack])
if test "$enable_nullslack" = "true" ; then
AC_MSG_RESULT([no (default)])
INSERT_NULLSLACK="#define SAFECLIB_STR_NULL_SLACK 1"
# AC_DEFINE([SAFECLIB_STR_NULL_SLACK], 1,
# [Define to 1 to null out the remaining part of a string
# buffer if it is not completely used])
else
AC_MSG_RESULT([yes])
INSERT_NULLSLACK="#undef SAFECLIB_STR_NULL_SLACK"
fi
AC_SUBST(INSERT_NULLSLACK)
AC_ARG_ENABLE(constraint-handler,
AS_HELP_STRING([--disable-constraint-handler],
[Disable C11 invoke_safe_{str,mem}_constraint_handler
for performance, smaller size and less flexibility.
@<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_constraint_handler=true ;;
no) enable_constraint_handler=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --disable-constraint-handler]) ;;
esac], [enable_constraint_handler=true])
AC_MSG_CHECKING([for --disable-constraint-handler])
if test "$enable_constraint_handler" = "false" ; then
AC_MSG_RESULT([yes])
INSERT_CONSTRAINT_HANDLER="#define SAFECLIB_DISABLE_CONSTRAINT_HANDLER 1"
else
AC_MSG_RESULT([no (default)])
INSERT_CONSTRAINT_HANDLER="#undef SAFECLIB_DISABLE_CONSTRAINT_HANDLER"
fi
AC_SUBST(INSERT_CONSTRAINT_HANDLER)
AC_ARG_ENABLE(unsafe,
AS_HELP_STRING([--enable-unsafe],
[Include unsafe std C11 functions: tmpnam_s @<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_unsafe=true ;;
no) enable_unsafe=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-unsafe]) ;;
esac], [enable_unsafe=no ])
AC_MSG_CHECKING([for --enable-unsafe])
if test "$enable_unsafe" = "true" ; then
AC_MSG_RESULT([yes])
INSERT_UNSAFE="#define SAFECLIB_ENABLE_UNSAFE 1"
else
AC_MSG_RESULT([no])
INSERT_UNSAFE="#undef SAFECLIB_ENABLE_UNSAFE"
fi
AC_SUBST(INSERT_UNSAFE)
AM_CONDITIONAL([ENABLE_UNSAFE], test "$enable_unsafe" = "true")
AC_ARG_ENABLE(norm-compat,
AS_HELP_STRING([--enable-norm-compat],
[Enable NFKC and NFKD modes for wcsnorm. @<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_norm_compat=true ;;
no) enable_norm_compat=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-norm-compat]) ;;
esac], [enable_norm_compat=false ])
AC_MSG_CHECKING([for --enable-norm-compat])
if test "$enable_norm_compat" = "true" ; then
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_NORM_COMPAT], 1,
[Define to 1 to enable the compat normalization modes for wcsnorm_s
NFKC and NFKD])
else
AC_MSG_RESULT([no (default)])
fi
AC_ARG_ENABLE(warn-dmax,
AS_HELP_STRING([--enable-warn-dmax],
[Enable dmax checks against __builtin_object_size(dest). @<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_warn_dmax=true ;;
no) enable_warn_dmax=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-warn-dmax]) ;;
esac], [enable_warn_dmax=false ])
AC_MSG_CHECKING([for --enable-warn-dmax])
if test "$enable_warn_dmax" = "true" ; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no (default)])
fi
AC_ARG_ENABLE(error-dmax,
AS_HELP_STRING([--enable-error-dmax],
[Make --enable-warn-dmax fatal. @<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_error_dmax=true ;;
no) enable_error_dmax=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-error-dmax]) ;;
esac], [enable_error_dmax=false ])
AC_MSG_CHECKING([for --enable-error-dmax])
if test "$enable_error_dmax" = "true" ; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no (default)])
fi
AC_ARG_WITH(default-handler,
AS_HELP_STRING([--with-default-handler=<ignore|abort>],
[enforce compile-time default-handler]),
[case "${withval}" in
ignore) default_handler=ignore ;;
abort) default_handler=abort ;;
*) AC_MSG_ERROR([bad value ${withval} for --with-default-handler=]) ;;
esac], [])
AC_MSG_CHECKING([for --with-default-handler])
if test -n "$default_handler" ; then
AC_MSG_RESULT([$default_handler])
INSERT_DEFAULT_HANDLER="#define SAFECLIB_DEFAULT_HANDLER ${default_handler}_handler_s"
else
AC_MSG_RESULT([no (default)])
INSERT_DEFAULT_HANDLER="#undef SAFECLIB_DEFAULT_HANDLER"
fi
AC_SUBST(INSERT_DEFAULT_HANDLER)
AC_ARG_ENABLE(doc,
AS_HELP_STRING([--disable-doc],
[disable documentation @<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_doc=true ;;
no) enable_doc=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-doc]) ;;
esac], [enable_doc=true])
AM_CONDITIONAL(ENABLE_DOC, test "$enable_doc" = "true")
dnl for windows dllimport. checking pic_flag DLL_EXPORT would be better,
dnl but this is only enabled for the shared objs, and we need it in the config
dnl for our tests.
if test "$enable_shared" = "no" ; then
INSERT_DISABLE_DLLIMPORT="#define DISABLE_DLLIMPORT 1"
else
INSERT_DISABLE_DLLIMPORT="#undef DISABLE_DLLIMPORT"
fi
AC_SUBST(INSERT_DISABLE_DLLIMPORT)
# Maintainer switches
AC_ARG_ENABLE(debug-build,
AS_HELP_STRING([--enable-debug-build],
[turn on build debugging, generally is not needed
unless you are the maintainer @<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_debug_build=true ;;
no) enable_debug_build=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug-build]) ;;
esac], [enable_debug_build=false ])
AM_CONDITIONAL(ENABLE_DEBUG_BUILD, test "$enable_debug_build" = "true")
AC_ARG_ENABLE(hardening,
AS_HELP_STRING([--disable-hardening],
[disable hardening @<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_hardening=true ;;
no) enable_hardening=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-hardening]) ;;
esac], [enable_hardening=true])
AC_MSG_NOTICE([Check programs])
# ===============================================
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AM_PROG_CC_C_O
#AC_PROG_CC_C99
#AC_PROG_CC_C11
if test "$ac_cv_prog_cc_c99" = "no"; then
dnl we really should ERROR, lets see how far can come without
AC_MSG_WARN([This compiler ${CC} has no c99 support])
INSERT_SAFECLIB_HAVE_C99="#undef SAFECLIB_HAVE_C99"
else
AC_DEFINE([SAFECLIB_HAVE_C99], 1,
[Defined to 1 when the compiler supports c99, mostly (...) macros])
if test "$ac_cv_prog_cc_c99" != ""; then
AC_MSG_RESULT([added $ac_cv_prog_cc_c99 to CFLAGS])
AM_CFLAGS="$AM_CFLAGS $ac_cv_prog_cc_c99"
fi
INSERT_SAFECLIB_HAVE_C99="#define SAFECLIB_HAVE_C99 1"
fi
dnl AM_CONDITIONAL([SAFECLIB_HAVE_C99], [test "$ac_cv_prog_cc_c99=no" != "no"])
AC_SUBST(SAFECLIB_HAVE_C99)
AC_SUBST(INSERT_SAFECLIB_HAVE_C99)
if test "$ac_cv_prog_cc_c11" != "no"; then
AC_DEFINE([HAVE_C11], 1,
[Defined to 1 when the compiler supports c11])
if test "$ac_cv_prog_cc_c11" != ""; then
AC_MSG_RESULT([added $ac_cv_prog_cc_c11 to CFLAGS])
AM_CFLAGS="$AM_CFLAGS $ac_cv_prog_cc_c11"
fi
fi
AC_SUBST(HAVE_C11)
dnl c++ needs less warnings
if test -z $ax_compiler_cxx; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
[#ifndef __cplusplus
#error "no C++"
#endif]])],
[ax_compiler_cxx=yes;],
[ax_compiler_cxx=no;])
fi
if test "$ax_compiler_cxx" = "yes" ; then
AC_DEFINE([HAVE_CXX], 1,
[Defined to 1 when the compiler is C++])
dnl ax_cv_check_cflags__Wnested_externs=no
dnl ax_cv_check_cflags__Wmissing_prototypes=no
dnl ax_cv_check_cflags__Wstrict_prototypes=no
dnl ax_cv_check_cflags__Wimplicit_function_declaration=no
dnl ax_cv_check_cflags__Wdeclaration_after_statement=no
dnl ax_cv_check_cflags__Wold_style_definition=no
dnl ax_cv_check_cflags__Wjump_misses_init=no
fi
dnl we still have some empty src files
ax_cv_check_ldflags___Wl___fatal_warnings=no
ax_cv_check_ldflags___Wl__fatal_warnings=no
dnl sprintf_s passing through to vsnprintf_s
ax_cv_check_cflags__Wformat_2=no
ax_cv_check_cflags__Wformat_nonliteral=no
dnl windows mult. decl are not properly sorted out yet
dnl const -Wdiscarded-qualifiers is stricter on mingw
case $host_os in
mingw*|cygwin*|msys*)
ax_cv_check_cflags__Wredundant_decls=no
ax_enable_compile_warnings=yes
;;
esac
dnl gcc 4.2 fails with -Wmissing-format-attribute
dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28492
if test "$GCC" != "" ; then
AC_MSG_CHECKING([for -Wmissing-format-attribute usability])
old_cflags="$CFLAGS"
CFLAGS="-Wmissing-format-attribute -Werror"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[
#include <stdio.h>
#include <stdarg.h>
void myvsprintf(char *dest, const char *fmt, va_list ap);
int mysprintf(char *dest, const char *fmt, ...);
int myvsprintf(char *dest, const char *fmt, va_list ap) {
return vsprintf(dest, fmt, ap);
}
int mysprintf(char *dest, const char *fmt, ...) {
va_list ap;
int ret;
va_start(ap, fmt);
ret = myvsprintf(dest, fmt, ap);
va_end(ap);
return ret;
}
]],[[
const char* fmt = "%s";
char dest[12];
return mysprintf(dest, fmt) ? 0: 1;
]]
)],
[ AC_MSG_RESULT([yes])],
[ AC_MSG_RESULT([no])
ax_cv_check_cflags__Winline=no
ax_cv_check_cflags__Wmissing_format_attribute=no
],
[ AC_MSG_RESULT([no (cross)])
ax_cv_check_cflags__Winline=no
ax_cv_check_cflags__Wmissing_format_attribute=no
])
CFLAGS="$old_cflags"
fi
AX_COMPILER_FLAGS
case $host_os in
mingw*|cygwin*)
WARN_CFLAGS="-Wall -Wextra"
;;
esac
dnl older non-c99 g++ complain about __VA_ARGS__, for();
if test "$ac_cv_prog_cc_c99" = "no" -a "$ax_compiler_cxx" = "yes"; then
WARN_CFLAGS=`echo $WARN_CFLAGS | sed -e"s,-Werror ,,"`
fi
AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],
[ax_ccf_err="-Werror=unknown-warning-option"],[ax_ccf_err=""])
# Try Intel's libmpx dynamic pointer bounds checker,
# available for gcc-5+ and icc-15.0+, but disabled on gcc by default. --enable-libmpx
# https://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler
# and https://intel-mpx.github.io/design/
# See also https://github.com/google/sanitizers/wiki/AddressSanitizerIntelMemoryProtectionExtensions
dnl gcc: slows down the optimizer with gcc-5.0. 5.3 should be better.
dnl AX_CHECK_COMPILE_FLAG([-fcheck-pointer-bounds -mmpx],
dnl [CFLAGS="$CFLAGS -fcheck-pointer-bounds -mmpx" LDFLAGS="$LDFLAGS -lmpx -lmpxwrappers"],
dnl [],[$ax_ccf_err])
#AX_APPEND_COMPILE_FLAGS(["-fcheck-pointer-bounds -mmpx"],
# [CFLAGS],[$ax_ccf_err])
dnl icc:
if test "$ac_compiler_gnu" = "no" -a -n "$ax_ccf_err"; then
AX_CHECK_COMPILE_FLAG([-check-pointers-mpx=rw],
[CFLAGS="$CFLAGS -check-pointers-mpx=rw" LIBS="$LIBS -lmpx -lchkp"],
[],[$ax_ccf_err])
#AX_APPEND_COMPILE_FLAGS(["-check-pointers-mpx=rw"],
# [CFLAGS],[$ax_ccf_err])
fi
dnl windows mult. decl are not properly sorted out yet
case $host_os in
mingw*|cygwin*|msys*)
dnl gcc 3.4 cannot do -Wno-attributes
AX_APPEND_COMPILE_FLAGS([-Wno-attributes -Wno-discarded-qualifiers],
[WARN_CFLAGS],[$ax_ccf_err])
dnl AM_LDFLAGS=`echo $AM_LDFLAGS|sed -e"s/-Wl,--as-needed -Wl,--no-as-needed//"`
dnl x86 needs that for _mm_mfence
AX_CHECK_COMPILE_FLAG([-msse2],
[CFLAGS="$CFLAGS -msse2" LDFLAGS="$LDFLAGS -msse2"],
[],[$ax_ccf_err])
;;
esac
if test "$enable_hardening" = "true" ; then
AX_APPEND_COMPILE_FLAGS(
[-fstack-protector-strong -fstack-clash-protection -fcf-protection \
-fno-strict-aliasing -fno-strict-overflow -fno-delete-null-pointer-checks \
-fno-lifetime-dse],
[WARN_CFLAGS],[$ax_ccf_err])
AX_APPEND_LINK_FLAGS(
[-fstack-protector-strong -fstack-clash-protection -fcf-protection],
[WARN_LDFLAGS],[$ax_ccf_err])
fi
if test $ax_cv_check_cflags__Wrestrict = yes; then
AC_DEFINE([HAVE_WARNING_RESTRICT], 1, [Have -Wrestrict])
fi
PEDANTIC="-pedantic"
WARN_CFLAGS_TEST="-Wall -Wextra"
if test $ac_compiler_gnu = no; then
AX_CHECK_COMPILE_FLAG([-pedantic],
[PEDANTIC="-pedantic"],
[PEDANTIC=""
WARN_CFLAGS_TEST=""],[$ax_ccf_err])
AX_CHECK_COMPILE_FLAG([-Werror],
[],
[WARN_CFLAGS=""
WARN_CFLAGS_TEST=""],[$ax_ccf_err])
fi
AC_SUBST(PEDANTIC, $PEDANTIC)
AX_GCC_BUILTIN(__builtin_object_size)
dnl against -Werror,-Wgcc-compat fortify errors, only on clang
INSERT_OBJECT_SIZE="#undef HAVE___BUILTIN_OBJECT_SIZE"
INSERT_WARN_DMAX="#undef HAVE_WARN_DMAX"
INSERT_ERROR_DMAX="#undef HAVE_ERROR_DMAX"
if test $ax_cv_have___builtin_object_size = yes; then
AX_CHECK_COMPILE_FLAG([-Wuser-defined-warnings],
[have_user_defined_warnings="yes"],[have_user_defined_warnings="no"])
AX_CHECK_COMPILE_FLAG([$ax_ccf_err -Wgcc-compat],
[WARN_CFLAGS="$WARN_CFLAGS -Wno-gcc-compat"],[])
if test $have_user_defined_warnings = yes; then
AX_APPEND_COMPILE_FLAGS([-Wno-error=user-defined-warnings],
[WARN_CFLAGS],[$ax_ccf_err])
AC_DEFINE([HAVE_USER_DEFINED_WARNINGS], 1, [Uses -Wuser-defined-warnings])
fi
INSERT_OBJECT_SIZE="# define HAVE___BUILTIN_OBJECT_SIZE 1"
if test "$enable_warn_dmax" = "true" ; then
INSERT_WARN_DMAX="# define HAVE_WARN_DMAX 1"
fi
if test "$enable_error_dmax" = "true" ; then
INSERT_WARN_DMAX="#define HAVE_WARN_DMAX 1"
INSERT_ERROR_DMAX="#define HAVE_ERROR_DMAX 1"
fi
else
if test "$enable_warn_dmax" = "true" ; then
AC_MSG_RESULT([warn-dmax ignored, no __builtin_object_size])
fi
fi
AC_SUBST(INSERT_OBJECT_SIZE)
AC_SUBST(INSERT_WARN_DMAX)
AC_SUBST(INSERT_ERROR_DMAX)
AC_MSG_CHECKING([for diagnose_if attribute])
old_cflags="$CFLAGS"
CFLAGS="-Werror"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[
#include <stdio.h>
int myfunc(char *ptr)
__attribute__((diagnose_if(!ptr, "empty ptr", "error")));
int myfunc(char *ptr) {
return ptr ? 1 : 0;
}
]],[[
char dest[12];
return myfunc(dest);
]]
)],
[ AC_MSG_RESULT([yes])
have_attribute_diagnose_if=yes
WARN_CFLAGS_TESTS="$WARN_CFLAGS_TESTS -Wno-gcc-compat"
AC_DEFINE([HAVE_ATTRIBUTE_DIAGNOSE_IF], 1,
[Defined to 1 when the compiler supports attribute diagnose_if, since clang-5])
],
[ AC_MSG_RESULT([no])
have_attribute_diagnose_if=no
],
[ AC_MSG_RESULT([no (cross)])
have_attribute_diagnose_if=no
])
CFLAGS="$old_cflags"
AM_CONDITIONAL([HAVE_ATTRIBUTE_DIAGNOSE_IF], [test "$have_attribute_diagnose_if" = "yes"])
AC_SUBST(WARN_CFLAGS_TEST, $WARN_CFLAGS_TEST)
AX_ASM_INLINE()
dnl Was needed for wcsnorm_s / mark.h. So far not needed anymore
dnl AX_CHECK_COMPILE_FLAG([-fbracket-depth=512],
dnl [AM_CFLAGS="$AM_CFLAGS -fbracket-depth=512"], [], [], [])
AM_CONDITIONAL([HAVE_MINGW], [test "$host_os" = "mingw32"])
AM_CONDITIONAL([HAVE_MINGW_CROSS],
[test "$host_os" = "mingw32" -a "$build_os" != "mingw32"])
if test "$host_os" = "mingw32" -a "$build_os" != "mingw32"; then
AC_CHECK_PROGS([WINE], [wine])
if test -z "$WINE"; then
AC_MSG_WARN([wine not found - cannot check cross-compiled executables])
else
AC_MSG_RESULT([ wine found - test with make check-wine])
AM_CFLAGS="$AM_CFLAGS -D_WINE_MSVCRT"
fi
fi
AC_CHECK_PROGS([DOXYGEN], [doxygen])
if test -z "$DOXYGEN";
then AC_MSG_WARN([doxygen not found - continuing without doxygen support])
fi
AC_CHECK_PROGS([POD2MAN], [pod2man])
if test -z "POD2MAN";
then AC_MSG_WARN([pod2man not found - continuing without pod2man support])
fi
AC_CHECK_PROGS([PANDOC], [pandoc])
if test -z "$PANDOC";
then AC_MSG_WARN([pandoc not found - README.rst cannot be generated from README.md])
fi
AM_CONDITIONAL([HAVE_DSYMUTIL], [test -n "$ac_ct_DSYMUTIL"])
case $host_os in
darwin*)
enable_valgrind_helgrind=no
enable_valgrind_drd=no
;;
esac
dnl passes only on some systems. --enable-valgrind-sgcheck
AX_VALGRIND_DFLT([sgcheck], [off])
AX_VALGRIND_CHECK()
# Checks for libraries
# ===============================================
# None
AC_MSG_NOTICE([Check header files])
# ===============================================
AC_HEADER_STDC
AC_HEADER_STDBOOL
AC_HEADER_TIME
AC_CHECK_HEADERS([sys/time.h])
AC_CHECK_HEADERS([stdlib.h \
memory.h \
ctype.h \
malloc.h \
string.h \
limits.h \
stddef.h \
unistd.h \
float.h \
math.h \
sys/types.h \
inttypes.h \
stdint.h \
errno.h \
wchar.h \
langinfo.h \
valgrind/valgrind.h \
fenv.h \
intrin.h \
xmmintrin.h \
emmintrin.h \
x86intrin.h \
arm_neon.h \
arm_acle.h \
mmintrin.h \
altivec.h \
spe.h \
mbarrier.h \
])
INSERT_SYS_TYPES_H=""
if test "$ac_cv_header_sys_types_h" = "yes"; then
INSERT_SYS_TYPES_H="#include <sys/types.h>"
fi
AC_SUBST(INSERT_SYS_TYPES_H)
INSERT_INTTYPES_H=""
if test "$ac_cv_header_inttypes_h" = "yes"; then
INSERT_INTTYPES_H="#include <inttypes.h>"
fi
AC_SUBST(INSERT_INTTYPES_H)
INSERT_STDINT_H=""
if test "$ac_cv_header_stdint_h" = "yes"; then
INSERT_STDINT_H="#include <stdint.h>"
fi
AC_SUBST(INSERT_STDINT_H)
INSERT_ERRNO_H=""
if test "$ac_cv_header_errno_h" = "yes"; then
INSERT_ERRNO_H="#include <errno.h>"
fi
AC_SUBST(INSERT_ERRNO_H)
INSERT_BOOL_SUPPORT="#include <stdbool.h>"
if test "$ac_cv_header_stdbool_h" = "no"; then
INSERT_BOOL_SUPPORT="
# define bool _Bool
# define false 0
# define true 1
# define __bool_true_false_are_defined 1
"
if test "$ac_cv_type__bool" = "no"; then
INSERT_BOOL_SUPPORT="
#ifdef __cplusplus
typedef bool _Bool;
#else
# define _Bool unsigned char
#endif
$INSERT_BOOL_SUPPORT
"
fi
fi
AC_SUBST(INSERT_BOOL_SUPPORT)
AC_MSG_NOTICE([Check typedefs, structures, and compiler characteristics])
# ===============================================
AC_C_CONST
AC_C_INLINE
AC_C_RESTRICT
AC_TYPE_SIZE_T
AC_TYPE_INT32_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINTPTR_T
AC_CHECK_TYPES([long long])
AC_TYPE_LONG_DOUBLE
AC_TYPE_LONG_DOUBLE_WIDER
AC_CHECK_SIZEOF(size_t)
AC_CHECK_TYPE([errno_t],
[FALLBACK_ERRNO_T=""],
[FALLBACK_ERRNO_T="typedef int errno_t;"],
[[#include <errno.h>]])
AC_SUBST(FALLBACK_ERRNO_T)
AC_TYPE_MBSTATE_T
AC_CHECK_MEMBER(struct tm.tm_gmtoff,
[AC_DEFINE(HAVE_TM_GMTOFF, 1,
[Define if struct tm has the tm_gmtoff member.])],
,
[#include <time.h>])
AX_COMPILE_CHECK_SIZEOF(time_t, [#include <time.h>])
AC_CHECK_TYPE([wchar_t],[],[],[[#include <wchar.h>]])
AC_MSG_CHECKING(for __float128)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[__float128 x = 1.0Q;]])],
have_float128=yes, have_float128=no)
AC_MSG_RESULT($have_float128)
if test $have_float128 = yes; then
AC_DEFINE([HAVE_FLOAT128], [1], [Define to 1 if __float128 is usable.])
fi
AX_GCC_BUILTIN(__builtin_ctz)
AX_GCC_BUILTIN(__builtin_constant_p)
INSERT_CONSTANT_P="#undef HAVE___BUILTIN_CONSTANT_P"
if test "$ax_cv_have___builtin_constant_p" = "yes"; then
INSERT_CONSTANT_P="#define HAVE___BUILTIN_CONSTANT_P 1"
fi
AC_SUBST(INSERT_CONSTANT_P)
AX_GCC_FUNC_ATTRIBUTE(format)
AX_GCC_FUNC_ATTRIBUTE(malloc)
AX_GCC_FUNC_ATTRIBUTE(returns_nonnull)
#not yet supported, planned since 2008
AX_GCC_FUNC_ATTRIBUTE(format_wprintf)
AX_GCC_FUNC_ATTRIBUTE(format_wscanf)
if test "$ax_cv_have_func_attribute_format_wprintf" = "yes"; then
HAVE_ATTRIBUTE_FORMAT_WPRINTF=1
else
HAVE_ATTRIBUTE_FORMAT_WPRINTF=0
fi
if test "$ax_cv_have_func_attribute_format_wscanf" = "yes"; then
HAVE_ATTRIBUTE_FORMAT_WSCANF=1
else
HAVE_ATTRIBUTE_FORMAT_WSCANF=0
fi
AC_SUBST(HAVE_ATTRIBUTE_FORMAT_WPRINTF)
AC_SUBST(HAVE_ATTRIBUTE_FORMAT_WSCANF)
builtins_chk="memcpy memmove memset strcpy strncpy strcat strncat
printf sprintf snprintf swprintf
vfprintf vfwprintf vsprintf vsnprintf"
#AX_GCC_BUILTIN(__builtin___memcpy_chk)
#AX_GCC_BUILTIN(__builtin___memmove_chk)
#AX_GCC_BUILTIN(__builtin___memset_chk)
#AX_GCC_BUILTIN(__builtin___strcpy_chk)
#AX_GCC_BUILTIN(__builtin___strncpy_chk)
#AX_GCC_BUILTIN(__builtin___strcat_chk)
#AX_GCC_BUILTIN(__builtin___strncat_chk)
#AX_GCC_BUILTIN(__builtin___printf_chk)
#AX_GCC_BUILTIN(__builtin___sprintf_chk)
#AX_GCC_BUILTIN(__builtin___snprintf_chk)
#AX_GCC_BUILTIN(__builtin___swprintf_chk)
#AX_GCC_BUILTIN(__builtin___vfprintf_chk)
#AX_GCC_BUILTIN(__builtin___vfwprintf_chk)
#AX_GCC_BUILTIN(__builtin___vsprintf_chk)
#AX_GCC_BUILTIN(__builtin___vsnprintf_chk)
builtins_bounds="narrow_ptr_bounds copy_ptr_bounds init_ptr_bounds
set_ptr_bounds null_ptr_bounds
chk_ptr_lbounds chk_ptr_ubounds chk_ptr_bounds get_ptr_lbound get_ptr_ubound"
#for b in $builtins_bounds; do
# AX_GCC_BUILTIN([__builtin___bnd_$b])
#done
#AX_GCC_BUILTIN(__builtin___bnd_narrow_ptr_bounds)
#AX_GCC_BUILTIN(__builtin___bnd_init_ptr_bounds)
#AX_GCC_BUILTIN(__builtin___bnd_copy_ptr_bounds)
AX_GCC_BUILTIN(__builtin___bnd_set_ptr_bounds)
AX_GCC_BUILTIN(__builtin___bnd_null_ptr_bounds)
#AX_GCC_BUILTIN(__builtin___bnd_chk_ptr_lbounds)
#AX_GCC_BUILTIN(__builtin___bnd_chk_ptr_ubounds)
AX_GCC_BUILTIN(__builtin___bnd_chk_ptr_bounds)
#AX_GCC_BUILTIN(__builtin___bnd_get_ptr_lbound)
#AX_GCC_BUILTIN(__builtin___bnd_get_ptr_ubound)
dnl arm intrinsic barriers
AX_GCC_BUILTIN(__dsb)
AX_GCC_BUILTIN(__isb)
AX_GCC_BUILTIN(__builtin___dsb)
AX_GCC_BUILTIN(__builtin___isb)
AC_CHECK_FUNCS([ vswprintf vswscanf mbsrtowcs ])
dnl this user choice needs to probe first for the default
AC_ARG_ENABLE(wchar,
AS_HELP_STRING([--disable-wchar],
[Disable multibyte and wchar support. @<:@default=no@:>@]),
[case "${enableval}" in
yes) enable_wchar=true ;;
no) enable_wchar=false ;;
dnl early mingw32 have only crippled wchar support: only wcscmp, wcslen
*) if test "$ac_cv_type_wchar_t" = "yes" -a "$ac_cv_func_vswprintf" = "yes" \
-a "$ac_cv_header_wchar_h" = "yes"
then
enable_wchar=true
else
AC_MSG_WARN([no proper wchar support])
enable_wchar=false
fi ;;
esac], [enable_wchar=true])
AC_MSG_CHECKING([for --disable-wchar or broken wchar usability])
dnl catch mingw32 1.0 with crippled wchar
if test "$ac_cv_header_wchar_h" = "yes" -a "$enable_wchar" = "true" \
-a "$ac_cv_func_vswprintf" = "yes" \
-a "$ac_cv_func_mbsrtowcs" = "yes" -a "$ac_cv_func_vswscanf" = "yes"
then
enable_wchar=true
else
enable_wchar=false
fi
if test "$enable_wchar" = "true" ; then
AC_MSG_RESULT([no (default)])
else
AC_MSG_RESULT([yes])
fi
AC_MSG_NOTICE([Check library functions])
# ===============================================
# dynamic checks if registered via malloc (e.g. libmpx)
AC_CHECK_FUNCS([__bnd_chk_ptr_bounds __bnd_set_ptr_bounds __bnd_null_ptr_bounds])
dnl bos enabled chk functions (but not yet usable)
#for b in $builtins_chk; do
AC_CHECK_FUNCS([__memcpy_chk __memmove_chk __memset_chk \
__strcpy_chk __strncpy_chk __strcat_chk __strncat_chk \
__printf_chk __sprintf_chk __snprintf_chk \
__vfprintf_chk __vfwprintf_chk __vsprintf_chk __vsnprintf_chk \
__vsscanf_chk ])
#done
dnl They need to include the relevant intrin header first
dnl TODO: probe for MEMORY_BARRIER and COMPILER_BARRIER here
dnl AC_CHECK_FUNCS([ __sync_synchronize MemoryBarrier _mm_mfence _mm_sfence \
dnl __machine_rw_barrier ])
AC_FUNC_MEMCMP
dnl no header needed as is checks if the linker can find it
dnl mbstowcs missing on cygwin64, isinfl on macOS, BSD, ...
AC_CHECK_FUNCS([ memset strcmp strcasecmp strcasestr strcspn strpbrk strspn \
strnstr strnlen strrchr memrchr strstr bcmp secure_getenv timingsafe_memcmp \
timingsafe_bcmp explicit_bzero explicit_memset \
asctime_r ctime_r gmtime_r localtime_r memccpy stpcpy stpncpy strerror \
fileno ftruncate isinfl])
if test "$enable_wchar" = "true" ; then
AC_CHECK_FUNCS([ wmemchr wmemcmp wcscmp wcsstr \
vswprintf vsnwprintf vswscanf mbsrtowcs mbstowcs iswdigit iswspace \
towlower towupper towctrans ])
AC_CHECK_FUNCS([ __swprintf_chk __vfwprintf_chk __vswscanf_chk ])
fi
dnl add the extensions, pretending we want them
echo "#define __STDC_WANT_LIB_EXT1__ 1" >>confdefs.h
dnl native safec shadowing functions (should be none)
AC_CHECK_FUNCS([_memcpy_s_chk _memmove_s_chk _memset_s_chk _memcmp_s_chk \
_strcpy_s_chk _strncpy_s_chk _strcat_s_chk _strncat_s_chk _strnlen_s_chk \
_printf_s_chk _sprintf_s_chk _snprintf_s_chk \
_vfprintf_s_chk _vsprintf_s_chk _vsnprintf_s_chk])
dnl native C11 Annex K functions
dnl vsnprintf_s vsnwprintf_s strtok_s wcstok_s deviate in mingw from c11
AC_CHECK_FUNCS(
[ memset_s memcpy_s memmove_s memzero_s memchr_s memrchr_s memccpy_s \
sprintf_s strcat_s strcpy_s strncat_s strncpy_s \
strnlen_s strtok_s strerror_s vsprintf_s tmpnam_s snprintf_s vsnprintf_s \
strspn_s strset_s strchr_s strrchr_s strstr_s strzero_s strnset_s \
stpcpy_s stpncpy_s \
sscanf_s fscanf_s scanf_s vfscanf_s \
vsscanf_s vscanf_s printf_s fprintf_s tmpfile_s vfprintf_s vprintf_s \
fopen_s freopen_s gets_s bsearch_s qsort_s gmtime_s localtime_s \
asctime_s ctime_s getenv_s feenableexcept ])
if test "$enable_wchar" = "true" ; then
AC_CHECK_FUNCS(
[ mbsrtowcs_s mbstowcs_s wcsrtombs_s wcstombs_s \
wcrtomb_s wctomb_s wcsnlen_s wcscpy_s wcsncpy_s wcscat_s wcsncat_s \
wmemcpy_s wmemmove_s wcstok_s vswprintf_s swprintf_s vfwprintf_s \
vwprintf_s wprintf_s snwprintf_s fwprintf_s swscanf_s vswscanf_s wscanf_s \
vfwscanf_s fwscanf_s vwscanf_s vsnwprintf_s wcsstr_s wmemcmp_s \
wcscmp_s wcsncmp_s wcsicmp_s wcsset_s wcsnset_s wcscoll_s wcslwr_s \
wcsupr_s towfc_s wcsfc_s ])
AC_CHECK_FUNCS([ _swprintf_s_chk _vfwprintf_s_chk ])
fi
dnl but delete it, because we override it case by case
$GREP -v '__STDC_WANT_LIB_EXT1__' confdefs.h > confdefs.h.tmp
mv confdefs.h.tmp confdefs.h
AM_CONDITIONAL([HAVE_WCSSTR], [test "$ac_cv_func_wcsstr" = "yes"])
AM_CONDITIONAL([HAVE_MBSTOWCS], [test "$ac_cv_func_mbstowcs" = "yes"])
AM_CONDITIONAL([HAVE_VSNWPRINTF_S], [test "$ac_cv_func_vsnwprintf_s" = "yes"])
AM_CONDITIONAL([HAVE_MEMCPY_S], [test "$ac_cv_func_memcpy_s" = "yes"])
AM_CONDITIONAL([HAVE_TIMINGSAFE_BCMP],
[test "$ac_cv_func_timingsafe_memcmp" = "yes" -a "$ac_cv_func_timingsafe_bcmp" = "yes" ])
if test "$ac_cv_func_towupper" = "yes"; then
AC_MSG_CHECKING([for towupper usability])
AC_RUN_IFELSE( [AC_LANG_PROGRAM([[
#include <wctype.h>
]],
dnl musl fails on this CYRILLIC SMALL LETTER ROUNDED VE, need at least Unicode 9
dnl windows has not yet updated to 12.1: the micro sign
[[
return (towupper(0x1C80) == 0x412
&& towupper(0xB5) == 0x3BC
&& towupper(0x432) == 0x1C80)
? 0 : 1;
]])],
[ AC_MSG_RESULT([yes])
ac_cv_towupper_ok=yes
AC_DEFINE_UNQUOTED([HAVE_TOWUPPER_OK], 1, [Define to 1 if 'towupper' is usable.])
],
[ AC_MSG_RESULT([no]) ],
[ AC_MSG_RESULT([no (cross)]) ])
fi
dnl cygwin had a broken strnstr until Aug 2017
if test "$ac_cv_func_strnstr" = "yes"; then
AC_MSG_CHECKING([for strnstr usability])
AC_RUN_IFELSE( [AC_LANG_PROGRAM([[
#include <string.h>
]],
[[
return strnstr("%s %n", "%n", 6) ? 0 : 1;
]])],
[ AC_MSG_RESULT([yes])
ac_cv_strnstr_ok=yes
AC_DEFINE_UNQUOTED([HAVE_STRNSTR_OK], 1, [Define to 1 if 'strnstr' is usable.])
],
[ AC_MSG_RESULT([no]) ],
[ AC_MSG_RESULT([no (cross)]) ])
fi
if test "$enable_wchar" = "true" ; then
INSERT_DISABLE_WCHAR="#undef SAFECLIB_DISABLE_WCHAR"
AX_COMPILE_CHECK_SIZEOF(wchar_t, [#include <wchar.h>])
else
INSERT_DISABLE_WCHAR="#define SAFECLIB_DISABLE_WCHAR 1"
ac_cv_header_wchar_h=no
fi
AM_CONDITIONAL([ENABLE_WCHAR], [test "$enable_wchar" = "true"])
AC_SUBST(INSERT_DISABLE_WCHAR)
# Checks for system services
# ===============================================
# None
# Output to downstream tools, like automake
# ===============================================
# This section emits all variables that are expected/needed by other tools
# mainly automake.
AH_TOP([
#ifndef __SAFECLIB_CONF_H__
#define __SAFECLIB_CONF_H__
])
AH_BOTTOM([
#endif /* __SAFECLIB_CONF_H__ */
])
AC_SUBST([TARBALL_VERSION_FILE])
# Define these substitutions here to keep all version information in
# one place. For information on how to properly maintain the library
# version information, refer to the libtool manual, section "Updating
# library version information":
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
AC_SUBST([SAFEC_SO_VERSION], [3:9:0])
# no patch version here
AC_SUBST([SAFEC_API_VERSION], [3.9])
AC_MSG_CHECKING([package version])
AC_MSG_RESULT($PACKAGE_VERSION)
AC_MSG_CHECKING([so version-info])
AC_MSG_RESULT($SAFEC_SO_VERSION)
# Automake variables, these variables get automagically included at the top
# of all automake generated make files. This is why you don't see them
# referenced in Makefile.am files.
AM_LDFLAGS="$AM_LDFLAGS $WARN_LDFLAGS"
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_LDFLAGS])
# Some build debugging output
if test "$enable_debug_build" = "true"; then
AC_MSG_RESULT([AM_CPPFLAGS = $AM_CPPFLAGS])
AC_MSG_RESULT([AM_CFLAGS = $AM_CFLAGS])
AC_MSG_RESULT([AM_LDFLAGS = $AM_LDFLAGS])
AC_MSG_RESULT([CFLAGS = $CFLAGS])
AC_MSG_RESULT([WARN_CFLAGS = $WARN_CFLAGS])
AC_MSG_RESULT([WARN_CFLAGS_TESTS = $WARN_CFLAGS_TESTS])
AC_MSG_RESULT([PEDANTIC = $PEDANTIC])
fi
# Output files
# ===============================================
# Generate two configuration headers; one for building the library
# itself with an autogenerated template, and a second one that will
# be installed alongside the library.
# This does the #define/#undef magic
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([libsafec.pc
Makefile
src/Makefile
tests/Makefile])
AC_CONFIG_FILES([include/safe_config.h], [chmod -w include/safe_config.h])
AC_CONFIG_FILES([include/safe_lib_errno.h], [chmod -w include/safe_lib_errno.h])
AC_CONFIG_FILES([include/safe_types.h], [chmod -w include/safe_types.h])
AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
AM_CONDITIONAL([HAVE_POD2MAN], [test -n "$POD2MAN"])
AM_CONDITIONAL([HAVE_PANDOC], [test -n "$PANDOC"])
AM_CONDITIONAL([HAVE_WINE], [test -n "$WINE"])
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([Doxyfile])])
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/footer])])
AC_OUTPUT
dnl Local Variables:
dnl comment-start: "dnl "
dnl comment-end: ""
dnl comment-start-skip: "\\bdnl\\b\\s *"
dnl compile-command: "autoreconf --warnings=all"
dnl End:
|