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*
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
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=""
|
|
|
|
AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization],
|
|
|
|
[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
|
|
|
])
|
2012-12-11 04:31:55 +08:00
|
|
|
AC_ARG_ENABLE(debug, AC_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
|
2011-03-26 19:27:09 +08:00
|
|
|
])
|
2012-12-11 04:31:55 +08:00
|
|
|
AC_ARG_ENABLE(pie, AC_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"
|
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
|
|
|
])
|