2 ## debug.m4 -- massage compiler flags for debugging/optimisation
4 ## Copyright (C) 1999-2000 Ralf S. Engelschall
5 ## Written by <rse@engelschall.com>
6 ## Modified for M4 by Gary V. Vaughan <gary@gnu.org>
8 ## This program is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; either version 2 of the License, or
11 ## (at your option) any later version.
13 ## This program is distributed in the hope that it will be useful,
14 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ## GNU General Public License for more details.
18 ## You should have received a copy of the GNU General Public License
19 ## along with this program; see the file COPYING. If not, write to
20 ## the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ## Boston, MA 02110-1301, USA.
28 AC_DEFUN([m4_CHECK_DEBUGGING],
29 [AC_REQUIRE([AC_PROG_CC])
30 AC_ARG_ENABLE([debug], [AC_HELP_STRING([--enable-debug],
31 [build for debugging [default=no]])])
32 AC_MSG_CHECKING(for compilation debug mode)
33 AC_MSG_RESULT([${enable_debug-no}])
36 compiler="${compiler-[$]2}"
37 test -n "$rm" || rm="rm -f"
39 if test "X$enable_debug" = Xyes; then
42 [Define this to enable additional runtime debugging])
43 if test "$GCC" = yes; then
45 *-O* ) CFLAGS=`echo $CFLAGS | $SED 's/-O[[^ ]]* / /;s/-O[[^ ]]*$//'` ;;
49 * ) AC_LIBTOOL_COMPILER_OPTION([if $compiler accepts -ggdb3],
50 [m4_cv_prog_compiler_ggdb3],
51 [-ggdb3 -c conftest.$ac_ext], [],
52 [CFLAGS="$CFLAGS -ggdb3"],
53 [CFLAGS="$CFLAGS -g"])
56 CFLAGS="$CFLAGS -Wall"
57 WMORE="-Wshadow -Wpointer-arith -Wcast-align -Wnested-externs"
58 WMORE="$WMORE -Wmissing-prototypes -Wmissing-declarations -Winline"
59 AC_LIBTOOL_COMPILER_OPTION([if $compiler accepts $WMORE],
60 [m4_cv_prog_compiler_warning_flags],
61 [$WMORE -c conftest.$ac_ext], [],
62 [CFLAGS="$CFLAGS $WMORE"])
64 AC_LIBTOOL_COMPILER_OPTION([if $compiler accepts -Wno-long-long],
65 [m4_cv_prog_compiler_wnolonglong],
66 [-Wno-long-long -c conftest.$ac_ext], [],
67 [CFLAGS="$CFLAGS -Wno-long-long"])
71 * ) CFLAGS="$CFLAGS -g" ;;
77 *-g* ) CFLAGS=`echo "$CFLAGS" |\
78 $SED -e 's/ -g / /g;s/ -g$//;s/^-g //g;s/^-g$//'`
82 *-g* ) CXXFLAGS=`echo "$CXXFLAGS" |\
83 $SED -e 's/ -g / /g;s/ -g$//;s/^-g //g;s/^-g$//'`
87 ])# m4_CHECK_DEBUGGING