Note that with autoconf+automake, CFLAGS belongs to the end-user, not the package developer or the package system. Your changes belong in AM_CFLAGS, AM_CXXFLAGS, AM_CPPFLAGS, AM_LDFLAGS where the end-user can override them with the non-AM_ variables on the configure command line or in the environment when configure is run. For details, see:
https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html