When you override CFLAGS on the configure command line, you give
configure the opportunity to add more flags to the CFLAGS variable that
are then passed on to make. On the other hand, when you modify CFLAGS on
the make command line, you are overriding all settings provided to the
Makefile by the configure script when the Makefile was built. For
example, I have a (generated) Makefile that contains the following
definition for CFLAGS:
CFLAGS = -g -O2 -DLINUX -Wall -Werror -O3
The -g -O2 comes from the AC_PROG_CC macro in my configure.ac file. The
-DLINUX comes from some hand-written script in that same configure.ac
that determines my platform (based on host_os), while thet -Wall -Werror
comes from some more script that determines which compiler I'm using.
Finally, the -O3 is determined by yet another piece of script that
determines based on --enable features specified how optimal I want the
code to be.
If you say "make CFLAGS=-g", you've just lost the definition for LINUX
and the warning options defined in the configure script. Before you all
flame me on this, let me say that I'm already aware that I should be
passing the -D option in the CPPFLAGS, but I would argue that CFLAGS is
the only viable place to pass the -W options, and that these options
should probably be set by a configure script that can figure out which
compiler you're using. I would also like to point out that this is a
simple example - I know of projects that also much more carefully craft
optimization flags - they pass a dozen or more -f flags based on
compiler and platform characteristics.