2004-08-13 00:00:35 +08:00
|
|
|
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*
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
2021-12-21 07:49:45 +08:00
|
|
|
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*
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
2008-12-23 13:04:54 +08:00
|
|
|
AC_DEFUN([COMPILER_FLAGS], [
|
2012-05-09 20:06:17 +08:00
|
|
|
with_cflags=""
|
2008-12-23 13:04:54 +08:00
|
|
|
if (test "$USE_MAINTAINER_MODE" = "yes"); then
|
2012-05-09 20:06:17 +08:00
|
|
|
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"
|
2014-12-03 01:28:38 +08:00
|
|
|
with_cflags="$with_cflags -Wswitch-enum"
|
2014-12-29 19:57:52 +08:00
|
|
|
with_cflags="$with_cflags -Wformat -Wformat-security"
|
2012-05-09 20:06:17 +08:00
|
|
|
with_cflags="$with_cflags -DG_DISABLE_DEPRECATED"
|
2013-11-27 23:44:56 +08:00
|
|
|
with_cflags="$with_cflags -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28"
|
2019-05-07 22:39:51 +08:00
|
|
|
with_cflags="$with_cflags -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32"
|
2008-12-23 13:04:54 +08:00
|
|
|
fi
|
2012-05-09 20:06:17 +08:00
|
|
|
AC_SUBST([WARNING_CFLAGS], $with_cflags)
|
2008-12-23 13:04:54 +08:00
|
|
|
])
|
|
|
|
|
2012-12-11 04:31:55 +08:00
|
|
|
AC_DEFUN([MISC_FLAGS], [
|
|
|
|
misc_cflags=""
|
|
|
|
misc_ldflags=""
|
2022-01-06 06:02:05 +08:00
|
|
|
AC_ARG_ENABLE(optimization, AS_HELP_STRING([--disable-optimization],
|
2012-12-11 04:31:55 +08:00
|
|
|
[disable code optimization through compiler]), [
|
|
|
|
if (test "${enableval}" = "no"); then
|
2013-01-08 23:46:26 +08:00
|
|
|
misc_cflags="$misc_cflags -O0"
|
2004-08-13 00:00:35 +08:00
|
|
|
fi
|
2011-02-24 20:13:24 +08:00
|
|
|
])
|
2022-01-06 06:02:05 +08:00
|
|
|
AC_ARG_ENABLE(asan, AS_HELP_STRING([--enable-asan],
|
2021-12-21 07:49:45 +08:00
|
|
|
[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
|
|
|
|
])
|
2022-01-06 06:02:05 +08:00
|
|
|
AC_ARG_ENABLE(lsan, AS_HELP_STRING([--enable-lsan],
|
2021-12-21 07:49:45 +08:00
|
|
|
[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
|
|
|
|
])
|
2022-01-06 06:02:05 +08:00
|
|
|
AC_ARG_ENABLE(ubsan, AS_HELP_STRING([--enable-ubsan],
|
2021-12-21 07:49:45 +08:00
|
|
|
[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
|
|
|
|
])
|
2022-01-06 06:02:05 +08:00
|
|
|
AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],
|
2012-12-11 04:31:55 +08:00
|
|
|
[enable compiling with debugging information]), [
|
|
|
|
if (test "${enableval}" = "yes" &&
|
|
|
|
test "${ac_cv_prog_cc_g}" = "yes"); then
|
|
|
|
misc_cflags="$misc_cflags -g"
|
|
|
|
fi
|
2011-03-26 19:27:09 +08:00
|
|
|
])
|
2022-01-06 06:02:05 +08:00
|
|
|
AC_ARG_ENABLE(pie, AS_HELP_STRING([--enable-pie],
|
2012-12-11 04:31:55 +08:00
|
|
|
[enable position independent executables flag]), [
|
|
|
|
if (test "${enableval}" = "yes" &&
|
|
|
|
test "${ac_cv_prog_cc_pie}" = "yes"); then
|
|
|
|
misc_cflags="$misc_cflags -fPIC"
|
2019-05-09 20:37:41 +08:00
|
|
|
misc_ldflags="$misc_ldflags -pie -Wl,-z,now"
|
2012-12-11 04:31:55 +08:00
|
|
|
fi
|
2012-10-03 21:18:29 +08:00
|
|
|
])
|
2014-12-14 07:31:26 +08:00
|
|
|
if (test "$enable_coverage" = "yes"); then
|
2013-12-11 17:01:25 +08:00
|
|
|
misc_cflags="$misc_cflags --coverage"
|
|
|
|
misc_ldflags="$misc_ldflags --coverage"
|
|
|
|
fi
|
2012-05-09 20:06:17 +08:00
|
|
|
AC_SUBST([MISC_CFLAGS], $misc_cflags)
|
2012-06-21 17:28:47 +08:00
|
|
|
AC_SUBST([MISC_LDFLAGS], $misc_ldflags)
|
2004-08-13 00:00:35 +08:00
|
|
|
])
|