Gem - modify CFLAGS for a wrong-behaving gem?

I am trying to build a really badly written gem that has an ungodly
habbit of completely rewriting CFLAGS in its extconf.rb (simply
$CFLAGS=) causing the whole compilation to fail.
Unfortunately, I do not seem to be able to impose my CFLAGS on it.
When I am trying to install with gem install stupid_gem –
–with-cflags=, I end up with the same cflags that are
set in gem’s extconfig.rb and that is rather disappointing. What’s the
correct procedure to override its CFLAGS with my CFLAGS, bypassing
gem’s wishes utterly? Thanks in advance.