configury: move local gnulib patches to build-aux subdirectory.
[m4/ericb.git] / ltdl / m4 / debug.m4
blob2bb5739d9b219dd2fe24abc946e9aa99ba1dde50
1 ##                                                           -*- Autoconf -*-
2 ## debug.m4 -- massage compiler flags for debugging/optimisation
3 ##
4 ## Copyright (C) 2000-2001, 2003, 2005-2007, 2010, 2013 Free Software
5 ## Foundation, Inc.
6 ## Copyright (C) 1999-2000 Ralf S. Engelschall
7 ## Written by <rse@engelschall.com>
8 ## Modified for M4 by Gary V. Vaughan <gary@gnu.org>
9 ##
10 ## This file is part of GNU M4.
12 ## GNU M4 is free software: you can redistribute it and/or modify
13 ## it under the terms of the GNU General Public License as published by
14 ## the Free Software Foundation, either version 3 of the License, or
15 ## (at your option) any later version.
17 ## GNU M4 is distributed in the hope that it will be useful,
18 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 ## GNU General Public License for more details.
22 ## You should have received a copy of the GNU General Public License
23 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
25 # serial 9
27 # M4_CHECK_DEBUGGING
28 # ------------------
29 # Debugging Support
30 AC_DEFUN([M4_CHECK_DEBUGGING],
31 [AC_REQUIRE([AC_PROG_CC])
32 AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug],
33                            [build for debugging [default=no]])])
34 AC_MSG_CHECKING([for compilation debug mode])
35 AC_MSG_RESULT([${enable_debug-no}])
37 : ${rm=rm -f}
38 : ${RM=rm -f}
40 set dummy $CC
41 compiler="${compiler-[$]2}"
42 test -n "$rm" || rm="rm -f"
44 if test "X$enable_debug" = Xyes; then
45   AC_DISABLE_SHARED
46   AC_DEFINE([DEBUG], [1],
47       [Define this to enable additional runtime debugging])
48   M4_default_preload="m4 traditional gnu load \
49 import modtest mpeval shadow stdlib time"
50   if test "$GCC" = yes; then
51     case "$CFLAGS" in
52       *-O* ) CFLAGS=`echo $CFLAGS | $SED 's/-O[[^ ]]* / /;s/-O[[^ ]]*$//'` ;;
53     esac
54     case "$CFLAGS" in
55         *-g* ) ;;
56          * ) AC_LIBTOOL_COMPILER_OPTION([if $compiler accepts -ggdb3],
57                  [M4_cv_prog_compiler_ggdb3],
58                  [-ggdb3 -c conftest.$ac_ext], [],
59                  [CFLAGS="$CFLAGS -ggdb3"],
60                [CFLAGS="$CFLAGS -g"])
61              ;;
62     esac
63     CFLAGS="$CFLAGS -Wall"
64     WMORE="-Wshadow -Wpointer-arith -Wcast-align -Wnested-externs"
65     WMORE="$WMORE -Wmissing-prototypes -Wmissing-declarations -Winline"
66     AC_LIBTOOL_COMPILER_OPTION([if $compiler accepts $WMORE],
67         [M4_cv_prog_compiler_warning_flags],
68         [$WMORE -c conftest.$ac_ext], [],
69         [CFLAGS="$CFLAGS $WMORE"])
71     AC_LIBTOOL_COMPILER_OPTION([if $compiler accepts -Wno-long-long],
72         [M4_cv_prog_compiler_wnolonglong],
73         [-Wno-long-long -c conftest.$ac_ext], [],
74         [CFLAGS="$CFLAGS -Wno-long-long"])
75   else
76     case "$CFLAGS" in
77         *-g* ) ;;
78            * ) CFLAGS="$CFLAGS -g" ;;
79     esac
80   fi
81 else
82   AC_ENABLE_SHARED
83   case "$CFLAGS" in
84     *-g* ) CFLAGS=`echo "$CFLAGS" |\
85                $SED -e 's/ -g / /g;s/ -g$//;s/^-g //g;s/^-g$//'`
86            ;;
87   esac
88   case "$CXXFLAGS" in
89     *-g* ) CXXFLAGS=`echo "$CXXFLAGS" |\
90                $SED -e 's/ -g / /g;s/ -g$//;s/^-g //g;s/^-g$//'`
91            ;;
92   esac
94 ])# M4_CHECK_DEBUGGING