Build: configure: check for -Werror support consistently
Previously, the configure script sometimes checked for -Werror support using
cc_support_flags and sometimes used it unconditionally. Now, a variable is
defined early on for use everywhere.
Also, helper functions for setting temporary CFLAGS were added, to reduce
code duplication and improve readability.