From: Andrei Pavel Date: Fri, 22 Sep 2023 11:49:48 +0000 (+0300) Subject: [#1520] reset default flags on --enable-debug X-Git-Tag: Kea-2.5.2~8 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=80269d59467ac06b3d96b335916933d6f8da7d43;p=thirdparty%2Fkea.git [#1520] reset default flags on --enable-debug --- diff --git a/configure.ac b/configure.ac index b77201952a..4f3f3410b9 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,14 @@ AC_CONFIG_MACRO_DIR([m4macros]) AC_CANONICAL_HOST AC_CANONICAL_BUILD +# Check if the user provided a CXXFLAGS. Must be done before AC_PROG_CXX which +# sets it to a default. +if test -n "${CXXFLAGS+x}"; then + custom_cxxflags=true +else + custom_cxxflags=false +fi + # Check for compilers. AC_PROG_CXX @@ -99,10 +107,22 @@ AC_ARG_ENABLE([debug], AM_CONDITIONAL([DEBUG_ENABLED], [test x$debug_enabled = xyes]) AM_COND_IF([DEBUG_ENABLED], [AC_DEFINE([ENABLE_DEBUG], [1], [Enable low-performing debugging facilities?])]) if test "${debug_enabled}" = 'yes'; then + # If the shell variable CXXFLAGS was not already set, based on compiler, + # AC_PROG_CXX can set it to -g, -O2, or both. Since they can conflict with + # what --enable-debug is setting, let's remove them, but only if the user has + # not explicitly set the variable. We don't inspect what the user set. If one + # of the conflicting flags was set, it might mean that the user wanted to + # override, which is fine. + if ! ${custom_cxxflags}; then + CXXFLAGS='' + fi + + KEA_CXXFLAGS="${KEA_CXXFLAGS} -g3 -O0" + + # g++ has some additional flags that can be useful. if test "${GXX}" = 'yes'; then KEA_CXXFLAGS="${KEA_CXXFLAGS} -ggdb3 -grecord-gcc-switches" fi - KEA_CXXFLAGS="${KEA_CXXFLAGS} -g3 -O0" fi # Include premium configuration