]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
configure: Do not modify user-provided CFLAGS variable
authorJan Engelhardt <jengelh@inai.de>
Mon, 31 Mar 2025 17:10:34 +0000 (19:10 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Tue, 27 May 2025 18:01:55 +0000 (18:01 +0000)
As per
https://www.gnu.org/software/automake/manual/html_node/User-Variables.html
CFLAGS is reserved for the user and should not be changed.

AM_CFLAGS is the right variable to use here.

configure.ac
m4/dovecot.m4

index 0b50c3bbbe4bc53f473f0c28f8fc95ba426c959a..1bbca6cee3ab4f751f4b69024e6d7662f61002c1 100644 (file)
@@ -267,7 +267,7 @@ AC_C_INLINE
 LT_INIT
 
 # SIZE_MAX is missing without this
-CXXFLAGS="$CXXFLAGS -D__STDC_LIMIT_MACROS"
+AM_CXXFLAGS="$AM_CXXFLAGS -D__STDC_LIMIT_MACROS"
 
 # Use the first x.y.z numbers of the version. Also allow x.y numbering.
 AS_IF([echo "$PACKAGE_VERSION" | grep '^[[0-9]]*\.[[0-9]]*\.[[0-9]]'], [
@@ -773,8 +773,10 @@ SETTING_LINKED_FILES=`echo $libdovecot_c_files | $SED -e s,$srcdir/src,./src,g -
 AC_SUBST(SETTING_FILES)
 AC_SUBST(SETTING_LINKED_FILES)
 
-CFLAGS="$CFLAGS $EXTRA_CFLAGS"
-CXXFLAGS="$CXXFLAGS $EXTRA_CFLAGS"
+AM_CFLAGS="$AM_CFLAGS $EXTRA_CFLAGS"
+AM_CXXFLAGS="$AM_CXXFLAGS $EXTRA_CFLAGS"
+AC_SUBST([AM_CFLAGS])
+AC_SUBST([AM_CXXFLAGS])
 BINARY_LDFLAGS="$PIE_LDFLAGS $RELRO_LDFLAGS"
 BINARY_CFLAGS="$PIE_CFLAGS"
 
@@ -941,7 +943,7 @@ echo "userdbs ........ :$userdb"
 if test "$not_userdb" != ""; then
   echo "                 :$not_userdb"
 fi
-echo "CFLAGS ......... : $CFLAGS"
+echo "AM_CFLAGS ...... : $AM_CFLAGS"
 
 if test "$systemdsystemunitdir" != ""; then
   echo "SYSTEMD ........ : $systemdservicetype - $systemdsystemunitdir/dovecot.service";
index 9a5ed8f28fcbbbdbb9485806d7aed9056342e26a..ce032282e21b4a10a4c2feb2506f60ddef607083 100644 (file)
@@ -18,7 +18,7 @@ AC_DEFUN([AC_CC_D_FORTIFY_SOURCE],[
       case "$host" in
         *)
           gl_COMPILER_OPTION_IF([-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2], [
-            CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
+            AM_CFLAGS="$AM_CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
             ],
             [],
             [AC_LANG_PROGRAM()]
@@ -43,20 +43,19 @@ AC_DEFUN([DC_DOVECOT_CFLAGS],[
     CFLAGS="-std=$mystd"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM()
     ], [
-      CFLAGS="$CFLAGS $old_cflags"
+      AM_CFLAGS="$AM_CFLAGS $CFLAGS"
       std=$mystd
       break
-    ], [
-      CFLAGS="$old_cflags"
     ])
   done
   AC_MSG_RESULT($std)
+  CFLAGS="$old_cflags"
 
   AS_IF([test "x$ac_cv_c_compiler_gnu" = "xyes"], [
     dnl -Wcast-qual -Wcast-align -Wconversion -Wunreachable-code # too many warnings
     dnl -Wstrict-prototypes -Wredundant-decls # may give warnings in some systems
     dnl -Wmissing-format-attribute -Wmissing-noreturn -Wwrite-strings # a couple of warnings
-    CFLAGS="$CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast"
+    AM_CFLAGS="$AM_CFLAGS -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast"
 
     AS_IF([test "$have_clang" = "yes"], [
       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@@ -65,11 +64,11 @@ AC_DEFUN([DC_DOVECOT_CFLAGS],[
       #endif
       ]], [[]])],[],[
         dnl clang 3.3+ unfortunately this gives warnings with hash.h
-        CFLAGS="$CFLAGS -Wno-duplicate-decl-specifier"
+        AM_CFLAGS="$AM_CFLAGS -Wno-duplicate-decl-specifier"
       ])
     ], [
       dnl This is simply to avoid warning when building strftime() wrappers..
-      CFLAGS="$CFLAGS -fno-builtin-strftime"
+      AM_CFLAGS="$AM_CFLAGS -fno-builtin-strftime"
     ])
 
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@@ -78,7 +77,7 @@ AC_DEFUN([DC_DOVECOT_CFLAGS],[
       #endif
       ]], [[]])],[
         dnl gcc4
-        CFLAGS="$CFLAGS -Wstrict-aliasing=2"
+        AM_CFLAGS="$AM_CFLAGS -Wstrict-aliasing=2"
       ],[])
   ])
 ])
@@ -210,12 +209,12 @@ AC_DEFUN([AC_CC_RETPOLINE],[
       case "$host" in
         *)
           gl_COMPILER_OPTION_IF([-mfunction-return=$with_retpoline],
-            [CFLAGS="$CFLAGS -mfunction-return=$with_retpoline"],
+            [AM_CFLAGS="$AM_CFLAGS -mfunction-return=$with_retpoline"],
             [],
             [AC_LANG_PROGRAM()]
           )
           gl_COMPILER_OPTION_IF([-mindirect-branch=$with_retpoline], [
-            CFLAGS="$CFLAGS -mindirect-branch=$with_retpoline"
+            AM_CFLAGS="$AM_CFLAGS -mindirect-branch=$with_retpoline"
             ],
             [],
             [AC_LANG_PROGRAM()]
@@ -234,11 +233,11 @@ AC_DEFUN([AC_CC_F_STACK_PROTECTOR],[
       case "$host" in
         *)
           gl_COMPILER_OPTION_IF([-fstack-protector-strong], [
-            CFLAGS="$CFLAGS -fstack-protector-strong"
+            AM_CFLAGS="$AM_CFLAGS -fstack-protector-strong"
             ],
             [
                gl_COMPILER_OPTION_IF([-fstack-protector], [
-                 CFLAGS="$CFLAGS -fstack-protector"
+                 AM_CFLAGS="$AM_CFLAGS -fstack-protector"
                  ], [], [AC_LANG_PROGRAM()])
             ],
             [AC_LANG_PROGRAM()]
@@ -310,7 +309,7 @@ AC_DEFUN([DC_DOVECOT_FUZZER],[
                 with_fuzzer=$withval,
                 with_fuzzer=no)
        AS_IF([test x$with_fuzzer = xclang], [
-               CFLAGS="$CFLAGS -fsanitize=fuzzer-no-link"
+               AM_CFLAGS="$AM_CFLAGS -fsanitize=fuzzer-no-link"
                # use $LIB_FUZZING_ENGINE for linking if it exists
                FUZZER_LDFLAGS=${LIB_FUZZING_ENGINE--fsanitize=fuzzer}
                # May need to use CXXLINK for linking, which wants sources to