Do not override Makefile user variables
This was supposed to be a comment to #19216 (moved) but i figured it's better to open a new ticket because it's out of scope.
The real solution to the issue fixed in ticket:19216#comment:4 is to stop assigning to CFLAGS (unless when testing the flag but restore the old CFLAGS after) because it's a user variable which should never be set by the package. Instead the additional parameters should be assigned to a temporary variable (like
TOR_CFLAGS or something) which can be
AC_SUBSTed and appended to
AM_CFLAGS. The same can be said about
LDFLAGS. For more information see [https://www.gnu.org/software/autoconf/manual/automake.html#Flag-Variables-Ordering].
Overriding user variables also causes issues when trying to run
make distcheck in build directories that are configured with
--enable-fatal-warnings. It seems the overridden CFLAGS are integrated into the tarball and causes the default Autoconf checks to fail.