add guards against implicit optimization, inherit user CFLAGS

 AC_PROG trumps global CFLAGS definitions, carefully order things so that we get clean
 CFLAGS where we need them and pass-through behavior where we dont.