Index: m4macros/xdt-features.m4 =================================================================== --- m4macros/xdt-features.m4 (revision 25298) +++ m4macros/xdt-features.m4 (working copy) @@ -32,39 +32,159 @@ -dnl XDT_FEATURE_DEBUG() +dnl _XDT_FEATURE_DEBUG() dnl -AC_DEFUN([XDT_FEATURE_DEBUG], +AC_DEFUN([_XDT_FEATURE_DEBUG], [ AC_ARG_ENABLE([debug], -AC_HELP_STRING([--enable-debug[=yes|no|full]], [Build with debugging support]) -AC_HELP_STRING([--disable-debug], [Include no debugging support [default]]), - [], [enable_debug=no]) + AC_HELP_STRING([--enable-debug=@<:@no/minimum/yes/full@:>@], [Turn on debugging @<:@default=xdt_cv_debug_default@:>@]), + [], [enable_debug=xdt_cv_debug_default]) + AC_MSG_CHECKING([whether to enable debugging support]) + if test x"$enable_debug" = x"full" -o x"$enable_debug" = x"yes"; then + dnl Print the result + AC_MSG_RESULT([$enable_debug]) - AC_MSG_CHECKING([whether to build with debugging support]) - if test x"$enable_debug" != x"no"; then - AC_DEFINE([DEBUG], [1], [Define for debugging support]) + dnl Check whether the compiler accepts the -errwarn=%all + dnl (Support for the Solaris CC compiler) + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -errwarn=%all" + AC_MSG_CHECKING([whether $CC accepts -errwarn=%all]) + AC_COMPILE_IFELSE(AC_LANG_SOURCE([int x;]), [ + AC_MSG_RESULT([yes]) + xdt_cv_additional_CFLAGS="$xdt_cv_additional_CFLAGS -errwarn=%all" + ], [ + AC_MSG_RESULT([no]) + ]) + CFLAGS="$save_CFLAGS" - if test x"$GCC" = x"yes"; then - xdt_cv_additional_CFLAGS="-Wall" - fi - xdt_cv_additional_CFLAGS="$xdt_cv_additional_CFLAGS -DXFCE_DISABLE_DEPRECATED" + dnl Make sure we detect possible errors (if supported) + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Wall -Werror" + AC_MSG_CHECKING([whether $CC accepts -Wall -Werror]) + AC_COMPILE_IFELSE(AC_LANG_SOURCE([int x;]), [ + AC_MSG_RESULT([yes]) + xdt_cv_additional_CFLAGS="$xdt_cv_additional_CFLAGS -Wall -Werror" + ], [ + AC_MSG_RESULT([no]) + ]) + CFLAGS="$save_CFLAGS" + dnl Check whether the compiler accepts the -fno-strict-aliasing + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fno-strict-aliasing" + AC_MSG_CHECKING([whether $CC accepts -fno-strict-aliasing]) + AC_COMPILE_IFELSE(AC_LANG_SOURCE([int x;]), [ + AC_MSG_RESULT([yes]) + xdt_cv_additional_CFLAGS="$xdt_cv_additional_CFLAGS -fno-strict-aliasing" + ], [ + AC_MSG_RESULT([no]) + ]) + CFLAGS="$save_CFLAGS" + + dnl Paranoia for --enable-debug=full if test x"$enable_debug" = x"full"; then - AC_DEFINE([DEBUG_TRACE], [1], [Define for tracing support]) - if test x"$GCC" = x"yes"; then - xdt_cv_additional_CFLAGS="-g3 -Werror $xdt_cv_additional_CFLAGS" - fi - AC_MSG_RESULT([full]) - else - if test x"$GCC" = x"yes"; then - xdt_cv_additional_CFLAGS="-g $xdt_cv_additional_CFLAGS" - fi - AC_MSG_RESULT([yes]) + dnl Enable extensive debugging + xdt_cv_additional_CPPFLAGS="$xdt_cv_additional_CPPFLAGS -DG_ENABLE_DEBUG" + + dnl Use -O0 -g3 if the compiler supports it + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -O0 -g3" + AC_MSG_CHECKING([whether $CC accepts -O0 -g3]) + AC_COMPILE_IFELSE(AC_LANG_SOURCE([int x;]), [ + AC_MSG_RESULT([yes]) + xdt_cv_additional_CFLAGS="$xdt_cv_additional_CFLAGS -O0 -g3" + ], [ + AC_MSG_RESULT([no]) + ]) + CFLAGS="$save_CFLAGS" fi + else + dnl Print the result + AC_MSG_RESULT([$enable_debug]) - CFLAGS="$CFLAGS $xdt_cv_additional_CFLAGS" - CXXFLAGS="$CXXFLAGS $xdt_cv_additional_CFLAGS" + dnl Disable debugging (release build) + xdt_cv_additional_CPPFLAGS="$xdt_cv_additional_CPPFLAGS -DNDEBUG" + + dnl Disable object cast checks + xdt_cv_additional_CPPFLAGS="$xdt_cv_additional_CPPFLAGS -DG_DISABLE_CAST_CHECKS" + + dnl Disable all checks for --enable-debug=no + if test x"$enable_debug" = x"no"; then + xdt_cv_additional_CPPFLAGS="$xdt_cv_additional_CPPFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS" + fi + fi +]) + + + +dnl XDT_FEATURE_DEBUG() +dnl +AC_DEFUN([XDT_FEATURE_DEBUG], +[ + dnl Check if a default debug mode is set + m4_define([xdt_cv_debug_default], [ifelse([$1], [], [minimum], [$1])]) + + dnl Check for debugging + AC_REQUIRE([_XDT_FEATURE_DEBUG]) + + dnl Set the flags + CFLAGS="$CFLAGS $xdt_cv_additional_CFLAGS $xdt_cv_additional_CPPFLAGS" + CXXFLAGS="$CXXFLAGS $xdt_cv_additional_CFLAGS $xdt_cv_additional_CPPFLAGS" +]) + + + +dnl XDT_FEATURE_DEBUG_PLATFORM() +dnl +AC_DEFUN([XDT_FEATURE_DEBUG_PLATFORM], +[ + dnl Check if a default debug mode is set + m4_define([xdt_cv_debug_default], [ifelse([$1], [], [minimum], [$1])]) + + dnl Check for debugging + AC_REQUIRE([_XDT_FEATURE_DEBUG]) + + dnl Set the platform flags + PLATFORM_CPPFLAGS="$PLATFORM_CPPFLAGS $xdt_cv_additional_CPPFLAGS" + PLATFORM_CFLAGS="$PLATFORM_CFLAGS $xdt_cv_additional_CFLAGS" +]) + + + +dnl XDT_FEATURE_LINKER() +dnl +AC_DEFUN([XDT_FEATURE_LINKER], +[ + AC_REQUIRE([AC_PROG_LD]) + AC_ARG_ENABLE([final], + AC_HELP_STRING([--enable-final], [Build final version (enable linker optimizations)]), + [], [enable_final=yes]) + + AC_MSG_CHECKING([whether to build final version]) + if test x"$enable_final" = x"yes"; then + AC_MSG_RESULT([yes]) + + AC_MSG_CHECKING([whether $LD accepts --as-needed]) + case `$LD --as-needed -v 2>&1 &1 &1