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
|
AC_DEFUN([AC_PROG_CC_PIE], [
AC_CACHE_CHECK([whether ${CC-cc} accepts -fPIE], ac_cv_prog_cc_pie, [
echo 'void f(){}' > conftest.c
if test -z "`${CC-cc} -fPIE -pie -c conftest.c 2>&1`"; then
ac_cv_prog_cc_pie=yes
else
ac_cv_prog_cc_pie=no
fi
rm -rf conftest*
])
])
AC_DEFUN([AC_PROG_CC_ASAN], [
AC_CACHE_CHECK([whether ${CC-cc} accepts -fsanitize=address],
ac_cv_prog_cc_asan, [
echo 'void f(){}' > asan.c
if test -z "`${CC-cc} -fsanitize=address -c asan.c 2>&1`"; then
ac_cv_prog_cc_asan=yes
else
ac_cv_prog_cc_asan=no
fi
rm -rf asan*
])
])
AC_DEFUN([AC_PROG_CC_LSAN], [
AC_CACHE_CHECK([whether ${CC-cc} accepts -fsanitize=leak],
ac_cv_prog_cc_lsan, [
echo 'void f(){}' > lsan.c
if test -z "`${CC-cc} -fsanitize=leak -c lsan.c 2>&1`"; then
ac_cv_prog_cc_lsan=yes
else
ac_cv_prog_cc_lsan=no
fi
rm -rf lsan*
])
])
AC_DEFUN([AC_PROG_CC_UBSAN], [
AC_CACHE_CHECK([whether ${CC-cc} accepts -fsanitize=undefined],
ac_cv_prog_cc_ubsan, [
echo 'void f(){}' > ubsan.c
if test -z "`${CC-cc} -fsanitize=undefined -c ubsan.c 2>&1`"; then
ac_cv_prog_cc_ubsan=yes
else
ac_cv_prog_cc_ubsan=no
fi
rm -rf ubsan*
])
])
AC_DEFUN([COMPILER_FLAGS], [
with_cflags=""
if (test "$USE_MAINTAINER_MODE" = "yes"); then
with_cflags="$with_cflags -Wall -Werror -Wextra"
with_cflags="$with_cflags -Wno-unused-parameter"
with_cflags="$with_cflags -Wno-missing-field-initializers"
with_cflags="$with_cflags -Wdeclaration-after-statement"
with_cflags="$with_cflags -Wmissing-declarations"
with_cflags="$with_cflags -Wredundant-decls"
with_cflags="$with_cflags -Wcast-align"
with_cflags="$with_cflags -Wswitch-enum"
with_cflags="$with_cflags -Wformat -Wformat-security"
with_cflags="$with_cflags -Wstringop-overflow"
with_cflags="$with_cflags -DG_DISABLE_DEPRECATED"
with_cflags="$with_cflags -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36"
with_cflags="$with_cflags -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36"
fi
AC_SUBST([WARNING_CFLAGS], $with_cflags)
])
AC_DEFUN([MISC_FLAGS], [
misc_cflags=""
misc_ldflags=""
AC_ARG_ENABLE(optimization, AS_HELP_STRING([--disable-optimization],
[disable code optimization through compiler]), [
if (test "${enableval}" = "no"); then
misc_cflags="$misc_cflags -O0"
fi
])
AC_ARG_ENABLE(asan, AS_HELP_STRING([--enable-asan],
[enable linking with address sanitizer]), [
save_LIBS=$LIBS
AC_CHECK_LIB(asan, _init)
LIBS=$save_LIBS
if (test "${enableval}" = "yes" &&
test "${ac_cv_lib_asan__init}" = "yes" &&
test "${ac_cv_prog_cc_asan}" = "yes"); then
misc_cflags="$misc_cflags -fsanitize=address";
misc_ldflags="$misc_ldflags -fsanitize=address"
AC_SUBST([ASAN_LIB], ${ac_cv_lib_asan__init})
fi
])
AC_ARG_ENABLE(lsan, AS_HELP_STRING([--enable-lsan],
[enable linking with address sanitizer]), [
save_LIBS=$LIBS
AC_CHECK_LIB(lsan, _init)
LIBS=$save_LIBS
if (test "${enableval}" = "yes" &&
test "${ac_cv_lib_lsan__init}" = "yes" &&
test "${ac_cv_prog_cc_lsan}" = "yes"); then
misc_cflags="$misc_cflags -fsanitize=leak";
misc_ldflags="$misc_ldflags -fsanitize=leak"
AC_SUBST([ASAN_LIB], ${ac_cv_lib_lsan__init})
fi
])
AC_ARG_ENABLE(ubsan, AS_HELP_STRING([--enable-ubsan],
[enable linking with address sanitizer]), [
save_LIBS=$LIBS
AC_CHECK_LIB(ubsan, _init)
LIBS=$save_LIBS
if (test "${enableval}" = "yes" &&
test "${ac_cv_lib_ubsan__init}" = "yes" &&
test "${ac_cv_prog_cc_ubsan}" = "yes"); then
misc_cflags="$misc_cflags -fsanitize=undefined";
misc_ldflags="$misc_ldflags -fsanitize=undefined";
fi
])
AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],
[enable compiling with debugging information]), [
if (test "${enableval}" = "yes" &&
test "${ac_cv_prog_cc_g}" = "yes"); then
misc_cflags="$misc_cflags -g"
fi
])
AC_ARG_ENABLE(pie, AS_HELP_STRING([--enable-pie],
[enable position independent executables flag]), [
if (test "${enableval}" = "yes" &&
test "${ac_cv_prog_cc_pie}" = "yes"); then
misc_cflags="$misc_cflags -fPIC"
misc_ldflags="$misc_ldflags -pie -Wl,-z,now"
fi
])
if (test "$enable_coverage" = "yes"); then
misc_cflags="$misc_cflags --coverage"
misc_ldflags="$misc_ldflags --coverage"
fi
if (test "$USE_MAINTAINER_MODE" = "yes"); then
AC_CACHE_CHECK([whether ${CC-cc} accepts -D_FORTIFY_SOURCE=3],
ac_cv_prog_cc_fortify_source_3, [
echo '#include <errno.h>' > fortify.c
if test -z "`${CC-cc} ${CFLAGS} ${misc_cflags} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -c fortify.c 2>&1`"; then
ac_cv_prog_cc_fortify_source_3=yes
else
ac_cv_prog_cc_fortify_source_3=no
fi
rm -f fortify.c fortify.o
])
if test "${ac_cv_prog_cc_fortify_source_3}" = "yes"; then
misc_cflags="$misc_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"
fi
fi
misc_cflags="$misc_cflags -ffunction-sections -fdata-sections"
misc_ldflags="$misc_ldflags -Wl,--gc-sections"
AC_SUBST([MISC_CFLAGS], $misc_cflags)
AC_SUBST([MISC_LDFLAGS], $misc_ldflags)
])
|