acinclude.m4 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. AC_DEFUN([AC_PROG_CC_PIE], [
  2. AC_CACHE_CHECK([whether ${CC-cc} accepts -fPIE], ac_cv_prog_cc_pie, [
  3. echo 'void f(){}' > conftest.c
  4. if test -z "`${CC-cc} -fPIE -pie -c conftest.c 2>&1`"; then
  5. ac_cv_prog_cc_pie=yes
  6. else
  7. ac_cv_prog_cc_pie=no
  8. fi
  9. rm -rf conftest*
  10. ])
  11. ])
  12. AC_DEFUN([COMPILER_FLAGS], [
  13. with_cflags=""
  14. if (test "$USE_MAINTAINER_MODE" = "yes"); then
  15. with_cflags="$with_cflags -Wall -Werror -Wextra"
  16. with_cflags="$with_cflags -Wno-unused-parameter"
  17. with_cflags="$with_cflags -Wno-missing-field-initializers"
  18. with_cflags="$with_cflags -Wdeclaration-after-statement"
  19. with_cflags="$with_cflags -Wmissing-declarations"
  20. with_cflags="$with_cflags -Wredundant-decls"
  21. with_cflags="$with_cflags -Wcast-align"
  22. with_cflags="$with_cflags -Wswitch-enum"
  23. with_cflags="$with_cflags -Wformat -Wformat-security"
  24. with_cflags="$with_cflags -DG_DISABLE_DEPRECATED"
  25. with_cflags="$with_cflags -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28"
  26. with_cflags="$with_cflags -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32"
  27. fi
  28. AC_SUBST([WARNING_CFLAGS], $with_cflags)
  29. ])
  30. AC_DEFUN([MISC_FLAGS], [
  31. misc_cflags=""
  32. misc_ldflags=""
  33. AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization],
  34. [disable code optimization through compiler]), [
  35. if (test "${enableval}" = "no"); then
  36. misc_cflags="$misc_cflags -O0"
  37. fi
  38. ])
  39. AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
  40. [enable compiling with debugging information]), [
  41. if (test "${enableval}" = "yes" &&
  42. test "${ac_cv_prog_cc_g}" = "yes"); then
  43. misc_cflags="$misc_cflags -g"
  44. fi
  45. ])
  46. AC_ARG_ENABLE(pie, AC_HELP_STRING([--enable-pie],
  47. [enable position independent executables flag]), [
  48. if (test "${enableval}" = "yes" &&
  49. test "${ac_cv_prog_cc_pie}" = "yes"); then
  50. misc_cflags="$misc_cflags -fPIC"
  51. misc_ldflags="$misc_ldflags -pie -Wl,-z,now"
  52. fi
  53. ])
  54. if (test "$enable_coverage" = "yes"); then
  55. misc_cflags="$misc_cflags --coverage"
  56. misc_ldflags="$misc_ldflags --coverage"
  57. fi
  58. AC_SUBST([MISC_CFLAGS], $misc_cflags)
  59. AC_SUBST([MISC_LDFLAGS], $misc_ldflags)
  60. ])