Ai
3 Star 1 Fork 4

Gitee 极速下载/safeclib

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/rurban/safeclib
克隆/下载
configure.ac 41.73 KB
一键复制 编辑 原始数据 按行查看 历史
Reini Urban 提交于 2024-12-28 16:35 +08:00 . Release 3.9.1
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234
# 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:
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/safeclib.git
git@gitee.com:mirrors/safeclib.git
mirrors
safeclib
safeclib
master

搜索帮助