$EGREP has undefined behavior on binary data, so this isn't portable.
I long ago gave up on AC_EGREP_CPP, since it's too flaky nowadays. Why can't we test directly for what we're worried about? I'm afraid I am not following why the value of PRIdMAX is related to whether printf should use the __gnu_printf__ or the __printf__ attribute.
By "test directly" I mean compile a little test program with printf and see whether GCC warns about misuse. By seeing what GCC warns about and what it doesn't we should be able to figure out which attribute is appropriate.